Skip to content

Commit b6132c8

Browse files
HPS-1kbenzie
authored andcommitted
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 intel/llvm#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 65ff80e commit b6132c8

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

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)