@@ -94,8 +94,8 @@ ur_result_t ur_queue_handle_t_::makeWithNative(native_type NativeQueue,
9494 UR_RETURN_ON_FAILURE (urDeviceCreateWithNativeHandle (
9595 hNativeHandle, nullptr , nullptr , &Device));
9696 }
97- auto URQueue =
98- std::make_unique<ur_queue_handle_t_>(NativeQueue, Context, Device);
97+ auto URQueue = std::make_unique<ur_queue_handle_t_>(NativeQueue, Context,
98+ Device, false );
9999 Queue = URQueue.release ();
100100 } catch (std::bad_alloc &) {
101101 return UR_RESULT_ERROR_OUT_OF_RESOURCES;
@@ -125,14 +125,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreate(
125125
126126 cl_int RetErr = CL_INVALID_OPERATION;
127127
128+ bool InOrder = !(CLProperties & SupportByOpenCL &
129+ CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
128130 if (Version < oclv::V2_0) {
129131 cl_command_queue Queue =
130132 clCreateCommandQueue (hContext->CLContext , hDevice->CLDevice ,
131133 CLProperties & SupportByOpenCL, &RetErr);
132134 CL_RETURN_ON_FAILURE (RetErr);
133135 try {
134- auto URQueue =
135- std::make_unique<ur_queue_handle_t_>(Queue, hContext, hDevice);
136+ auto URQueue = std::make_unique<ur_queue_handle_t_>(Queue, hContext,
137+ hDevice, InOrder );
136138 *phQueue = URQueue.release ();
137139 } catch (std::bad_alloc &) {
138140 return UR_RESULT_ERROR_OUT_OF_RESOURCES;
@@ -151,7 +153,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreate(
151153 CL_RETURN_ON_FAILURE (RetErr);
152154 try {
153155 auto URQueue =
154- std::make_unique<ur_queue_handle_t_>(Queue, hContext, hDevice);
156+ std::make_unique<ur_queue_handle_t_>(Queue, hContext, hDevice, InOrder );
155157 *phQueue = URQueue.release ();
156158 } catch (std::bad_alloc &) {
157159 return UR_RESULT_ERROR_OUT_OF_RESOURCES;
@@ -166,12 +168,23 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
166168 size_t propSize,
167169 void *pPropValue,
168170 size_t *pPropSizeRet) {
169- if (propName == UR_QUEUE_INFO_EMPTY) {
170- // OpenCL doesn't provide API to check the status of the queue.
171- return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
172- }
173171 cl_command_queue_info CLCommandQueueInfo = mapURQueueInfoToCL (propName);
174172 UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
173+ if (propName == UR_QUEUE_INFO_EMPTY) {
174+ if (!hQueue->LastEvent ) {
175+ // OpenCL doesn't provide API to check the status of the queue.
176+ return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
177+ } else {
178+ ur_event_status_t Status;
179+ UR_RETURN_ON_FAILURE (urEventGetInfo (
180+ hQueue->LastEvent , UR_EVENT_INFO_COMMAND_EXECUTION_STATUS,
181+ sizeof (ur_event_status_t ), (void *)&Status, nullptr ));
182+ if (Status == UR_EVENT_STATUS_COMPLETE) {
183+ return ReturnValue (true );
184+ }
185+ return ReturnValue (false );
186+ }
187+ }
175188 switch (propName) {
176189 case UR_QUEUE_INFO_CONTEXT: {
177190 return ReturnValue (hQueue->Context );
0 commit comments