Class NativeCUDADenseLinearAlgebraDoubleBackend<E extends FieldElement<E>>
java.lang.Object
org.episteme.nativ.mathematics.linearalgebra.backends.NativeCUDADenseLinearAlgebraDoubleBackend<E>
- All Implemented Interfaces:
AutoCloseable, LinearAlgebraProvider<E>, AlgorithmProvider, Backend, ComputeBackend, GPUBackend, NativeBackend
@AutoService({Backend.class,ComputeBackend.class,NativeBackend.class,LinearAlgebraProvider.class,GPUBackend.class})
public class NativeCUDADenseLinearAlgebraDoubleBackend<E extends FieldElement<E>>
extends Object
implements LinearAlgebraProvider<E>, NativeBackend, GPUBackend
Native CUDA Dense Linear Algebra Backend for Double precision.
-
Nested Class Summary
Nested classes/interfaces inherited from interface GPUBackend
GPUBackend.DeviceInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongallocateGPUMemory(long sizeBytes) Allocates GPU memory and returns a handle.Returns the angle between two vectors in radians.Computes the Cholesky decomposition of the specified matrix.voidclose()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.Creates an execution context for running operations.Returns the cross product of two 3D vectors.determinant(Matrix<E> a) Computes the eigenvalue decomposition of the specified matrix.voidfreeGPUMemory(long gpuHandle) Frees GPU memory.Returns the type of hardware accelerator used by this backend.Returns information about available GPU devices.getId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").getName()Returns the display name for UI presentation.Returns the name of the native library this backend depends on.intPriority of this provider (higher means more preferred).getType()Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").booleanChecks if the provider is available in the current environment.booleanisCompatible(Ring<?> ring) Checks if this provider is compatible with the given ring.booleanChecks if this backend is specifically disabled via a system property:"episteme.backend.disable." + getId().booleanisLoaded()Checks if the native library is loaded and available.Computes the LU decomposition of the specified matrix.voidmatrixMultiply(DoubleBuffer A, DoubleBuffer B, DoubleBuffer C, int m, int n, int k) Performs matrix multiplication C = A * B on the GPU.Returns the normalized vector (unit vector).Computes the QR decomposition of the specified matrix.voidselectDevice(int deviceId) Selects a GPU device for computation.voidshutdown()Called when the provider is no longer needed (e.g., application shutdown).solveTriangular(Matrix<E> a, Vector<E> b, boolean upper, boolean transpose, boolean conjugate, boolean unit) Solves the triangular system Ax = b.Computes the Singular Value Decomposition (SVD) of the specified matrix.voidSynchronizes GPU execution (waits for all kernels to complete).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadataMethods inherited from interface Backend
getAlgorithmProviders, getStatusMessageMethods inherited from interface ComputeBackend
createBackend, getDescription, supportsComplexNumbers, supportsFloatingPoint, supportsParallelOps
-
Constructor Details
-
NativeCUDADenseLinearAlgebraDoubleBackend
public NativeCUDADenseLinearAlgebraDoubleBackend()
-
-
Method Details
-
isLoaded
public boolean isLoaded()Description copied from interface:NativeBackendChecks if the native library is loaded and available.- Specified by:
isLoadedin interfaceNativeBackend- Returns:
- true if the native library has been successfully loaded
-
getNativeLibraryName
Description copied from interface:NativeBackendReturns the name of the native library this backend depends on.- Specified by:
getNativeLibraryNamein interfaceNativeBackend- Returns:
- library name (e.g., "openblas", "cuda", "fftw3")
-
isAvailable
public boolean isAvailable()Description copied from interface:AlgorithmProviderChecks if the provider is available in the current environment.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend
-
isExplicitlyDisabled
public boolean isExplicitlyDisabled()Description copied from interface:BackendChecks if this backend is specifically disabled via a system property:"episteme.backend.disable." + getId().It also checks specialized properties like
"episteme.linearalgebra.disable." + getId().- Specified by:
isExplicitlyDisabledin interfaceBackend- Returns:
- true if explicitly disabled
-
isCompatible
Description copied from interface:LinearAlgebraProviderChecks if this provider is compatible with the given ring.- Specified by:
isCompatiblein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
getId
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceBackend- Specified by:
getNamein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
getPriority
public int getPriority()Description copied from interface:LinearAlgebraProviderPriority of this provider (higher means more preferred). Used for automatic backend selection.- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend- Specified by:
getPriorityin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
shutdown
public void shutdown()Description copied from interface:AlgorithmProviderCalled when the provider is no longer needed (e.g., application shutdown). Use this to release local resources or close native segments.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend
-
add
-
subtract
-
scale
- Specified by:
scalein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
multiply
-
dot
- Specified by:
dotin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
norm
- Specified by:
normin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
trace
- Specified by:
tracein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
conjugateTranspose
- Specified by:
conjugateTransposein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
normalize
Description copied from interface:LinearAlgebraProviderReturns the normalized vector (unit vector).- Specified by:
normalizein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
cross
Description copied from interface:LinearAlgebraProviderReturns the cross product of two 3D vectors.- Specified by:
crossin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
angle
Description copied from interface:LinearAlgebraProviderReturns the angle between two vectors in radians.- Specified by:
anglein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
multiply
-
transpose
- Specified by:
transposein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
lu
Description copied from interface:LinearAlgebraProviderComputes the LU decomposition of the specified matrix.- Specified by:
luin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
qr
Description copied from interface:LinearAlgebraProviderComputes the QR decomposition of the specified matrix.- Specified by:
qrin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
svd
Description copied from interface:LinearAlgebraProviderComputes the Singular Value Decomposition (SVD) of the specified matrix.- Specified by:
svdin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
solve
-
determinant
- Specified by:
determinantin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
solve
-
inverse
- Specified by:
inversein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
solveTriangular
public Vector<E> solveTriangular(Matrix<E> a, Vector<E> b, boolean upper, boolean transpose, boolean conjugate, boolean unit) Description copied from interface:LinearAlgebraProviderSolves the triangular system Ax = b.- Specified by:
solveTriangularin interfaceLinearAlgebraProvider<E extends FieldElement<E>>- Parameters:
a- the triangular matrixb- the right-hand side vectorupper- true if A is upper triangular, false if lowertranspose- true if solving A^T x = bconjugate- true if solving A^H x = b (only if transpose is true and complex)unit- true if A is unit triangular (diagonal is all ones)
-
cholesky
Description copied from interface:LinearAlgebraProviderComputes the Cholesky decomposition of the specified matrix.- Specified by:
choleskyin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
eigen
Description copied from interface:LinearAlgebraProviderComputes the eigenvalue decomposition of the specified matrix.- Specified by:
eigenin interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLinearAlgebraProvider<E extends FieldElement<E>>
-
getAcceleratorType
Description copied from interface:ComputeBackendReturns the type of hardware accelerator used by this backend.- Specified by:
getAcceleratorTypein interfaceComputeBackend- Returns:
- the accelerator type
-
getType
-
createContext
Description copied from interface:ComputeBackendCreates an execution context for running operations.The context should be used within a try-with-resources block to ensure proper cleanup of resources.
- Specified by:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
getDevices
Description copied from interface:GPUBackendReturns information about available GPU devices.- Specified by:
getDevicesin interfaceGPUBackend
-
selectDevice
public void selectDevice(int deviceId) Description copied from interface:GPUBackendSelects a GPU device for computation.- Specified by:
selectDevicein interfaceGPUBackend- Parameters:
deviceId- Device index (0-based)
-
allocateGPUMemory
public long allocateGPUMemory(long sizeBytes) Description copied from interface:GPUBackendAllocates GPU memory and returns a handle.- Specified by:
allocateGPUMemoryin interfaceGPUBackend- Parameters:
sizeBytes- Size in bytes- Returns:
- GPU memory handle (opaque pointer)
-
copyToGPU
Description copied from interface:GPUBackendCopies data from host to GPU.- Specified by:
copyToGPUin interfaceGPUBackend- Parameters:
gpuHandle- GPU memory handlehostBuffer- Host buffersizeBytes- Number of bytes to copy
-
copyFromGPU
Description copied from interface:GPUBackendCopies data from GPU to host.- Specified by:
copyFromGPUin interfaceGPUBackend- Parameters:
gpuHandle- GPU memory handlehostBuffer- Host buffersizeBytes- Number of bytes to copy
-
freeGPUMemory
public void freeGPUMemory(long gpuHandle) Description copied from interface:GPUBackendFrees GPU memory.- Specified by:
freeGPUMemoryin interfaceGPUBackend- Parameters:
gpuHandle- GPU memory handle
-
synchronize
public void synchronize()Description copied from interface:GPUBackendSynchronizes GPU execution (waits for all kernels to complete).- Specified by:
synchronizein interfaceGPUBackend
-
matrixMultiply
Description copied from interface:GPUBackendPerforms matrix multiplication C = A * B on the GPU. Dimensions: A(m x k), B(k x n), C(m x n).- Specified by:
matrixMultiplyin interfaceGPUBackend
-