Skip to content

Commit 195414f

Browse files
committed
[SYCL][PI] Queue constr. throws if invalid backend
Constructor of the SYCL queue throws an exception if the device passed in is from a different backend than the context that is associated with the queue. Signed-off-by: Ruyman Reyes <[email protected]>
1 parent f910c93 commit 195414f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sycl/source/detail/queue_impl.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ class queue_impl {
6969
: MDevice(Device), MContext(Context), MAsyncHandler(AsyncHandler),
7070
MPropList(PropList), MHostQueue(MDevice->is_host()),
7171
MOpenCLInterop(!MHostQueue) {
72-
if (!MHostQueue) {
73-
MCommandQueue = createQueue(Order);
74-
}
72+
7573
if (!Context->hasDevice(Device))
7674
throw cl::sycl::invalid_parameter_error(
7775
"Queue cannot be constructed with the given context and device "
7876
"as the context does not contain the given device.",
7977
PI_INVALID_DEVICE);
78+
79+
if (!MHostQueue) {
80+
MCommandQueue = createQueue(Order);
81+
}
8082
}
8183

8284
/// Constructs a SYCL queue from plugin interoperability handle.
@@ -240,6 +242,8 @@ class queue_impl {
240242
RT::PiContext Context = MContext->getHandleRef();
241243
RT::PiDevice Device = MDevice->getHandleRef();
242244
const detail::plugin &Plugin = getPlugin();
245+
246+
assert(Plugin == MDevice->getPlugin());
243247
RT::PiResult Error = Plugin.call_nocheck<PiApiKind::piQueueCreate>(
244248
Context, Device, CreationFlags, &Queue);
245249

0 commit comments

Comments
 (0)