Module: Ignis::Solver::CuSolverBindings
- Extended by:
- FFI::Library
- Defined in:
- lib/nvruby/solver/cusolver_bindings.rb
Overview
cuSOLVER Dense (Dn) library FFI bindings Provides LU decomposition, SVD, and eigenvalue solvers
Constant Summary collapse
- CUSOLVER_STATUS_SUCCESS =
cuSOLVER status codes
0- CUSOLVER_STATUS_NOT_INITIALIZED =
1- CUSOLVER_STATUS_ALLOC_FAILED =
2- CUSOLVER_STATUS_INVALID_VALUE =
3- CUSOLVER_STATUS_ARCH_MISMATCH =
4- CUSOLVER_STATUS_MAPPING_ERROR =
5- CUSOLVER_STATUS_EXECUTION_FAILED =
6- CUSOLVER_STATUS_INTERNAL_ERROR =
7- CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED =
8- CUSOLVER_STATUS_NOT_SUPPORTED =
9- CUSOLVER_STATUS_ZERO_PIVOT =
10- CUSOLVER_STATUS_INVALID_LICENSE =
11- CUSOLVER_STATUS_IRS_PARAMS_NOT_INITIALIZED =
12- CUSOLVER_STATUS_IRS_PARAMS_INVALID =
13- CUSOLVER_STATUS_IRS_PARAMS_INVALID_PREC =
14- CUSOLVER_STATUS_IRS_PARAMS_INVALID_REFINE =
15- CUSOLVER_STATUS_IRS_PARAMS_INVALID_MAXITER =
16- CUSOLVER_STATUS_IRS_INTERNAL_ERROR =
20- CUSOLVER_STATUS_IRS_NOT_SUPPORTED =
21- CUSOLVER_STATUS_IRS_OUT_OF_RANGE =
22- CUSOLVER_STATUS_IRS_NRHS_NOT_SUPPORTED_FOR_REFINE_GMRES =
23- CUSOLVER_STATUS_IRS_INFOS_NOT_INITIALIZED =
25- CUSOLVER_EIG_MODE_NOVECTOR =
cuSOLVER EigMode (for eigenvalue/eigenvector computation)
0- CUSOLVER_EIG_MODE_VECTOR =
Compute eigenvalues only
1- CUSOLVER_EIG_TYPE_1 =
cuSOLVER EigType (for generalized eigenvalue problem)
1- CUSOLVER_EIG_TYPE_2 =
A*x = lambda*B*x
2- CUSOLVER_EIG_TYPE_3 =
A*B*x = lambda*x
3- CUSOLVER_EIG_RANGE_ALL =
cuSOLVER EigRange (eigenvalue range selection)
0- CUSOLVER_EIG_RANGE_V =
All eigenvalues
1- CUSOLVER_EIG_RANGE_I =
Eigenvalues in half-open interval (vl, vu]
2- CUBLAS_FILL_MODE_LOWER =
cuBLAS fill mode (used by cuSOLVER)
0- CUBLAS_FILL_MODE_UPPER =
1- CUBLAS_FILL_MODE_FULL =
2- CUBLAS_OP_N =
cuBLAS operation types
0- CUBLAS_OP_T =
No transpose
1- CUBLAS_OP_C =
Transpose
2- STATUS_DESCRIPTIONS =
Status code descriptions
{ CUSOLVER_STATUS_SUCCESS => "Success", CUSOLVER_STATUS_NOT_INITIALIZED => "Library not initialized", CUSOLVER_STATUS_ALLOC_FAILED => "Resource allocation failed", CUSOLVER_STATUS_INVALID_VALUE => "Invalid parameter value", CUSOLVER_STATUS_ARCH_MISMATCH => "Architecture mismatch", CUSOLVER_STATUS_MAPPING_ERROR => "Mapping error", CUSOLVER_STATUS_EXECUTION_FAILED => "Execution failed", CUSOLVER_STATUS_INTERNAL_ERROR => "Internal error", CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED => "Matrix type not supported", CUSOLVER_STATUS_NOT_SUPPORTED => "Operation not supported", CUSOLVER_STATUS_ZERO_PIVOT => "Zero pivot encountered", CUSOLVER_STATUS_INVALID_LICENSE => "Invalid license" }.freeze
Class Attribute Summary collapse
-
.handle ⇒ FFI::Pointer?
CuSOLVER handle.
Class Method Summary collapse
-
.check_status!(status, context = "cuSOLVER operation") ⇒ void
Check cuSOLVER status and raise error if not success.
-
.ensure_loaded! ⇒ void
Ensure cuSOLVER is loaded and initialized.
-
.finalize! ⇒ void
Finalize cuSOLVER and release resources.
-
.get_handle ⇒ FFI::Pointer
Get or create cuSOLVER handle.
-
.loaded? ⇒ Boolean
Check if cuSOLVER is loaded.
-
.set_stream(stream) ⇒ void
Set the CUDA stream for cuSOLVER operations.
Class Attribute Details
.handle ⇒ FFI::Pointer?
Returns cuSOLVER handle.
82 83 84 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 82 def handle @handle end |
Class Method Details
.check_status!(status, context = "cuSOLVER operation") ⇒ void
This method returns an undefined value.
Check cuSOLVER status and raise error if not success
151 152 153 154 155 156 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 151 def check_status!(status, context = "cuSOLVER operation") return if status == CUSOLVER_STATUS_SUCCESS description = STATUS_DESCRIPTIONS[status] || "Unknown error" raise CuSolverError.new("#{context} failed: #{description}", cusolver_code: status) end |
.ensure_loaded! ⇒ void
This method returns an undefined value.
Ensure cuSOLVER is loaded and initialized
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 93 def ensure_loaded! @mutex.synchronize do return if @loaded CUDA::LibraryLoader.load_library(:cusolver) cuda_bin = Ignis.configuration.cuda_bin_path dll_path = if cuda_bin Dir.glob(File.join(cuda_bin, "cusolver64_*.dll")).max else "cusolver64_12" end raise LibraryNotFoundError, "cusolver" unless dll_path ffi_lib dll_path attach_cusolver_functions! initialize_cusolver! @loaded = true Ignis.logger.info("cuSOLVER initialized successfully") end end |
.finalize! ⇒ void
This method returns an undefined value.
Finalize cuSOLVER and release resources
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 135 def finalize! @mutex.synchronize do return unless @handle cusolverDnDestroy(@handle) @handle = nil @loaded = false Ignis.logger.info("cuSOLVER finalized") end end |
.get_handle ⇒ FFI::Pointer
Get or create cuSOLVER handle
119 120 121 122 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 119 def get_handle ensure_loaded! @handle end |
.loaded? ⇒ Boolean
Check if cuSOLVER is loaded
86 87 88 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 86 def loaded? @loaded end |
.set_stream(stream) ⇒ void
This method returns an undefined value.
Set the CUDA stream for cuSOLVER operations
127 128 129 130 131 |
# File 'lib/nvruby/solver/cusolver_bindings.rb', line 127 def set_stream(stream) ensure_loaded! status = cusolverDnSetStream(@handle, stream) check_status!(status, "cusolverDnSetStream") end |