Skip to content

Commit 1f477e9

Browse files
committed
Automatically generate functions with multiple returns
1 parent 819c586 commit 1f477e9

3 files changed

Lines changed: 885 additions & 492 deletions

File tree

‎cuda_bindings/cuda/bindings/_v2/nvrtc.pyx‎

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# This code was automatically generated across versions from 12.9.0 to 13.3.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=a36c7e54cf29166832dd9aebc1fa71cc3649498794a2846e707396419caebe10
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=81a8413522bab04b3eb89373f90a9879758fdeeeb8141425dc27c4504df84b78
77

88

99
# <<<< PREAMBLE CONTENT >>>>
@@ -657,6 +657,8 @@ cpdef tuple version():
657657
cpdef int get_num_supported_archs() except? -1:
658658
"""nvrtcGetNumSupportedArchs sets the output parameter ``num_archs`` with the number of architectures supported by NVRTC. This can then be used to pass an array to ``nvrtcGetSupportedArchs`` to get the supported architectures.
659659
660+
see ``nvrtcGetSupportedArchs``.
661+
660662
Returns:
661663
int: number of supported architectures.
662664
@@ -672,6 +674,8 @@ cpdef int get_num_supported_archs() except? -1:
672674
cpdef object get_supported_archs():
673675
"""nvrtcGetSupportedArchs populates the array passed via the output parameter ``supported_archs`` 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 ``nvrtcGetNumSupportedArchs``.
674676
677+
see ``nvrtcGetNumSupportedArchs``.
678+
675679
Returns:
676680
int: sorted array of supported architectures.
677681
@@ -681,13 +685,19 @@ cpdef object get_supported_archs():
681685
with nogil:
682686
__status__ = nvrtcGetNumSupportedArchs(&numArchs)
683687
check_status(__status__)
688+
cdef _cyb_view.array supported_archs_alloc
689+
cdef int *supported_archs_ptr
684690
if numArchs == 0:
685-
return _cyb_view.array(shape=(1,), itemsize=sizeof(int), format="i", mode="c")[:0]
686-
cdef _cyb_view.array supported_archs = _cyb_view.array(shape=(numArchs,), itemsize=sizeof(int), format="i", mode="c")
687-
cdef int *supported_archs_ptr = <int *>(supported_archs.data)
688-
with nogil:
689-
__status__ = nvrtcGetSupportedArchs(supported_archs_ptr)
690-
check_status(__status__)
691+
supported_archs_alloc = _cyb_view.array(shape=(1,), itemsize=sizeof(int), format="i", mode="c")
692+
supported_archs = supported_archs_alloc[:0]
693+
else:
694+
supported_archs_alloc = _cyb_view.array(shape=(numArchs,), itemsize=sizeof(int), format="i", mode="c")
695+
supported_archs = supported_archs_alloc
696+
supported_archs_ptr = <int *>(supported_archs_alloc.data)
697+
if numArchs != 0:
698+
with nogil:
699+
__status__ = nvrtcGetSupportedArchs(supported_archs_ptr)
700+
check_status(__status__)
691701
return supported_archs
692702

693703

@@ -739,13 +749,12 @@ cpdef bytes get_ptx(intptr_t prog):
739749
with nogil:
740750
__status__ = nvrtcGetPTXSize(<Program>prog, &ptxSizeRet)
741751
check_status(__status__)
742-
if ptxSizeRet == 0:
743-
return b""
744752
cdef bytes _ptx_ = bytes(ptxSizeRet)
745753
cdef char* ptx = _ptx_
746-
with nogil:
747-
__status__ = nvrtcGetPTX(<Program>prog, ptx)
748-
check_status(__status__)
754+
if ptxSizeRet != 0:
755+
with nogil:
756+
__status__ = nvrtcGetPTX(<Program>prog, ptx)
757+
check_status(__status__)
749758
return _ptx_
750759

751760

