Class GPUMemoryManager
java.lang.Object
org.apache.sysds.runtime.instructions.gpu.context.GPUMemoryManager
- All cudaFree and cudaMalloc in SystemDS should go through this class to avoid OOM or incorrect results.
- This class can be refactored in future to accept a chunk of memory ahead of time rather than while execution. This will only thow memory-related errors during startup.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that governs the eviction policy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the allocated GPU objectsvoidClears up the memory used by non-dirty pointers that are not inside lineage cachevoidDeallocate the pointerlonggetSizeAllocatedGPUPointer(jcuda.Pointer ptr) Get size of allocated GPU PointervoidguardedCudaFree(jcuda.Pointer toFree) voidguardedCudaFree(jcuda.Pointer toFree, boolean noStats) Note: This method should not be called from an iterator as it removes entries from allocatedGPUPointers and rmvarGPUPointersjcuda.PointerAllocate pointer of the given size in bytes.voidremoveGPUObject(GPUObject gpuObj) Removes the GPU object from the memory managertoString()Print debugging information
-
Constructor Details
-
GPUMemoryManager
-
-
Method Details
-
getGPUMatrixMemoryManager
-
getGPULazyCudaFreeMemoryManager
-
getSizeAllocatedGPUPointer
public long getSizeAllocatedGPUPointer(jcuda.Pointer ptr) Get size of allocated GPU Pointer- Parameters:
ptr- pointer to get size of- Returns:
- either the size or -1 if no such pointer exists
-
malloc
Allocate pointer of the given size in bytes.- Parameters:
opcode- instruction namesize- size in bytesinitialize- if cudaMemset() should be called- Returns:
- allocated pointer
-
guardedCudaFree
public void guardedCudaFree(jcuda.Pointer toFree, boolean noStats) Note: This method should not be called from an iterator as it removes entries from allocatedGPUPointers and rmvarGPUPointers- Parameters:
toFree- pointer to call cudaFree method onnoStats- do not collect statistics
-
guardedCudaFree
public void guardedCudaFree(jcuda.Pointer toFree) -
free
Deallocate the pointer- Parameters:
opcode- instruction nametoFree- pointer to freeeager- whether to deallocate eagerly- Throws:
DMLRuntimeException- if error occurs
-
removeGPUObject
Removes the GPU object from the memory manager- Parameters:
gpuObj- the handle to the GPU object
-
clearMemory
public void clearMemory()Clear the allocated GPU objects -
clearTemporaryMemory
public void clearTemporaryMemory()Clears up the memory used by non-dirty pointers that are not inside lineage cache -
toString
Print debugging information
-