Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle CTK version specific options in the linker test #371

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eba7d22
add exception manager to handle options which aren't covered in all c…
ksimpson-work Jan 10, 2025
4b9b81a
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 10, 2025
d473c24
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 14, 2025
6e5114e
Update cuda_core/tests/test_linker.py
ksimpson-work Jan 15, 2025
66b03fc
address comments
ksimpson-work Jan 15, 2025
36a7eab
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 15, 2025
1e9a8e8
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 15, 2025
3a25e41
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 16, 2025
0e34720
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 16, 2025
0466528
Merge remote-tracking branch 'upstream/main' into handle-version-spec…
ksimpson-work Jan 17, 2025
45eeb33
Merge remote-tracking branch 'origin/handle-version-specific-options'…
ksimpson-work Jan 17, 2025
df897e8
switch to hardcode
ksimpson-work Jan 17, 2025
02b52d5
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 20, 2025
4c7ae33
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 21, 2025
1986452
Merge remote-tracking branch 'upstream/main' into handle-version-spec…
ksimpson-work Jan 21, 2025
94af829
construct the options class within if else logic
ksimpson-work Jan 21, 2025
3c932d6
Merge remote-tracking branch 'origin/handle-version-specific-options'…
ksimpson-work Jan 21, 2025
5586587
fix mistake
ksimpson-work Jan 23, 2025
b3e254d
fix mistake
ksimpson-work Jan 23, 2025
fc682d9
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 27, 2025
38801fe
minor tweak
ksimpson-work Jan 28, 2025
252e5f0
Merge branch 'main' into handle-version-specific-options
ksimpson-work Jan 30, 2025
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
21 changes: 20 additions & 1 deletion cuda_core/tests/test_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE

from contextlib import contextmanager

Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete the extra empty line again?

import pytest

from cuda.core.experimental import Linker, LinkerOptions, Program, _linker
Expand All @@ -18,6 +20,8 @@
device_function_c = "__device__ int C(int a, int b) { return a + b; }"

culink_backend = _linker._decide_nvjitlink_or_driver()
if not culink_backend:
from cuda.bindings import nvjitlink


@pytest.fixture(scope="function")
Expand All @@ -40,6 +44,19 @@ def compile_ltoir_functions(init_cuda):
return object_code_a_ltoir, object_code_b_ltoir, object_code_c_ltoir


@contextmanager
def skip_version_specific_linker_options():
if culink_backend:
return
ksimpson-work marked this conversation as resolved.
Show resolved Hide resolved
try:
yield
except nvjitlink.nvJitLinkError as e:
if e.status == nvjitlink.Result.ERROR_UNRECOGNIZED_OPTION:
pytest.skip("current nvjitlink version does not support the option provided")
ksimpson-work marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
raise e
ksimpson-work marked this conversation as resolved.
Show resolved Hide resolved


culink_options = [
LinkerOptions(arch=ARCH, verbose=True),
LinkerOptions(arch=ARCH, max_register_count=32),
Expand Down Expand Up @@ -72,7 +89,9 @@ def compile_ltoir_functions(init_cuda):
],
)
def test_linker_init(compile_ptx_functions, options):
linker = Linker(*compile_ptx_functions, options=options)
with skip_version_specific_linker_options():
linker = Linker(*compile_ptx_functions, options=options)

object_code = linker.link("cubin")
assert isinstance(object_code, ObjectCode)

Expand Down
Loading