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

public interface GPUBackend extends ComputeBackend
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)
  • 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

      void copyToGPU(long gpuHandle, DoubleBuffer hostBuffer, long sizeBytes)
      Copies data from host to GPU.
      Parameters:
      gpuHandle - GPU memory handle
      hostBuffer - Host buffer
      sizeBytes - Number of bytes to copy
    • copyFromGPU

      void copyFromGPU(long gpuHandle, DoubleBuffer hostBuffer, long sizeBytes)
      Copies data from GPU to host.
      Parameters:
      gpuHandle - GPU memory handle
      hostBuffer - Host buffer
      sizeBytes - 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

      void matrixMultiply(DoubleBuffer A, DoubleBuffer B, DoubleBuffer C, int m, int n, int k)
      Performs matrix multiplication C = A * B on the GPU. Dimensions: A(m x k), B(k x n), C(m x n).