Skip to content

Commit 735424d

Browse files
author
khaled
committed
Merge 1047, fix caching of DpctlSyclQueue issues
1 parent 6e8314b commit 735424d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

numba_dpex/core/types/dpctl_types.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
import random
6+
57
from dpctl import SyclQueue
68
from numba import types
79
from numba.core import cgutils
@@ -27,6 +29,19 @@ def __init__(self, sycl_queue):
2729
def sycl_queue(self):
2830
return self._sycl_queue
2931

32+
@property
33+
def key(self):
34+
"""Returns a Python object used as the key to cache an instance of
35+
DpctlSyclQueue.
36+
The key is constructed by hashing the actual dpctl.SyclQueue object
37+
encapsulated by an instance of DpctlSyclQueue. Doing so ensures, that
38+
different dpctl.SyclQueue instances are inferred as separate instances
39+
of the DpctlSyclQueue type.
40+
Returns:
41+
int: hash of the self._sycl_queue Python object.
42+
"""
43+
return hash(self._sycl_queue)
44+
3045
@property
3146
def box_type(self):
3247
return SyclQueue

numba_dpex/core/types/usm_ndarray_type.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def __init__(
4646
raise TypeError(
4747
"numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
4848
"The queue keyword arg should be a dpctl.SyclQueue object or None."
49+
"Found type(queue) ="
50+
+ str(type(queue) + " and queue =" + queue)
4951
)
5052
self.queue = queue
5153
else:
@@ -207,7 +209,13 @@ def can_convert_to(self, typingctx, other):
207209

208210
@property
209211
def key(self):
210-
return (*super().key, self.addrspace, self.usm_type, self.device)
212+
return (
213+
*super().key,
214+
self.addrspace,
215+
self.usm_type,
216+
self.device,
217+
self.queue,
218+
)
211219

212220
@property
213221
def as_array(self):

0 commit comments

Comments
 (0)