Skip to content

Commit 2ad3268

Browse files
Hugh Delaneyaarongreig
andauthored
Associate queue with device in context (#1992)
Making a native queue doesn't require hDevice to be non null, but this associates the queue with a null device, even if hContext contains valid devices. This fixes the behaviour for a single device context, making the queue be associated with the only device in the context. But there is a question mark over whether this entry point makes sense for a multi device UR context. Should we be able to construct a queue with a native queue without knowing what the UR device associated with the queue is? Probably not. Co-authored-by: aarongreig <aaron.greig@codeplay.com>
1 parent 8256ae2 commit 2ad3268

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

source/adapters/cuda/queue.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
265265
ur_native_handle_t hNativeQueue, ur_context_handle_t hContext,
266266
ur_device_handle_t hDevice, const ur_queue_native_properties_t *pProperties,
267267
ur_queue_handle_t *phQueue) {
268-
(void)hDevice;
268+
if (!hDevice && hContext->getDevices().size() == 1)
269+
hDevice = hContext->getDevices().front();
269270

270271
unsigned int CuFlags;
271272
CUstream CuStream = reinterpret_cast<CUstream>(hNativeQueue);

source/adapters/hip/queue.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
299299
ur_native_handle_t hNativeQueue, ur_context_handle_t hContext,
300300
ur_device_handle_t hDevice, const ur_queue_native_properties_t *pProperties,
301301
ur_queue_handle_t *phQueue) {
302-
(void)hDevice;
302+
if (!hDevice && hContext->getDevices().size() == 1)
303+
hDevice = hContext->getDevices().front();
303304

304305
unsigned int HIPFlags;
305306
hipStream_t HIPStream = reinterpret_cast<hipStream_t>(hNativeQueue);

0 commit comments

Comments
 (0)