Skip to content

Commit

Permalink
[SYCL][PI] Queue constr. throws if invalid backend
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Ruyk committed Apr 23, 2020
1 parent f910c93 commit 195414f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ class queue_impl {
: MDevice(Device), MContext(Context), MAsyncHandler(AsyncHandler),
MPropList(PropList), MHostQueue(MDevice->is_host()),
MOpenCLInterop(!MHostQueue) {
if (!MHostQueue) {
MCommandQueue = createQueue(Order);
}

if (!Context->hasDevice(Device))
throw cl::sycl::invalid_parameter_error(
"Queue cannot be constructed with the given context and device "
"as the context does not contain the given device.",
PI_INVALID_DEVICE);

if (!MHostQueue) {
MCommandQueue = createQueue(Order);
}
}

/// Constructs a SYCL queue from plugin interoperability handle.
Expand Down Expand Up @@ -240,6 +242,8 @@ class queue_impl {
RT::PiContext Context = MContext->getHandleRef();
RT::PiDevice Device = MDevice->getHandleRef();
const detail::plugin &Plugin = getPlugin();

assert(Plugin == MDevice->getPlugin());
RT::PiResult Error = Plugin.call_nocheck<PiApiKind::piQueueCreate>(
Context, Device, CreationFlags, &Queue);

Expand Down

0 comments on commit 195414f

Please sign in to comment.