Skip to content

Method _usm_type of Memory class should accept sycl_context #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions dppl/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,20 @@ cdef class Memory:
return "<Intel(R) USM allocated memory block of {} bytes at {}>" \
.format(self.nbytes, hex(<object>(<Py_ssize_t>self.memory_ptr)))

def _usm_type(self):
def _usm_type(self, sycl_context=None):
cdef const char* kind
kind = DPPLUSM_GetPointerType(self.memory_ptr,
self.context.get_context_ref())
cdef SyclContext ctx
if sycl_context is None:
ctx = self.context
kind = DPPLUSM_GetPointerType(self.memory_ptr,
ctx.get_context_ref())
elif isinstance(sycl_context, SyclContext):
ctx = <SyclContext>(sycl_context)
kind = DPPLUSM_GetPointerType(self.memory_ptr,
ctx.get_context_ref())
else:
raise ValueError("sycl_context keyword can be either None, "
"or an instance of dppl.SyclConext")
return kind.decode('UTF-8')


Expand Down