@@ -782,13 +791,12 @@ cpdef bytes get_cubin(intptr_t prog):
782791
with nogil:
783792
__status__ = nvrtcGetCUBINSize(<Program>prog, &cubinSizeRet)
784793
check_status(__status__)
785-
if cubinSizeRet == 0:
786-
return b""
787794
cdef bytes _cubin_ = bytes(cubinSizeRet)
788795
cdef char* cubin = _cubin_
789-
with nogil:
790-
__status__ = nvrtcGetCUBIN(<Program>prog, cubin)
791-
check_status(__status__)
796+
if cubinSizeRet != 0:
797+
with nogil:
798+
__status__ = nvrtcGetCUBIN(<Program>prog, cubin)
799+
check_status(__status__)
792800
return _cubin_
793801

794802

@@ -825,13 +833,12 @@ cpdef bytes get_ltoir(intptr_t prog):
825833
with nogil:
826834
__status__ = nvrtcGetLTOIRSize(<Program>prog, &LTOIRSizeRet)
827835
check_status(__status__)
828-
if LTOIRSizeRet == 0:
829-
return b""
830836
cdef bytes _ltoir_ = bytes(LTOIRSizeRet)
831837
cdef char* ltoir = _ltoir_
832-
with nogil:
833-
__status__ = nvrtcGetLTOIR(<Program>prog, ltoir)
834-
check_status(__status__)
838+
if LTOIRSizeRet != 0:
839+
with nogil:
840+
__status__ = nvrtcGetLTOIR(<Program>prog, ltoir)
841+
check_status(__status__)
835842
return _ltoir_
836843

837844

@@ -868,19 +875,21 @@ cpdef bytes get_optix_ir(intptr_t prog):
868875
with nogil:
869876
__status__ = nvrtcGetOptiXIRSize(<Program>prog, &optixirSizeRet)
870877
check_status(__status__)
871-
if optixirSizeRet == 0:
872-
return b""
873878
cdef bytes _optixir_ = bytes(optixirSizeRet)
874879
cdef char* optixir = _optixir_
875-
with nogil:
876-
__status__ = nvrtcGetOptiXIR(<Program>prog, optixir)
877-
check_status(__status__)
880+
if optixirSizeRet != 0:
881+
with nogil:
882+
__status__ = nvrtcGetOptiXIR(<Program>prog, optixir)
883+
check_status(__status__)
878884
return _optixir_
879885

880886

