Skip to content

Commit de68712

Browse files
Use size_t instead of Py_ssize_t to fit device USM pointer
Also to avoid formatting of the USM-device pointer as a negative hex value
1 parent a96cf11 commit de68712

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

dpctl/memory/_memory.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ cdef class _Memory:
228228

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

233233
def __len__(self):
234234
return self.nbytes
@@ -245,7 +245,7 @@ cdef class _Memory:
245245
property __sycl_usm_array_interface__:
246246
def __get__(self):
247247
cdef dict iface = {
248-
"data": (<Py_ssize_t>(<void *>self.memory_ptr),
248+
"data": (<size_t>(<void *>self.memory_ptr),
249249
True), # bool(self.writeable)),
250250
"shape": (self.nbytes,),
251251
"strides": None,

dpctl/memory/_sycl_usm_array_interface_utils.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ cdef class _USMBufferData:
121121
cdef object ary_syclobj = ary_iface.get('syclobj', None)
122122
cdef Py_ssize_t ary_offset = ary_iface.get('offset', 0)
123123
cdef int ary_version = ary_iface.get('version', 0)
124-
cdef Py_ssize_t arr_data_ptr = 0
124+
cdef size_t arr_data_ptr = 0
125125
cdef DPCTLSyclUSMRef memRef = NULL
126126
cdef Py_ssize_t itemsize = -1
127127
cdef int writeable = -1
@@ -141,7 +141,7 @@ cdef class _USMBufferData:
141141
raise ValueError("__sycl_usm_array_interface__ is malformed:"
142142
" 'data' field is required, and must be a tuple"
143143
" (usm_pointer, is_writeable_boolean).")
144-
arr_data_ptr = <Py_ssize_t>ary_data_tuple[0]
144+
arr_data_ptr = <size_t>ary_data_tuple[0]
145145
writeable = 1 if ary_data_tuple[1] else 0
146146
# Check that memory and syclobj are consistent:
147147
# (USM pointer is bound to this sycl context)

0 commit comments

Comments
 (0)