Skip to content

Commit bcc45f4

Browse files
authored
[SYCL][UR] Add UR_QUEUE_INFO_EMPTY support for OpenCL (#19151)
To fix CTS test (https://github.com/KhronosGroup/SYCL-CTS/blob/b5cf985ecc497f82045165e9309fdc7a990c7e60/tests/extension/khr_queue_empty_query/queue_empty.cpp) failures for the `sycl_khr_queue_empty_query` extension (implemented in #18799), which are caused by the error `UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION` emitted in the old code. --------- Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
1 parent 1bba44f commit bcc45f4

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

sycl/test-e2e/Basic/out_of_order_queue_status_ext_oneapi_empty.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,5 @@ int main() {
7373
ExceptionThrown = true;
7474
}
7575

76-
// Feature is not supported for OpenCL, exception must be thrown.
77-
if (Q.get_device().get_backend() == backend::opencl)
78-
return ExceptionThrown ? 0 : -1;
79-
80-
return 0;
76+
return ExceptionThrown ? -1 : 0;
8177
}

sycl/test-e2e/Basic/out_of_order_queue_status_khr_empty.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,5 @@ int main() {
7474
ExceptionThrown = true;
7575
}
7676

77-
// Feature is not supported for OpenCL, exception must be thrown.
78-
if (Q.get_device().get_backend() == backend::opencl)
79-
return ExceptionThrown ? 0 : -1;
80-
81-
return 0;
77+
return ExceptionThrown ? -1 : 0;
8278
}

unified-runtime/source/adapters/opencl/queue.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===-----------------------------------------------------------------===//
88

99
#include "queue.hpp"
10+
#include "CL/cl.h"
1011
#include "common.hpp"
1112
#include "context.hpp"
1213
#include "device.hpp"
@@ -172,8 +173,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
172173
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
173174
if (propName == UR_QUEUE_INFO_EMPTY) {
174175
if (!hQueue->LastEvent) {
175-
// OpenCL doesn't provide API to check the status of the queue.
176-
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
176+
// Check the status of the queue under OpenCL backend.
177+
cl_event Event;
178+
CL_RETURN_ON_FAILURE(
179+
clEnqueueMarkerWithWaitList(hQueue->CLQueue, 0, nullptr, &Event));
180+
cl_int QueryResult;
181+
CL_RETURN_ON_FAILURE(
182+
clGetEventInfo(Event, CL_EVENT_COMMAND_EXECUTION_STATUS,
183+
sizeof(QueryResult), &QueryResult, nullptr));
184+
CL_RETURN_ON_FAILURE(clReleaseEvent(Event));
185+
if (QueryResult == CL_COMPLETE) {
186+
return ReturnValue(true);
187+
}
188+
return ReturnValue(false);
177189
} else {
178190
ur_event_status_t Status;
179191
UR_RETURN_ON_FAILURE(urEventGetInfo(

0 commit comments

Comments
 (0)