Module: Ignis::Solver::AMGXBindings

Extended by:
FFI::Library
Defined in:
lib/nvruby/solver/amgx_bindings.rb

Overview

FFI bindings for NVIDIA AMGX algebraic multigrid solver library AMGX provides GPU-accelerated solvers for sparse linear systems

Defined Under Namespace

Modules: Mode, RC, SolveStatus

Class Method Summary collapse

Class Method Details

.check_rc!(rc, context = "AMGX operation") ⇒ void

This method returns an undefined value.

Check AMGX return code and raise error if not OK

Parameters:

  • rc (Integer)

    Return code

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

    Error context

Raises:



150
151
152
153
154
155
156
157
158
# File 'lib/nvruby/solver/amgx_bindings.rb', line 150

def self.check_rc!(rc, context = "AMGX operation")
  return if rc == RC::OK

  msg_buf = FFI::MemoryPointer.new(:char, 4096)
  AMGX_get_error_string(rc, msg_buf, 4096)
  error_msg = msg_buf.read_string

  raise AMGXError.new("#{context}: #{error_msg}", amgx_code: rc)
end

.ensure_loaded!(dll_path = nil) ⇒ void

This method returns an undefined value.

Load AMGX library

Parameters:

  • dll_path (String, nil) (defaults to: nil)

    Path to amgxsh.dll (searches common paths if nil)

Raises:

  • (LoadError)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/nvruby/solver/amgx_bindings.rb', line 59

def ensure_loaded!(dll_path = nil)
  return if @loaded

  paths = dll_path ? [dll_path] : search_paths
  loaded_path = nil

  paths.each do |path|
    next unless File.exist?(path)

    begin
      ffi_lib path
      loaded_path = path
      break
    rescue FFI::LoadError
      next
    end
  end

  raise LoadError, "Could not load amgxsh.dll. Searched: #{paths.join(', ')}" unless loaded_path

  attach_functions!
  @loaded = true
  Ignis.logger.info { "Loaded AMGX: #{loaded_path}" }
end

.loaded?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/nvruby/solver/amgx_bindings.rb', line 52

def loaded?
  @loaded ||= false
end