Skip to content

Use size_t instead of Py_ssize_t to fit device USM pointer #405

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 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions dpctl/memory/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ cdef class _Memory:

def __repr__(self):
return "<Intel(R) USM allocated memory block of {} bytes at {}>" \
.format(self.nbytes, hex(<object>(<Py_ssize_t>self.memory_ptr)))
.format(self.nbytes, hex(<object>(<size_t>self.memory_ptr)))

def __len__(self):
return self.nbytes
Expand All @@ -245,7 +245,7 @@ cdef class _Memory:
property __sycl_usm_array_interface__:
def __get__(self):
cdef dict iface = {
"data": (<Py_ssize_t>(<void *>self.memory_ptr),
"data": (<size_t>(<void *>self.memory_ptr),
True), # bool(self.writeable)),
"shape": (self.nbytes,),
"strides": None,
Expand Down
4 changes: 2 additions & 2 deletions dpctl/memory/_sycl_usm_array_interface_utils.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cdef class _USMBufferData:
cdef object ary_syclobj = ary_iface.get('syclobj', None)
cdef Py_ssize_t ary_offset = ary_iface.get('offset', 0)
cdef int ary_version = ary_iface.get('version', 0)
cdef Py_ssize_t arr_data_ptr = 0
cdef size_t arr_data_ptr = 0
cdef DPCTLSyclUSMRef memRef = NULL
cdef Py_ssize_t itemsize = -1
cdef int writeable = -1
Expand All @@ -141,7 +141,7 @@ cdef class _USMBufferData:
raise ValueError("__sycl_usm_array_interface__ is malformed:"
" 'data' field is required, and must be a tuple"
" (usm_pointer, is_writeable_boolean).")
arr_data_ptr = <Py_ssize_t>ary_data_tuple[0]
arr_data_ptr = <size_t>ary_data_tuple[0]
writeable = 1 if ary_data_tuple[1] else 0
# Check that memory and syclobj are consistent:
# (USM pointer is bound to this sycl context)
Expand Down