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
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'ext/cumo/cuda/nvrtc.c', line 199
static VALUE
rb_nvrtcCompileProgram(VALUE self, VALUE prog, VALUE options)
{
nvrtcResult status;
nvrtcProgram _prog = (nvrtcProgram)NUM2SIZET(prog);
int _numOptions = ary_len(options, "options");
const char** _options = NULL;
VALUE strings;
strings = rb_ary_new_capa(_numOptions);
push_strings(strings, options, _numOptions);
if (_numOptions > 0) {
_options = alloc_cstrs(_numOptions);
fill_cstrs(_options, strings, 0, _numOptions);
}
{
struct nvrtcCompileProgramParam param = {_prog, _numOptions, _options};
status = (nvrtcResult)rb_thread_call_without_gvl(nvrtcCompileProgram_without_gvl_cb, ¶m, NULL, NULL);
}
free(_options);
RB_GC_GUARD(strings);
check_status(status);
return Qnil;
}
|
.nvrtcCreateProgram(src, name, headers, includeNames) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'ext/cumo/cuda/nvrtc.c', line 109
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 = ary_len(headers, "headers");
const char** _headers = NULL;
const char** _includeNames = NULL;
VALUE strings;
// nvrtcCreateProgram reads numHeaders entries out of includeNames as well,
// so a shorter array would be read past its end.
if (ary_len(includeNames, "include_names") != _numHeaders) {
rb_raise(rb_eArgError,
"headers and include_names must have the same length (%d vs %ld)",
_numHeaders, RARRAY_LEN(includeNames));
}
strings = rb_ary_new_capa((long)_numHeaders * 2);
push_strings(strings, headers, _numHeaders);
push_strings(strings, includeNames, _numHeaders);
if (_numHeaders > 0) {
// Both vectors come out of one allocation, so there is one pointer to
// free rather than two.
_headers = alloc_cstrs((long)_numHeaders * 2);
_includeNames = _headers + _numHeaders;
fill_cstrs(_headers, strings, 0, _numHeaders);
fill_cstrs(_includeNames, strings, _numHeaders, _numHeaders);
}
{
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);
RB_GC_GUARD(strings);
check_status(status);
return SIZET2NUM((size_t)_prog);
}
|
.nvrtcDestroyProgram(prog) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'ext/cumo/cuda/nvrtc.c', line 171
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
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'ext/cumo/cuda/nvrtc.c', line 247
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
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'ext/cumo/cuda/nvrtc.c', line 227
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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'ext/cumo/cuda/nvrtc.c', line 21
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);
}
|