Skip to content

Commit f66c340

Browse files
committed
Fix #1644: Faster conversion of sequence of enum to vector
1 parent 020c48e commit f66c340

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

cuda_bindings/cuda/bindings/driver.pyx.in

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

4-
# This code was automatically generated with version 13.1.0, generator version fd3f910. Do not modify it directly.
4+
# This code was automatically generated with version 13.1.0, generator version c185cc3. Do not modify it directly.
55
from typing import Any, Optional
66
import cython
77
import ctypes
@@ -26111,7 +26111,7 @@ def cuDeviceGetHostAtomicCapabilities(operations : Optional[tuple[CUatomicOperat
2611126111
cycapabilities = <unsigned int*>calloc(count, sizeof(unsigned int))
2611226112
if cycapabilities is NULL:
2611326113
raise MemoryError('Failed to allocate length x size memory: ' + str(count) + 'x' + str(sizeof(unsigned int)))
26114-
cdef vector[cydriver.CUatomicOperation] cyoperations = [int(pyoperations) for pyoperations in (operations)]
26114+
cdef vector[cydriver.CUatomicOperation] cyoperations = operations
2611526115
if count > len(operations): raise RuntimeError("List is too small: " + str(len(operations)) + " < " + str(count))
2611626116
with nogil:
2611726117
err = cydriver.cuDeviceGetHostAtomicCapabilities(cycapabilities, cyoperations.data(), count, cydev)
@@ -28374,7 +28374,7 @@ def cuModuleLoadDataEx(image, unsigned int numOptions, options : Optional[tuple[
2837428374
cdef void* cyimage = _helper_input_void_ptr(image, &cyimageHelper)
2837528375
if numOptions > len(options): raise RuntimeError("List is too small: " + str(len(options)) + " < " + str(numOptions))
2837628376
if numOptions > len(optionValues): raise RuntimeError("List is too small: " + str(len(optionValues)) + " < " + str(numOptions))
28377-
cdef vector[cydriver.CUjit_option] cyoptions = [int(pyoptions) for pyoptions in (options)]
28377+
cdef vector[cydriver.CUjit_option] cyoptions = options
2837828378
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(options, optionValues)]
2837928379
cdef _InputVoidPtrPtrHelper voidStarHelperoptionValues = _InputVoidPtrPtrHelper(pylist)
2838028380
cdef void** cyoptionValues_ptr = <void**><void_ptr>voidStarHelperoptionValues.cptr
@@ -28744,7 +28744,7 @@ def cuLinkCreate(unsigned int numOptions, options : Optional[tuple[CUjit_option]
2874428744
raise TypeError("Argument 'options' is not instance of type (expected tuple[cydriver.CUjit_option] or list[cydriver.CUjit_option]")
2874528745
if numOptions > len(options): raise RuntimeError("List is too small: " + str(len(options)) + " < " + str(numOptions))
2874628746
if numOptions > len(optionValues): raise RuntimeError("List is too small: " + str(len(optionValues)) + " < " + str(numOptions))
28747-
cdef vector[cydriver.CUjit_option] cyoptions = [int(pyoptions) for pyoptions in (options)]
28747+
cdef vector[cydriver.CUjit_option] cyoptions = options
2874828748
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(options, optionValues)]
2874928749
cdef _InputVoidPtrPtrHelper voidStarHelperoptionValues = _InputVoidPtrPtrHelper(pylist)
2875028750
cdef void** cyoptionValues_ptr = <void**><void_ptr>voidStarHelperoptionValues.cptr
@@ -28824,7 +28824,7 @@ def cuLinkAddData(state, typename not None : CUjitInputType, data, size_t size,
2882428824
cdef void* cydata = _helper_input_void_ptr(data, &cydataHelper)
2882528825
if numOptions > len(options): raise RuntimeError("List is too small: " + str(len(options)) + " < " + str(numOptions))
2882628826
if numOptions > len(optionValues): raise RuntimeError("List is too small: " + str(len(optionValues)) + " < " + str(numOptions))
28827-
cdef vector[cydriver.CUjit_option] cyoptions = [int(pyoptions) for pyoptions in (options)]
28827+
cdef vector[cydriver.CUjit_option] cyoptions = options
2882828828
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(options, optionValues)]
2882928829
cdef _InputVoidPtrPtrHelper voidStarHelperoptionValues = _InputVoidPtrPtrHelper(pylist)
2883028830
cdef void** cyoptionValues_ptr = <void**><void_ptr>voidStarHelperoptionValues.cptr
@@ -28895,7 +28895,7 @@ def cuLinkAddFile(state, typename not None : CUjitInputType, char* path, unsigne
2889528895
cdef cydriver.CUjitInputType cytypename = int(typename)
2889628896
if numOptions > len(options): raise RuntimeError("List is too small: " + str(len(options)) + " < " + str(numOptions))
2889728897
if numOptions > len(optionValues): raise RuntimeError("List is too small: " + str(len(optionValues)) + " < " + str(numOptions))
28898-
cdef vector[cydriver.CUjit_option] cyoptions = [int(pyoptions) for pyoptions in (options)]
28898+
cdef vector[cydriver.CUjit_option] cyoptions = options
2889928899
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(options, optionValues)]
2890028900
cdef _InputVoidPtrPtrHelper voidStarHelperoptionValues = _InputVoidPtrPtrHelper(pylist)
2890128901
cdef void** cyoptionValues_ptr = <void**><void_ptr>voidStarHelperoptionValues.cptr
@@ -29160,13 +29160,13 @@ def cuLibraryLoadData(code, jitOptions : Optional[tuple[CUjit_option] | list[CUj
2916029160
cdef CUlibrary library = CUlibrary()
2916129161
cdef _HelperInputVoidPtrStruct cycodeHelper
2916229162
cdef void* cycode = _helper_input_void_ptr(code, &cycodeHelper)
29163-
cdef vector[cydriver.CUjit_option] cyjitOptions = [int(pyjitOptions) for pyjitOptions in (jitOptions)]
29163+
cdef vector[cydriver.CUjit_option] cyjitOptions = jitOptions
2916429164
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(jitOptions, jitOptionsValues)]
2916529165
cdef _InputVoidPtrPtrHelper voidStarHelperjitOptionsValues = _InputVoidPtrPtrHelper(pylist)
2916629166
cdef void** cyjitOptionsValues_ptr = <void**><void_ptr>voidStarHelperjitOptionsValues.cptr
2916729167
if numJitOptions > len(jitOptions): raise RuntimeError("List is too small: " + str(len(jitOptions)) + " < " + str(numJitOptions))
2916829168
if numJitOptions > len(jitOptionsValues): raise RuntimeError("List is too small: " + str(len(jitOptionsValues)) + " < " + str(numJitOptions))
29169-
cdef vector[cydriver.CUlibraryOption] cylibraryOptions = [int(pylibraryOptions) for pylibraryOptions in (libraryOptions)]
29169+
cdef vector[cydriver.CUlibraryOption] cylibraryOptions = libraryOptions
2917029170
pylist = [_HelperCUlibraryOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(libraryOptions, libraryOptionValues)]
2917129171
cdef _InputVoidPtrPtrHelper voidStarHelperlibraryOptionValues = _InputVoidPtrPtrHelper(pylist)
2917229172
cdef void** cylibraryOptionValues_ptr = <void**><void_ptr>voidStarHelperlibraryOptionValues.cptr
@@ -29258,13 +29258,13 @@ def cuLibraryLoadFromFile(char* fileName, jitOptions : Optional[tuple[CUjit_opti
2925829258
if not all(isinstance(_x, (CUjit_option)) for _x in jitOptions):
2925929259
raise TypeError("Argument 'jitOptions' is not instance of type (expected tuple[cydriver.CUjit_option] or list[cydriver.CUjit_option]")
2926029260
cdef CUlibrary library = CUlibrary()
29261-
cdef vector[cydriver.CUjit_option] cyjitOptions = [int(pyjitOptions) for pyjitOptions in (jitOptions)]
29261+
cdef vector[cydriver.CUjit_option] cyjitOptions = jitOptions
2926229262
pylist = [_HelperCUjit_option(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(jitOptions, jitOptionsValues)]
2926329263
cdef _InputVoidPtrPtrHelper voidStarHelperjitOptionsValues = _InputVoidPtrPtrHelper(pylist)
2926429264
cdef void** cyjitOptionsValues_ptr = <void**><void_ptr>voidStarHelperjitOptionsValues.cptr
2926529265
if numJitOptions > len(jitOptions): raise RuntimeError("List is too small: " + str(len(jitOptions)) + " < " + str(numJitOptions))
2926629266
if numJitOptions > len(jitOptionsValues): raise RuntimeError("List is too small: " + str(len(jitOptionsValues)) + " < " + str(numJitOptions))
29267-
cdef vector[cydriver.CUlibraryOption] cylibraryOptions = [int(pylibraryOptions) for pylibraryOptions in (libraryOptions)]
29267+
cdef vector[cydriver.CUlibraryOption] cylibraryOptions = libraryOptions
2926829268
pylist = [_HelperCUlibraryOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(libraryOptions, libraryOptionValues)]
2926929269
cdef _InputVoidPtrPtrHelper voidStarHelperlibraryOptionValues = _InputVoidPtrPtrHelper(pylist)
2927029270
cdef void** cylibraryOptionValues_ptr = <void**><void_ptr>voidStarHelperlibraryOptionValues.cptr
@@ -38566,7 +38566,7 @@ def cuMemRangeGetAttributes(dataSizes : tuple[int] | list[int], attributes : Opt
3856638566
cdef _InputVoidPtrPtrHelper voidStarHelperdata = _InputVoidPtrPtrHelper(pylist)
3856738567
cdef void** cyvoidStarHelper_ptr = <void**><void_ptr>voidStarHelperdata.cptr
3856838568
cdef vector[size_t] cydataSizes = dataSizes
38569-
cdef vector[cydriver.CUmem_range_attribute] cyattributes = [int(pyattributes) for pyattributes in (attributes)]
38569+
cdef vector[cydriver.CUmem_range_attribute] cyattributes = attributes
3857038570
if numAttributes > <size_t>len(dataSizes): raise RuntimeError("List is too small: " + str(len(dataSizes)) + " < " + str(numAttributes))
3857138571
if numAttributes > <size_t>len(attributes): raise RuntimeError("List is too small: " + str(len(attributes)) + " < " + str(numAttributes))
3857238572
with nogil:
@@ -38715,7 +38715,7 @@ def cuPointerGetAttributes(unsigned int numAttributes, attributes : Optional[tup
3871538715
if not all(isinstance(_x, (CUpointer_attribute)) for _x in attributes):
3871638716
raise TypeError("Argument 'attributes' is not instance of type (expected tuple[cydriver.CUpointer_attribute] or list[cydriver.CUpointer_attribute]")
3871738717
if numAttributes > len(attributes): raise RuntimeError("List is too small: " + str(len(attributes)) + " < " + str(numAttributes))
38718-
cdef vector[cydriver.CUpointer_attribute] cyattributes = [int(pyattributes) for pyattributes in (attributes)]
38718+
cdef vector[cydriver.CUpointer_attribute] cyattributes = attributes
3871938719
pylist = [_HelperCUpointer_attribute(pyattributes, 0, is_getter=True) for pyattributes in attributes]
3872038720
cdef _InputVoidPtrPtrHelper voidStarHelperdata = _InputVoidPtrPtrHelper(pylist)
3872138721
cdef void** cyvoidStarHelper_ptr = <void**><void_ptr>voidStarHelperdata.cptr
@@ -52586,7 +52586,7 @@ def cuDeviceGetP2PAtomicCapabilities(operations : Optional[tuple[CUatomicOperati
5258652586
cycapabilities = <unsigned int*>calloc(count, sizeof(unsigned int))
5258752587
if cycapabilities is NULL:
5258852588
raise MemoryError('Failed to allocate length x size memory: ' + str(count) + 'x' + str(sizeof(unsigned int)))
52589-
cdef vector[cydriver.CUatomicOperation] cyoperations = [int(pyoperations) for pyoperations in (operations)]
52589+
cdef vector[cydriver.CUatomicOperation] cyoperations = operations
5259052590
if count > len(operations): raise RuntimeError("List is too small: " + str(len(operations)) + " < " + str(count))
5259152591
with nogil:
5259252592
err = cydriver.cuDeviceGetP2PAtomicCapabilities(cycapabilities, cyoperations.data(), count, cysrcDevice, cydstDevice)

cuda_bindings/cuda/bindings/runtime.pyx.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33

4-
# This code was automatically generated with version 13.1.0, generator version fd3f910. Do not modify it directly.
4+
# This code was automatically generated with version 13.1.0, generator version c185cc3. Do not modify it directly.
55
from typing import Any, Optional
66
import cython
77
import ctypes
@@ -21878,7 +21878,7 @@ def cudaDeviceGetHostAtomicCapabilities(operations : Optional[tuple[cudaAtomicOp
2187821878
cycapabilities = <unsigned int*>calloc(count, sizeof(unsigned int))
2187921879
if cycapabilities is NULL:
2188021880
raise MemoryError('Failed to allocate length x size memory: ' + str(count) + 'x' + str(sizeof(unsigned int)))
21881-
cdef vector[cyruntime.cudaAtomicOperation] cyoperations = [int(pyoperations) for pyoperations in (operations)]
21881+
cdef vector[cyruntime.cudaAtomicOperation] cyoperations = operations
2188221882
if count > len(operations): raise RuntimeError("List is too small: " + str(len(operations)) + " < " + str(count))
2188321883
with nogil:
2188421884
err = cyruntime.cudaDeviceGetHostAtomicCapabilities(cycapabilities, cyoperations.data(), count, device)
@@ -22212,7 +22212,7 @@ def cudaDeviceGetP2PAtomicCapabilities(operations : Optional[tuple[cudaAtomicOpe
2221222212
cycapabilities = <unsigned int*>calloc(count, sizeof(unsigned int))
2221322213
if cycapabilities is NULL:
2221422214
raise MemoryError('Failed to allocate length x size memory: ' + str(count) + 'x' + str(sizeof(unsigned int)))
22215-
cdef vector[cyruntime.cudaAtomicOperation] cyoperations = [int(pyoperations) for pyoperations in (operations)]
22215+
cdef vector[cyruntime.cudaAtomicOperation] cyoperations = operations
2221622216
if count > len(operations): raise RuntimeError("List is too small: " + str(len(operations)) + " < " + str(count))
2221722217
with nogil:
2221822218
err = cyruntime.cudaDeviceGetP2PAtomicCapabilities(cycapabilities, cyoperations.data(), count, srcDevice, dstDevice)
@@ -29693,7 +29693,7 @@ def cudaMemRangeGetAttributes(dataSizes : tuple[int] | list[int], attributes : O
2969329693
cdef _InputVoidPtrPtrHelper voidStarHelperdata = _InputVoidPtrPtrHelper(pylist)
2969429694
cdef void** cyvoidStarHelper_ptr = <void**><void_ptr>voidStarHelperdata.cptr
2969529695
cdef vector[size_t] cydataSizes = dataSizes
29696-
cdef vector[cyruntime.cudaMemRangeAttribute] cyattributes = [int(pyattributes) for pyattributes in (attributes)]
29696+
cdef vector[cyruntime.cudaMemRangeAttribute] cyattributes = attributes
2969729697
if numAttributes > <size_t>len(dataSizes): raise RuntimeError("List is too small: " + str(len(dataSizes)) + " < " + str(numAttributes))
2969829698
if numAttributes > <size_t>len(attributes): raise RuntimeError("List is too small: " + str(len(attributes)) + " < " + str(numAttributes))
2969929699
cdef _HelperInputVoidPtrStruct cydevPtrHelper
@@ -38074,13 +38074,13 @@ def cudaLibraryLoadData(code, jitOptions : Optional[tuple[cudaJitOption] | list[
3807438074
cdef cudaLibrary_t library = cudaLibrary_t()
3807538075
cdef _HelperInputVoidPtrStruct cycodeHelper
3807638076
cdef void* cycode = _helper_input_void_ptr(code, &cycodeHelper)
38077-
cdef vector[cyruntime.cudaJitOption] cyjitOptions = [int(pyjitOptions) for pyjitOptions in (jitOptions)]
38077+
cdef vector[cyruntime.cudaJitOption] cyjitOptions = jitOptions
3807838078
pylist = [_HelperCudaJitOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(jitOptions, jitOptionsValues)]
3807938079
cdef _InputVoidPtrPtrHelper voidStarHelperjitOptionsValues = _InputVoidPtrPtrHelper(pylist)
3808038080
cdef void** cyjitOptionsValues_ptr = <void**><void_ptr>voidStarHelperjitOptionsValues.cptr
3808138081
if numJitOptions > len(jitOptions): raise RuntimeError("List is too small: " + str(len(jitOptions)) + " < " + str(numJitOptions))
3808238082
if numJitOptions > len(jitOptionsValues): raise RuntimeError("List is too small: " + str(len(jitOptionsValues)) + " < " + str(numJitOptions))
38083-
cdef vector[cyruntime.cudaLibraryOption] cylibraryOptions = [int(pylibraryOptions) for pylibraryOptions in (libraryOptions)]
38083+
cdef vector[cyruntime.cudaLibraryOption] cylibraryOptions = libraryOptions
3808438084
pylist = [_HelperCudaLibraryOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(libraryOptions, libraryOptionValues)]
3808538085
cdef _InputVoidPtrPtrHelper voidStarHelperlibraryOptionValues = _InputVoidPtrPtrHelper(pylist)
3808638086
cdef void** cylibraryOptionValues_ptr = <void**><void_ptr>voidStarHelperlibraryOptionValues.cptr
@@ -38173,13 +38173,13 @@ def cudaLibraryLoadFromFile(char* fileName, jitOptions : Optional[tuple[cudaJitO
3817338173
if not all(isinstance(_x, (cudaJitOption)) for _x in jitOptions):
3817438174
raise TypeError("Argument 'jitOptions' is not instance of type (expected tuple[cyruntime.cudaJitOption] or list[cyruntime.cudaJitOption]")
3817538175
cdef cudaLibrary_t library = cudaLibrary_t()
38176-
cdef vector[cyruntime.cudaJitOption] cyjitOptions = [int(pyjitOptions) for pyjitOptions in (jitOptions)]
38176+
cdef vector[cyruntime.cudaJitOption] cyjitOptions = jitOptions
3817738177
pylist = [_HelperCudaJitOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(jitOptions, jitOptionsValues)]
3817838178
cdef _InputVoidPtrPtrHelper voidStarHelperjitOptionsValues = _InputVoidPtrPtrHelper(pylist)
3817938179
cdef void** cyjitOptionsValues_ptr = <void**><void_ptr>voidStarHelperjitOptionsValues.cptr
3818038180
if numJitOptions > len(jitOptions): raise RuntimeError("List is too small: " + str(len(jitOptions)) + " < " + str(numJitOptions))
3818138181
if numJitOptions > len(jitOptionsValues): raise RuntimeError("List is too small: " + str(len(jitOptionsValues)) + " < " + str(numJitOptions))
38182-
cdef vector[cyruntime.cudaLibraryOption] cylibraryOptions = [int(pylibraryOptions) for pylibraryOptions in (libraryOptions)]
38182+
cdef vector[cyruntime.cudaLibraryOption] cylibraryOptions = libraryOptions
3818338183
pylist = [_HelperCudaLibraryOption(pyoptions, pyoptionValues) for pyoptions, pyoptionValues in zip(libraryOptions, libraryOptionValues)]
3818438184
cdef _InputVoidPtrPtrHelper voidStarHelperlibraryOptionValues = _InputVoidPtrPtrHelper(pylist)
3818538185
cdef void** cylibraryOptionValues_ptr = <void**><void_ptr>voidStarHelperlibraryOptionValues.cptr

0 commit comments

Comments
 (0)