Skip to content

Commit 51dd293

Browse files
committed
add two kernels test
1 parent 067ea82 commit 51dd293

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ def kernel(arg):
6969
# self.assertEqual(counter, 0) # We don't have a way to explicitly
7070
# evict kernel and its modules at the moment.
7171

72+
def test_two_kernels(self):
73+
counter = 0
74+
75+
def setup(mod, stream):
76+
nonlocal counter
77+
counter += 1
78+
79+
def teardown(mod, stream):
80+
nonlocal counter
81+
counter -= 1
82+
83+
lib = CUSource("", setup_callback=setup, teardown_callback=teardown)
84+
85+
@cuda.jit(link=[lib])
86+
def kernel():
87+
pass
88+
89+
@cuda.jit(link=[lib])
90+
def kernel2():
91+
pass
92+
93+
kernel[1, 1]()
94+
self.assertEqual(counter, 1)
95+
kernel2[1, 1]()
96+
self.assertEqual(counter, 2)
97+
98+
# del kernel
99+
# gc.collect()
100+
# cuda.current_context().deallocations.clear()
101+
# self.assertEqual(counter, 0) # We don't have a way to explicitly
102+
# evict kernel and its modules at the moment.
103+
72104

73105
class TestModuleCallbacks(CUDATestCase):
74106

0 commit comments

Comments
 (0)