Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 17 additions & 28 deletions cuda_core/tests/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from cuda.core._module import Kernel, ObjectCode
from cuda.core._program import Program, ProgramOptions
from cuda.core._utils.cuda_utils import CUDAError, handle_return, nvrtc
from cuda.core._utils.version import binding_version
from cuda.core.typing import CompilerBackendType, PCHStatusType
from cuda.pathfinder import DynamicLibNotFoundError

Expand Down Expand Up @@ -68,6 +69,17 @@ def _get_nvrtc_version_for_tests():
reason="use_bundled_headers requires NVRTC >= 13.3",
)

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


def _has_check_nvvm_compiler_options():
try:
Expand Down Expand Up @@ -211,13 +223,7 @@ def ptx_code_object():
),
ProgramOptions(frandom_seed="12345"),
ProgramOptions(ofast_compile="min"),
pytest.param(
ProgramOptions(pch=True),
marks=pytest.mark.skipif(
(_get_nvrtc_version_for_tests() or 0) < 12800,
reason="PCH requires NVRTC >= 12.8",
),
),
ProgramOptions(pch=True),
# TODO: pch_dir requires actual PCH directory to exist - needs integration test
# pytest.param(
# ProgramOptions(pch_dir="/tmp/pch"),
Expand All @@ -226,29 +232,12 @@ def ptx_code_object():
# reason="PCH requires NVRTC >= 12.8",
# ),
# ),
pytest.param(
ProgramOptions(pch_verbose=True),
marks=pytest.mark.skipif(
(_get_nvrtc_version_for_tests() or 0) < 12800,
reason="PCH requires NVRTC >= 12.8",
),
),
pytest.param(
ProgramOptions(pch_messages=False),
marks=pytest.mark.skipif(
(_get_nvrtc_version_for_tests() or 0) < 12800,
reason="PCH requires NVRTC >= 12.8",
),
),
pytest.param(
ProgramOptions(instantiate_templates_in_pch=True),
marks=pytest.mark.skipif(
(_get_nvrtc_version_for_tests() or 0) < 12800,
reason="PCH requires NVRTC >= 12.8",
),
),
ProgramOptions(pch_verbose=True),
ProgramOptions(pch_messages=False),
ProgramOptions(instantiate_templates_in_pch=True),
],
)
@nvrtc_at_bindings_version

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

important: Gate only unsupported option cases.

With cuda-bindings 13.4 and NVRTC 13.3, this skips every parameter, including ftz, which NVRTC 13.3 supports. (docs.nvidia.com) This removes option coverage from supported mixed-version environments. Apply version gates to the affected parameters instead.

As per path instructions: “skip only for genuine setup or feature-unavailable conditions.”

Source: Path instructions

def test_cpp_program_with_various_options(init_cuda, options):
code = 'extern "C" __global__ void my_kernel() {}'
program = Program(code, "c++", options)
Expand Down
Loading