java.lang.Object
com.ibm.gpu.CUDAManager
This class contains information important to IBM GPU enabled functions.
-
Method Summary
Modifier and TypeMethodDescriptionintLook 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.intGets 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).intIdentifies the number of available CUDA devices.Identifies the CUDA device that has the most memory available.intGets 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.intGets the minimum length of a float array that will be sorted using a GPU if enabled.longgetFreeMemoryForDevice(int deviceId) Get the amount of free memory (in bytes) available for the provided CUDA device.static CUDAManagerDeprecated.intGets the minimum length of an int array that will be sorted using a GPU if enabled.intGets the minimum length of a long array that will be sorted using a GPU if enabled.intReturns the next CUDA device that is available to run calculations on.static StringGet the header used to prefix all IBM GPU related output.booleanGet the value of the verboseGPUOutput flag.static StringGet the version of this class.booleanUse 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.static CUDAManagerinstance()Return a CUDAManager instance.booleanThis method provides a means to determine if sort is enabled to be used by any available CUDA device.booleanThis method provides a means to determine if sort is forced to be used by any available CUDA device.voidPrint information for each detected CUDA device.voidreleaseDevice(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.voidsetDefaultDevice(int deviceId) Sets the default device to the given device ID.voidsetDevice(int deviceId) Use this method to set the device to use for subsequent calls.voidsetVerboseGPU(boolean condition) Set the value of the verboseGPUOutput flag.static voidtearDown()Deprecated.This method has no effect; it will be removed in a future version.
-
Method Details
-
getInstance
@Deprecated public static CUDAManager getInstance() throws GPUConfigurationException, SecurityExceptionDeprecated.Useinstance()instead.Return a CUDAManager instance.- Returns:
- a CUDAManager instance
- Throws:
GPUConfigurationException- This exception is not actually thrown; useinstance()instead.SecurityException- If a security manager exists and the calling thread does not have permission to access the CUDAManager instance.
-
instance
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
Get the header used to prefix all IBM GPU related output.- Returns:
- The header used for IBM GPU related output.
-
getVersion
Get the version of this class.- Returns:
- Returns the version of this class.
-
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
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
CUDADevicefor 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
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
CUDADevicefor 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
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
Use this method to return an array of enabled CUDA devices.- Returns:
- Returns an array containing enabled CUDA devices -
see
CUDADevicefor 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
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
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.
-
instance()instead.