Skip to content

Commit aaee3a3

Browse files
authored
Fix indentation bug in test_linker.py (#875)
`add_from_numba` and `debuggable_kernel` reference `test_device_functions_ltoir` which is only defined inside `if TEST_BIN_DIR:`. When `NUMBA_CUDA_TEST_BIN_DIR` is not set, this causes a `NameError` at module load time. This PR: 1. Moves `add_from_numba` and `debuggable_kernel` inside the `if TEST_BIN_DIR:` block 2. Adds `@unittest.skipUnless(TEST_BIN_DIR, ...)` to `test_debug_kernel_with_lto` so it is skipped when the env var is unset -- Leo's bot
1 parent 3c7c2f3 commit aaee3a3

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

numba_cuda/numba/cuda/tests/cudadrv/test_linker.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,15 @@ def simple_lmem(A, B, dty):
116116
TEST_BIN_DIR, "test_device_functions.ltoir"
117117
)
118118

119+
add_from_numba = cuda.declare_device(
120+
"add_from_numba",
121+
"int32(int32, int32)",
122+
link=[test_device_functions_ltoir],
123+
)
119124

120-
add_from_numba = cuda.declare_device(
121-
"add_from_numba",
122-
"int32(int32, int32)",
123-
link=[test_device_functions_ltoir],
124-
)
125-
126-
127-
def debuggable_kernel(result):
128-
i = cuda.grid(1)
129-
result[i] = add_from_numba(i, i)
125+
def debuggable_kernel(result):
126+
i = cuda.grid(1)
127+
result[i] = add_from_numba(i, i)
130128

131129

132130
@skip_on_cudasim("Linking unsupported in the simulator")
@@ -350,6 +348,7 @@ def test_get_local_mem_per_specialized(self):
350348
calc_size = np.dtype(np.float64).itemsize * LMEM_SIZE
351349
self.assertGreaterEqual(local_mem_size, calc_size)
352350

351+
@unittest.skipUnless(TEST_BIN_DIR, "NUMBA_CUDA_TEST_BIN_DIR not set")
353352
def test_debug_kernel_with_lto(self):
354353
cuda.jit("void(int32[::1])", debug=True, opt=False)(debuggable_kernel)
355354

0 commit comments

Comments
 (0)