Skip to content

Commit 0b42803

Browse files
Used DPCTL<Obj>_Hash function in __hash__ methods
1 parent 41bd9ab commit 0b42803

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

dpctl/_sycl_context.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ from ._backend cimport ( # noqa: E211
3434
DPCTLContext_Delete,
3535
DPCTLContext_DeviceCount,
3636
DPCTLContext_GetDevices,
37+
DPCTLContext_Hash,
3738
DPCTLDevice_Copy,
3839
DPCTLDevice_Delete,
3940
DPCTLDeviceMgr_GetCachedContext,
@@ -337,11 +338,10 @@ cdef class SyclContext(_SyclContext):
337338

338339
def __hash__(self):
339340
"""
340-
Return a Py_ssize_t hash value by using the address of the
341-
``DPCTLSyclContextRef`` pointer stored in ``self._ctxt_ref``.
341+
Returns hash value corresponding to ``self._ctxt_ref``.
342342
343343
"""
344-
return hash(self.addressof_ref())
344+
return DPCTLContext_Hash(self._ctxt_ref)
345345

346346
cdef DPCTLSyclContextRef get_context_ref(self):
347347
return self._ctxt_ref

dpctl/_sycl_device.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ from ._backend cimport ( # noqa: E211
5858
DPCTLDevice_GetSubGroupIndependentForwardProgress,
5959
DPCTLDevice_GetVendor,
6060
DPCTLDevice_HasAspect,
61+
DPCTLDevice_Hash,
6162
DPCTLDevice_IsAccelerator,
6263
DPCTLDevice_IsCPU,
6364
DPCTLDevice_IsGPU,
@@ -711,11 +712,10 @@ cdef class SyclDevice(_SyclDevice):
711712

712713
def __hash__(self):
713714
"""
714-
Return a Py_ssize_t hash value by using the address of the
715-
``DPCTLSyclDeviceRef`` pointer stored in ``self._device_ref``.
715+
Returns hash value corresponding to ``self._device_ref``.
716716
717717
"""
718-
return hash(self.addressof_ref())
718+
return DPCTLDevice_Hash(self._device_ref)
719719

720720
cdef list create_sub_devices_equally(self, size_t count):
721721
""" Returns a list of sub-devices partitioned from this SYCL device

dpctl/_sycl_queue.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from ._backend cimport ( # noqa: E211
3838
DPCTLQueue_GetBackend,
3939
DPCTLQueue_GetContext,
4040
DPCTLQueue_GetDevice,
41+
DPCTLQueue_Hash,
4142
DPCTLQueue_IsInOrder,
4243
DPCTLQueue_MemAdvise,
4344
DPCTLQueue_Memcpy,
@@ -865,11 +866,10 @@ cdef class SyclQueue(_SyclQueue):
865866

866867
def __hash__(self):
867868
"""
868-
Return a Py_ssize_t hash value by using the address of the
869-
``DPCTLSyclQueueRef`` pointer stored in ``self._queue_ref``.
869+
Returns hash value corresponding to ``self._queue_ref``.
870870
871871
"""
872-
return hash(self.addressof_ref())
872+
return DPCTLQueue_Hash(self._queue_ref)
873873

874874
def _get_capsule(self):
875875
cdef DPCTLSyclQueueRef QRef = NULL

0 commit comments

Comments
 (0)