Module: Cumo::CUDA::NVRTC
- Defined in:
- ext/cumo/cuda/nvrtc.c
Class Method Summary collapse
- .nvrtcCompileProgram(prog, options) ⇒ Object
- .nvrtcCreateProgram(src, name, headers, includeNames) ⇒ Object
- .nvrtcDestroyProgram(prog) ⇒ Object
- .nvrtcGetProgramLog(prog) ⇒ Object
- .nvrtcGetPTX(prog) ⇒ Object
- .nvrtcVersion ⇒ Object
Class Method Details
.nvrtcCompileProgram(prog, options) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'ext/cumo/cuda/nvrtc.c', line 130
static VALUE
rb_nvrtcCompileProgram(VALUE self, VALUE prog, VALUE options)
{
nvrtcResult status;
nvrtcProgram _prog = (nvrtcProgram)NUM2SIZET(prog);
int _numOptions = RARRAY_LEN(options);
const char** _options = (const char **)malloc(_numOptions * sizeof(char *));
int i;
for (i = 0; i < _numOptions; i++) {
VALUE option = RARRAY_PTR(options)[i];
_options[i] = StringValueCStr(option);
}
{
struct nvrtcCompileProgramParam param = {_prog, _numOptions, _options};
status = (nvrtcResult)rb_thread_call_without_gvl(nvrtcCompileProgram_without_gvl_cb, ¶m, NULL, NULL);
}
free(_options);
check_status(status);
return Qnil;
}
|
.nvrtcCreateProgram(src, name, headers, includeNames) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'ext/cumo/cuda/nvrtc.c', line 53
static VALUE
rb_nvrtcCreateProgram(
VALUE self,
VALUE src,
VALUE name,
VALUE headers,
VALUE includeNames)
{
nvrtcResult status;
nvrtcProgram _prog;
const char* _src = StringValueCStr(src);
const char* _name = StringValueCStr(name);
int _numHeaders = RARRAY_LEN(headers);
const char** _headers = (const char **)malloc(_numHeaders * sizeof(char *));
const char** _includeNames = (const char **)malloc(_numHeaders * sizeof(char *));
int i;
for (i = 0; i < _numHeaders; i++) {
VALUE header = RARRAY_PTR(headers)[i];
_headers[i] = StringValueCStr(header);
}
for (i = 0; i < _numHeaders; i++) {
VALUE include_name = RARRAY_PTR(includeNames)[i];
_includeNames[i] = StringValueCStr(include_name);
}
{
struct nvrtcCreateProgramParam param = {&_prog, _src, _name, _numHeaders, _headers, _includeNames};
status = (nvrtcResult)rb_thread_call_without_gvl(nvrtcCreateProgram_without_gvl_cb, ¶m, NULL, NULL);
}
free(_headers);
free(_includeNames);
check_status(status);
return SIZET2NUM((size_t)_prog);
}
|
.nvrtcDestroyProgram(prog) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/cumo/cuda/nvrtc.c', line 102
static VALUE
rb_nvrtcDestroyProgram(VALUE self, VALUE prog)
{
nvrtcResult status;
nvrtcProgram _prog = (nvrtcProgram)NUM2SIZET(prog);
struct nvrtcDestroyProgramParam param = {&_prog};
status = (nvrtcResult)rb_thread_call_without_gvl(nvrtcDestroyProgram_without_gvl_cb, ¶m, NULL, NULL);
check_status(status);
return Qnil;
}
|
.nvrtcGetProgramLog(prog) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'ext/cumo/cuda/nvrtc.c', line 173
static VALUE
rb_nvrtcGetProgramLog(VALUE self, VALUE prog)
{
nvrtcResult status;
nvrtcProgram _prog = (nvrtcProgram)NUM2SIZET(prog);
size_t _logSizeRet;
char *_log;
VALUE log;
status = nvrtcGetProgramLogSize(_prog, &_logSizeRet);
check_status(status);
log = rb_str_new(NULL, _logSizeRet);
_log = RSTRING_PTR(log);
status = nvrtcGetProgramLog(_prog, _log);
check_status(status);
return log;
}
|
.nvrtcGetPTX(prog) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'ext/cumo/cuda/nvrtc.c', line 153
static VALUE
rb_nvrtcGetPTX(VALUE self, VALUE prog)
{
nvrtcResult status;
nvrtcProgram _prog = (nvrtcProgram)NUM2SIZET(prog);
size_t _ptxSizeRet;
char *_ptx;
VALUE ptx;
status = nvrtcGetPTXSize(_prog, &_ptxSizeRet);
check_status(status);
ptx = rb_str_new(NULL, _ptxSizeRet);
_ptx = RSTRING_PTR(ptx);
status = nvrtcGetPTX(_prog, _ptx);
check_status(status);
return ptx;
}
|
.nvrtcVersion ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'ext/cumo/cuda/nvrtc.c', line 20
static VALUE
rb_nvrtcVersion(VALUE self)
{
int _major, _minor;
nvrtcResult status;
VALUE major, minor;
status = nvrtcVersion(&_major, &_minor);
check_status(status);
major = INT2NUM(_major);
minor = INT2NUM(_minor);
return rb_ary_new3(2, major, minor);
}
|