Class: SGC::CU::CUModule
- Inherits:
-
Object
- Object
- SGC::CU::CUModule
- Defined in:
- lib/cuda/driver/module.rb
Instance Method Summary collapse
-
#function(name) ⇒ CUFunction
Lookup for a CUDA function corresponds to the function name name in the loaded compute module.
-
#global(name) ⇒ Array(CUDevicePtr, Integer)
Lookup for the device pointer and the size of the global variable name in the loaded compute modules.
-
#initialize ⇒ CUModule
constructor
Allocate a CUDA module.
-
#load(path) ⇒ CUModule
Load a compute module from the file at path into the current CUDA context.
-
#load_data(image_str) ⇒ CUModule
Load a compute module from the String image_str into the current CUDA context.
- #load_data_ex ⇒ Object
- #load_fat_binary ⇒ Object
-
#surfref(name) ⇒ Object
A surface texture reference corresponds to the surface name in the loaded compute module.
-
#texref(name) ⇒ Object
A texture reference corresponds to the texture name in the loaded compute module.
-
#unload ⇒ CUModule
Unload this CUDA module from the current CUDA context.
Constructor Details
Instance Method Details
#function(name) ⇒ CUFunction
Lookup for a CUDA function corresponds to the function name name in the loaded compute module. A compute module was loaded with #load and alike methods.
98 99 100 101 102 103 |
# File 'lib/cuda/driver/module.rb', line 98 def function(name) p = FFI::MemoryPointer.new(:CUFunction) status = API::cuModuleGetFunction(p, self.to_api, name) Pvt::handle_error(status, "Failed to get module function: name = #{name}.") CUFunction.send(:new, p) end |
#global(name) ⇒ Array(CUDevicePtr, Integer)
Lookup for the device pointer and the size of the global variable name in the loaded compute modules.
109 110 111 112 113 114 115 |
# File 'lib/cuda/driver/module.rb', line 109 def global(name) pdevptr = FFI::MemoryPointer.new(:CUDevicePtr) psize = FFI::MemoryPointer.new(:size_t) status = API::cuModuleGetGlobal(pdevptr, psize, self.to_api, name) Pvt::handle_error(status, "Failed to get module global: name = #{name}.") [CUDevicePtr.send(:new, pdevptr), API::read_size_t(psize)] end |
#load(path) ⇒ CUModule
Load a compute module from the file at path into the current CUDA context. The file should be a cubin file or a PTX file.
A PTX file may be obtained by compiling the .cu file using nvcc with -ptx option.
$ nvcc -ptx vadd.cu
50 51 52 53 54 |
# File 'lib/cuda/driver/module.rb', line 50 def load(path) status = API::cuModuleLoad(@pmod, path) Pvt::handle_error(status, "Failed to load module: path = #{path}.") self end |
#load_data(image_str) ⇒ CUModule
Load a compute module from the String image_str into the current CUDA context.
62 63 64 65 66 |
# File 'lib/cuda/driver/module.rb', line 62 def load_data(image_str) status = API::cuModuleLoadData(@pmod, image_str) Pvt::handle_error(status, "Failed to load module data.") self end |
#load_data_ex ⇒ Object
Not implemented yet.
72 73 74 |
# File 'lib/cuda/driver/module.rb', line 72 def load_data_ex raise NotImplementedError end |
#load_fat_binary ⇒ Object
Not implemented yet.
80 81 82 |
# File 'lib/cuda/driver/module.rb', line 80 def load_fat_binary raise NotImplementedError end |
#surfref(name) ⇒ Object
Not implemented yet.
Returns A surface texture reference corresponds to the surface name in the loaded compute module.
129 130 131 |
# File 'lib/cuda/driver/module.rb', line 129 def surfref(name) raise NotImplementedError end |
#texref(name) ⇒ Object
Not implemented yet.
Returns A texture reference corresponds to the texture name in the loaded compute module.
121 122 123 |
# File 'lib/cuda/driver/module.rb', line 121 def texref(name) raise NotImplementedError end |