Module: Ignis::Linalg::CuTensorBindings

Extended by:
FFI::Library
Defined in:
lib/nvruby/linalg/cutensor_bindings.rb

Overview

FFI bindings for NVIDIA cuTENSOR v2.4+ High-performance tensor primitives for CUDA

Constant Summary collapse

CUTENSOR_STATUS_SUCCESS =

cuTENSOR status codes

0
CUTENSOR_STATUS_NOT_INITIALIZED =
1
CUTENSOR_STATUS_ALLOC_FAILED =
2
CUTENSOR_STATUS_INVALID_VALUE =
3
CUTENSOR_STATUS_ARCH_MISMATCH =
4
CUTENSOR_STATUS_MAPPING_ERROR =
5
CUTENSOR_STATUS_EXECUTION_FAILED =
6
CUTENSOR_STATUS_INTERNAL_ERROR =
7
CUTENSOR_STATUS_NOT_SUPPORTED =
8
CUTENSOR_STATUS_LICENSE_ERROR =
9
CUTENSOR_STATUS_CUBLAS_ERROR =
10
CUTENSOR_STATUS_CUDA_ERROR =
11
CUTENSOR_STATUS_INSUFFICIENT_WORKSPACE =
12
CUTENSOR_STATUS_INSUFFICIENT_DRIVER =
13
CUTENSOR_ALGO_DEFAULT =

cuTENSOR Algorithms

-1
CUTENSOR_ALGO_GETT =
-2
CUTENSOR_ALGO_TGETT =
-3
CUTENSOR_WORKSPACE_MIN =

Workspace preference enums

1
2
CUTENSOR_WORKSPACE_MAX =
3

Class Method Summary collapse

Class Method Details

.check_status!(status, context = "cuTENSOR operation") ⇒ Object

Check status and raise error if not success

Parameters:

  • status (Integer)

    status code

  • context (String) (defaults to: "cuTENSOR operation")

    Context for error message

Raises:



65
66
67
68
69
# File 'lib/nvruby/linalg/cutensor_bindings.rb', line 65

def check_status!(status, context = "cuTENSOR operation")
  return if status == CUTENSOR_STATUS_SUCCESS

  raise CuTensorError.new("#{context} failed", status_code: status)
end

.ensure_loaded!void

This method returns an undefined value.

Ensure cuTENSOR library is loaded and functions attached



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nvruby/linalg/cutensor_bindings.rb', line 44

def ensure_loaded!
  @mutex.synchronize do
    return if @loaded

    CUDA::LibraryLoader.load_library(:cutensor)
    dll_path = CUDA::LibraryLoader.library_paths[:cutensor]
    
    raise LibraryNotFoundError, "cutensor" unless dll_path

    ffi_lib dll_path
    attach_functions!

    @loaded = true
    Ignis.logger.debug("cuTENSOR bindings loaded from #{dll_path}")
  end
end