org.apache.sysds.runtime.instructions.gpu.context

## Class CudaMemoryAllocator

- java.lang.Object
- - org.apache.sysds.runtime.instructions.gpu.context.CudaMemoryAllocator

- All Implemented Interfaces:
    GPUMemoryAllocator

      public class CudaMemoryAllocator
      extends Object
      implements GPUMemoryAllocator

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CudaMemoryAllocator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `allocate(jcuda.Pointer devPtr, long size)` Allocate memory on the device.
    `boolean` | `canAllocate(long size)` Check if there is enough memory to allocate a pointer of given size
    `void` | `free(jcuda.Pointer devPtr)` Frees memory on the device
    `long` | `getAvailableMemory()` Gets the available memory on GPU that SystemDS can use.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CudaMemoryAllocator

          public CudaMemoryAllocator()

  - ### Method Detail

    - #### allocate

          public void allocate(jcuda.Pointer devPtr,
                               long size)
                        throws jcuda.CudaException

      Allocate memory on the device.
      Specified by:
        `allocate` in interface `GPUMemoryAllocator`
      Parameters:
        `devPtr` - Pointer to allocated device memory
        `size` - size in bytes
      Throws:
        `jcuda.CudaException` - if unable to allocate

    - #### free

          public void free(jcuda.Pointer devPtr)
                    throws jcuda.CudaException

      Frees memory on the device
      Specified by:
        `free` in interface `GPUMemoryAllocator`
      Parameters:
        `devPtr` - Device pointer to memory to free
      Throws:
        `jcuda.CudaException` - if error occurs

    - #### canAllocate

          public boolean canAllocate(long size)

      Check if there is enough memory to allocate a pointer of given size
      Specified by:
        `canAllocate` in interface `GPUMemoryAllocator`
      Parameters:
        `size` - size in bytes
      Returns:
        true if there is enough available memory to allocate a pointer of the given size

    - #### getAvailableMemory

          public long getAvailableMemory()

      Gets the available memory on GPU that SystemDS can use.
      Specified by:
        `getAvailableMemory` in interface `GPUMemoryAllocator`
      Returns:
        the available memory in bytes

Copyright © 2020 The Apache Software Foundation. All rights reserved.