|
30 | 30 |
|
31 | 31 | import dpctl
|
32 | 32 | from dpctl._backend cimport *
|
33 |
| -from ._sycl_core cimport SyclContext, SyclQueue |
| 33 | +from ._sycl_core cimport SyclContext, SyclQueue, SyclDevice |
34 | 34 | from ._sycl_core cimport get_current_queue
|
35 | 35 |
|
36 | 36 | from cpython cimport Py_buffer
|
@@ -93,6 +93,7 @@ cdef class _BufferData:
|
93 | 93 | cdef object dt
|
94 | 94 | cdef _BufferData buf
|
95 | 95 | cdef Py_ssize_t arr_data_ptr
|
| 96 | + cdef SyclDevice dev |
96 | 97 |
|
97 | 98 | if ary_version != 1:
|
98 | 99 | _throw_sycl_usm_ary_iface()
|
@@ -124,9 +125,10 @@ cdef class _BufferData:
|
124 | 125 | # FIXME: need a way to construct a queue from
|
125 | 126 | # context and device, which can be obtaine from the
|
126 | 127 | # pointer and the context.
|
127 |
| - # cdef SyclDevice dev = DPPLget_pointer_device(arr_data_ptr, <SyclContext> ary_syclobj) |
| 128 | + # |
128 | 129 | # cdef SyclQueue new_queue = SyclQueue._create_from_dev_context(dev, <SyclContext> ary_syclobj)
|
129 | 130 | # buf.queue = new_queue
|
| 131 | + dev = Memory.get_pointer_device(buf.p, <SyclContext> ary_syclobj) |
130 | 132 | buf.queue = get_current_queue()
|
131 | 133 |
|
132 | 134 | return buf
|
@@ -314,7 +316,7 @@ cdef class Memory:
|
314 | 316 | ctx.get_context_ref())
|
315 | 317 | else:
|
316 | 318 | raise ValueError("syclobj keyword can be either None, "
|
317 |
| - "or an instance of SyclConext or SyclQueue") |
| 319 | + "or an instance of SyclContext or SyclQueue") |
318 | 320 | return kind.decode('UTF-8')
|
319 | 321 |
|
320 | 322 | cpdef copy_to_host (self, obj=None):
|
@@ -402,6 +404,12 @@ cdef class Memory:
|
402 | 404 | self.copy_to_host(mv) # output is discarded
|
403 | 405 | return b
|
404 | 406 |
|
| 407 | + @staticmethod |
| 408 | + cdef SyclDevice get_pointer_device(DPPLSyclUSMRef p, SyclContext ctx): |
| 409 | + cdef DPPLSyclDeviceRef dref = DPPLUSM_GetPointerDevice(p, ctx.get_context_ref()) |
| 410 | + |
| 411 | + return SyclDevice._create(dref) |
| 412 | + |
405 | 413 |
|
406 | 414 | cdef class MemoryUSMShared(Memory):
|
407 | 415 | """
|
|
0 commit comments