Interface GPUBackend
- All Superinterfaces:
Backend, ComputeBackend
- All Known Implementing Classes:
NativeCUDADenseLinearAlgebraDoubleBackend, NativeCUDADenseLinearAlgebraFloatBackend, NativeCUDANBodyBackend, NativeCUDASparseLinearAlgebraDoubleBackend, NativeCUDASparseLinearAlgebraFloatBackend, NativeCUDATensorBackend, NativeCUDAVisionBackend, NativeOpenCLDenseLinearAlgebraDoubleBackend, NativeOpenCLDenseLinearAlgebraFloatBackend, NativeOpenCLFFTBackend, NativeOpenCLLatticeBoltzmannBackend, NativeOpenCLNBodyBackend, NativeOpenCLSparseLinearAlgebraDoubleBackend, NativeOpenCLSparseLinearAlgebraFloatBackend, NativeOpenCLVisionBackend
GPU device management backend using CUDA or OpenCL.
This interface provides GPU device discovery, selection, and memory management. Algorithm-specific GPU operations (FFT, matrix multiply, reductions) are provided by their respective AlgorithmProvider implementations.
Implementation Strategy:
- Use JCuda for NVIDIA GPUs: http://www.jcuda.org/
- Use JOCL for OpenCL devices: http://www.jocl.org/
- Use Project Panama for direct native GPU library access
- Since:
- 1.2
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionlongallocateGPUMemory(long sizeBytes) Allocates GPU memory and returns a handle.voidcopyFromGPU(long gpuHandle, DoubleBuffer hostBuffer, long sizeBytes) Copies data from GPU to host.voidcopyToGPU(long gpuHandle, DoubleBuffer hostBuffer, long sizeBytes) Copies data from host to GPU.voidfreeGPUMemory(long gpuHandle) Frees GPU memory.Returns information about available GPU devices.voidmatrixMultiply(DoubleBuffer A, DoubleBuffer B, DoubleBuffer C, int m, int n, int k) Performs matrix multiplication C = A * B on the GPU.voidselectDevice(int deviceId) Selects a GPU device for computation.voidSynchronizes GPU execution (waits for all kernels to complete).Methods inherited from interface Backend
getAlgorithmProviders, getName, getPriority, getStatusMessage, isAvailable, isExplicitlyDisabled, shutdownMethods inherited from interface ComputeBackend
createBackend, createContext, getAcceleratorType, getDescription, getId, getType, supportsComplexNumbers, supportsFloatingPoint, supportsParallelOps
-
Method Details
-
getDevices
GPUBackend.DeviceInfo[] getDevices()Returns information about available GPU devices. -
selectDevice
void selectDevice(int deviceId) Selects a GPU device for computation.- Parameters:
deviceId- Device index (0-based)
-
allocateGPUMemory
long allocateGPUMemory(long sizeBytes) Allocates GPU memory and returns a handle.- Parameters:
sizeBytes- Size in bytes- Returns:
- GPU memory handle (opaque pointer)
-
copyToGPU
Copies data from host to GPU.- Parameters:
gpuHandle- GPU memory handlehostBuffer- Host buffersizeBytes- Number of bytes to copy
-
copyFromGPU
Copies data from GPU to host.- Parameters:
gpuHandle- GPU memory handlehostBuffer- Host buffersizeBytes- Number of bytes to copy
-
freeGPUMemory
void freeGPUMemory(long gpuHandle) Frees GPU memory.- Parameters:
gpuHandle- GPU memory handle
-
synchronize
void synchronize()Synchronizes GPU execution (waits for all kernels to complete). -
matrixMultiply
Performs matrix multiplication C = A * B on the GPU. Dimensions: A(m x k), B(k x n), C(m x n).
-