Skip to content

Commit a0a3328

Browse files
authored
Update tests to accept variants of generated PTX (#585)
1 parent cb1978f commit a0a3328

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

numba_cuda/numba/cuda/tests/cudapy/test_casting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ def test_float_to_complex(self):
255255
@skip_on_cudasim("Compilation unsupported in the simulator")
256256
def test_native_cast(self):
257257
float32_ptx, _ = cuda.compile_ptx(native_cast, (float32,), device=True)
258-
self.assertIn("st.f32", float32_ptx)
258+
self.assertRegex(float32_ptx, r"st\.[bf]32")
259259

260260
float16_ptx, _ = cuda.compile_ptx(native_cast, (float16,), device=True)
261-
self.assertIn("st.u16", float16_ptx)
261+
self.assertRegex(float16_ptx, r"st\.[bu]16", float16_ptx)
262262

263263

264264
if __name__ == "__main__":

numba_cuda/numba/cuda/tests/cudapy/test_compiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ def f():
661661
sig = "void()"
662662
ptx, resty = cuda.compile_ptx(f, sig, launch_bounds=launch_bounds)
663663
self.assertIsInstance(resty, types.NoneType)
664-
self.assertRegex(ptx, r".maxntid\s+128,\s+1,\s+1")
664+
# Match either `.maxntid, 128, 1, 1` or `.maxntid 128` on a line by
665+
# itself:
666+
self.assertRegex(ptx, r".maxntid\s+128(?:,\s+1,\s+1)?\s*\n")
665667
return ptx
666668

667669
def test_launch_bounds_scalar(self):

numba_cuda/numba/cuda/tests/cudapy/test_constmem.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def test_const_array(self):
9898
self.assertTrue(np.all(A == CONST1D + 1))
9999

100100
if not ENABLE_CUDASIM:
101-
self.assertIn(
102-
"ld.const.f64",
101+
self.assertRegex(
103102
jcuconst.inspect_asm(sig),
104-
"as we're adding to it, load as a double",
103+
r"ld\.const\.[bf]64",
104+
"load as a 64-bit value",
105105
)
106106

107107
def test_const_empty(self):
@@ -124,10 +124,10 @@ def test_const_array_2d(self):
124124
self.assertTrue(np.all(A == CONST2D))
125125

126126
if not ENABLE_CUDASIM:
127-
self.assertIn(
128-
"ld.const.u32",
127+
self.assertRegex(
129128
jcuconst2d.inspect_asm(sig),
130-
"load the ints as ints",
129+
r"ld\.const\.[bu]32",
130+
"load as a 32-bit value",
131131
)
132132

133133
def test_const_array_3d(self):
@@ -139,9 +139,9 @@ def test_const_array_3d(self):
139139

140140
if not ENABLE_CUDASIM:
141141
asm = jcuconst3d.inspect_asm(sig)
142-
complex_load = "ld.const.v2.f32"
143-
description = "Load the complex as a vector of 2x f32"
144-
self.assertIn(complex_load, asm, description)
142+
complex_load = r"ld\.const\.v2\.[bf]32"
143+
description = "Load the complex as a vector of 2x 32-bits"
144+
self.assertRegex(asm, complex_load, description)
145145

146146
def test_const_record_empty(self):
147147
jcuconstRecEmpty = cuda.jit("void(int64[:])")(cuconstRecEmpty)

numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,9 @@ def f():
773773

774774
sig = f.signatures[0]
775775
ptx = f.inspect_asm(sig)
776-
self.assertRegex(ptx, r".maxntid\s+128,\s+1,\s+1")
776+
# Match either `.maxntid, 128, 1, 1` or `.maxntid 128` on a line by
777+
# itself:
778+
self.assertRegex(ptx, r".maxntid\s+128(?:,\s+1,\s+1)?\s*\n")
777779

778780
return ptx
779781

numba_cuda/numba/cuda/tests/nrt/test_nrt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ def g():
128128
match = re.search(p1, ptx)
129129
assert match is not None
130130

131-
p2 = r"call\.uni.*\n.*NRT_incref"
131+
p2 = r"call\.uni.*\n?.*NRT_incref"
132132
match = re.search(p2, ptx)
133133
assert match is not None
134134

135-
p3 = r"call\.uni.*\n.*NRT_decref"
135+
p3 = r"call\.uni.*\n?.*NRT_decref"
136136
match = re.search(p3, ptx)
137137
assert match is not None
138138

0 commit comments

Comments
 (0)