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
10 changes: 8 additions & 2 deletions cuda_core/tests/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
#
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

import re
import warnings

import pytest
from cuda.core.experimental import _linker
from cuda.core.experimental._module import Kernel, ObjectCode
from cuda.core.experimental._program import Program, ProgramOptions
from cuda.core.experimental._utils.cuda_utils import driver, handle_return
from cuda.core.experimental._utils.cuda_utils import CUDAError, driver, handle_return

cuda_driver_version = handle_return(driver.cuDriverGetVersion())
is_culink_backend = _linker._decide_nvjitlink_or_driver()
Expand Down Expand Up @@ -317,7 +318,12 @@ def test_nvvm_program_creation_compilation(nvvm_ir):
assert program.backend == "NVVM"
assert program.handle is not None
obj = program.compile("ptx")
ker = obj.get_kernel("simple") # noqa: F841
try:
ker = obj.get_kernel("simple") # noqa: F841
except CUDAError as e:
if re.search(r"CUDA_UNSUPPORTED_PTX_VERSION", str(e)):
pytest.xfail("PTX version not supported by current CUDA Driver")
raise

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: Shouldn't this be

Suggested change
raise
else:
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The else isn't needed: pytest.xfail exits the test right at the call site.

But the else doesn't do harm either.

I tend to fully rely on the pytest behavior, i.e. not add redundant flow control, for more compact code.

program.close()


Expand Down
Loading