Skip to content

[SYCL][UR] Add UR_QUEUE_INFO_EMPTY support for OpenCL #19151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,5 @@ int main() {
ExceptionThrown = true;
}

// Feature is not supported for OpenCL, exception must be thrown.
if (Q.get_device().get_backend() == backend::opencl)
return ExceptionThrown ? 0 : -1;

return 0;
return ExceptionThrown ? -1 : 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,5 @@ int main() {
ExceptionThrown = true;
}

// Feature is not supported for OpenCL, exception must be thrown.
if (Q.get_device().get_backend() == backend::opencl)
return ExceptionThrown ? 0 : -1;

return 0;
return ExceptionThrown ? -1 : 0;
}
15 changes: 13 additions & 2 deletions unified-runtime/source/adapters/opencl/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===-----------------------------------------------------------------===//

#include "queue.hpp"
#include "CL/cl.h"
#include "common.hpp"
#include "context.hpp"
#include "device.hpp"
Expand Down Expand Up @@ -172,8 +173,18 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
if (propName == UR_QUEUE_INFO_EMPTY) {
if (!hQueue->LastEvent) {
// OpenCL doesn't provide API to check the status of the queue.
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
// Check the status of the queue under OpenCL backend.
cl_event Event;
CL_RETURN_ON_FAILURE(
clEnqueueMarkerWithWaitList(hQueue->CLQueue, 0, nullptr, &Event));
cl_int QueryResult;
CL_RETURN_ON_FAILURE(
clGetEventInfo(Event, CL_EVENT_COMMAND_EXECUTION_STATUS,
sizeof(QueryResult), &QueryResult, nullptr));
if (QueryResult == CL_COMPLETE) {
return ReturnValue(true);
}
return ReturnValue(false);
} else {
ur_event_status_t Status;
UR_RETURN_ON_FAILURE(urEventGetInfo(
Expand Down
Loading