Skip to content
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
2 changes: 1 addition & 1 deletion dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ cdef class SyclDevice(_SyclDevice):
partition = int(partition)
return self.create_sub_devices_equally(partition)
except Exception as e:
raise TypeError("Unsupported type of sub-device argument")
raise TypeError("Unsupported type of sub-device argument") from e

@property
def parent_device(self):
Expand Down
9 changes: 4 additions & 5 deletions dpctl/memory/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ from dpctl._backend cimport *
from .._sycl_context cimport SyclContext
from .._sycl_device cimport SyclDevice
from .._sycl_queue cimport SyclQueue
from .._sycl_queue_manager cimport get_current_queue

from cpython cimport Py_buffer
from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize
Expand Down Expand Up @@ -222,7 +221,7 @@ cdef class _Memory:

if (nbytes > 0):
if queue is None:
queue = get_current_queue()
queue = dpctl.SyclQueue()

if (ptr_type == b"shared"):
if alignment > 0:
Expand Down Expand Up @@ -493,7 +492,7 @@ cdef class MemoryUSMShared(_Memory):
USM shared memory.

Non-positive alignments are not used (malloc_shared is used instead).
The queue=None the current `dpctl.get_current_queue()` is used to allocate memory.
For the queue=None cast the `dpctl.SyclQueue()` is used to allocate memory.

MemoryUSMShared(usm_obj) constructor create instance from `usm_obj` expected to
implement `__sycl_usm_array_interface__` protocol and exposing a contiguous block of
Expand Down Expand Up @@ -525,7 +524,7 @@ cdef class MemoryUSMHost(_Memory):
USM host memory.

Non-positive alignments are not used (malloc_host is used instead).
The queue=None the current `dpctl.get_current_queue()` is used to allocate memory.
For the queue=None case `dpctl.SyclQueue()` is used to allocate memory.

MemoryUSMDevice(usm_obj) constructor create instance from `usm_obj` expected to
implement `__sycl_usm_array_interface__` protocol and exposing a contiguous block of
Expand Down Expand Up @@ -557,7 +556,7 @@ cdef class MemoryUSMDevice(_Memory):
USM device memory.

Non-positive alignments are not used (malloc_device is used instead).
The queue=None the current `dpctl.get_current_queue()` is used to allocate memory.
For the queue=None cast the `dpctl.SyclQueue()` is used to allocate memory.

MemoryUSMDevice(usm_obj) constructor create instance from `usm_obj` expected to
implement `__sycl_usm_array_interface__` protocol and exposing a contiguous block of
Expand Down
44 changes: 22 additions & 22 deletions dpctl/tests/test_sycl_kernel_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@ def test_create_program_from_source(self):
size_t index = get_global_id(0); \
c[index] = d*a[index] + b[index]; \
}"
with dpctl.device_context("opencl:gpu:0"):
q = dpctl.get_current_queue()
prog = dpctl_prog.create_program_from_source(q, oclSrc)
axpyKernel = prog.get_sycl_kernel("axpy")
q = dpctl.SyclQueue("opencl:gpu")
prog = dpctl_prog.create_program_from_source(q, oclSrc)
axpyKernel = prog.get_sycl_kernel("axpy")

abuf = dpctl_mem.MemoryUSMShared(1024 * np.dtype("i").itemsize)
bbuf = dpctl_mem.MemoryUSMShared(1024 * np.dtype("i").itemsize)
cbuf = dpctl_mem.MemoryUSMShared(1024 * np.dtype("i").itemsize)
a = np.ndarray((1024), buffer=abuf, dtype="i")
b = np.ndarray((1024), buffer=bbuf, dtype="i")
c = np.ndarray((1024), buffer=cbuf, dtype="i")
a[:] = np.arange(1024)
b[:] = np.arange(1024, 0, -1)
c[:] = 0
d = 2
args = []
bufBytes = 1024 * np.dtype("i").itemsize
abuf = dpctl_mem.MemoryUSMShared(bufBytes, queue=q)
bbuf = dpctl_mem.MemoryUSMShared(bufBytes, queue=q)
cbuf = dpctl_mem.MemoryUSMShared(bufBytes, queue=q)
a = np.ndarray((1024), buffer=abuf, dtype="i")
b = np.ndarray((1024), buffer=bbuf, dtype="i")
c = np.ndarray((1024), buffer=cbuf, dtype="i")
a[:] = np.arange(1024)
b[:] = np.arange(1024, 0, -1)
c[:] = 0
d = 2
args = []

args.append(a.base)
args.append(b.base)
args.append(c.base)
args.append(ctypes.c_int(d))
args.append(a.base)
args.append(b.base)
args.append(c.base)
args.append(ctypes.c_int(d))

r = [1024]
r = [1024]

q.submit(axpyKernel, args, r)
self.assertTrue(np.allclose(c, a * d + b))
q.submit(axpyKernel, args, r)
self.assertTrue(np.allclose(c, a * d + b))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion dpctl/tests/test_sycl_queue_memcpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_memcpy_copy_usm_to_usm(self):
)
def test_memcpy_type_error(self):
mobj = self._create_memory()
q = dpctl.get_current_queue()
q = mobj._queue

with self.assertRaises(TypeError) as cm:
q.memcpy(None, mobj, 3)
Expand Down