Coverage for cuda / bindings / nvrtc.pyx: 52.76%
326 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-29 01:27 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-29 01:27 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4# This code was automatically generated with version 13.2.0, generator version 0.3.1.dev1364+ged01d643e. Do not modify it directly.
5from typing import Any, Optional
6import cython
7import ctypes
8from libc.stdlib cimport calloc, malloc, free
9from libc cimport string
10from libc.stdint cimport int32_t, uint32_t, int64_t, uint64_t, uintptr_t
11from libc.stddef cimport wchar_t
12from libc.limits cimport CHAR_MIN
13from libcpp.vector cimport vector
14from cpython.buffer cimport PyObject_CheckBuffer, PyObject_GetBuffer, PyBuffer_Release, PyBUF_SIMPLE, PyBUF_ANY_CONTIGUOUS
15from cpython.bytes cimport PyBytes_FromStringAndSize
16from ._internal._fast_enum import FastEnum as _FastEnum
18import cuda.bindings.driver as _driver
19_driver = _driver.__dict__
20include "_lib/utils.pxi"
22ctypedef unsigned long long signed_char_ptr
23ctypedef unsigned long long unsigned_char_ptr
24ctypedef unsigned long long char_ptr
25ctypedef unsigned long long short_ptr
26ctypedef unsigned long long unsigned_short_ptr
27ctypedef unsigned long long int_ptr
28ctypedef unsigned long long long_int_ptr
29ctypedef unsigned long long long_long_int_ptr
30ctypedef unsigned long long unsigned_int_ptr
31ctypedef unsigned long long unsigned_long_int_ptr
32ctypedef unsigned long long unsigned_long_long_int_ptr
33ctypedef unsigned long long uint32_t_ptr
34ctypedef unsigned long long uint64_t_ptr
35ctypedef unsigned long long int32_t_ptr
36ctypedef unsigned long long int64_t_ptr
37ctypedef unsigned long long unsigned_ptr
38ctypedef unsigned long long unsigned_long_long_ptr
39ctypedef unsigned long long long_long_ptr
40ctypedef unsigned long long size_t_ptr
41ctypedef unsigned long long long_ptr
42ctypedef unsigned long long float_ptr
43ctypedef unsigned long long double_ptr
44ctypedef unsigned long long void_ptr
46class nvrtcResult(_FastEnum):
47 """
48 The enumerated type nvrtcResult defines API call result codes.
49 NVRTC API functions return nvrtcResult to indicate the call result.
50 """
52 NVRTC_SUCCESS = cynvrtc.nvrtcResult.NVRTC_SUCCESS
54 NVRTC_ERROR_OUT_OF_MEMORY = cynvrtc.nvrtcResult.NVRTC_ERROR_OUT_OF_MEMORY
56 NVRTC_ERROR_PROGRAM_CREATION_FAILURE = cynvrtc.nvrtcResult.NVRTC_ERROR_PROGRAM_CREATION_FAILURE
58 NVRTC_ERROR_INVALID_INPUT = cynvrtc.nvrtcResult.NVRTC_ERROR_INVALID_INPUT
60 NVRTC_ERROR_INVALID_PROGRAM = cynvrtc.nvrtcResult.NVRTC_ERROR_INVALID_PROGRAM
62 NVRTC_ERROR_INVALID_OPTION = cynvrtc.nvrtcResult.NVRTC_ERROR_INVALID_OPTION
64 NVRTC_ERROR_COMPILATION = cynvrtc.nvrtcResult.NVRTC_ERROR_COMPILATION
66 NVRTC_ERROR_BUILTIN_OPERATION_FAILURE = cynvrtc.nvrtcResult.NVRTC_ERROR_BUILTIN_OPERATION_FAILURE
68 NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = cynvrtc.nvrtcResult.NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION
70 NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = cynvrtc.nvrtcResult.NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION
72 NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID = cynvrtc.nvrtcResult.NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID
74 NVRTC_ERROR_INTERNAL_ERROR = cynvrtc.nvrtcResult.NVRTC_ERROR_INTERNAL_ERROR
76 NVRTC_ERROR_TIME_FILE_WRITE_FAILED = cynvrtc.nvrtcResult.NVRTC_ERROR_TIME_FILE_WRITE_FAILED
78 NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED = cynvrtc.nvrtcResult.NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED
80 NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED = cynvrtc.nvrtcResult.NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED
82 NVRTC_ERROR_PCH_CREATE = cynvrtc.nvrtcResult.NVRTC_ERROR_PCH_CREATE
84 NVRTC_ERROR_CANCELLED = cynvrtc.nvrtcResult.NVRTC_ERROR_CANCELLED
86 NVRTC_ERROR_TIME_TRACE_FILE_WRITE_FAILED = cynvrtc.nvrtcResult.NVRTC_ERROR_TIME_TRACE_FILE_WRITE_FAILED
88cdef object _nvrtcResult = nvrtcResult
89cdef object _nvrtcResult_SUCCESS = nvrtcResult.NVRTC_SUCCESS
91cdef class nvrtcProgram:
92 """ nvrtcProgram is the unit of compilation, and an opaque handle for a program.
94 To compile a CUDA program string, an instance of nvrtcProgram must be created first with nvrtcCreateProgram, then compiled with nvrtcCompileProgram.
96 Methods
97 -------
98 getPtr()
99 Get memory address of class instance
101 """
102 def __cinit__(self, void_ptr init_value = 0, void_ptr _ptr = 0):
103 if _ptr == 0: 2j a b c d e f g h k l m n o p q r s t u v w x y ybzb
104 self._pvt_ptr = &self._pvt_val 2j a b c d e f g h k l m n o p q r s t u v w x y ybzb
105 self._pvt_ptr[0] = <cynvrtc.nvrtcProgram>init_value 2j a b c d e f g h k l m n o p q r s t u v w x y ybzb
106 else:
107 self._pvt_ptr = <cynvrtc.nvrtcProgram *>_ptr
108 def __init__(self, *args, **kwargs):
109 pass 2j a b c d e f g h k l m n o p q r s t u v w x y ybzb
110 def __repr__(self):
111 return '<nvrtcProgram ' + str(hex(self.__int__())) + '>'
112 def __index__(self):
113 return self.__int__()
114 def __eq__(self, other):
115 if not isinstance(other, nvrtcProgram):
116 return False
117 return self._pvt_ptr[0] == (<nvrtcProgram>other)._pvt_ptr[0]
118 def __hash__(self):
119 return hash(<uintptr_t><void*>(self._pvt_ptr[0]))
120 def __int__(self):
121 return <void_ptr>self._pvt_ptr[0] 1jabcdefghklmnopqrstuvwxy
122 def getPtr(self):
123 return <void_ptr>self._pvt_ptr 1jklmnopqrstuvwx
125@cython.embedsignature(True)
126def nvrtcGetErrorString(result not None : nvrtcResult):
127 """ nvrtcGetErrorString is a helper function that returns a string describing the given nvrtcResult code, e.g., NVRTC_SUCCESS to `"NVRTC_SUCCESS"`. For unrecognized enumeration values, it returns `"NVRTC_ERROR unknown"`.
129 Parameters
130 ----------
131 result : :py:obj:`~.nvrtcResult`
132 CUDA Runtime Compilation API result code.
134 Returns
135 -------
136 nvrtcResult.NVRTC_SUCCESS
137 nvrtcResult.NVRTC_SUCCESS
138 bytes
139 Message string for the given :py:obj:`~.nvrtcResult` code.
140 """
141 cdef cynvrtc.nvrtcResult cyresult = int(result) 2i j Ab
142 with nogil: 2j Ab
143 err = cynvrtc.nvrtcGetErrorString(cyresult) 2j Ab
144 return (nvrtcResult.NVRTC_SUCCESS, err) 2j Ab
146@cython.embedsignature(True)
147def nvrtcVersion():
148 """ nvrtcVersion sets the output parameters `major` and `minor` with the CUDA Runtime Compilation version number.
150 Returns
151 -------
152 nvrtcResult
153 - :py:obj:`~.NVRTC_SUCCESS`
154 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
155 major : int
156 CUDA Runtime Compilation major version number.
157 minor : int
158 CUDA Runtime Compilation minor version number.
159 """
160 cdef int major = 0 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
161 cdef int minor = 0 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
162 with nogil: 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
163 err = cynvrtc.nvrtcVersion(&major, &minor) 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
164 if err != cynvrtc.NVRTC_SUCCESS: 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
165 return (_nvrtcResult(err), None, None)
166 return (_nvrtcResult_SUCCESS, major, minor) 2i a b c d e f g h A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxb
168@cython.embedsignature(True)
169def nvrtcGetNumSupportedArchs():
170 """ nvrtcGetNumSupportedArchs sets the output parameter `numArchs` with the number of architectures supported by NVRTC. This can then be used to pass an array to :py:obj:`~.nvrtcGetSupportedArchs` to get the supported architectures.
172 see :py:obj:`~.nvrtcGetSupportedArchs`
174 Returns
175 -------
176 nvrtcResult
177 - :py:obj:`~.NVRTC_SUCCESS`
178 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
179 numArchs : int
180 number of supported architectures.
181 """
182 cdef int numArchs = 0 1z
183 with nogil: 1z
184 err = cynvrtc.nvrtcGetNumSupportedArchs(&numArchs) 1z
185 if err != cynvrtc.NVRTC_SUCCESS: 1z
186 return (_nvrtcResult(err), None)
187 return (_nvrtcResult_SUCCESS, numArchs) 1iz
189@cython.embedsignature(True)
190def nvrtcGetSupportedArchs():
191 """ nvrtcGetSupportedArchs populates the array passed via the output parameter `supportedArchs` with the architectures supported by NVRTC. The array is sorted in the ascending order. The size of the array to be passed can be determined using :py:obj:`~.nvrtcGetNumSupportedArchs`.
193 see :py:obj:`~.nvrtcGetNumSupportedArchs`
195 Returns
196 -------
197 nvrtcResult
198 - :py:obj:`~.NVRTC_SUCCESS`
199 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
200 supportedArchs : list[int]
201 sorted array of supported architectures.
202 """
203 cdef vector[int] supportedArchs
204 _, s = nvrtcGetNumSupportedArchs() 1z
205 supportedArchs.resize(s) 1z
207 with nogil: 1z
208 err = cynvrtc.nvrtcGetSupportedArchs(supportedArchs.data()) 1z
209 if err != cynvrtc.NVRTC_SUCCESS: 1z
210 return (_nvrtcResult(err), None)
211 return (_nvrtcResult_SUCCESS, supportedArchs) 1z
213@cython.embedsignature(True)
214def nvrtcCreateProgram(char* src, char* name, int numHeaders, headers : Optional[tuple[bytes] | list[bytes]], includeNames : Optional[tuple[bytes] | list[bytes]]):
215 """ nvrtcCreateProgram creates an instance of nvrtcProgram with the given input parameters, and sets the output parameter `prog` with it.
217 Parameters
218 ----------
219 src : bytes
220 CUDA program source.
221 name : bytes
222 CUDA program name. `name` can be `NULL`; `"default_program"` is
223 used when `name` is `NULL` or "".
224 numHeaders : int
225 Number of headers used. `numHeaders` must be greater than or equal
226 to 0.
227 headers : list[bytes]
228 Sources of the headers. `headers` can be `NULL` when `numHeaders`
229 is 0.
230 includeNames : list[bytes]
231 Name of each header by which they can be included in the CUDA
232 program source. `includeNames` can be `NULL` when `numHeaders` is
233 0. These headers must be included with the exact names specified
234 here.
236 Returns
237 -------
238 nvrtcResult
239 - :py:obj:`~.NVRTC_SUCCESS`
240 - :py:obj:`~.NVRTC_ERROR_OUT_OF_MEMORY`
241 - :py:obj:`~.NVRTC_ERROR_PROGRAM_CREATION_FAILURE`
242 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
243 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
244 prog : :py:obj:`~.nvrtcProgram`
245 CUDA Runtime Compilation program.
247 See Also
248 --------
249 :py:obj:`~.nvrtcDestroyProgram`
250 """
251 includeNames = [] if includeNames is None else includeNames 1jabcdefghklmnopqrstuvwx
252 if not all(isinstance(_x, (bytes)) for _x in includeNames): 1jabcdefghklmnopqrstuvwx
253 raise TypeError("Argument 'includeNames' is not instance of type (expected tuple[bytes] or list[bytes]")
254 headers = [] if headers is None else headers 1jabcdefghklmnopqrstuvwx
255 if not all(isinstance(_x, (bytes)) for _x in headers): 1jabcdefghklmnopqrstuvwx
256 raise TypeError("Argument 'headers' is not instance of type (expected tuple[bytes] or list[bytes]")
257 cdef nvrtcProgram prog = nvrtcProgram() 1jabcdefghklmnopqrstuvwx
258 if numHeaders > len(headers): raise RuntimeError("List is too small: " + str(len(headers)) + " < " + str(numHeaders)) 1jabcdefghklmnopqrstuvwx
259 if numHeaders > len(includeNames): raise RuntimeError("List is too small: " + str(len(includeNames)) + " < " + str(numHeaders)) 1jabcdefghklmnopqrstuvwx
260 cdef vector[const char*] cyheaders = headers 1jabcdefghklmnopqrstuvwx
261 cdef vector[const char*] cyincludeNames = includeNames 1jabcdefghklmnopqrstuvwx
262 with nogil: 1jabcdefghklmnopqrstuvwx
263 err = cynvrtc.nvrtcCreateProgram(<cynvrtc.nvrtcProgram*>prog._pvt_ptr, src, name, numHeaders, cyheaders.data(), cyincludeNames.data()) 1jabcdefghklmnopqrstuvwx
264 if err != cynvrtc.NVRTC_SUCCESS: 1jabcdefghklmnopqrstuvwx
265 return (_nvrtcResult(err), None)
266 return (_nvrtcResult_SUCCESS, prog) 1jabcdefghklmnopqrstuvwx
268@cython.embedsignature(True)
269def nvrtcDestroyProgram(prog):
270 """ nvrtcDestroyProgram destroys the given program.
272 Parameters
273 ----------
274 prog : :py:obj:`~.nvrtcProgram`
275 CUDA Runtime Compilation program.
277 Returns
278 -------
279 nvrtcResult
280 - :py:obj:`~.NVRTC_SUCCESS`
281 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
283 See Also
284 --------
285 :py:obj:`~.nvrtcCreateProgram`
286 """
287 cdef cynvrtc.nvrtcProgram *cyprog
288 if prog is None: 1jklmnopqrstuvwx
289 cyprog = <cynvrtc.nvrtcProgram*><void_ptr>NULL
290 elif isinstance(prog, (nvrtcProgram,)): 1jklmnopqrstuvwx
291 pprog = prog.getPtr() 1jklmnopqrstuvwx
292 cyprog = <cynvrtc.nvrtcProgram*><void_ptr>pprog 1jklmnopqrstuvwx
293 elif isinstance(prog, (int)):
294 cyprog = <cynvrtc.nvrtcProgram*><void_ptr>prog
295 else:
296 raise TypeError("Argument 'prog' is not instance of type (expected <class 'int, nvrtc.nvrtcProgram'>, found " + str(type(prog)))
297 with nogil: 1ijklmnopqrstuvwx
298 err = cynvrtc.nvrtcDestroyProgram(cyprog) 1jklmnopqrstuvwx
299 return (_nvrtcResult(err),) 1jklmnopqrstuvwx
301@cython.embedsignature(True)
302def nvrtcCompileProgram(prog, int numOptions, options : Optional[tuple[bytes] | list[bytes]]):
303 """ nvrtcCompileProgram compiles the given program.
305 It supports compile options listed in :py:obj:`~.Supported Compile
306 Options`.
308 Parameters
309 ----------
310 prog : :py:obj:`~.nvrtcProgram`
311 CUDA Runtime Compilation program.
312 numOptions : int
313 Number of compiler options passed.
314 options : list[bytes]
315 Compiler options in the form of C string array. `options` can be
316 `NULL` when `numOptions` is 0.
318 Returns
319 -------
320 nvrtcResult
321 - :py:obj:`~.NVRTC_SUCCESS`
322 - :py:obj:`~.NVRTC_ERROR_OUT_OF_MEMORY`
323 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
324 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
325 - :py:obj:`~.NVRTC_ERROR_INVALID_OPTION`
326 - :py:obj:`~.NVRTC_ERROR_COMPILATION`
327 - :py:obj:`~.NVRTC_ERROR_BUILTIN_OPERATION_FAILURE`
328 - :py:obj:`~.NVRTC_ERROR_TIME_FILE_WRITE_FAILED`
329 - :py:obj:`~.NVRTC_ERROR_CANCELLED`
330 """
331 options = [] if options is None else options 1jabcdefghklmnopqrstuvwx
332 if not all(isinstance(_x, (bytes)) for _x in options): 1jabcdefghklmnopqrstuvwx
333 raise TypeError("Argument 'options' is not instance of type (expected tuple[bytes] or list[bytes]")
334 cdef cynvrtc.nvrtcProgram cyprog
335 if prog is None: 1jabcdefghklmnopqrstuvwx
336 pprog = 0
337 elif isinstance(prog, (nvrtcProgram,)): 1jabcdefghklmnopqrstuvwx
338 pprog = int(prog) 1jabcdefghklmnopqrstuvwx
339 else:
340 pprog = int(nvrtcProgram(prog))
341 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1jabcdefghklmnopqrstuvwx
342 if numOptions > len(options): raise RuntimeError("List is too small: " + str(len(options)) + " < " + str(numOptions)) 1jabcdefghklmnopqrstuvwx
343 cdef vector[const char*] cyoptions = options 1jabcdefghklmnopqrstuvwx
344 with nogil: 1jabcdefghklmnopqrstuvwx
345 err = cynvrtc.nvrtcCompileProgram(cyprog, numOptions, cyoptions.data()) 1jabcdefghklmnopqrstuvwx
346 return (_nvrtcResult(err),) 1jabcdefghklmnopqrstuvwx
348@cython.embedsignature(True)
349def nvrtcGetPTXSize(prog):
350 """ nvrtcGetPTXSize sets the value of `ptxSizeRet` with the size of the PTX generated by the previous compilation of `prog` (including the trailing `NULL`).
352 Parameters
353 ----------
354 prog : :py:obj:`~.nvrtcProgram`
355 CUDA Runtime Compilation program.
357 Returns
358 -------
359 nvrtcResult
360 - :py:obj:`~.NVRTC_SUCCESS`
361 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
362 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
363 ptxSizeRet : int
364 Size of the generated PTX (including the trailing `NULL`).
366 See Also
367 --------
368 :py:obj:`~.nvrtcGetPTX`
369 """
370 cdef cynvrtc.nvrtcProgram cyprog
371 if prog is None:
372 pprog = 0
373 elif isinstance(prog, (nvrtcProgram,)):
374 pprog = int(prog)
375 else:
376 pprog = int(nvrtcProgram(prog))
377 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
378 cdef size_t ptxSizeRet = 0
379 with nogil:
380 err = cynvrtc.nvrtcGetPTXSize(cyprog, &ptxSizeRet)
381 if err != cynvrtc.NVRTC_SUCCESS:
382 return (_nvrtcResult(err), None)
383 return (_nvrtcResult_SUCCESS, ptxSizeRet)
385@cython.embedsignature(True)
386def nvrtcGetPTX(prog, char* ptx):
387 """ nvrtcGetPTX stores the PTX generated by the previous compilation of `prog` in the memory pointed by `ptx`.
389 Parameters
390 ----------
391 prog : :py:obj:`~.nvrtcProgram`
392 CUDA Runtime Compilation program.
393 ptx : bytes
394 Compiled result.
396 Returns
397 -------
398 nvrtcResult
399 - :py:obj:`~.NVRTC_SUCCESS`
400 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
401 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
403 See Also
404 --------
405 :py:obj:`~.nvrtcGetPTXSize`
406 """
407 cdef cynvrtc.nvrtcProgram cyprog
408 if prog is None:
409 pprog = 0
410 elif isinstance(prog, (nvrtcProgram,)):
411 pprog = int(prog)
412 else:
413 pprog = int(nvrtcProgram(prog))
414 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
415 with nogil:
416 err = cynvrtc.nvrtcGetPTX(cyprog, ptx)
417 return (_nvrtcResult(err),)
419@cython.embedsignature(True)
420def nvrtcGetCUBINSize(prog):
421 """ nvrtcGetCUBINSize sets the value of `cubinSizeRet` with the size of the cubin generated by the previous compilation of `prog`. The value of cubinSizeRet is set to 0 if the value specified to `-arch` is a virtual architecture instead of an actual architecture.
423 Parameters
424 ----------
425 prog : :py:obj:`~.nvrtcProgram`
426 CUDA Runtime Compilation program.
428 Returns
429 -------
430 nvrtcResult
431 - :py:obj:`~.NVRTC_SUCCESS`
432 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
433 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
434 cubinSizeRet : int
435 Size of the generated cubin.
437 See Also
438 --------
439 :py:obj:`~.nvrtcGetCUBIN`
440 """
441 cdef cynvrtc.nvrtcProgram cyprog
442 if prog is None: 1abcdefghopqrst
443 pprog = 0
444 elif isinstance(prog, (nvrtcProgram,)): 1abcdefghopqrst
445 pprog = int(prog) 1abcdefghopqrst
446 else:
447 pprog = int(nvrtcProgram(prog))
448 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1abcdefghopqrst
449 cdef size_t cubinSizeRet = 0 1abcdefghopqrst
450 with nogil: 1abcdefghopqrst
451 err = cynvrtc.nvrtcGetCUBINSize(cyprog, &cubinSizeRet) 1abcdefghopqrst
452 if err != cynvrtc.NVRTC_SUCCESS: 1abcdefghopqrst
453 return (_nvrtcResult(err), None)
454 return (_nvrtcResult_SUCCESS, cubinSizeRet) 1abcdefghopqrst
456@cython.embedsignature(True)
457def nvrtcGetCUBIN(prog, char* cubin):
458 """ nvrtcGetCUBIN stores the cubin generated by the previous compilation of `prog` in the memory pointed by `cubin`. No cubin is available if the value specified to `-arch` is a virtual architecture instead of an actual architecture.
460 Parameters
461 ----------
462 prog : :py:obj:`~.nvrtcProgram`
463 CUDA Runtime Compilation program.
464 cubin : bytes
465 Compiled and assembled result.
467 Returns
468 -------
469 nvrtcResult
470 - :py:obj:`~.NVRTC_SUCCESS`
471 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
472 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
474 See Also
475 --------
476 :py:obj:`~.nvrtcGetCUBINSize`
477 """
478 cdef cynvrtc.nvrtcProgram cyprog
479 if prog is None: 1abcdefghopqrst
480 pprog = 0
481 elif isinstance(prog, (nvrtcProgram,)): 1abcdefghopqrst
482 pprog = int(prog) 1abcdefghopqrst
483 else:
484 pprog = int(nvrtcProgram(prog))
485 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1abcdefghopqrst
486 with nogil: 1abcdefghopqrst
487 err = cynvrtc.nvrtcGetCUBIN(cyprog, cubin) 1abcdefghopqrst
488 return (_nvrtcResult(err),) 1abcdefghopqrst
490@cython.embedsignature(True)
491def nvrtcGetLTOIRSize(prog):
492 """ nvrtcGetLTOIRSize sets the value of `LTOIRSizeRet` with the size of the LTO IR generated by the previous compilation of `prog`. The value of LTOIRSizeRet is set to 0 if the program was not compiled with `-dlto`.
494 Parameters
495 ----------
496 prog : :py:obj:`~.nvrtcProgram`
497 CUDA Runtime Compilation program.
499 Returns
500 -------
501 nvrtcResult
502 - :py:obj:`~.NVRTC_SUCCESS`
503 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
504 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
505 LTOIRSizeRet : int
506 Size of the generated LTO IR.
508 See Also
509 --------
510 :py:obj:`~.nvrtcGetLTOIR`
511 """
512 cdef cynvrtc.nvrtcProgram cyprog
513 if prog is None: 1klmnuvwx
514 pprog = 0
515 elif isinstance(prog, (nvrtcProgram,)): 1klmnuvwx
516 pprog = int(prog) 1klmnuvwx
517 else:
518 pprog = int(nvrtcProgram(prog))
519 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1klmnuvwx
520 cdef size_t LTOIRSizeRet = 0 1klmnuvwx
521 with nogil: 1klmnuvwx
522 err = cynvrtc.nvrtcGetLTOIRSize(cyprog, <OIRSizeRet) 1klmnuvwx
523 if err != cynvrtc.NVRTC_SUCCESS: 1klmnuvwx
524 return (_nvrtcResult(err), None)
525 return (_nvrtcResult_SUCCESS, LTOIRSizeRet) 1klmnuvwx
527@cython.embedsignature(True)
528def nvrtcGetLTOIR(prog, char* LTOIR):
529 """ nvrtcGetLTOIR stores the LTO IR generated by the previous compilation of `prog` in the memory pointed by `LTOIR`. No LTO IR is available if the program was compiled without `-dlto`.
531 Parameters
532 ----------
533 prog : :py:obj:`~.nvrtcProgram`
534 CUDA Runtime Compilation program.
535 LTOIR : bytes
536 Compiled result.
538 Returns
539 -------
540 nvrtcResult
541 - :py:obj:`~.NVRTC_SUCCESS`
542 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
543 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
545 See Also
546 --------
547 :py:obj:`~.nvrtcGetLTOIRSize`
548 """
549 cdef cynvrtc.nvrtcProgram cyprog
550 if prog is None: 1klmnuvwx
551 pprog = 0
552 elif isinstance(prog, (nvrtcProgram,)): 1klmnuvwx
553 pprog = int(prog) 1klmnuvwx
554 else:
555 pprog = int(nvrtcProgram(prog))
556 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1klmnuvwx
557 with nogil: 1klmnuvwx
558 err = cynvrtc.nvrtcGetLTOIR(cyprog, LTOIR) 1klmnuvwx
559 return (_nvrtcResult(err),) 1klmnuvwx
561@cython.embedsignature(True)
562def nvrtcGetOptiXIRSize(prog):
563 """ nvrtcGetOptiXIRSize sets the value of `optixirSizeRet` with the size of the OptiX IR generated by the previous compilation of `prog`. The value of nvrtcGetOptiXIRSize is set to 0 if the program was compiled with options incompatible with OptiX IR generation.
565 Parameters
566 ----------
567 prog : :py:obj:`~.nvrtcProgram`
568 CUDA Runtime Compilation program.
570 Returns
571 -------
572 nvrtcResult
573 - :py:obj:`~.NVRTC_SUCCESS`
574 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
575 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
576 optixirSizeRet : int
577 Size of the generated LTO IR.
579 See Also
580 --------
581 :py:obj:`~.nvrtcGetOptiXIR`
582 """
583 cdef cynvrtc.nvrtcProgram cyprog
584 if prog is None:
585 pprog = 0
586 elif isinstance(prog, (nvrtcProgram,)):
587 pprog = int(prog)
588 else:
589 pprog = int(nvrtcProgram(prog))
590 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
591 cdef size_t optixirSizeRet = 0
592 with nogil:
593 err = cynvrtc.nvrtcGetOptiXIRSize(cyprog, &optixirSizeRet)
594 if err != cynvrtc.NVRTC_SUCCESS:
595 return (_nvrtcResult(err), None)
596 return (_nvrtcResult_SUCCESS, optixirSizeRet)
598@cython.embedsignature(True)
599def nvrtcGetOptiXIR(prog, char* optixir):
600 """ nvrtcGetOptiXIR stores the OptiX IR generated by the previous compilation of `prog` in the memory pointed by `optixir`. No OptiX IR is available if the program was compiled with options incompatible with OptiX IR generation.
602 Parameters
603 ----------
604 prog : :py:obj:`~.nvrtcProgram`
605 CUDA Runtime Compilation program.
606 optixir : bytes
607 Optix IR Compiled result.
609 Returns
610 -------
611 nvrtcResult
612 - :py:obj:`~.NVRTC_SUCCESS`
613 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
614 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
616 See Also
617 --------
618 :py:obj:`~.nvrtcGetOptiXIRSize`
619 """
620 cdef cynvrtc.nvrtcProgram cyprog
621 if prog is None:
622 pprog = 0
623 elif isinstance(prog, (nvrtcProgram,)):
624 pprog = int(prog)
625 else:
626 pprog = int(nvrtcProgram(prog))
627 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
628 with nogil:
629 err = cynvrtc.nvrtcGetOptiXIR(cyprog, optixir)
630 return (_nvrtcResult(err),)
632@cython.embedsignature(True)
633def nvrtcGetProgramLogSize(prog):
634 """ nvrtcGetProgramLogSize sets `logSizeRet` with the size of the log generated by the previous compilation of `prog` (including the trailing `NULL`).
636 Note that compilation log may be generated with warnings and
637 informative messages, even when the compilation of `prog` succeeds.
639 Parameters
640 ----------
641 prog : :py:obj:`~.nvrtcProgram`
642 CUDA Runtime Compilation program.
644 Returns
645 -------
646 nvrtcResult
647 - :py:obj:`~.NVRTC_SUCCESS`
648 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
649 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
650 logSizeRet : int
651 Size of the compilation log (including the trailing `NULL`).
653 See Also
654 --------
655 :py:obj:`~.nvrtcGetProgramLog`
656 """
657 cdef cynvrtc.nvrtcProgram cyprog
658 if prog is None: 1jabcdefgh
659 pprog = 0
660 elif isinstance(prog, (nvrtcProgram,)): 1jabcdefgh
661 pprog = int(prog) 1jabcdefgh
662 else:
663 pprog = int(nvrtcProgram(prog))
664 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1jabcdefgh
665 cdef size_t logSizeRet = 0 1jabcdefgh
666 with nogil: 1jabcdefgh
667 err = cynvrtc.nvrtcGetProgramLogSize(cyprog, &logSizeRet) 1jabcdefgh
668 if err != cynvrtc.NVRTC_SUCCESS: 1jabcdefgh
669 return (_nvrtcResult(err), None)
670 return (_nvrtcResult_SUCCESS, logSizeRet) 1jabcdefgh
672@cython.embedsignature(True)
673def nvrtcGetProgramLog(prog, char* log):
674 """ nvrtcGetProgramLog stores the log generated by the previous compilation of `prog` in the memory pointed by `log`.
676 Parameters
677 ----------
678 prog : :py:obj:`~.nvrtcProgram`
679 CUDA Runtime Compilation program.
680 log : bytes
681 Compilation log.
683 Returns
684 -------
685 nvrtcResult
686 - :py:obj:`~.NVRTC_SUCCESS`
687 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
688 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
690 See Also
691 --------
692 :py:obj:`~.nvrtcGetProgramLogSize`
693 """
694 cdef cynvrtc.nvrtcProgram cyprog
695 if prog is None: 1jabcdefgh
696 pprog = 0
697 elif isinstance(prog, (nvrtcProgram,)): 1jabcdefgh
698 pprog = int(prog) 1jabcdefgh
699 else:
700 pprog = int(nvrtcProgram(prog))
701 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1jabcdefgh
702 with nogil: 1jabcdefgh
703 err = cynvrtc.nvrtcGetProgramLog(cyprog, log) 1jabcdefgh
704 return (_nvrtcResult(err),) 1jabcdefgh
706@cython.embedsignature(True)
707def nvrtcAddNameExpression(prog, char* name_expression):
708 """ nvrtcAddNameExpression notes the given name expression denoting the address of a global function or device/__constant__ variable.
710 The identical name expression string must be provided on a subsequent
711 call to nvrtcGetLoweredName to extract the lowered name.
713 Parameters
714 ----------
715 prog : :py:obj:`~.nvrtcProgram`
716 CUDA Runtime Compilation program.
717 name_expression : bytes
718 constant expression denoting the address of a global function or
719 device/__constant__ variable.
721 Returns
722 -------
723 nvrtcResult
724 - :py:obj:`~.NVRTC_SUCCESS`
725 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
726 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
727 - :py:obj:`~.NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION`
729 See Also
730 --------
731 :py:obj:`~.nvrtcGetLoweredName`
732 """
733 cdef cynvrtc.nvrtcProgram cyprog
734 if prog is None:
735 pprog = 0
736 elif isinstance(prog, (nvrtcProgram,)):
737 pprog = int(prog)
738 else:
739 pprog = int(nvrtcProgram(prog))
740 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
741 with nogil:
742 err = cynvrtc.nvrtcAddNameExpression(cyprog, name_expression)
743 return (_nvrtcResult(err),)
745@cython.embedsignature(True)
746def nvrtcGetLoweredName(prog, char* name_expression):
747 """ nvrtcGetLoweredName extracts the lowered (mangled) name for a global function or device/__constant__ variable, and updates lowered_name to point to it. The memory containing the name is released when the NVRTC program is destroyed by nvrtcDestroyProgram. The identical name expression must have been previously provided to nvrtcAddNameExpression.
749 Parameters
750 ----------
751 prog : nvrtcProgram
752 CUDA Runtime Compilation program.
753 name_expression : bytes
754 constant expression denoting the address of a global function or
755 device/__constant__ variable.
757 Returns
758 -------
759 nvrtcResult
760 NVRTC_SUCCESS
761 NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION
762 NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID
763 lowered_name : bytes
764 initialized by the function to point to a C string containing the
765 lowered (mangled) name corresponding to the provided name
766 expression.
768 See Also
769 --------
770 nvrtcAddNameExpression
771 """
772 cdef cynvrtc.nvrtcProgram cyprog
773 if prog is None: 1y
774 pprog = 0 1y
775 elif isinstance(prog, (nvrtcProgram,)): 1y
776 pprog = int(prog)
777 else:
778 pprog = int(nvrtcProgram(prog)) 1y
779 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog 1y
780 cdef const char* lowered_name = NULL 1y
781 with nogil: 1y
782 err = cynvrtc.nvrtcGetLoweredName(cyprog, name_expression, &lowered_name) 1y
783 if err != cynvrtc.NVRTC_SUCCESS: 1y
784 return (_nvrtcResult(err), None) 1y
785 return (_nvrtcResult_SUCCESS, <bytes>lowered_name if lowered_name != NULL else None)
787@cython.embedsignature(True)
788def nvrtcGetPCHHeapSize():
789 """ retrieve the current size of the PCH Heap.
791 Returns
792 -------
793 nvrtcResult
794 - :py:obj:`~.NVRTC_SUCCESS`
795 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
796 ret : int
797 pointer to location where the size of the PCH Heap will be stored
798 """
799 cdef size_t ret = 0
800 with nogil:
801 err = cynvrtc.nvrtcGetPCHHeapSize(&ret)
802 if err != cynvrtc.NVRTC_SUCCESS:
803 return (_nvrtcResult(err), None)
804 return (_nvrtcResult_SUCCESS, ret)
806@cython.embedsignature(True)
807def nvrtcSetPCHHeapSize(size_t size):
808 """ set the size of the PCH Heap.
810 The requested size may be rounded up to a platform dependent alignment
811 (e.g. page size). If the PCH Heap has already been allocated, the heap
812 memory will be freed and a new PCH Heap will be allocated.
814 Parameters
815 ----------
816 size : size_t
817 requested size of the PCH Heap, in bytes
819 Returns
820 -------
821 nvrtcResult
822 - :py:obj:`~.NVRTC_SUCCESS`
823 """
824 with nogil:
825 err = cynvrtc.nvrtcSetPCHHeapSize(size)
826 return (_nvrtcResult(err),)
828@cython.embedsignature(True)
829def nvrtcGetPCHCreateStatus(prog):
830 """ returns the PCH creation status.
832 NVRTC_SUCCESS indicates that the PCH was successfully created.
833 NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED indicates that no PCH creation was
834 attempted, either because PCH functionality was not requested during
835 the preceding nvrtcCompileProgram call, or automatic PCH processing was
836 requested, and compiler chose not to create a PCH file.
837 NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED indicates that a PCH file could
838 potentially have been created, but the compiler ran out space in the
839 PCH heap. In this scenario, the
840 :py:obj:`~.nvrtcGetPCHHeapSizeRequired()` can be used to query the
841 required heap size, the heap can be reallocated for this size with
842 :py:obj:`~.nvrtcSetPCHHeapSize()` and PCH creation may be reattempted
843 again invoking :py:obj:`~.nvrtcCompileProgram()` with a new NVRTC
844 program instance. NVRTC_ERROR_PCH_CREATE indicates that an error
845 condition prevented the PCH file from being created.
847 Parameters
848 ----------
849 prog : :py:obj:`~.nvrtcProgram`
850 CUDA Runtime Compilation program.
852 Returns
853 -------
854 nvrtcResult
855 - :py:obj:`~.NVRTC_SUCCESS`
856 - :py:obj:`~.NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED`
857 - :py:obj:`~.NVRTC_ERROR_PCH_CREATE`
858 - :py:obj:`~.NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED`
859 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
860 """
861 cdef cynvrtc.nvrtcProgram cyprog
862 if prog is None:
863 pprog = 0
864 elif isinstance(prog, (nvrtcProgram,)):
865 pprog = int(prog)
866 else:
867 pprog = int(nvrtcProgram(prog))
868 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
869 with nogil:
870 err = cynvrtc.nvrtcGetPCHCreateStatus(cyprog)
871 return (_nvrtcResult(err),)
873@cython.embedsignature(True)
874def nvrtcGetPCHHeapSizeRequired(prog):
875 """ retrieve the required size of the PCH heap required to compile the given program.
877 Parameters
878 ----------
879 prog : :py:obj:`~.nvrtcProgram`
880 CUDA Runtime Compilation program.
882 Returns
883 -------
884 nvrtcResult
885 - :py:obj:`~.NVRTC_SUCCESS`
886 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
887 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT` The size retrieved using this function is only valid if :py:obj:`~.nvrtcGetPCHCreateStatus()` returned NVRTC_SUCCESS or NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED
888 size : int
889 pointer to location where the required size of the PCH Heap will be
890 stored
891 """
892 cdef cynvrtc.nvrtcProgram cyprog
893 if prog is None:
894 pprog = 0
895 elif isinstance(prog, (nvrtcProgram,)):
896 pprog = int(prog)
897 else:
898 pprog = int(nvrtcProgram(prog))
899 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
900 cdef size_t size = 0
901 with nogil:
902 err = cynvrtc.nvrtcGetPCHHeapSizeRequired(cyprog, &size)
903 if err != cynvrtc.NVRTC_SUCCESS:
904 return (_nvrtcResult(err), None)
905 return (_nvrtcResult_SUCCESS, size)
907@cython.embedsignature(True)
908def nvrtcSetFlowCallback(prog, callback, payload):
909 """ nvrtcSetFlowCallback registers a callback function that the compiler will invoke at different points during a call to nvrtcCompileProgram, and the callback function can decide whether to cancel compilation by returning specific values.
911 The callback function must satisfy the following constraints:
913 (1) Its signature should be:
915 **View CUDA Toolkit Documentation for a C++ code example**
917 When invoking the callback, the compiler will always pass `payload` to
918 param1 so that the callback may make decisions based on `payload` .
919 It'll always pass NULL to param2 for now which is reserved for future
920 extensions.
922 (2) It must return 1 to cancel compilation or 0 to continue. Other
923 return values are reserved for future use.
925 (3) It must return consistent values. Once it returns 1 at one point,
926 it must return 1 in all following invocations during the current
927 nvrtcCompileProgram call in progress.
929 (4) It must be thread-safe.
931 (5) It must not invoke any nvrtc/libnvvm/ptx APIs.
933 Parameters
934 ----------
935 prog : :py:obj:`~.nvrtcProgram`
936 CUDA Runtime Compilation program.
937 callback : Any
938 the callback that issues cancellation signal.
939 payload : Any
940 to be passed as a parameter when invoking the callback.
942 Returns
943 -------
944 nvrtcResult
945 - :py:obj:`~.NVRTC_SUCCESS`
946 - :py:obj:`~.NVRTC_ERROR_INVALID_PROGRAM`
947 - :py:obj:`~.NVRTC_ERROR_INVALID_INPUT`
948 """
949 cdef cynvrtc.nvrtcProgram cyprog
950 if prog is None:
951 pprog = 0
952 elif isinstance(prog, (nvrtcProgram,)):
953 pprog = int(prog)
954 else:
955 pprog = int(nvrtcProgram(prog))
956 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
957 cdef _HelperInputVoidPtrStruct cycallbackHelper
958 cdef void* cycallback = _helper_input_void_ptr(callback, &cycallbackHelper)
959 cdef _HelperInputVoidPtrStruct cypayloadHelper
960 cdef void* cypayload = _helper_input_void_ptr(payload, &cypayloadHelper)
961 with nogil:
962 err = cynvrtc.nvrtcSetFlowCallback(cyprog, cycallback, cypayload)
963 _helper_input_void_ptr_free(&cycallbackHelper)
964 _helper_input_void_ptr_free(&cypayloadHelper)
965 return (_nvrtcResult(err),)
967@cython.embedsignature(True)
968def nvrtcGetTileIRSize(prog):
969 """
971 Parameters
972 ----------
973 prog : :py:obj:`~.nvrtcProgram`
974 None
976 Returns
977 -------
978 nvrtcResult
980 TileIRSizeRet : int
981 None
982 """
983 cdef cynvrtc.nvrtcProgram cyprog
984 if prog is None:
985 pprog = 0
986 elif isinstance(prog, (nvrtcProgram,)):
987 pprog = int(prog)
988 else:
989 pprog = int(nvrtcProgram(prog))
990 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
991 cdef size_t TileIRSizeRet = 0
992 with nogil:
993 err = cynvrtc.nvrtcGetTileIRSize(cyprog, &TileIRSizeRet)
994 if err != cynvrtc.NVRTC_SUCCESS:
995 return (_nvrtcResult(err), None)
996 return (_nvrtcResult_SUCCESS, TileIRSizeRet)
998@cython.embedsignature(True)
999def nvrtcGetTileIR(prog, char* TileIR):
1000 """
1002 Parameters
1003 ----------
1004 prog : :py:obj:`~.nvrtcProgram`
1005 None
1006 TileIR : bytes
1007 None
1009 Returns
1010 -------
1011 nvrtcResult
1013 """
1014 cdef cynvrtc.nvrtcProgram cyprog
1015 if prog is None:
1016 pprog = 0
1017 elif isinstance(prog, (nvrtcProgram,)):
1018 pprog = int(prog)
1019 else:
1020 pprog = int(nvrtcProgram(prog))
1021 cyprog = <cynvrtc.nvrtcProgram><void_ptr>pprog
1022 with nogil:
1023 err = cynvrtc.nvrtcGetTileIR(cyprog, TileIR)
1024 return (_nvrtcResult(err),)
1026@cython.embedsignature(True)
1027def sizeof(objType):
1028 """ Returns the size of provided CUDA Python structure in bytes
1030 Parameters
1031 ----------
1032 objType : Any
1033 CUDA Python object
1035 Returns
1036 -------
1037 lowered_name : int
1038 The size of `objType` in bytes
1039 """
1041 if objType == nvrtcProgram:
1042 return sizeof(cynvrtc.nvrtcProgram)
1043 raise TypeError("Unknown type: " + str(objType))