Skip to content
Closed
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
7 changes: 6 additions & 1 deletion numba_dpex/core/types/dpctl_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ class DpctlSyclQueue(types.Type):
Numba.
"""

def __init__(self):
def __init__(self, sycl_queue):
self._sycl_queue = sycl_queue
super(DpctlSyclQueue, self).__init__(name="DpctlSyclQueue")

@property
def sycl_queue(self):
return self._sycl_queue

@property
def box_type(self):
return SyclQueue
Expand Down
46 changes: 24 additions & 22 deletions numba_dpex/core/types/usm_ndarray_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import dpctl
import dpctl.tensor
from numba import types
from numba.core.typeconv import Conversion
from numba.core.typeinfer import CallConstraint
from numba.core.types.npytypes import Array
from numba.np.numpy_support import from_dtype

Expand All @@ -24,42 +24,44 @@ def __init__(
layout="C",
dtype=None,
usm_type="device",
device="unknown",
device=None,
queue=None,
readonly=False,
name=None,
aligned=True,
addrspace=address_space.GLOBAL,
):
if not isinstance(device, str):
raise TypeError(
"The device keyword arg should be a str object specifying "
"a SYCL filter selector"
)

if not isinstance(queue, dpctl.SyclQueue) and queue is not None:
if queue and not isinstance(queue, types.misc.Omitted) and device:
raise TypeError(
"The queue keyword arg should be a dpctl.SyclQueue object or None"
"numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
"`device` and `sycl_queue` are exclusive keywords, i.e. use one or other."
)

self.usm_type = usm_type
self.addrspace = addrspace

if device == "unknown":
device = None

if queue is not None and device is not None:
raise TypeError(
"'queue' and 'device' keywords can not be both specified"
)

if queue is not None:
if queue and not isinstance(queue, types.misc.Omitted):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a non-None queue argument can it be anything but a dpctl.SyclQueue? Where can we end up with the queue being a types.misc.Omitted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a non-None queue argument can it be anything but a dpctl.SyclQueue?

Then we fail on these tests numba_dpex/tests/dpjit_tests/parfors/test_builtin_ops.py::test_built_in_operators2

Where can we end up with the queue being a types.misc.Omitted?

The type of queue becomes types.misc.Omitted when dpnp.epmty() is being called by dpnp functions internally.

if not isinstance(queue, dpctl.SyclQueue):
raise TypeError(
"numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
"The queue keyword arg should be a dpctl.SyclQueue object or None."
)
self.queue = queue
else:
if device is None:
device = dpctl.SyclDevice()

self.queue = dpctl.get_device_cached_queue(device)
sycl_device = dpctl.SyclDevice()
else:
if not isinstance(device, str):
raise TypeError(
"numba_dpex.core.types.usm_ndarray_type.USMNdArray.__init__(): "
"The device keyword arg should be a str object specifying "
"a SYCL filter selector."
)
sycl_device = dpctl.SyclDevice(device)

self.queue = dpctl._sycl_queue_manager.get_device_cached_queue(
sycl_device
)

self.device = self.queue.sycl_device.filter_string

Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/core/typing/typeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ def typeof_dpctl_sycl_queue(val, c):

Returns: A numba_dpex.core.types.dpctl_types.DpctlSyclQueue instance.
"""
return DpctlSyclQueue()
return DpctlSyclQueue(val)
Loading