2
2
#
3
3
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
4
4
5
+ from contextlib import contextmanager
6
+
5
7
import pytest
6
8
7
9
from cuda .core .experimental import Linker , LinkerOptions , Program , _linker
18
20
device_function_c = "__device__ int C(int a, int b) { return a + b; }"
19
21
20
22
culink_backend = _linker ._decide_nvjitlink_or_driver ()
23
+ if not culink_backend :
24
+ from cuda .bindings import nvjitlink
21
25
22
26
23
27
@pytest .fixture (scope = "function" )
@@ -40,6 +44,19 @@ def compile_ltoir_functions(init_cuda):
40
44
return object_code_a_ltoir , object_code_b_ltoir , object_code_c_ltoir
41
45
42
46
47
+ @contextmanager
48
+ def skip_version_specific_linker_options ():
49
+ if culink_backend :
50
+ return
51
+ try :
52
+ yield
53
+ except nvjitlink .nvJitLinkError as e :
54
+ if e .status == nvjitlink .Result .ERROR_UNRECOGNIZED_OPTION :
55
+ pytest .skip ("current nvjitlink version does not support the option provided" )
56
+ except Exception as e :
57
+ raise e
58
+
59
+
43
60
culink_options = [
44
61
LinkerOptions (arch = ARCH , verbose = True ),
45
62
LinkerOptions (arch = ARCH , max_register_count = 32 ),
@@ -72,7 +89,9 @@ def compile_ltoir_functions(init_cuda):
72
89
],
73
90
)
74
91
def test_linker_init (compile_ptx_functions , options ):
75
- linker = Linker (* compile_ptx_functions , options = options )
92
+ with skip_version_specific_linker_options ():
93
+ linker = Linker (* compile_ptx_functions , options = options )
94
+
76
95
object_code = linker .link ("cubin" )
77
96
assert isinstance (object_code , ObjectCode )
78
97
0 commit comments