Module openj9.gpu
Package com.ibm.gpu

Class CUDAManager

java.lang.Object
com.ibm.gpu.CUDAManager

public final class CUDAManager extends Object
This class contains information important to IBM GPU enabled functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Look for the next free device and mark it as busy.
    Use this method to obtain a reference to an ArrayList containing references to all discovered CUDA devices.
    int
    Gets the ID of the default device, set to 0 by default.
    getDevice(int deviceId)
    Get a reference to the CUDA device by means of its index (with 0 being the first).
    int
    Identifies the number of available CUDA devices.
    Identifies the CUDA device that has the most memory available.
    int
    Gets the minimum length of a double array that will be sorted using a GPU if enabled.
    Use this method to return an array of enabled CUDA devices.
    int
    Gets the minimum length of a float array that will be sorted using a GPU if enabled.
    long
    getFreeMemoryForDevice(int deviceId)
    Get the amount of free memory (in bytes) available for the provided CUDA device.
    Deprecated.
    Use instance() instead.
    int
    Gets the minimum length of an int array that will be sorted using a GPU if enabled.
    int
    Gets the minimum length of a long array that will be sorted using a GPU if enabled.
    int
    Returns the next CUDA device that is available to run calculations on.
    static String
    Get the header used to prefix all IBM GPU related output.
    boolean
    Get the value of the verboseGPUOutput flag.
    static String
    Get the version of this class.
    boolean
    Use this method to identify if CUDA is supported on this machine and within this environment: returns true if the number of CUDA devices detected is greater than 0.
    Return a CUDAManager instance.
    boolean
    This method provides a means to determine if sort is enabled to be used by any available CUDA device.
    boolean
    This method provides a means to determine if sort is forced to be used by any available CUDA device.
    void
    Print information for each detected CUDA device.
    void
    releaseDevice(int deviceId)
    Mark a device as being free; must be in a try finally block as we MUST release the handle regardless of whether or not a sort was successful.
    void
    setDefaultDevice(int deviceId)
    Sets the default device to the given device ID.
    void
    setDevice(int deviceId)
    Use this method to set the device to use for subsequent calls.
    void
    setVerboseGPU(boolean condition)
    Set the value of the verboseGPUOutput flag.
    static void
    Deprecated.
    This method has no effect; it will be removed in a future version.

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      Deprecated.
      Use instance() instead.
      Return a CUDAManager instance.
      Returns:
      a CUDAManager instance
      Throws:
      GPUConfigurationException - This exception is not actually thrown; use instance() instead.
      SecurityException - If a security manager exists and the calling thread does not have permission to access the CUDAManager instance.
    • instance

      public static CUDAManager instance() throws SecurityException
      Return a CUDAManager instance.
      Returns:
      a CUDAManager instance
      Throws:
      SecurityException - If a security manager exists and the calling thread does not have permission to access the CUDAManager instance.
    • getOutputHeader

      public static String getOutputHeader()
      Get the header used to prefix all IBM GPU related output.
      Returns:
      The header used for IBM GPU related output.
    • getVersion

      public static String getVersion()
      Get the version of this class.
      Returns:
      Returns the version of this class.
    • tearDown

      @Deprecated public static void tearDown()
      Deprecated.
      This method has no effect; it will be removed in a future version.
      Performs cleanup on the CUDAManager class.
    • acquireFreeDevice

      public int acquireFreeDevice()
      Look for the next free device and mark it as busy.
      Returns:
      Returns the device ID of the next free device.
    • getCUDADevices

      public ArrayList<CUDADevice> getCUDADevices()
      Use this method to obtain a reference to an ArrayList containing references to all discovered CUDA devices.
      Returns:
      Returns an ArrayList containing all discovered CUDA devices - see CUDADevice for details.
    • getDefaultDevice

      public int getDefaultDevice()
      Gets the ID of the default device, set to 0 by default.
      Returns:
      Returns the device ID of the current default device.
    • getDevice

      public CUDADevice getDevice(int deviceId) throws GPUConfigurationException
      Get a reference to the CUDA device by means of its index (with 0 being the first).
      Parameters:
      deviceId - The index of the device to retrieve (with 0 being the first).
      Returns:
      Returns a CUDA device at the specified index - see CUDADevice for details.
      Throws:
      GPUConfigurationException - Throws this exception if an invalid deviceId has been specified.
    • getDeviceCount

      public int getDeviceCount()
      Identifies the number of available CUDA devices.
      Returns:
      Returns how many CUDA devices have been detected.
    • getDeviceWithMostAvailableMemory

      public CUDADevice getDeviceWithMostAvailableMemory() throws GPUConfigurationException
      Identifies the CUDA device that has the most memory available.
      Returns:
      Returns a reference to the CUDA device with the most memory available.
      Throws:
      GPUConfigurationException - Throws this exception if an attempt was made to access an invalid device (no longer available).
    • getDoubleThreshold

      public int getDoubleThreshold()
      Gets the minimum length of a double array that will be sorted using a GPU if enabled.
      Returns:
      The minimum length of a double array that will be sorted using a GPU.
    • getEnabledCUDADevices

      public CUDADevice[] getEnabledCUDADevices()
      Use this method to return an array of enabled CUDA devices.
      Returns:
      Returns an array containing enabled CUDA devices - see CUDADevice for details.
    • getFloatThreshold

      public int getFloatThreshold()
      Gets the minimum length of a float array that will be sorted using a GPU if enabled.
      Returns:
      The minimum length of a float array that will be sorted using a GPU.
    • getFreeMemoryForDevice

      public long getFreeMemoryForDevice(int deviceId) throws GPUConfigurationException
      Get the amount of free memory (in bytes) available for the provided CUDA device. Does not persistently change the current device.
      Parameters:
      deviceId - The index of the device to query (with 0 being the first).
      Returns:
      Returns the amount of free memory available.
      Throws:
      GPUConfigurationException - Throw this exception if cannot get free memory amount.
    • getIntThreshold

      public int getIntThreshold()
      Gets the minimum length of an int array that will be sorted using a GPU if enabled.
      Returns:
      The minimum length of an int array that will be sorted using a GPU.
    • getLongThreshold

      public int getLongThreshold()
      Gets the minimum length of a long array that will be sorted using a GPU if enabled.
      Returns:
      The minimum length of a long array that will be sorted using a GPU.
    • getNextAvailableDevice

      public int getNextAvailableDevice()
      Returns the next CUDA device that is available to run calculations on.
      Returns:
      -1 if there are no free devices, otherwise returns the ID of the free CUDA device.
    • getVerboseGPUOutput

      public boolean getVerboseGPUOutput()
      Get the value of the verboseGPUOutput flag.
      Returns:
      Whether or not verbose output should be produced.
    • hasCUDASupport

      public boolean hasCUDASupport()
      Use this method to identify if CUDA is supported on this machine and within this environment: returns true if the number of CUDA devices detected is greater than 0.
      Returns:
      Returns true if one or more CUDA devices have been detected.
    • isSortEnabledOnGPU

      public boolean isSortEnabledOnGPU()
      This method provides a means to determine if sort is enabled to be used by any available CUDA device.
      Returns:
      Returns true if GPU sort is enabled.
    • isSortEnforcedOnGPU

      public boolean isSortEnforcedOnGPU()
      This method provides a means to determine if sort is forced to be used by any available CUDA device.
      Returns:
      Returns true if GPU sort is forced.
    • printAllDeviceInfo

      public void printAllDeviceInfo()
      Print information for each detected CUDA device.
    • releaseDevice

      public void releaseDevice(int deviceId)
      Mark a device as being free; must be in a try finally block as we MUST release the handle regardless of whether or not a sort was successful.
      Parameters:
      deviceId - The device to be marked as free.
    • setDefaultDevice

      public void setDefaultDevice(int deviceId)
      Sets the default device to the given device ID.
      Parameters:
      deviceId - The new default device.
    • setDevice

      public void setDevice(int deviceId) throws GPUConfigurationException
      Use this method to set the device to use for subsequent calls.
      Parameters:
      deviceId - Set the default device ID to be this.
      Throws:
      GPUConfigurationException - Throws this exception if an invalid device number was specified.
    • setVerboseGPU

      public void setVerboseGPU(boolean condition)
      Set the value of the verboseGPUOutput flag. When this flag is true, GPU output will be produced.
      Parameters:
      condition - Whether or not verbose output should be produced.