66from numba .cuda .runtime import rtsys
77from numba .tests .support import EnableNRTStatsMixin
88from numba .cuda .testing import CUDATestCase
9-
109from numba .cuda .tests .nrt .mock_numpy import cuda_empty , cuda_empty_like
1110
1211from numba import cuda
@@ -25,17 +24,17 @@ def test_no_return(self):
2524 """
2625 n = 10
2726
28- @cuda .jit ( debug = True )
27+ @cuda .jit
2928 def kernel ():
3029 for i in range (n ):
3130 temp = cuda_empty (2 , np .float64 ) # noqa: F841
3231 return None
3332
34- init_stats = rtsys . get_allocation_stats ()
35-
33+ stream = cuda . default_stream ()
34+ init_stats = rtsys . get_allocation_stats ( stream )
3635 with patch ('numba.config.CUDA_ENABLE_NRT' , True , create = True ):
37- kernel [1 ,1 ]()
38- cur_stats = rtsys .get_allocation_stats ()
36+ kernel [1 , 1 , stream ]()
37+ cur_stats = rtsys .get_allocation_stats (stream )
3938 self .assertEqual (cur_stats .alloc - init_stats .alloc , n )
4039 self .assertEqual (cur_stats .free - init_stats .free , n )
4140
@@ -57,10 +56,11 @@ def g(n):
5756
5857 return None
5958
60- init_stats = rtsys .get_allocation_stats ()
59+ stream = cuda .default_stream ()
60+ init_stats = rtsys .get_allocation_stats (stream )
6161 with patch ('numba.config.CUDA_ENABLE_NRT' , True , create = True ):
62- g [1 , 1 ](10 )
63- cur_stats = rtsys .get_allocation_stats ()
62+ g [1 , 1 , stream ](10 )
63+ cur_stats = rtsys .get_allocation_stats (stream )
6464 self .assertEqual (cur_stats .alloc - init_stats .alloc , 1 )
6565 self .assertEqual (cur_stats .free - init_stats .free , 1 )
6666
@@ -80,10 +80,11 @@ def if_with_allocation_and_initialization(arr1, test1):
8080
8181 arr = np .random .random ((5 , 5 )) # the values are not consumed
8282
83- init_stats = rtsys .get_allocation_stats ()
83+ stream = cuda .default_stream ()
84+ init_stats = rtsys .get_allocation_stats (stream )
8485 with patch ('numba.config.CUDA_ENABLE_NRT' , True , create = True ):
85- if_with_allocation_and_initialization [1 , 1 ](arr , False )
86- cur_stats = rtsys .get_allocation_stats ()
86+ if_with_allocation_and_initialization [1 , 1 , stream ](arr , False )
87+ cur_stats = rtsys .get_allocation_stats (stream )
8788 self .assertEqual (cur_stats .alloc - init_stats .alloc ,
8889 cur_stats .free - init_stats .free )
8990
@@ -103,10 +104,12 @@ def f(arr):
103104 res += t [i ]
104105
105106 arr = np .ones ((2 , 2 ))
106- init_stats = rtsys .get_allocation_stats ()
107+
108+ stream = cuda .default_stream ()
109+ init_stats = rtsys .get_allocation_stats (stream )
107110 with patch ('numba.config.CUDA_ENABLE_NRT' , True , create = True ):
108- f [1 , 1 ](arr )
109- cur_stats = rtsys .get_allocation_stats ()
111+ f [1 , 1 , stream ](arr )
112+ cur_stats = rtsys .get_allocation_stats (stream )
110113 self .assertEqual (cur_stats .alloc - init_stats .alloc ,
111114 cur_stats .free - init_stats .free )
112115
0 commit comments