881887
cpdef size_t get_program_log_size(intptr_t prog) except? 0:
882888
"""nvrtcGetProgramLogSize sets ``log_size_ret`` with the size of the log generated by the previous compilation of ``prog`` (including the trailing ``NULL``).
883889
890+
Note that compilation log may be generated with warnings and informative
891+
messages, even when the compilation of ``prog`` succeeds.
892+
884893
Args:
885894
prog (intptr_t): CUDA Runtime Compilation program.
886895
@@ -912,19 +921,21 @@ cpdef bytes get_program_log(intptr_t prog):
912921
with nogil:
913922
__status__ = nvrtcGetProgramLogSize(<Program>prog, &logSizeRet)
914923
check_status(__status__)
915-
if logSizeRet == 0:
916-
return b""
917924
cdef bytes _log_ = bytes(logSizeRet)
918925
cdef char* log = _log_
919-
with nogil:
920-
__status__ = nvrtcGetProgramLog(<Program>prog, log)
921-
check_status(__status__)
926+
if logSizeRet != 0:
927+
with nogil:
928+
__status__ = nvrtcGetProgramLog(<Program>prog, log)
929+
check_status(__status__)
922930
return _log_
923931

924932

925933
cpdef add_name_expression(intptr_t prog, name_expression):
926934
"""nvrtcAddNameExpression notes the given name expression denoting the address of a global function or device/__constant__ variable.
927935
936+
The identical name expression string must be provided on a subsequent call
937+
to nvrtcGetLoweredName to extract the lowered name.
938+
928939
Args:
929940
prog (intptr_t): CUDA Runtime Compilation program.
930941
name_expression (str): constant expression denoting the
@@ -961,6 +972,10 @@ cpdef size_t get_pch_heap_size() except? 0:
961972
cpdef set_pch_heap_size(size_t size):
962973
"""set the size of the PCH Heap.
963974
975+
The requested size may be rounded up to a platform dependent alignment
976+
(e.g. page size). If the PCH Heap has already been allocated, the heap
977+
memory will be freed and a new PCH Heap will be allocated.
978+
964979
Args:
965980
size (size_t): requested size of the PCH Heap, in bytes.
966981
@@ -974,6 +989,20 @@ cpdef set_pch_heap_size(size_t size):
974989
cpdef int get_pch_create_status(intptr_t prog) except? -1:
975990
"""returns the PCH creation status.
976991
992+
NVRTC_SUCCESS indicates that the PCH was successfully created.
993+
NVRTC_ERROR_NO_PCH_CREATE_ATTEMPTED indicates that no PCH creation was
994+
attempted, either because PCH functionality was not requested during the
995+
preceding nvrtcCompileProgram call, or automatic PCH processing was
996+
requested, and compiler chose not to create a PCH file.
997+
NVRTC_ERROR_PCH_CREATE_HEAP_EXHAUSTED indicates that a PCH file could
998+
potentially have been created, but the compiler ran out space in the PCH
999+
heap. In this scenario, the :func:`get_pch_heap_size_required` can be used
1000+
to query the required heap size, the heap can be reallocated for this size
1001+
with :func:`set_pch_heap_size` and PCH creation may be reattempted again
1002+
invoking :func:`compile_program` with a new NVRTC program instance.
1003+
NVRTC_ERROR_PCH_CREATE indicates that an error condition prevented the PCH
1004+
file from being created.
1005+
9771006
Args:
9781007
prog (intptr_t): CUDA Runtime Compilation program.
9791008
@@ -1037,13 +1066,12 @@ cpdef bytes get_tile_ir(intptr_t prog):
10371066
with nogil:
10381067
__status__ = nvrtcGetTileIRSize(<Program>prog, &TileIRSizeRet)
10391068
check_status(__status__)
1040-
if TileIRSizeRet == 0:
1041-
return b""
10421069
cdef bytes _tile_ir_ = bytes(TileIRSizeRet)
10431070
cdef char* tile_ir = _tile_ir_
1044-
with nogil:
1045-
__status__ = nvrtcGetTileIR(<Program>prog, tile_ir)
1046-
check_status(__status__)
1071+
if TileIRSizeRet != 0:
1072+
with nogil:
1073+
__status__ = nvrtcGetTileIR(<Program>prog, tile_ir)
1074+
check_status(__status__)
10471075
return _tile_ir_
10481076

10491077

‎cuda_bindings/cuda/bindings/nvml.pxd‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# This code was automatically generated across versions from 12.9.1 to 13.3.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=b6fe9a4efd0077f8c09ef4f826880ad0a54100455d4465953c4127d3de8c4d91
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=c45bc4c9772d2e6fe0163353f54a44655db866a025cc1adab756e44df3b39731
77

88

99

