Class GPUMemoryManager

  • public class GPUMemoryManager
    extends Object
    - 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.
    • Constructor Detail

      • GPUMemoryManager

        public GPUMemoryManager​(GPUContext gpuCtx)
    • Method Detail

      • getSizeAllocatedGPUPointer

        public long getSizeAllocatedGPUPointer​(jcuda.Pointer ptr)
        Get size of allocated GPU Pointer
        ptr - pointer to get size of
        either the size or -1 if no such pointer exists
      • malloc

        public jcuda.Pointer malloc​(String opcode,
                                    long size,
                                    boolean initialize)
        Allocate pointer of the given size in bytes.
        opcode - instruction name
        size - size in bytes
        initialize - if cudaMemset() should be called
        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
        toFree - pointer to call cudaFree method on
        noStats - do not collect statistics
      • guardedCudaFree

        public void guardedCudaFree​(jcuda.Pointer toFree)
      • free

        public void free​(String opcode,
                         jcuda.Pointer toFree,
                         boolean eager)
                  throws DMLRuntimeException
        Deallocate the pointer
        opcode - instruction name
        toFree - pointer to free
        eager - whether to deallocate eagerly
        DMLRuntimeException - if error occurs
      • removeGPUObject

        public void removeGPUObject​(GPUObject gpuObj)
        Removes the GPU object from the memory manager
        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

        public String toString()
        Print debugging information
        toString in class Object