nvrtc.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. # mypy: ignore-errors
  2. # -*- coding: utf-8 -*-
  3. #
  4. # TARGET arch is: []
  5. # WORD_SIZE is: 8
  6. # POINTER_SIZE is: 8
  7. # LONGDOUBLE_SIZE is: 16
  8. #
  9. import ctypes, ctypes.util
  10. _libraries = {}
  11. _libraries['libnvrtc.so'] = ctypes.CDLL(ctypes.util.find_library('nvrtc'))
  12. def string_cast(char_pointer, encoding='utf-8', errors='strict'):
  13. value = ctypes.cast(char_pointer, ctypes.c_char_p).value
  14. if value is not None and encoding is not None:
  15. value = value.decode(encoding, errors=errors)
  16. return value
  17. def char_pointer_cast(string, encoding='utf-8'):
  18. if encoding is not None:
  19. try:
  20. string = string.encode(encoding)
  21. except AttributeError:
  22. # In Python3, bytes has no encode attribute
  23. pass
  24. string = ctypes.c_char_p(string)
  25. return ctypes.cast(string, ctypes.POINTER(ctypes.c_char))
  26. class AsDictMixin:
  27. @classmethod
  28. def as_dict(cls, self):
  29. result = {}
  30. if not isinstance(self, AsDictMixin):
  31. # not a structure, assume it's already a python object
  32. return self
  33. if not hasattr(cls, "_fields_"):
  34. return result
  35. # sys.version_info >= (3, 5)
  36. # for (field, *_) in cls._fields_: # noqa
  37. for field_tuple in cls._fields_: # noqa
  38. field = field_tuple[0]
  39. if field.startswith('PADDING_'):
  40. continue
  41. value = getattr(self, field)
  42. type_ = type(value)
  43. if hasattr(value, "_length_") and hasattr(value, "_type_"):
  44. # array
  45. if not hasattr(type_, "as_dict"):
  46. value = [v for v in value]
  47. else:
  48. type_ = type_._type_
  49. value = [type_.as_dict(v) for v in value]
  50. elif hasattr(value, "contents") and hasattr(value, "_type_"):
  51. # pointer
  52. try:
  53. if not hasattr(type_, "as_dict"):
  54. value = value.contents
  55. else:
  56. type_ = type_._type_
  57. value = type_.as_dict(value.contents)
  58. except ValueError:
  59. # nullptr
  60. value = None
  61. elif isinstance(value, AsDictMixin):
  62. # other structure
  63. value = type_.as_dict(value)
  64. result[field] = value
  65. return result
  66. class Structure(ctypes.Structure, AsDictMixin):
  67. def __init__(self, *args, **kwds):
  68. # We don't want to use positional arguments fill PADDING_* fields
  69. args = dict(zip(self.__class__._field_names_(), args))
  70. args.update(kwds)
  71. super(Structure, self).__init__(**args)
  72. @classmethod
  73. def _field_names_(cls):
  74. if hasattr(cls, '_fields_'):
  75. return (f[0] for f in cls._fields_ if not f[0].startswith('PADDING'))
  76. else:
  77. return ()
  78. @classmethod
  79. def get_type(cls, field):
  80. for f in cls._fields_:
  81. if f[0] == field:
  82. return f[1]
  83. return None
  84. @classmethod
  85. def bind(cls, bound_fields):
  86. fields = {}
  87. for name, type_ in cls._fields_:
  88. if hasattr(type_, "restype"):
  89. if name in bound_fields:
  90. if bound_fields[name] is None:
  91. fields[name] = type_()
  92. else:
  93. # use a closure to capture the callback from the loop scope
  94. fields[name] = (
  95. type_((lambda callback: lambda *args: callback(*args))(
  96. bound_fields[name]))
  97. )
  98. del bound_fields[name]
  99. else:
  100. # default callback implementation (does nothing)
  101. try:
  102. default_ = type_(0).restype().value
  103. except TypeError:
  104. default_ = None
  105. fields[name] = type_((
  106. lambda default_: lambda *args: default_)(default_))
  107. else:
  108. # not a callback function, use default initialization
  109. if name in bound_fields:
  110. fields[name] = bound_fields[name]
  111. del bound_fields[name]
  112. else:
  113. fields[name] = type_()
  114. if len(bound_fields) != 0:
  115. raise ValueError(
  116. "Cannot bind the following unknown callback(s) {}.{}".format(
  117. cls.__name__, bound_fields.keys()
  118. ))
  119. return cls(**fields)
  120. class Union(ctypes.Union, AsDictMixin):
  121. pass
  122. _libraries['libnvJitLink.so'] = ctypes.CDLL(ctypes.util.find_library('nvJitLink'))
  123. c_int128 = ctypes.c_ubyte*16
  124. c_uint128 = c_int128
  125. void = None
  126. if ctypes.sizeof(ctypes.c_longdouble) == 16:
  127. c_long_double_t = ctypes.c_longdouble
  128. else:
  129. c_long_double_t = ctypes.c_ubyte*16
  130. # values for enumeration 'c__EA_nvrtcResult'
  131. c__EA_nvrtcResult__enumvalues = {
  132. 0: 'NVRTC_SUCCESS',
  133. 1: 'NVRTC_ERROR_OUT_OF_MEMORY',
  134. 2: 'NVRTC_ERROR_PROGRAM_CREATION_FAILURE',
  135. 3: 'NVRTC_ERROR_INVALID_INPUT',
  136. 4: 'NVRTC_ERROR_INVALID_PROGRAM',
  137. 5: 'NVRTC_ERROR_INVALID_OPTION',
  138. 6: 'NVRTC_ERROR_COMPILATION',
  139. 7: 'NVRTC_ERROR_BUILTIN_OPERATION_FAILURE',
  140. 8: 'NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION',
  141. 9: 'NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION',
  142. 10: 'NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID',
  143. 11: 'NVRTC_ERROR_INTERNAL_ERROR',
  144. 12: 'NVRTC_ERROR_TIME_FILE_WRITE_FAILED',
  145. }
  146. NVRTC_SUCCESS = 0
  147. NVRTC_ERROR_OUT_OF_MEMORY = 1
  148. NVRTC_ERROR_PROGRAM_CREATION_FAILURE = 2
  149. NVRTC_ERROR_INVALID_INPUT = 3
  150. NVRTC_ERROR_INVALID_PROGRAM = 4
  151. NVRTC_ERROR_INVALID_OPTION = 5
  152. NVRTC_ERROR_COMPILATION = 6
  153. NVRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7
  154. NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8
  155. NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9
  156. NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10
  157. NVRTC_ERROR_INTERNAL_ERROR = 11
  158. NVRTC_ERROR_TIME_FILE_WRITE_FAILED = 12
  159. c__EA_nvrtcResult = ctypes.c_uint32 # enum
  160. nvrtcResult = c__EA_nvrtcResult
  161. nvrtcResult__enumvalues = c__EA_nvrtcResult__enumvalues
  162. try:
  163. nvrtcGetErrorString = _libraries['libnvrtc.so'].nvrtcGetErrorString
  164. nvrtcGetErrorString.restype = ctypes.POINTER(ctypes.c_char)
  165. nvrtcGetErrorString.argtypes = [nvrtcResult]
  166. except AttributeError:
  167. pass
  168. try:
  169. nvrtcVersion = _libraries['libnvrtc.so'].nvrtcVersion
  170. nvrtcVersion.restype = nvrtcResult
  171. nvrtcVersion.argtypes = [ctypes.POINTER(ctypes.c_int32), ctypes.POINTER(ctypes.c_int32)]
  172. except AttributeError:
  173. pass
  174. try:
  175. nvrtcGetNumSupportedArchs = _libraries['libnvrtc.so'].nvrtcGetNumSupportedArchs
  176. nvrtcGetNumSupportedArchs.restype = nvrtcResult
  177. nvrtcGetNumSupportedArchs.argtypes = [ctypes.POINTER(ctypes.c_int32)]
  178. except AttributeError:
  179. pass
  180. try:
  181. nvrtcGetSupportedArchs = _libraries['libnvrtc.so'].nvrtcGetSupportedArchs
  182. nvrtcGetSupportedArchs.restype = nvrtcResult
  183. nvrtcGetSupportedArchs.argtypes = [ctypes.POINTER(ctypes.c_int32)]
  184. except AttributeError:
  185. pass
  186. class struct__nvrtcProgram(Structure):
  187. pass
  188. nvrtcProgram = ctypes.POINTER(struct__nvrtcProgram)
  189. try:
  190. nvrtcCreateProgram = _libraries['libnvrtc.so'].nvrtcCreateProgram
  191. nvrtcCreateProgram.restype = nvrtcResult
  192. nvrtcCreateProgram.argtypes = [ctypes.POINTER(ctypes.POINTER(struct__nvrtcProgram)), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_char), ctypes.c_int32, ctypes.POINTER(ctypes.POINTER(ctypes.c_char)), ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  193. except AttributeError:
  194. pass
  195. try:
  196. nvrtcDestroyProgram = _libraries['libnvrtc.so'].nvrtcDestroyProgram
  197. nvrtcDestroyProgram.restype = nvrtcResult
  198. nvrtcDestroyProgram.argtypes = [ctypes.POINTER(ctypes.POINTER(struct__nvrtcProgram))]
  199. except AttributeError:
  200. pass
  201. try:
  202. nvrtcCompileProgram = _libraries['libnvrtc.so'].nvrtcCompileProgram
  203. nvrtcCompileProgram.restype = nvrtcResult
  204. nvrtcCompileProgram.argtypes = [nvrtcProgram, ctypes.c_int32, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  205. except AttributeError:
  206. pass
  207. try:
  208. nvrtcGetPTXSize = _libraries['libnvrtc.so'].nvrtcGetPTXSize
  209. nvrtcGetPTXSize.restype = nvrtcResult
  210. nvrtcGetPTXSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  211. except AttributeError:
  212. pass
  213. try:
  214. nvrtcGetPTX = _libraries['libnvrtc.so'].nvrtcGetPTX
  215. nvrtcGetPTX.restype = nvrtcResult
  216. nvrtcGetPTX.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  217. except AttributeError:
  218. pass
  219. try:
  220. nvrtcGetCUBINSize = _libraries['libnvrtc.so'].nvrtcGetCUBINSize
  221. nvrtcGetCUBINSize.restype = nvrtcResult
  222. nvrtcGetCUBINSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  223. except AttributeError:
  224. pass
  225. try:
  226. nvrtcGetCUBIN = _libraries['libnvrtc.so'].nvrtcGetCUBIN
  227. nvrtcGetCUBIN.restype = nvrtcResult
  228. nvrtcGetCUBIN.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  229. except AttributeError:
  230. pass
  231. try:
  232. nvrtcGetNVVMSize = _libraries['libnvrtc.so'].nvrtcGetNVVMSize
  233. nvrtcGetNVVMSize.restype = nvrtcResult
  234. nvrtcGetNVVMSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  235. except AttributeError:
  236. pass
  237. try:
  238. nvrtcGetNVVM = _libraries['libnvrtc.so'].nvrtcGetNVVM
  239. nvrtcGetNVVM.restype = nvrtcResult
  240. nvrtcGetNVVM.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  241. except AttributeError:
  242. pass
  243. try:
  244. nvrtcGetLTOIRSize = _libraries['libnvrtc.so'].nvrtcGetLTOIRSize
  245. nvrtcGetLTOIRSize.restype = nvrtcResult
  246. nvrtcGetLTOIRSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  247. except AttributeError:
  248. pass
  249. try:
  250. nvrtcGetLTOIR = _libraries['libnvrtc.so'].nvrtcGetLTOIR
  251. nvrtcGetLTOIR.restype = nvrtcResult
  252. nvrtcGetLTOIR.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  253. except AttributeError:
  254. pass
  255. try:
  256. nvrtcGetOptiXIRSize = _libraries['libnvrtc.so'].nvrtcGetOptiXIRSize
  257. nvrtcGetOptiXIRSize.restype = nvrtcResult
  258. nvrtcGetOptiXIRSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  259. except AttributeError:
  260. pass
  261. try:
  262. nvrtcGetOptiXIR = _libraries['libnvrtc.so'].nvrtcGetOptiXIR
  263. nvrtcGetOptiXIR.restype = nvrtcResult
  264. nvrtcGetOptiXIR.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  265. except AttributeError:
  266. pass
  267. try:
  268. nvrtcGetProgramLogSize = _libraries['libnvrtc.so'].nvrtcGetProgramLogSize
  269. nvrtcGetProgramLogSize.restype = nvrtcResult
  270. nvrtcGetProgramLogSize.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_uint64)]
  271. except AttributeError:
  272. pass
  273. try:
  274. nvrtcGetProgramLog = _libraries['libnvrtc.so'].nvrtcGetProgramLog
  275. nvrtcGetProgramLog.restype = nvrtcResult
  276. nvrtcGetProgramLog.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  277. except AttributeError:
  278. pass
  279. try:
  280. nvrtcAddNameExpression = _libraries['libnvrtc.so'].nvrtcAddNameExpression
  281. nvrtcAddNameExpression.restype = nvrtcResult
  282. nvrtcAddNameExpression.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char)]
  283. except AttributeError:
  284. pass
  285. try:
  286. nvrtcGetLoweredName = _libraries['libnvrtc.so'].nvrtcGetLoweredName
  287. nvrtcGetLoweredName.restype = nvrtcResult
  288. nvrtcGetLoweredName.argtypes = [nvrtcProgram, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  289. except AttributeError:
  290. pass
  291. # values for enumeration 'c__EA_nvJitLinkResult'
  292. c__EA_nvJitLinkResult__enumvalues = {
  293. 0: 'NVJITLINK_SUCCESS',
  294. 1: 'NVJITLINK_ERROR_UNRECOGNIZED_OPTION',
  295. 2: 'NVJITLINK_ERROR_MISSING_ARCH',
  296. 3: 'NVJITLINK_ERROR_INVALID_INPUT',
  297. 4: 'NVJITLINK_ERROR_PTX_COMPILE',
  298. 5: 'NVJITLINK_ERROR_NVVM_COMPILE',
  299. 6: 'NVJITLINK_ERROR_INTERNAL',
  300. 7: 'NVJITLINK_ERROR_THREADPOOL',
  301. 8: 'NVJITLINK_ERROR_UNRECOGNIZED_INPUT',
  302. }
  303. NVJITLINK_SUCCESS = 0
  304. NVJITLINK_ERROR_UNRECOGNIZED_OPTION = 1
  305. NVJITLINK_ERROR_MISSING_ARCH = 2
  306. NVJITLINK_ERROR_INVALID_INPUT = 3
  307. NVJITLINK_ERROR_PTX_COMPILE = 4
  308. NVJITLINK_ERROR_NVVM_COMPILE = 5
  309. NVJITLINK_ERROR_INTERNAL = 6
  310. NVJITLINK_ERROR_THREADPOOL = 7
  311. NVJITLINK_ERROR_UNRECOGNIZED_INPUT = 8
  312. c__EA_nvJitLinkResult = ctypes.c_uint32 # enum
  313. nvJitLinkResult = c__EA_nvJitLinkResult
  314. nvJitLinkResult__enumvalues = c__EA_nvJitLinkResult__enumvalues
  315. # values for enumeration 'c__EA_nvJitLinkInputType'
  316. c__EA_nvJitLinkInputType__enumvalues = {
  317. 0: 'NVJITLINK_INPUT_NONE',
  318. 1: 'NVJITLINK_INPUT_CUBIN',
  319. 2: 'NVJITLINK_INPUT_PTX',
  320. 3: 'NVJITLINK_INPUT_LTOIR',
  321. 4: 'NVJITLINK_INPUT_FATBIN',
  322. 5: 'NVJITLINK_INPUT_OBJECT',
  323. 6: 'NVJITLINK_INPUT_LIBRARY',
  324. 10: 'NVJITLINK_INPUT_ANY',
  325. }
  326. NVJITLINK_INPUT_NONE = 0
  327. NVJITLINK_INPUT_CUBIN = 1
  328. NVJITLINK_INPUT_PTX = 2
  329. NVJITLINK_INPUT_LTOIR = 3
  330. NVJITLINK_INPUT_FATBIN = 4
  331. NVJITLINK_INPUT_OBJECT = 5
  332. NVJITLINK_INPUT_LIBRARY = 6
  333. NVJITLINK_INPUT_ANY = 10
  334. c__EA_nvJitLinkInputType = ctypes.c_uint32 # enum
  335. nvJitLinkInputType = c__EA_nvJitLinkInputType
  336. nvJitLinkInputType__enumvalues = c__EA_nvJitLinkInputType__enumvalues
  337. class struct_nvJitLink(Structure):
  338. pass
  339. nvJitLinkHandle = ctypes.POINTER(struct_nvJitLink)
  340. uint32_t = ctypes.c_uint32
  341. try:
  342. __nvJitLinkCreate_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkCreate_12_4
  343. __nvJitLinkCreate_12_4.restype = nvJitLinkResult
  344. __nvJitLinkCreate_12_4.argtypes = [ctypes.POINTER(ctypes.POINTER(struct_nvJitLink)), uint32_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  345. except AttributeError:
  346. pass
  347. try:
  348. nvJitLinkCreate = _libraries['libnvJitLink.so'].nvJitLinkCreate
  349. nvJitLinkCreate.restype = nvJitLinkResult
  350. nvJitLinkCreate.argtypes = [ctypes.POINTER(ctypes.POINTER(struct_nvJitLink)), uint32_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
  351. except AttributeError:
  352. pass
  353. try:
  354. __nvJitLinkDestroy_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkDestroy_12_4
  355. __nvJitLinkDestroy_12_4.restype = nvJitLinkResult
  356. __nvJitLinkDestroy_12_4.argtypes = [ctypes.POINTER(ctypes.POINTER(struct_nvJitLink))]
  357. except AttributeError:
  358. pass
  359. try:
  360. nvJitLinkDestroy = _libraries['libnvJitLink.so'].nvJitLinkDestroy
  361. nvJitLinkDestroy.restype = nvJitLinkResult
  362. nvJitLinkDestroy.argtypes = [ctypes.POINTER(ctypes.POINTER(struct_nvJitLink))]
  363. except AttributeError:
  364. pass
  365. size_t = ctypes.c_uint64
  366. try:
  367. __nvJitLinkAddData_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkAddData_12_4
  368. __nvJitLinkAddData_12_4.restype = nvJitLinkResult
  369. __nvJitLinkAddData_12_4.argtypes = [nvJitLinkHandle, nvJitLinkInputType, ctypes.POINTER(None), size_t, ctypes.POINTER(ctypes.c_char)]
  370. except AttributeError:
  371. pass
  372. try:
  373. nvJitLinkAddData = _libraries['libnvJitLink.so'].nvJitLinkAddData
  374. nvJitLinkAddData.restype = nvJitLinkResult
  375. nvJitLinkAddData.argtypes = [nvJitLinkHandle, nvJitLinkInputType, ctypes.POINTER(None), size_t, ctypes.POINTER(ctypes.c_char)]
  376. except AttributeError:
  377. pass
  378. try:
  379. __nvJitLinkAddFile_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkAddFile_12_4
  380. __nvJitLinkAddFile_12_4.restype = nvJitLinkResult
  381. __nvJitLinkAddFile_12_4.argtypes = [nvJitLinkHandle, nvJitLinkInputType, ctypes.POINTER(ctypes.c_char)]
  382. except AttributeError:
  383. pass
  384. try:
  385. nvJitLinkAddFile = _libraries['libnvJitLink.so'].nvJitLinkAddFile
  386. nvJitLinkAddFile.restype = nvJitLinkResult
  387. nvJitLinkAddFile.argtypes = [nvJitLinkHandle, nvJitLinkInputType, ctypes.POINTER(ctypes.c_char)]
  388. except AttributeError:
  389. pass
  390. try:
  391. __nvJitLinkComplete_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkComplete_12_4
  392. __nvJitLinkComplete_12_4.restype = nvJitLinkResult
  393. __nvJitLinkComplete_12_4.argtypes = [nvJitLinkHandle]
  394. except AttributeError:
  395. pass
  396. try:
  397. nvJitLinkComplete = _libraries['libnvJitLink.so'].nvJitLinkComplete
  398. nvJitLinkComplete.restype = nvJitLinkResult
  399. nvJitLinkComplete.argtypes = [nvJitLinkHandle]
  400. except AttributeError:
  401. pass
  402. try:
  403. __nvJitLinkGetLinkedCubinSize_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetLinkedCubinSize_12_4
  404. __nvJitLinkGetLinkedCubinSize_12_4.restype = nvJitLinkResult
  405. __nvJitLinkGetLinkedCubinSize_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  406. except AttributeError:
  407. pass
  408. try:
  409. nvJitLinkGetLinkedCubinSize = _libraries['libnvJitLink.so'].nvJitLinkGetLinkedCubinSize
  410. nvJitLinkGetLinkedCubinSize.restype = nvJitLinkResult
  411. nvJitLinkGetLinkedCubinSize.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  412. except AttributeError:
  413. pass
  414. try:
  415. __nvJitLinkGetLinkedCubin_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetLinkedCubin_12_4
  416. __nvJitLinkGetLinkedCubin_12_4.restype = nvJitLinkResult
  417. __nvJitLinkGetLinkedCubin_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(None)]
  418. except AttributeError:
  419. pass
  420. try:
  421. nvJitLinkGetLinkedCubin = _libraries['libnvJitLink.so'].nvJitLinkGetLinkedCubin
  422. nvJitLinkGetLinkedCubin.restype = nvJitLinkResult
  423. nvJitLinkGetLinkedCubin.argtypes = [nvJitLinkHandle, ctypes.POINTER(None)]
  424. except AttributeError:
  425. pass
  426. try:
  427. __nvJitLinkGetLinkedPtxSize_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetLinkedPtxSize_12_4
  428. __nvJitLinkGetLinkedPtxSize_12_4.restype = nvJitLinkResult
  429. __nvJitLinkGetLinkedPtxSize_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  430. except AttributeError:
  431. pass
  432. try:
  433. nvJitLinkGetLinkedPtxSize = _libraries['libnvJitLink.so'].nvJitLinkGetLinkedPtxSize
  434. nvJitLinkGetLinkedPtxSize.restype = nvJitLinkResult
  435. nvJitLinkGetLinkedPtxSize.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  436. except AttributeError:
  437. pass
  438. try:
  439. __nvJitLinkGetLinkedPtx_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetLinkedPtx_12_4
  440. __nvJitLinkGetLinkedPtx_12_4.restype = nvJitLinkResult
  441. __nvJitLinkGetLinkedPtx_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  442. except AttributeError:
  443. pass
  444. try:
  445. nvJitLinkGetLinkedPtx = _libraries['libnvJitLink.so'].nvJitLinkGetLinkedPtx
  446. nvJitLinkGetLinkedPtx.restype = nvJitLinkResult
  447. nvJitLinkGetLinkedPtx.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  448. except AttributeError:
  449. pass
  450. try:
  451. __nvJitLinkGetErrorLogSize_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetErrorLogSize_12_4
  452. __nvJitLinkGetErrorLogSize_12_4.restype = nvJitLinkResult
  453. __nvJitLinkGetErrorLogSize_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  454. except AttributeError:
  455. pass
  456. try:
  457. nvJitLinkGetErrorLogSize = _libraries['libnvJitLink.so'].nvJitLinkGetErrorLogSize
  458. nvJitLinkGetErrorLogSize.restype = nvJitLinkResult
  459. nvJitLinkGetErrorLogSize.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  460. except AttributeError:
  461. pass
  462. try:
  463. __nvJitLinkGetErrorLog_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetErrorLog_12_4
  464. __nvJitLinkGetErrorLog_12_4.restype = nvJitLinkResult
  465. __nvJitLinkGetErrorLog_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  466. except AttributeError:
  467. pass
  468. try:
  469. nvJitLinkGetErrorLog = _libraries['libnvJitLink.so'].nvJitLinkGetErrorLog
  470. nvJitLinkGetErrorLog.restype = nvJitLinkResult
  471. nvJitLinkGetErrorLog.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  472. except AttributeError:
  473. pass
  474. try:
  475. __nvJitLinkGetInfoLogSize_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetInfoLogSize_12_4
  476. __nvJitLinkGetInfoLogSize_12_4.restype = nvJitLinkResult
  477. __nvJitLinkGetInfoLogSize_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  478. except AttributeError:
  479. pass
  480. try:
  481. nvJitLinkGetInfoLogSize = _libraries['libnvJitLink.so'].nvJitLinkGetInfoLogSize
  482. nvJitLinkGetInfoLogSize.restype = nvJitLinkResult
  483. nvJitLinkGetInfoLogSize.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_uint64)]
  484. except AttributeError:
  485. pass
  486. try:
  487. __nvJitLinkGetInfoLog_12_4 = _libraries['libnvJitLink.so'].__nvJitLinkGetInfoLog_12_4
  488. __nvJitLinkGetInfoLog_12_4.restype = nvJitLinkResult
  489. __nvJitLinkGetInfoLog_12_4.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  490. except AttributeError:
  491. pass
  492. try:
  493. nvJitLinkGetInfoLog = _libraries['libnvJitLink.so'].nvJitLinkGetInfoLog
  494. nvJitLinkGetInfoLog.restype = nvJitLinkResult
  495. nvJitLinkGetInfoLog.argtypes = [nvJitLinkHandle, ctypes.POINTER(ctypes.c_char)]
  496. except AttributeError:
  497. pass
  498. try:
  499. nvJitLinkVersion = _libraries['libnvJitLink.so'].nvJitLinkVersion
  500. nvJitLinkVersion.restype = nvJitLinkResult
  501. nvJitLinkVersion.argtypes = [ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_uint32)]
  502. except AttributeError:
  503. pass
  504. __all__ = \
  505. ['NVJITLINK_ERROR_INTERNAL', 'NVJITLINK_ERROR_INVALID_INPUT',
  506. 'NVJITLINK_ERROR_MISSING_ARCH', 'NVJITLINK_ERROR_NVVM_COMPILE',
  507. 'NVJITLINK_ERROR_PTX_COMPILE', 'NVJITLINK_ERROR_THREADPOOL',
  508. 'NVJITLINK_ERROR_UNRECOGNIZED_INPUT',
  509. 'NVJITLINK_ERROR_UNRECOGNIZED_OPTION', 'NVJITLINK_INPUT_ANY',
  510. 'NVJITLINK_INPUT_CUBIN', 'NVJITLINK_INPUT_FATBIN',
  511. 'NVJITLINK_INPUT_LIBRARY', 'NVJITLINK_INPUT_LTOIR',
  512. 'NVJITLINK_INPUT_NONE', 'NVJITLINK_INPUT_OBJECT',
  513. 'NVJITLINK_INPUT_PTX', 'NVJITLINK_SUCCESS',
  514. 'NVRTC_ERROR_BUILTIN_OPERATION_FAILURE',
  515. 'NVRTC_ERROR_COMPILATION', 'NVRTC_ERROR_INTERNAL_ERROR',
  516. 'NVRTC_ERROR_INVALID_INPUT', 'NVRTC_ERROR_INVALID_OPTION',
  517. 'NVRTC_ERROR_INVALID_PROGRAM',
  518. 'NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID',
  519. 'NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION',
  520. 'NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION',
  521. 'NVRTC_ERROR_OUT_OF_MEMORY',
  522. 'NVRTC_ERROR_PROGRAM_CREATION_FAILURE',
  523. 'NVRTC_ERROR_TIME_FILE_WRITE_FAILED', 'NVRTC_SUCCESS',
  524. '__nvJitLinkAddData_12_4', '__nvJitLinkAddFile_12_4',
  525. '__nvJitLinkComplete_12_4', '__nvJitLinkCreate_12_4',
  526. '__nvJitLinkDestroy_12_4', '__nvJitLinkGetErrorLogSize_12_4',
  527. '__nvJitLinkGetErrorLog_12_4', '__nvJitLinkGetInfoLogSize_12_4',
  528. '__nvJitLinkGetInfoLog_12_4',
  529. '__nvJitLinkGetLinkedCubinSize_12_4',
  530. '__nvJitLinkGetLinkedCubin_12_4',
  531. '__nvJitLinkGetLinkedPtxSize_12_4',
  532. '__nvJitLinkGetLinkedPtx_12_4', 'c__EA_nvJitLinkInputType',
  533. 'c__EA_nvJitLinkResult', 'c__EA_nvrtcResult', 'nvJitLinkAddData',
  534. 'nvJitLinkAddFile', 'nvJitLinkComplete', 'nvJitLinkCreate',
  535. 'nvJitLinkDestroy', 'nvJitLinkGetErrorLog',
  536. 'nvJitLinkGetErrorLogSize', 'nvJitLinkGetInfoLog',
  537. 'nvJitLinkGetInfoLogSize', 'nvJitLinkGetLinkedCubin',
  538. 'nvJitLinkGetLinkedCubinSize', 'nvJitLinkGetLinkedPtx',
  539. 'nvJitLinkGetLinkedPtxSize', 'nvJitLinkHandle',
  540. 'nvJitLinkInputType', 'nvJitLinkInputType__enumvalues',
  541. 'nvJitLinkResult', 'nvJitLinkResult__enumvalues',
  542. 'nvJitLinkVersion', 'nvrtcAddNameExpression',
  543. 'nvrtcCompileProgram', 'nvrtcCreateProgram',
  544. 'nvrtcDestroyProgram', 'nvrtcGetCUBIN', 'nvrtcGetCUBINSize',
  545. 'nvrtcGetErrorString', 'nvrtcGetLTOIR', 'nvrtcGetLTOIRSize',
  546. 'nvrtcGetLoweredName', 'nvrtcGetNVVM', 'nvrtcGetNVVMSize',
  547. 'nvrtcGetNumSupportedArchs', 'nvrtcGetOptiXIR',
  548. 'nvrtcGetOptiXIRSize', 'nvrtcGetPTX', 'nvrtcGetPTXSize',
  549. 'nvrtcGetProgramLog', 'nvrtcGetProgramLogSize',
  550. 'nvrtcGetSupportedArchs', 'nvrtcProgram', 'nvrtcResult',
  551. 'nvrtcResult__enumvalues', 'nvrtcVersion', 'size_t',
  552. 'struct__nvrtcProgram', 'struct_nvJitLink', 'uint32_t']