Skip to content

Commit b462136

Browse files
Andy-Jostclaude
andauthored
test(cuda.core): gate the NVRTC option tests on the cuda-bindings version (NVIDIA#3335)
test_cpp_program_with_various_options checks that cuda.core encodes each ProgramOptions field as a flag that NVRTC accepts. An older NVRTC rejects flags that it predates, so the test failed with NVRTC 12.6 or 12.8 for no_cache, frandom_seed, and ofast_compile, which first appear in 12.9. Run the test only when the NVRTC major.minor is at least the cuda-bindings major.minor. The gate moves with cuda-bindings releases and needs no per-option version table. It makes the per-option PCH gates (12.8) redundant, so remove them. Closes NVIDIA#3333. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e6c23d4 commit b462136

1 file changed

Lines changed: 17 additions & 28 deletions

File tree

‎cuda_core/tests/test_program.py‎

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from cuda.core._module import Kernel, ObjectCode
2020
from cuda.core._program import Program, ProgramOptions
2121
from cuda.core._utils.cuda_utils import CUDAError, handle_return, nvrtc
22+
from cuda.core._utils.version import binding_version
2223
from cuda.core.typing import CompilerBackendType, PCHStatusType
2324
from cuda.pathfinder import DynamicLibNotFoundError
2425

@@ -68,6 +69,17 @@ def _get_nvrtc_version_for_tests():
6869
reason="use_bundled_headers requires NVRTC >= 13.3",
6970
)
7071

72+
# The option tests check that cuda.core encodes each ProgramOptions field as a
73+
# flag that NVRTC accepts. One pass on a current NVRTC proves the encoding, and
74+
# an older NVRTC rejects flags that it predates. Run them only when NVRTC is at
75+
# least the CUDA version of the installed cuda-bindings, so that the gate moves
76+
# with cuda-bindings releases and needs no per-option version table.
77+
_bindings_major, _bindings_minor, _ = binding_version()
78+
nvrtc_at_bindings_version = pytest.mark.skipif(
79+
(_get_nvrtc_version_for_tests() or 0) < _bindings_major * 1000 + _bindings_minor * 100,
80+
reason=f"NVRTC option tests require NVRTC >= {_bindings_major}.{_bindings_minor} (the cuda-bindings version)",
81+
)
82+
7183

7284
def _has_check_nvvm_compiler_options():
7385
try:
@@ -211,13 +223,7 @@ def ptx_code_object():
211223
),
212224
ProgramOptions(frandom_seed="12345"),
213225
ProgramOptions(ofast_compile="min"),
214-
pytest.param(
215-
ProgramOptions(pch=True),
216-
marks=pytest.mark.skipif(
217-
(_get_nvrtc_version_for_tests() or 0) < 12800,
218-
reason="PCH requires NVRTC >= 12.8",
219-
),
220-
),
226+
ProgramOptions(pch=True),
221227
# TODO: pch_dir requires actual PCH directory to exist - needs integration test
222228
# pytest.param(
223229
# ProgramOptions(pch_dir="/tmp/pch"),
@@ -226,29 +232,12 @@ def ptx_code_object():
226232
# reason="PCH requires NVRTC >= 12.8",
227233
# ),
228234
# ),
229-
pytest.param(
230-
ProgramOptions(pch_verbose=True),
231-
marks=pytest.mark.skipif(
232-
(_get_nvrtc_version_for_tests() or 0) < 12800,
233-
reason="PCH requires NVRTC >= 12.8",
234-
),
235-
),
236-
pytest.param(
237-
ProgramOptions(pch_messages=False),
238-
marks=pytest.mark.skipif(
239-
(_get_nvrtc_version_for_tests() or 0) < 12800,
240-
reason="PCH requires NVRTC >= 12.8",
241-
),
242-
),
243-
pytest.param(
244-
ProgramOptions(instantiate_templates_in_pch=True),
245-
marks=pytest.mark.skipif(
246-
(_get_nvrtc_version_for_tests() or 0) < 12800,
247-
reason="PCH requires NVRTC >= 12.8",
248-
),
249-
),
235+
ProgramOptions(pch_verbose=True),
236+
ProgramOptions(pch_messages=False),
237+
ProgramOptions(instantiate_templates_in_pch=True),
250238
],
251239
)
240+
@nvrtc_at_bindings_version
252241
def test_cpp_program_with_various_options(init_cuda, options):
253242
code = 'extern "C" __global__ void my_kernel() {}'
254243
program = Program(code, "c++", options)

0 commit comments

Comments
 (0)