@@ -88,7 +88,9 @@ def _get_libnvvm_version_for_tests():
8888 try :
8989 major , minor , debug_major , debug_minor = nvvm .ir_version ()
9090 global precheck_nvvm_ir
91- precheck_nvvm_ir = precheck_nvvm_ir .format (major = major , minor = minor , debug_major = debug_major , debug_minor = debug_minor )
91+ precheck_nvvm_ir = precheck_nvvm_ir .format (
92+ major = major , minor = minor , debug_major = debug_major , debug_minor = debug_minor
93+ )
9294 precheck_ir_bytes = precheck_nvvm_ir .encode ("utf-8" )
9395 nvvm .add_module_to_program (program , precheck_ir_bytes , len (precheck_ir_bytes ), "precheck.ll" )
9496
@@ -120,13 +122,12 @@ def nvvm_ir():
120122 fallback assumes no version metadata will be present in
121123 the input nvvm ir
122124 """
123- try :
124- from cuda .core .experimental ._program import _get_nvvm_module
125+ from cuda .core .experimental ._program import _get_nvvm_module
125126
126- nvvm = _get_nvvm_module ()
127- major , minor , debug_major , debug_minor = nvvm .ir_version ()
127+ nvvm = _get_nvvm_module ()
128+ major , minor , debug_major , debug_minor = nvvm .ir_version ()
128129
129- nvvm_ir_template = """target triple = "nvptx64-unknown-cuda"
130+ nvvm_ir_template = """target triple = "nvptx64-unknown-cuda"
130131target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
131132
132133define i32 @ave(i32 %a, i32 %b) {{
@@ -159,39 +160,7 @@ def nvvm_ir():
159160!nvvmir.version = !{{!1}}
160161!1 = !{{i32 {major}, i32 {minor}, i32 {debug_major}, i32 {debug_minor}}}
161162""" # noqa: E501
162-
163- return nvvm_ir_template .format (major = major , minor = minor , debug_major = debug_major , debug_minor = debug_minor )
164- except Exception :
165- return """target triple = "nvptx64-unknown-cuda"
166- target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
167-
168- define i32 @ave(i32 %a, i32 %b) {
169- entry:
170- %add = add nsw i32 %a, %b
171- %div = sdiv i32 %add, 2
172- ret i32 %div
173- }
174-
175- define void @simple(i32* %data) {
176- entry:
177- %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
178- %1 = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
179- %mul = mul i32 %0, %1
180- %2 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
181- %add = add i32 %mul, %2
182- %call = call i32 @ave(i32 %add, i32 %add)
183- %idxprom = sext i32 %add to i64
184- store i32 %call, i32* %data, align 4
185- ret void
186- }
187-
188- declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() nounwind readnone
189- declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x() nounwind readnone
190- declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() nounwind readnone
191-
192- !nvvm.annotations = !{!0}
193- !0 = !{void (i32*)* @simple, !"kernel", i32 1}
194- """ # noqa: E501
163+ return nvvm_ir_template .format (major = major , minor = minor , debug_major = debug_major , debug_minor = debug_minor )
195164
196165
197166@pytest .fixture (scope = "module" )
0 commit comments