forked from NVIDIA/cuda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcynvrtc.pyx.in
More file actions
863 lines (772 loc) · 33.8 KB
/
cynvrtc.pyx.in
File metadata and controls
863 lines (772 loc) · 33.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
# This code was automatically generated with version 12.9.0. Do not modify it directly.
{{if 'Windows' == platform.system()}}
import os
import win32api
{{else}}
cimport cuda.bindings._lib.dlfcn as dlfcn
from libc.stdint cimport uintptr_t
{{endif}}
from cuda.pathfinder import load_nvidia_dynamic_lib
from libc.stdint cimport intptr_t
import threading
cdef object __symbol_lock = threading.Lock()
cdef bint __cuPythonInit = False
{{if 'nvrtcGetErrorString' in found_functions}}cdef void *__nvrtcGetErrorString = NULL{{endif}}
{{if 'nvrtcVersion' in found_functions}}cdef void *__nvrtcVersion = NULL{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}cdef void *__nvrtcGetNumSupportedArchs = NULL{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}cdef void *__nvrtcGetSupportedArchs = NULL{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}cdef void *__nvrtcCreateProgram = NULL{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}cdef void *__nvrtcDestroyProgram = NULL{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}cdef void *__nvrtcCompileProgram = NULL{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}cdef void *__nvrtcGetPTXSize = NULL{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}cdef void *__nvrtcGetPTX = NULL{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}cdef void *__nvrtcGetCUBINSize = NULL{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}cdef void *__nvrtcGetCUBIN = NULL{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}cdef void *__nvrtcGetNVVMSize = NULL{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}cdef void *__nvrtcGetNVVM = NULL{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}cdef void *__nvrtcGetLTOIRSize = NULL{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}cdef void *__nvrtcGetLTOIR = NULL{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}cdef void *__nvrtcGetOptiXIRSize = NULL{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}cdef void *__nvrtcGetOptiXIR = NULL{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}cdef void *__nvrtcGetProgramLogSize = NULL{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}cdef void *__nvrtcGetProgramLog = NULL{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}cdef void *__nvrtcAddNameExpression = NULL{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}cdef void *__nvrtcGetLoweredName = NULL{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}cdef void *__nvrtcGetPCHHeapSize = NULL{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}cdef void *__nvrtcSetPCHHeapSize = NULL{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}cdef void *__nvrtcGetPCHCreateStatus = NULL{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}cdef void *__nvrtcGetPCHHeapSizeRequired = NULL{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}cdef void *__nvrtcSetFlowCallback = NULL{{endif}}
cdef int cuPythonInit() except -1 nogil:
global __cuPythonInit
if __cuPythonInit:
return 0
# Load library
with gil, __symbol_lock:
{{if 'Windows' == platform.system()}}
handle = load_nvidia_dynamic_lib("nvrtc")._handle_uint
# Load function
{{if 'nvrtcGetErrorString' in found_functions}}
try:
global __nvrtcGetErrorString
__nvrtcGetErrorString = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetErrorString')
except:
pass
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
try:
global __nvrtcVersion
__nvrtcVersion = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcVersion')
except:
pass
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
try:
global __nvrtcGetNumSupportedArchs
__nvrtcGetNumSupportedArchs = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetNumSupportedArchs')
except:
pass
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
try:
global __nvrtcGetSupportedArchs
__nvrtcGetSupportedArchs = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetSupportedArchs')
except:
pass
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
try:
global __nvrtcCreateProgram
__nvrtcCreateProgram = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcCreateProgram')
except:
pass
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
try:
global __nvrtcDestroyProgram
__nvrtcDestroyProgram = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcDestroyProgram')
except:
pass
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
try:
global __nvrtcCompileProgram
__nvrtcCompileProgram = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcCompileProgram')
except:
pass
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
try:
global __nvrtcGetPTXSize
__nvrtcGetPTXSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetPTXSize')
except:
pass
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
try:
global __nvrtcGetPTX
__nvrtcGetPTX = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetPTX')
except:
pass
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
try:
global __nvrtcGetCUBINSize
__nvrtcGetCUBINSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetCUBINSize')
except:
pass
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
try:
global __nvrtcGetCUBIN
__nvrtcGetCUBIN = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetCUBIN')
except:
pass
{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}
try:
global __nvrtcGetNVVMSize
__nvrtcGetNVVMSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetNVVMSize')
except:
pass
{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}
try:
global __nvrtcGetNVVM
__nvrtcGetNVVM = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetNVVM')
except:
pass
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
try:
global __nvrtcGetLTOIRSize
__nvrtcGetLTOIRSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetLTOIRSize')
except:
pass
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
try:
global __nvrtcGetLTOIR
__nvrtcGetLTOIR = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetLTOIR')
except:
pass
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
try:
global __nvrtcGetOptiXIRSize
__nvrtcGetOptiXIRSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetOptiXIRSize')
except:
pass
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
try:
global __nvrtcGetOptiXIR
__nvrtcGetOptiXIR = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetOptiXIR')
except:
pass
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
try:
global __nvrtcGetProgramLogSize
__nvrtcGetProgramLogSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetProgramLogSize')
except:
pass
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
try:
global __nvrtcGetProgramLog
__nvrtcGetProgramLog = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetProgramLog')
except:
pass
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
try:
global __nvrtcAddNameExpression
__nvrtcAddNameExpression = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcAddNameExpression')
except:
pass
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
try:
global __nvrtcGetLoweredName
__nvrtcGetLoweredName = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetLoweredName')
except:
pass
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
try:
global __nvrtcGetPCHHeapSize
__nvrtcGetPCHHeapSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetPCHHeapSize')
except:
pass
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
try:
global __nvrtcSetPCHHeapSize
__nvrtcSetPCHHeapSize = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcSetPCHHeapSize')
except:
pass
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
try:
global __nvrtcGetPCHCreateStatus
__nvrtcGetPCHCreateStatus = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetPCHCreateStatus')
except:
pass
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
try:
global __nvrtcGetPCHHeapSizeRequired
__nvrtcGetPCHHeapSizeRequired = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcGetPCHHeapSizeRequired')
except:
pass
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
try:
global __nvrtcSetFlowCallback
__nvrtcSetFlowCallback = <void*><unsigned long long>win32api.GetProcAddress(handle, 'nvrtcSetFlowCallback')
except:
pass
{{endif}}
{{else}}
handle = <void*><uintptr_t>(load_nvidia_dynamic_lib("nvrtc")._handle_uint)
# Load function
{{if 'nvrtcGetErrorString' in found_functions}}
global __nvrtcGetErrorString
__nvrtcGetErrorString = dlfcn.dlsym(handle, 'nvrtcGetErrorString')
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
global __nvrtcVersion
__nvrtcVersion = dlfcn.dlsym(handle, 'nvrtcVersion')
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
global __nvrtcGetNumSupportedArchs
__nvrtcGetNumSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetNumSupportedArchs')
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
global __nvrtcGetSupportedArchs
__nvrtcGetSupportedArchs = dlfcn.dlsym(handle, 'nvrtcGetSupportedArchs')
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
global __nvrtcCreateProgram
__nvrtcCreateProgram = dlfcn.dlsym(handle, 'nvrtcCreateProgram')
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
global __nvrtcDestroyProgram
__nvrtcDestroyProgram = dlfcn.dlsym(handle, 'nvrtcDestroyProgram')
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
global __nvrtcCompileProgram
__nvrtcCompileProgram = dlfcn.dlsym(handle, 'nvrtcCompileProgram')
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
global __nvrtcGetPTXSize
__nvrtcGetPTXSize = dlfcn.dlsym(handle, 'nvrtcGetPTXSize')
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
global __nvrtcGetPTX
__nvrtcGetPTX = dlfcn.dlsym(handle, 'nvrtcGetPTX')
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
global __nvrtcGetCUBINSize
__nvrtcGetCUBINSize = dlfcn.dlsym(handle, 'nvrtcGetCUBINSize')
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
global __nvrtcGetCUBIN
__nvrtcGetCUBIN = dlfcn.dlsym(handle, 'nvrtcGetCUBIN')
{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}
global __nvrtcGetNVVMSize
__nvrtcGetNVVMSize = dlfcn.dlsym(handle, 'nvrtcGetNVVMSize')
{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}
global __nvrtcGetNVVM
__nvrtcGetNVVM = dlfcn.dlsym(handle, 'nvrtcGetNVVM')
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
global __nvrtcGetLTOIRSize
__nvrtcGetLTOIRSize = dlfcn.dlsym(handle, 'nvrtcGetLTOIRSize')
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
global __nvrtcGetLTOIR
__nvrtcGetLTOIR = dlfcn.dlsym(handle, 'nvrtcGetLTOIR')
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
global __nvrtcGetOptiXIRSize
__nvrtcGetOptiXIRSize = dlfcn.dlsym(handle, 'nvrtcGetOptiXIRSize')
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
global __nvrtcGetOptiXIR
__nvrtcGetOptiXIR = dlfcn.dlsym(handle, 'nvrtcGetOptiXIR')
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
global __nvrtcGetProgramLogSize
__nvrtcGetProgramLogSize = dlfcn.dlsym(handle, 'nvrtcGetProgramLogSize')
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
global __nvrtcGetProgramLog
__nvrtcGetProgramLog = dlfcn.dlsym(handle, 'nvrtcGetProgramLog')
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
global __nvrtcAddNameExpression
__nvrtcAddNameExpression = dlfcn.dlsym(handle, 'nvrtcAddNameExpression')
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
global __nvrtcGetLoweredName
__nvrtcGetLoweredName = dlfcn.dlsym(handle, 'nvrtcGetLoweredName')
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
global __nvrtcGetPCHHeapSize
__nvrtcGetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSize')
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
global __nvrtcSetPCHHeapSize
__nvrtcSetPCHHeapSize = dlfcn.dlsym(handle, 'nvrtcSetPCHHeapSize')
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
global __nvrtcGetPCHCreateStatus
__nvrtcGetPCHCreateStatus = dlfcn.dlsym(handle, 'nvrtcGetPCHCreateStatus')
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
global __nvrtcGetPCHHeapSizeRequired
__nvrtcGetPCHHeapSizeRequired = dlfcn.dlsym(handle, 'nvrtcGetPCHHeapSizeRequired')
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
global __nvrtcSetFlowCallback
__nvrtcSetFlowCallback = dlfcn.dlsym(handle, 'nvrtcSetFlowCallback')
{{endif}}
{{endif}}
__cuPythonInit = True
return 0
{{if 'nvrtcGetErrorString' in found_functions}}
cdef const char* _nvrtcGetErrorString(nvrtcResult result) except ?NULL nogil:
global __nvrtcGetErrorString
cuPythonInit()
if __nvrtcGetErrorString == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetErrorString" not found')
err = (<const char* (*)(nvrtcResult) except ?NULL nogil> __nvrtcGetErrorString)(result)
return err
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
cdef nvrtcResult _nvrtcVersion(int* major, int* minor) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcVersion
cuPythonInit()
if __nvrtcVersion == NULL:
with gil:
raise RuntimeError('Function "nvrtcVersion" not found')
err = (<nvrtcResult (*)(int*, int*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcVersion)(major, minor)
return err
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
cdef nvrtcResult _nvrtcGetNumSupportedArchs(int* numArchs) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetNumSupportedArchs
cuPythonInit()
if __nvrtcGetNumSupportedArchs == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetNumSupportedArchs" not found')
err = (<nvrtcResult (*)(int*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetNumSupportedArchs)(numArchs)
return err
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
cdef nvrtcResult _nvrtcGetSupportedArchs(int* supportedArchs) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetSupportedArchs
cuPythonInit()
if __nvrtcGetSupportedArchs == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetSupportedArchs" not found')
err = (<nvrtcResult (*)(int*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetSupportedArchs)(supportedArchs)
return err
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
cdef nvrtcResult _nvrtcCreateProgram(nvrtcProgram* prog, const char* src, const char* name, int numHeaders, const char** headers, const char** includeNames) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcCreateProgram
cuPythonInit()
if __nvrtcCreateProgram == NULL:
with gil:
raise RuntimeError('Function "nvrtcCreateProgram" not found')
err = (<nvrtcResult (*)(nvrtcProgram*, const char*, const char*, int, const char**, const char**) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcCreateProgram)(prog, src, name, numHeaders, headers, includeNames)
return err
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
cdef nvrtcResult _nvrtcDestroyProgram(nvrtcProgram* prog) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcDestroyProgram
cuPythonInit()
if __nvrtcDestroyProgram == NULL:
with gil:
raise RuntimeError('Function "nvrtcDestroyProgram" not found')
err = (<nvrtcResult (*)(nvrtcProgram*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcDestroyProgram)(prog)
return err
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
cdef nvrtcResult _nvrtcCompileProgram(nvrtcProgram prog, int numOptions, const char** options) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcCompileProgram
cuPythonInit()
if __nvrtcCompileProgram == NULL:
with gil:
raise RuntimeError('Function "nvrtcCompileProgram" not found')
err = (<nvrtcResult (*)(nvrtcProgram, int, const char**) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcCompileProgram)(prog, numOptions, options)
return err
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
cdef nvrtcResult _nvrtcGetPTXSize(nvrtcProgram prog, size_t* ptxSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetPTXSize
cuPythonInit()
if __nvrtcGetPTXSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetPTXSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetPTXSize)(prog, ptxSizeRet)
return err
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
cdef nvrtcResult _nvrtcGetPTX(nvrtcProgram prog, char* ptx) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetPTX
cuPythonInit()
if __nvrtcGetPTX == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetPTX" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetPTX)(prog, ptx)
return err
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
cdef nvrtcResult _nvrtcGetCUBINSize(nvrtcProgram prog, size_t* cubinSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetCUBINSize
cuPythonInit()
if __nvrtcGetCUBINSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetCUBINSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetCUBINSize)(prog, cubinSizeRet)
return err
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
cdef nvrtcResult _nvrtcGetCUBIN(nvrtcProgram prog, char* cubin) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetCUBIN
cuPythonInit()
if __nvrtcGetCUBIN == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetCUBIN" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetCUBIN)(prog, cubin)
return err
{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}
cdef nvrtcResult _nvrtcGetNVVMSize(nvrtcProgram prog, size_t* nvvmSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetNVVMSize
cuPythonInit()
if __nvrtcGetNVVMSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetNVVMSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetNVVMSize)(prog, nvvmSizeRet)
return err
{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}
cdef nvrtcResult _nvrtcGetNVVM(nvrtcProgram prog, char* nvvm) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetNVVM
cuPythonInit()
if __nvrtcGetNVVM == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetNVVM" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetNVVM)(prog, nvvm)
return err
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
cdef nvrtcResult _nvrtcGetLTOIRSize(nvrtcProgram prog, size_t* LTOIRSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetLTOIRSize
cuPythonInit()
if __nvrtcGetLTOIRSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetLTOIRSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetLTOIRSize)(prog, LTOIRSizeRet)
return err
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
cdef nvrtcResult _nvrtcGetLTOIR(nvrtcProgram prog, char* LTOIR) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetLTOIR
cuPythonInit()
if __nvrtcGetLTOIR == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetLTOIR" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetLTOIR)(prog, LTOIR)
return err
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
cdef nvrtcResult _nvrtcGetOptiXIRSize(nvrtcProgram prog, size_t* optixirSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetOptiXIRSize
cuPythonInit()
if __nvrtcGetOptiXIRSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetOptiXIRSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetOptiXIRSize)(prog, optixirSizeRet)
return err
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
cdef nvrtcResult _nvrtcGetOptiXIR(nvrtcProgram prog, char* optixir) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetOptiXIR
cuPythonInit()
if __nvrtcGetOptiXIR == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetOptiXIR" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetOptiXIR)(prog, optixir)
return err
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
cdef nvrtcResult _nvrtcGetProgramLogSize(nvrtcProgram prog, size_t* logSizeRet) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetProgramLogSize
cuPythonInit()
if __nvrtcGetProgramLogSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetProgramLogSize" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetProgramLogSize)(prog, logSizeRet)
return err
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
cdef nvrtcResult _nvrtcGetProgramLog(nvrtcProgram prog, char* log) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetProgramLog
cuPythonInit()
if __nvrtcGetProgramLog == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetProgramLog" not found')
err = (<nvrtcResult (*)(nvrtcProgram, char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetProgramLog)(prog, log)
return err
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
cdef nvrtcResult _nvrtcAddNameExpression(nvrtcProgram prog, const char* name_expression) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcAddNameExpression
cuPythonInit()
if __nvrtcAddNameExpression == NULL:
with gil:
raise RuntimeError('Function "nvrtcAddNameExpression" not found')
err = (<nvrtcResult (*)(nvrtcProgram, const char*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcAddNameExpression)(prog, name_expression)
return err
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
cdef nvrtcResult _nvrtcGetLoweredName(nvrtcProgram prog, const char* name_expression, const char** lowered_name) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetLoweredName
cuPythonInit()
if __nvrtcGetLoweredName == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetLoweredName" not found')
err = (<nvrtcResult (*)(nvrtcProgram, const char*, const char**) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetLoweredName)(prog, name_expression, lowered_name)
return err
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
cdef nvrtcResult _nvrtcGetPCHHeapSize(size_t* ret) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetPCHHeapSize
cuPythonInit()
if __nvrtcGetPCHHeapSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetPCHHeapSize" not found')
err = (<nvrtcResult (*)(size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetPCHHeapSize)(ret)
return err
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
cdef nvrtcResult _nvrtcSetPCHHeapSize(size_t size) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcSetPCHHeapSize
cuPythonInit()
if __nvrtcSetPCHHeapSize == NULL:
with gil:
raise RuntimeError('Function "nvrtcSetPCHHeapSize" not found')
err = (<nvrtcResult (*)(size_t) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcSetPCHHeapSize)(size)
return err
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
cdef nvrtcResult _nvrtcGetPCHCreateStatus(nvrtcProgram prog) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetPCHCreateStatus
cuPythonInit()
if __nvrtcGetPCHCreateStatus == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetPCHCreateStatus" not found')
err = (<nvrtcResult (*)(nvrtcProgram) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetPCHCreateStatus)(prog)
return err
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
cdef nvrtcResult _nvrtcGetPCHHeapSizeRequired(nvrtcProgram prog, size_t* size) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcGetPCHHeapSizeRequired
cuPythonInit()
if __nvrtcGetPCHHeapSizeRequired == NULL:
with gil:
raise RuntimeError('Function "nvrtcGetPCHHeapSizeRequired" not found')
err = (<nvrtcResult (*)(nvrtcProgram, size_t*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcGetPCHHeapSizeRequired)(prog, size)
return err
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
cdef nvrtcResult _nvrtcSetFlowCallback(nvrtcProgram prog, void* callback, void* payload) except ?NVRTC_ERROR_INVALID_INPUT nogil:
global __nvrtcSetFlowCallback
cuPythonInit()
if __nvrtcSetFlowCallback == NULL:
with gil:
raise RuntimeError('Function "nvrtcSetFlowCallback" not found')
err = (<nvrtcResult (*)(nvrtcProgram, void*, void*) except ?NVRTC_ERROR_INVALID_INPUT nogil> __nvrtcSetFlowCallback)(prog, callback, payload)
return err
{{endif}}
cdef dict func_ptrs = None
cpdef dict _inspect_function_pointers():
global func_ptrs
if func_ptrs is not None:
return func_ptrs
cuPythonInit()
cdef dict data = {}
{{if 'nvrtcGetErrorString' in found_functions}}
global __nvrtcGetErrorString
data["__nvrtcGetErrorString"] = <intptr_t>__nvrtcGetErrorString
{{else}}
data["__nvrtcGetErrorString"] = <intptr_t>0
{{endif}}
{{if 'nvrtcVersion' in found_functions}}
global __nvrtcVersion
data["__nvrtcVersion"] = <intptr_t>__nvrtcVersion
{{else}}
data["__nvrtcVersion"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetNumSupportedArchs' in found_functions}}
global __nvrtcGetNumSupportedArchs
data["__nvrtcGetNumSupportedArchs"] = <intptr_t>__nvrtcGetNumSupportedArchs
{{else}}
data["__nvrtcGetNumSupportedArchs"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetSupportedArchs' in found_functions}}
global __nvrtcGetSupportedArchs
data["__nvrtcGetSupportedArchs"] = <intptr_t>__nvrtcGetSupportedArchs
{{else}}
data["__nvrtcGetSupportedArchs"] = <intptr_t>0
{{endif}}
{{if 'nvrtcCreateProgram' in found_functions}}
global __nvrtcCreateProgram
data["__nvrtcCreateProgram"] = <intptr_t>__nvrtcCreateProgram
{{else}}
data["__nvrtcCreateProgram"] = <intptr_t>0
{{endif}}
{{if 'nvrtcDestroyProgram' in found_functions}}
global __nvrtcDestroyProgram
data["__nvrtcDestroyProgram"] = <intptr_t>__nvrtcDestroyProgram
{{else}}
data["__nvrtcDestroyProgram"] = <intptr_t>0
{{endif}}
{{if 'nvrtcCompileProgram' in found_functions}}
global __nvrtcCompileProgram
data["__nvrtcCompileProgram"] = <intptr_t>__nvrtcCompileProgram
{{else}}
data["__nvrtcCompileProgram"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetPTXSize' in found_functions}}
global __nvrtcGetPTXSize
data["__nvrtcGetPTXSize"] = <intptr_t>__nvrtcGetPTXSize
{{else}}
data["__nvrtcGetPTXSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetPTX' in found_functions}}
global __nvrtcGetPTX
data["__nvrtcGetPTX"] = <intptr_t>__nvrtcGetPTX
{{else}}
data["__nvrtcGetPTX"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetCUBINSize' in found_functions}}
global __nvrtcGetCUBINSize
data["__nvrtcGetCUBINSize"] = <intptr_t>__nvrtcGetCUBINSize
{{else}}
data["__nvrtcGetCUBINSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetCUBIN' in found_functions}}
global __nvrtcGetCUBIN
data["__nvrtcGetCUBIN"] = <intptr_t>__nvrtcGetCUBIN
{{else}}
data["__nvrtcGetCUBIN"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetNVVMSize' in found_functions}}
global __nvrtcGetNVVMSize
data["__nvrtcGetNVVMSize"] = <intptr_t>__nvrtcGetNVVMSize
{{else}}
data["__nvrtcGetNVVMSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetNVVM' in found_functions}}
global __nvrtcGetNVVM
data["__nvrtcGetNVVM"] = <intptr_t>__nvrtcGetNVVM
{{else}}
data["__nvrtcGetNVVM"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetLTOIRSize' in found_functions}}
global __nvrtcGetLTOIRSize
data["__nvrtcGetLTOIRSize"] = <intptr_t>__nvrtcGetLTOIRSize
{{else}}
data["__nvrtcGetLTOIRSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetLTOIR' in found_functions}}
global __nvrtcGetLTOIR
data["__nvrtcGetLTOIR"] = <intptr_t>__nvrtcGetLTOIR
{{else}}
data["__nvrtcGetLTOIR"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetOptiXIRSize' in found_functions}}
global __nvrtcGetOptiXIRSize
data["__nvrtcGetOptiXIRSize"] = <intptr_t>__nvrtcGetOptiXIRSize
{{else}}
data["__nvrtcGetOptiXIRSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetOptiXIR' in found_functions}}
global __nvrtcGetOptiXIR
data["__nvrtcGetOptiXIR"] = <intptr_t>__nvrtcGetOptiXIR
{{else}}
data["__nvrtcGetOptiXIR"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetProgramLogSize' in found_functions}}
global __nvrtcGetProgramLogSize
data["__nvrtcGetProgramLogSize"] = <intptr_t>__nvrtcGetProgramLogSize
{{else}}
data["__nvrtcGetProgramLogSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetProgramLog' in found_functions}}
global __nvrtcGetProgramLog
data["__nvrtcGetProgramLog"] = <intptr_t>__nvrtcGetProgramLog
{{else}}
data["__nvrtcGetProgramLog"] = <intptr_t>0
{{endif}}
{{if 'nvrtcAddNameExpression' in found_functions}}
global __nvrtcAddNameExpression
data["__nvrtcAddNameExpression"] = <intptr_t>__nvrtcAddNameExpression
{{else}}
data["__nvrtcAddNameExpression"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetLoweredName' in found_functions}}
global __nvrtcGetLoweredName
data["__nvrtcGetLoweredName"] = <intptr_t>__nvrtcGetLoweredName
{{else}}
data["__nvrtcGetLoweredName"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetPCHHeapSize' in found_functions}}
global __nvrtcGetPCHHeapSize
data["__nvrtcGetPCHHeapSize"] = <intptr_t>__nvrtcGetPCHHeapSize
{{else}}
data["__nvrtcGetPCHHeapSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcSetPCHHeapSize' in found_functions}}
global __nvrtcSetPCHHeapSize
data["__nvrtcSetPCHHeapSize"] = <intptr_t>__nvrtcSetPCHHeapSize
{{else}}
data["__nvrtcSetPCHHeapSize"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetPCHCreateStatus' in found_functions}}
global __nvrtcGetPCHCreateStatus
data["__nvrtcGetPCHCreateStatus"] = <intptr_t>__nvrtcGetPCHCreateStatus
{{else}}
data["__nvrtcGetPCHCreateStatus"] = <intptr_t>0
{{endif}}
{{if 'nvrtcGetPCHHeapSizeRequired' in found_functions}}
global __nvrtcGetPCHHeapSizeRequired
data["__nvrtcGetPCHHeapSizeRequired"] = <intptr_t>__nvrtcGetPCHHeapSizeRequired
{{else}}
data["__nvrtcGetPCHHeapSizeRequired"] = <intptr_t>0
{{endif}}
{{if 'nvrtcSetFlowCallback' in found_functions}}
global __nvrtcSetFlowCallback
data["__nvrtcSetFlowCallback"] = <intptr_t>__nvrtcSetFlowCallback
{{else}}
data["__nvrtcSetFlowCallback"] = <intptr_t>0
{{endif}}
func_ptrs = data
return data
cpdef _inspect_function_pointer(str name):
global func_ptrs
if func_ptrs is None:
func_ptrs = _inspect_function_pointers()
return func_ptrs[name]