@@ -62,7 +62,6 @@ ctypedef nvmlUnrepairableMemoryStatus_v1_t UnrepairableMemoryStatus_v1
6262
ctypedef nvmlRusdSettings_v1_t RusdSettings_v1
6363
ctypedef nvmlPowerValue_v2_t PowerValue_v2
6464
ctypedef nvmlVgpuTypeMaxInstance_v1_t VgpuTypeMaxInstance_v1
65-
ctypedef nvmlVgpuProcessUtilizationSample_t VgpuProcessUtilizationSample
6665
ctypedef nvmlGpuFabricInfo_t GpuFabricInfo
6766
ctypedef nvmlSystemEventSetCreateRequest_v1_t SystemEventSetCreateRequest_v1
6867
ctypedef nvmlSystemEventSetFreeRequest_v1_t SystemEventSetFreeRequest_v1
@@ -163,13 +162,15 @@ cpdef int system_get_cuda_driver_version() except *
163162
cpdef int system_get_cuda_driver_version_v2() except 0
164163
cpdef str system_get_process_name(unsigned int pid)
165164
cpdef object system_get_hic_version()
165+
cpdef object system_get_topology_gpu_set(unsigned int cpu_number)
166166
cpdef unsigned int unit_get_count() except? 0
167167
cpdef intptr_t unit_get_handle_by_index(unsigned int index) except? 0
168168
cpdef object unit_get_unit_info(intptr_t unit)
169169
cpdef object unit_get_led_state(intptr_t unit)
170170
cpdef object unit_get_psu_info(intptr_t unit)
171171
cpdef unsigned int unit_get_temperature(intptr_t unit, unsigned int type) except? 0
172172
cpdef object unit_get_fan_speed_info(intptr_t unit)
173+
cpdef object unit_get_devices(intptr_t unit)
173174
cpdef unsigned int device_get_count_v2() except? 0
174175
cpdef object device_get_attributes_v2(intptr_t device)
175176
cpdef intptr_t device_get_handle_by_index_v2(unsigned int index) except? 0
@@ -189,6 +190,7 @@ cpdef device_set_cpu_affinity(intptr_t device)
189190
cpdef device_clear_cpu_affinity(intptr_t device)
190191
cpdef unsigned int device_get_numa_node_id(intptr_t device) except? 0
191192
cpdef int device_get_topology_common_ancestor(intptr_t device1, intptr_t device2) except? -1
193+
cpdef object device_get_topology_nearest_gpus(intptr_t device, int level)
192194
cpdef int device_get_p2p_status(intptr_t device1, intptr_t device2, int p2p_index) except? -1
193195
cpdef str device_get_uuid(intptr_t device)
194196
cpdef unsigned int device_get_minor_number(intptr_t device) except? 0
@@ -271,6 +273,7 @@ cpdef object device_get_graphics_running_processes_v3(intptr_t device)
271273
cpdef object device_get_mps_compute_running_processes_v3(intptr_t device)
272274
cpdef int device_on_same_board(intptr_t device1, intptr_t device2) except? 0
273275
cpdef int device_get_api_restriction(intptr_t device, int api_type) except? -1
276+
cpdef tuple device_get_samples(intptr_t device, int type, unsigned long long last_seen_time_stamp)
274277
cpdef object device_get_bar1_memory_info(intptr_t device)
275278
cpdef unsigned int device_get_irq_num(intptr_t device) except? 0
276279
cpdef unsigned int device_get_num_gpu_cores(intptr_t device) except? 0
@@ -297,6 +300,7 @@ cpdef object device_get_accounting_stats(intptr_t device, unsigned int pid)
297300
cpdef object device_get_accounting_pids(intptr_t device)
298301
cpdef unsigned int device_get_accounting_buffer_size(intptr_t device) except? 0
299302
cpdef object device_get_retired_pages(intptr_t device, int cause)
303+
cpdef tuple device_get_retired_pages_v2(intptr_t device, int cause)
300304
cpdef int device_get_retired_pages_pending_status(intptr_t device) except? -1
301305
cpdef tuple device_get_remapped_rows(intptr_t device)
302306
cpdef object device_get_row_remapper_histogram(intptr_t device)
@@ -352,6 +356,8 @@ cpdef device_set_vgpu_capabilities(intptr_t device, int capability, int state)
352356
cpdef object device_get_grid_licensable_features_v4(intptr_t device)
353357
cpdef unsigned int get_vgpu_driver_capabilities(int capability) except? 0
354358
cpdef unsigned int device_get_vgpu_capabilities(intptr_t device, int capability) except? 0
359+
cpdef object device_get_supported_vgpus(intptr_t device)
360+
cpdef object device_get_creatable_vgpus(intptr_t device)
355361
cpdef str vgpu_type_get_class(unsigned int vgpu_type_id)
356362
cpdef unsigned int vgpu_type_get_gpu_instance_profile_id(unsigned int vgpu_type_id) except? 0
357363
cpdef tuple vgpu_type_get_device_id(unsigned int vgpu_type_id)
@@ -363,6 +369,8 @@ cpdef unsigned int vgpu_type_get_frame_rate_limit(unsigned int vgpu_type_id) exc
363369
cpdef unsigned int vgpu_type_get_max_instances(intptr_t device, unsigned int vgpu_type_id) except? 0
364370
cpdef unsigned int vgpu_type_get_max_instances_per_vm(unsigned int vgpu_type_id) except? 0
365371
cpdef object vgpu_type_get_bar1_info(unsigned int vgpu_type_id)
372+
cpdef object device_get_active_vgpus(intptr_t device)
373+
cpdef tuple vgpu_instance_get_vm_id(unsigned int vgpu_instance)
366374
cpdef str vgpu_instance_get_uuid(unsigned int vgpu_instance)
367375
cpdef str vgpu_instance_get_vm_driver_version(unsigned int vgpu_instance)
368376
cpdef unsigned long long vgpu_instance_get_fb_usage(unsigned int vgpu_instance) except? 0
@@ -388,8 +396,10 @@ cpdef object device_get_vgpu_scheduler_log(intptr_t device)
388396
cpdef object device_get_vgpu_scheduler_state(intptr_t device)
389397
cpdef object device_get_vgpu_scheduler_capabilities(intptr_t device)
390398
cpdef device_set_vgpu_scheduler_state(intptr_t device, intptr_t p_scheduler_state)
399+
cpdef tuple get_vgpu_version()
391400
cpdef set_vgpu_version(intptr_t vgpu_version)
392-
cpdef tuple device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp)
401+
cpdef tuple device_get_vgpu_utilization(intptr_t device, unsigned long long last_seen_time_stamp)
402+
cpdef object device_get_vgpu_process_utilization(intptr_t device, unsigned long long last_seen_time_stamp)
393403
cpdef int vgpu_instance_get_accounting_mode(unsigned int vgpu_instance) except? -1
394404
cpdef object vgpu_instance_get_accounting_pids(unsigned int vgpu_instance)
395405
cpdef object vgpu_instance_get_accounting_stats(unsigned int vgpu_instance, unsigned int pid)
@@ -404,6 +414,7 @@ cpdef unsigned int device_get_gpu_instance_remaining_capacity(intptr_t device, u
404414
cpdef intptr_t device_create_gpu_instance(intptr_t device, unsigned int profile_id) except? 0
405415
cpdef intptr_t device_create_gpu_instance_with_placement(intptr_t device, unsigned int profile_id, intptr_t placement) except? 0
406416
cpdef gpu_instance_destroy(intptr_t gpu_instance)
417+
cpdef object device_get_gpu_instances(intptr_t device, unsigned int profile_id)
407418
cpdef intptr_t device_get_gpu_instance_by_id(intptr_t device, unsigned int id) except? 0
408419
cpdef object gpu_instance_get_info(intptr_t gpu_instance)
409420
cpdef object gpu_instance_get_compute_instance_profile_info_v(intptr_t gpu_instance, unsigned int profile, unsigned int eng_profile)
@@ -412,6 +423,7 @@ cpdef object gpu_instance_get_compute_instance_possible_placements(intptr_t gpu_
412423
cpdef intptr_t gpu_instance_create_compute_instance(intptr_t gpu_instance, unsigned int profile_id) except? 0
413424
cpdef intptr_t gpu_instance_create_compute_instance_with_placement(intptr_t gpu_instance, unsigned int profile_id, intptr_t placement) except? 0
414425
cpdef compute_instance_destroy(intptr_t compute_instance)
426+
cpdef object gpu_instance_get_compute_instances(intptr_t gpu_instance, unsigned int profile_id)
415427
cpdef intptr_t gpu_instance_get_compute_instance_by_id(intptr_t gpu_instance, unsigned int id) except? 0
416428
cpdef object compute_instance_get_info_v2(intptr_t compute_instance)
417429
cpdef unsigned int device_is_mig_device_handle(intptr_t device) except? 0

0 commit comments

Comments
 (0)