Class: Ignis::JIT::CompiledKernel
- Inherits:
-
Object
- Object
- Ignis::JIT::CompiledKernel
- Defined in:
- lib/nvruby/jit/compiled_kernel.rb
Overview
Represents compiled CUDA code (CUBIN binary) Device-agnostic representation that can be loaded onto any compatible GPU Thread-safe immutable object suitable for caching
Instance Attribute Summary collapse
-
#compile_options ⇒ Array<String>
readonly
Compilation options used.
-
#compiled_at ⇒ Time
readonly
Compilation timestamp.
-
#compute_capability ⇒ Integer
readonly
Target compute capability (e.g., 89 for sm_89).
-
#cubin_data ⇒ String
readonly
The compiled CUBIN binary data.
-
#cubin_size ⇒ Integer
readonly
Size of the CUBIN data in bytes.
-
#kernel_name ⇒ String
readonly
Kernel function name.
-
#source_code ⇒ String
readonly
The original source code (for debugging).
Instance Method Summary collapse
-
#compatible_with?(target_cc) ⇒ Boolean
Check if compatible with a given compute capability.
-
#initialize(cubin_data:, compute_capability:, kernel_name:, source_code: nil, compile_options: []) ⇒ CompiledKernel
constructor
Create a new CompiledKernel.
-
#inspect ⇒ String
Get detailed inspection.
-
#load(device_id: 0) ⇒ KernelModule
Load this compiled kernel onto a specific device.
-
#to_s ⇒ String
Get a string representation.
Constructor Details
#initialize(cubin_data:, compute_capability:, kernel_name:, source_code: nil, compile_options: []) ⇒ CompiledKernel
Create a new CompiledKernel
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 36 def initialize(cubin_data:, compute_capability:, kernel_name:, source_code: nil, compile_options: []) @cubin_data = cubin_data.freeze @cubin_size = cubin_data.bytesize @compute_capability = compute_capability @kernel_name = kernel_name.freeze @source_code = source_code&.freeze @compile_options = .map(&:freeze).freeze @compiled_at = Time.now.freeze freeze end |
Instance Attribute Details
#compile_options ⇒ Array<String> (readonly)
Returns Compilation options used.
25 26 27 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 25 def @compile_options end |
#compiled_at ⇒ Time (readonly)
Returns Compilation timestamp.
28 29 30 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 28 def compiled_at @compiled_at end |
#compute_capability ⇒ Integer (readonly)
Returns Target compute capability (e.g., 89 for sm_89).
16 17 18 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 16 def compute_capability @compute_capability end |
#cubin_data ⇒ String (readonly)
Returns The compiled CUBIN binary data.
10 11 12 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 10 def cubin_data @cubin_data end |
#cubin_size ⇒ Integer (readonly)
Returns Size of the CUBIN data in bytes.
13 14 15 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 13 def cubin_size @cubin_size end |
#kernel_name ⇒ String (readonly)
Returns Kernel function name.
22 23 24 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 22 def kernel_name @kernel_name end |
#source_code ⇒ String (readonly)
Returns The original source code (for debugging).
19 20 21 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 19 def source_code @source_code end |
Instance Method Details
#compatible_with?(target_cc) ⇒ Boolean
Check if compatible with a given compute capability
75 76 77 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 75 def compatible_with?(target_cc) target_cc >= @compute_capability end |
#inspect ⇒ String
Get detailed inspection
64 65 66 67 68 69 70 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 64 def inspect "#<Ignis::JIT::CompiledKernel:0x#{object_id.to_s(16)} " \ "kernel=#{@kernel_name.inspect} " \ "sm=#{@compute_capability} " \ "size=#{@cubin_size} " \ "compiled_at=#{@compiled_at.strftime('%Y-%m-%d %H:%M:%S')}>" end |
#load(device_id: 0) ⇒ KernelModule
Load this compiled kernel onto a specific device
51 52 53 54 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 51 def load(device_id: 0) Ignis.set_device(device_id) KernelModule.new(self, device_id: device_id) end |
#to_s ⇒ String
Get a string representation
58 59 60 |
# File 'lib/nvruby/jit/compiled_kernel.rb', line 58 def to_s "#<Ignis::JIT::CompiledKernel #{@kernel_name} sm_#{@compute_capability} #{@cubin_size} bytes>" end |