Class: SGC::CU::CUModule
- Inherits:
-
Object
- Object
- SGC::CU::CUModule
- Defined in:
- lib/cuda/driver/module.rb
Instance Method Summary (collapse)
-
- (CUFunction) function(name)
Lookup for a CUDA function corresponds to the function name name in the loaded compute module.
-
- (Array(CUDevicePtr, Integer)) global(name)
Lookup for the device pointer and the size of the global variable name in the loaded compute modules.
-
- (CUModule) initialize
constructor
Allocate a CUDA module.
-
- (CUModule) load(path)
Load a compute module from the file at path into the current CUDA context.
-
- (CUModule) load_data(image_str)
Load a compute module from the String image_str into the current CUDA context.
- - (Object) load_data_ex
- - (Object) load_fat_binary
-
- (Object) surfref(name)
A surface texture reference corresponds to the surface name in the loaded compute module.
-
- (Object) texref(name)
A texture reference corresponds to the texture name in the loaded compute module.
-
- (CUModule) unload
Unload this CUDA module from the current CUDA context.
Constructor Details
- (CUModule) initialize
Allocate a CUDA module.
37 38 39 |
# File 'lib/cuda/driver/module.rb', line 37 def initialize @pmod = FFI::MemoryPointer.new(:CUModule) end |
Instance Method Details
- (CUFunction) function(name)
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 |
- (Array(CUDevicePtr, Integer)) global(name)
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 |
- (CUModule) load(path)
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 |
- (CUModule) load_data(image_str)
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 |
- (Object) load_data_ex
Not implemented yet.
72 73 74 |
# File 'lib/cuda/driver/module.rb', line 72 def load_data_ex raise NotImplementedError end |
- (Object) load_fat_binary
Not implemented yet.
80 81 82 |
# File 'lib/cuda/driver/module.rb', line 80 def load_fat_binary raise NotImplementedError end |
- (Object) surfref(name)
Not implemented yet.
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 |
- (Object) texref(name)
Not implemented yet.
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 |
- (CUModule) unload
Unload this CUDA module from the current CUDA context.
87 88 89 90 91 |
# File 'lib/cuda/driver/module.rb', line 87 def unload status = API::cuModuleUnload(self.to_api) Pvt::handle_error(status, "Failed to unload module.") self end |