Skip to content

Commit e04118b

Browse files
committed
Fix type of constants to prevent overflow
1 parent 6a2d754 commit e04118b

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

‎cuda_bindings_13/cuda/bindings/cydriver.pxd‎

Lines changed: 2 additions & 2 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.5.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=2927ba6081022d5e0e3bd10ebda9ac8b3deacb27af81ab343ae4e86b67ff9b17
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=7048bf2a5eceb5c31e99d2264b739f2234592cb6b05443fdd32f10e868592504
77

88

99
# <<<< PREAMBLE CONTENT >>>>
@@ -4011,4 +4011,4 @@ cdef enum: RESOURCE_ABI_VERSION = 1
40114011

40124012
cdef enum: RESOURCE_ABI_EXTERNAL_BYTES = 42
40134013

4014-
cdef enum: CU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID_ANY = 4294967295
4014+
cdef const uint32_t CU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID_ANY = 0xffffffff

‎cuda_bindings_13/cuda/bindings/cyruntime.pxd‎

Lines changed: 2 additions & 5 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.5.0. Do not modify it directly.
6-
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=946dfd0c4e22f5055de2b2d7fc4fab6a870125c70e398ae9ae88a99e4a47e148
6+
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=299362274ed3a011e1c567ea13e77ef2ac175a1214f973afd972d178340efa2d
77

88

99
# <<<< PREAMBLE CONTENT >>>>
@@ -2733,10 +2733,7 @@ cdef extern from 'cuda_runtime_api.h':
27332733
cdef enum:
27342734
CUDA_EGL_MAX_PLANES = 3
27352735

2736-
# cudaDevSmResourceGroupLocalityDomainIdAny is defined as (~0u) in driver_types.h; the
2737-
# pyclibrary-based cython-gen parser can't evaluate that expression, so hardcode the value
2738-
cdef enum:
2739-
cudaDevSmResourceGroupLocalityDomainIdAny = 4294967295
2736+
cdef const uint32_t cudaDevSmResourceGroupLocalityDomainIdAny = 0xffffffff
27402737

27412738
# libraryPropertyType_t (starts lowercase, outside type pattern)
27422739
cdef extern from 'library_types.h':

‎cuda_bindings_13/tests/test_cudart.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,3 +2092,27 @@ def test_ffi_phase2_new_yuv_channel_kinds_descriptor_construction():
20922092
desc.x, desc.y, desc.z, desc.w, desc.f = bits, bits, bits, w_bit, kind
20932093
assert desc.f == kind
20942094
assert desc.x == bits
2095+
2096+
2097+
@pytest.mark.agent_authored(model="claude-sonnet-5-5")
2098+
@pytest.mark.parametrize(
2099+
("module", "class_name", "constant_name"),
2100+
[
2101+
(cuda, "CU_DEV_SM_RESOURCE_GROUP_PARAMS", "CU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID_ANY"),
2102+
(cudart, "cudaDevSmResourceGroupParams", "cudaDevSmResourceGroupLocalityDomainIdAny"),
2103+
],
2104+
)
2105+
def test_locality_domain_id_any_sentinel(module, class_name, constant_name):
2106+
# The names only exist in bindings generated from a CUDA release that has them.
2107+
if not hasattr(module, class_name) or not hasattr(module, constant_name):
2108+
pytest.skip(f"{module.__name__} has no {class_name} / {constant_name}")
2109+
sentinel = getattr(module, constant_name)
2110+
assert int(sentinel) == 0xFFFFFFFF
2111+
2112+
# The field must accept the constant that the bindings export for it, and
2113+
# the unsigned maximum itself.
2114+
params = getattr(module, class_name)()
2115+
params.localityDomainId = sentinel
2116+
assert params.localityDomainId == 0xFFFFFFFF
2117+
params.localityDomainId = 0xFFFFFFFF
2118+
assert params.localityDomainId == 0xFFFFFFFF

0 commit comments

Comments
 (0)