@@ -28,101 +28,88 @@ def compile_ltoir_functions(init_cuda):
28
28
return object_code_a_ltoir , object_code_b_ltoir , object_code_c_ltoir
29
29
30
30
31
- def test_linker_init_valid_options ():
32
- options = LinkerOptions (arch = ARCH )
33
- linker = Linker (options )
34
- assert linker .handle is not None
31
+ @pytest .mark .parametrize ("options" , [
32
+ LinkerOptions (arch = ARCH ),
33
+ LinkerOptions (arch = ARCH , max_register_count = 32 ),
34
+ LinkerOptions (arch = ARCH , time = True ),
35
+ LinkerOptions (arch = ARCH , verbose = True ),
36
+ LinkerOptions (arch = ARCH , optimization_level = 3 ),
37
+ LinkerOptions (arch = ARCH , debug = True ),
38
+ LinkerOptions (arch = ARCH , lineinfo = True ),
39
+ LinkerOptions (arch = ARCH , ftz = True ),
40
+ LinkerOptions (arch = ARCH , prec_div = True ),
41
+ LinkerOptions (arch = ARCH , prec_sqrt = True ),
42
+ LinkerOptions (arch = ARCH , fma = True ),
43
+ LinkerOptions (arch = ARCH , kernels_used = ["kernel1" ]),
44
+ LinkerOptions (arch = ARCH , variables_used = ["var1" ]),
45
+ LinkerOptions (arch = ARCH , optimize_unused_variables = True ),
46
+ LinkerOptions (arch = ARCH , xptxas = ["-v" ]),
47
+ LinkerOptions (arch = ARCH , split_compile = 0 ),
48
+ LinkerOptions (arch = ARCH , split_compile_extended = 1 ),
49
+ LinkerOptions (arch = ARCH , jump_table_density = 100 ),
50
+ LinkerOptions (arch = ARCH , no_cache = True )
51
+ ])
52
+ def test_linker_init (compile_ptx_functions , options ):
53
+ linker = Linker (options , object_codes = compile_ptx_functions )
54
+ object_code = linker .link ("cubin" )
55
+ assert isinstance (object_code , ObjectCode )
56
+
35
57
36
58
def test_linker_init_invalid_arch ():
37
59
options = LinkerOptions (arch = None )
38
60
with pytest .raises (ValueError ):
39
61
Linker (options )
40
62
41
- def test_linker_init (compile_ptx_functions ):
42
- combinations = [
43
- LinkerOptions (arch = ARCH ),
44
- LinkerOptions (arch = ARCH , max_register_count = 32 ),
45
- LinkerOptions (arch = ARCH , time = True ),
46
- LinkerOptions (arch = ARCH , verbose = True ),
47
- LinkerOptions (arch = ARCH , optimization_level = 3 ),
48
- LinkerOptions (arch = ARCH , debug = True ),
49
- LinkerOptions (arch = ARCH , lineinfo = True ),
50
- LinkerOptions (arch = ARCH , ftz = True ),
51
- LinkerOptions (arch = ARCH , prec_div = True ),
52
- LinkerOptions (arch = ARCH , prec_sqrt = True ),
53
- LinkerOptions (arch = ARCH , fma = True ),
54
- LinkerOptions (arch = ARCH , kernels_used = ["kernel1" ]),
55
- LinkerOptions (arch = ARCH , variables_used = ["var1" ]),
56
- LinkerOptions (arch = ARCH , optimize_unused_variables = True ),
57
- LinkerOptions (arch = ARCH , xptxas = ["-v" ]),
58
- LinkerOptions (arch = ARCH , split_compile = 0 ),
59
- LinkerOptions (arch = ARCH , split_compile_extended = 1 ),
60
- LinkerOptions (arch = ARCH , jump_table_density = 100 ),
61
- LinkerOptions (arch = ARCH , no_cache = True )
62
- ]
63
-
64
- # Try the combinations, with and without providing object codes to the constructor
65
- for i , options in enumerate (combinations ):
66
- linker = Linker (options , object_codes = compile_ptx_functions )
67
- object_code = linker .link ("cubin" )
68
- assert isinstance (object_code , ObjectCode )
69
63
70
64
def test_linker_add_code_object (compile_ptx_functions ):
71
65
options = LinkerOptions (arch = ARCH )
72
66
linker = Linker (options )
73
- functions = compile_ptx_functions
74
- linker .add_code_object (functions [0 ])
75
- linker .add_code_object (functions [1 ])
76
- linker .add_code_object (functions [2 ])
67
+ for functions in compile_ptx_functions :
68
+ linker .add_code_object (functions )
69
+
77
70
78
71
def test_linker_link_ptx (compile_ltoir_functions ):
79
72
options = LinkerOptions (arch = ARCH , link_time_optimization = True , ptx = True )
80
73
linker = Linker (options )
81
- functions = compile_ltoir_functions
82
- linker .add_code_object (functions [0 ])
83
- linker .add_code_object (functions [1 ])
84
- linker .add_code_object (functions [2 ])
74
+ for functions in compile_ltoir_functions :
75
+ linker .add_code_object (functions )
85
76
linked_code = linker .link ("ptx" )
86
77
assert isinstance (linked_code , ObjectCode )
87
78
79
+
88
80
def test_linker_link_cubin (compile_ptx_functions ):
89
81
options = LinkerOptions (arch = ARCH )
90
82
linker = Linker (options )
91
- functions = compile_ptx_functions
92
- linker .add_code_object (functions [0 ])
93
- linker .add_code_object (functions [1 ])
94
- linker .add_code_object (functions [2 ])
83
+ for functions in compile_ptx_functions :
84
+ linker .add_code_object (functions )
95
85
linked_code = linker .link ("cubin" )
96
86
assert isinstance (linked_code , ObjectCode )
97
87
88
+
98
89
def test_linker_link_invalid_target_type (compile_ptx_functions ):
99
90
options = LinkerOptions (arch = ARCH )
100
91
linker = Linker (options )
101
- functions = compile_ptx_functions
102
- linker .add_code_object (functions [0 ])
103
- linker .add_code_object (functions [1 ])
104
- linker .add_code_object (functions [2 ])
92
+ for functions in compile_ptx_functions :
93
+ linker .add_code_object (functions )
105
94
with pytest .raises (ValueError ):
106
95
linker .link ("invalid_target" )
107
96
97
+
108
98
def test_linker_get_error_log (compile_ptx_functions ):
109
99
options = LinkerOptions (arch = ARCH )
110
100
linker = Linker (options )
111
- functions = compile_ptx_functions
112
- linker .add_code_object (functions [0 ])
113
- linker .add_code_object (functions [1 ])
114
- linker .add_code_object (functions [2 ])
101
+ for functions in compile_ptx_functions :
102
+ linker .add_code_object (functions )
115
103
linker .link ("cubin" )
116
104
log = linker .get_error_log ()
117
105
assert isinstance (log , str )
118
106
107
+
119
108
def test_linker_get_info_log (compile_ptx_functions ):
120
109
options = LinkerOptions (arch = ARCH )
121
110
linker = Linker (options )
122
- functions = compile_ptx_functions
123
- linker .add_code_object (functions [0 ])
124
- linker .add_code_object (functions [1 ])
125
- linker .add_code_object (functions [2 ])
111
+ for functions in compile_ptx_functions :
112
+ linker .add_code_object (functions )
126
113
linker .link ("cubin" )
127
114
log = linker .get_info_log ()
128
115
assert isinstance (log , str )
0 commit comments