Skip to content

Commit

Permalink
[SYCL][CUDA] Pass device from context in create queue. (intel#10491)
Browse files Browse the repository at this point in the history
Recently in the switch to UR `urQueueCreateFromNativeHandle` changed the
previous behaviour whereby a queue was created with a device taken as
the default device from the context. It changed it so that the queue was
created with the device argument instead. Since the sycl runtime always
passes a nullptr for the device when programmers call
`make_queue(nativeStream, context)`, this broke `make_queue`. This patch
reverts to the previous behaviour before the switch from pi cuda to ur
cuda.

Note that this should also fix `make_queue` for l0 which I also guess
was broken due to the asserts meaning that this line was never reached:
https://github.com/intel/llvm/blob/sycl/sycl/plugins/unified_runtime/ur/adapters/level_zero/queue.cpp#L574.
But I have not tested this.

---------

Signed-off-by: JackAKirk <[email protected]>
  • Loading branch information
JackAKirk authored Aug 4, 2023
1 parent b4c5397 commit d64b35d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
ur_device_handle_t hDevice, const ur_queue_native_properties_t *pProperties,
ur_queue_handle_t *phQueue) {
(void)pProperties;
(void)hDevice;

unsigned int CuFlags;
CUstream CuStream = reinterpret_cast<CUstream>(hNativeQueue);
UR_ASSERT(hContext->getDevice() == hDevice, UR_RESULT_ERROR_INVALID_DEVICE);

auto Return = UR_CHECK_ERROR(cuStreamGetFlags(CuStream, &CuFlags));

Expand All @@ -266,7 +266,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
*phQueue = new ur_queue_handle_t_{std::move(ComputeCuStreams),
std::move(TransferCuStreams),
hContext,
hDevice,
hContext->getDevice(),
CuFlags,
Flags,
/*backend_owns*/ false};
Expand Down

0 comments on commit d64b35d

Please sign in to comment.