Skip to content

Commit 26b2a8d

Browse files
Method _usm_type of Memory class should accept sycl_context
1 parent c9b2f94 commit 26b2a8d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

dppl/_memory.pyx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,20 @@ cdef class Memory:
7474
return "<Intel(R) USM allocated memory block of {} bytes at {}>" \
7575
.format(self.nbytes, hex(<object>(<Py_ssize_t>self.memory_ptr)))
7676

77-
def _usm_type(self):
77+
def _usm_type(self, sycl_context=None):
7878
cdef const char* kind
79-
kind = DPPLUSM_GetPointerType(self.memory_ptr,
80-
self.context.get_context_ref())
79+
cdef SyclContext ctx
80+
if sycl_context is None:
81+
ctx = self.context
82+
kind = DPPLUSM_GetPointerType(self.memory_ptr,
83+
ctx.get_context_ref())
84+
elif isinstance(sycl_context, SyclContext):
85+
ctx = <SyclContext>(sycl_context)
86+
kind = DPPLUSM_GetPointerType(self.memory_ptr,
87+
ctx.get_context_ref())
88+
else:
89+
raise ValueError("sycl_context keyword can be either None, "
90+
"or an instance of dppl.SyclConext")
8191
return kind.decode('UTF-8')
8292

8393

0 commit comments

Comments
 (0)