@@ -351,7 +351,8 @@ extern "C" {
351
351
std::cerr << " Warning : Not Implemented : " << __FUNCTION__ \
352
352
<< " - File : " << __FILE__; \
353
353
std::cerr << " / Line : " << __LINE__ << std::endl; \
354
- }
354
+ } \
355
+ return PI_SUCCESS;
355
356
356
357
pi_result piPlatformsGet (pi_uint32 NumEntries, pi_platform *Platforms,
357
358
pi_uint32 *NumPlatforms) {
@@ -684,6 +685,12 @@ pi_result piContextRelease(pi_context Context) {
684
685
685
686
pi_result piQueueCreate (pi_context Context, pi_device Device,
686
687
pi_queue_properties Properties, pi_queue *Queue) {
688
+ if (Properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) {
689
+ // TODO : Support Out-of-order Queue
690
+ *Queue = nullptr ;
691
+ return PI_INVALID_QUEUE_PROPERTIES;
692
+ }
693
+
687
694
cm_support::CmQueue *CmQueue;
688
695
689
696
int Result = Context->Device ->CmDevicePtr ->CreateQueue (CmQueue);
@@ -729,7 +736,10 @@ pi_result piQueueRelease(pi_queue Queue) {
729
736
}
730
737
731
738
pi_result piQueueFinish (pi_queue) {
732
- DIE_NO_IMPLEMENTATION;
739
+ // No-op as enqueued commands with ESIMD_CPU plugin are blocking
740
+ // ones that do not return until their completion - kernel execution
741
+ // and memory read.
742
+ CONTINUE_NO_IMPLEMENTATION;
733
743
}
734
744
735
745
pi_result piextQueueGetNativeHandle (pi_queue, pi_native_handle *) {
@@ -1190,6 +1200,12 @@ pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src,
1190
1200
1191
1201
_pi_buffer *buf = static_cast <_pi_buffer *>(Src);
1192
1202
1203
+ std::unique_ptr<_pi_event> RetEv{nullptr };
1204
+ if (Event) {
1205
+ RetEv = std::unique_ptr<_pi_event>(new _pi_event ());
1206
+ RetEv->IsDummyEvent = true ;
1207
+ }
1208
+
1193
1209
int Status =
1194
1210
buf->CmBufferPtr ->ReadSurface (reinterpret_cast <unsigned char *>(Dst),
1195
1211
nullptr , // event
@@ -1200,18 +1216,7 @@ pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src,
1200
1216
}
1201
1217
1202
1218
if (Event) {
1203
- try {
1204
- *Event = new _pi_event ();
1205
- } catch (const std::bad_alloc &) {
1206
- return PI_OUT_OF_HOST_MEMORY;
1207
- } catch (...) {
1208
- return PI_ERROR_UNKNOWN;
1209
- }
1210
-
1211
- // At this point, CM already completed buffer-read (ReadSurface)
1212
- // operation. Therefore, 'event' corresponding to this operation
1213
- // is marked as dummy one and ignored during events-waiting.
1214
- (*Event)->IsDummyEvent = true ;
1219
+ *Event = RetEv.release ();
1215
1220
}
1216
1221
1217
1222
return PI_SUCCESS;
@@ -1286,6 +1291,14 @@ pi_result piEnqueueMemImageRead(pi_queue CommandQueue, pi_mem Image,
1286
1291
assert (false && " ESIMD_CPU does not support Blocking Read" );
1287
1292
}
1288
1293
_pi_image *PiImg = static_cast <_pi_image *>(Image);
1294
+
1295
+ std::unique_ptr<_pi_event> RetEv{nullptr };
1296
+
1297
+ if (Event) {
1298
+ RetEv = std::unique_ptr<_pi_event>(new _pi_event ());
1299
+ RetEv->IsDummyEvent = true ;
1300
+ }
1301
+
1289
1302
int Status =
1290
1303
PiImg->CmSurfacePtr ->ReadSurface (reinterpret_cast <unsigned char *>(Ptr),
1291
1304
nullptr , // event
@@ -1295,18 +1308,7 @@ pi_result piEnqueueMemImageRead(pi_queue CommandQueue, pi_mem Image,
1295
1308
}
1296
1309
1297
1310
if (Event) {
1298
- try {
1299
- *Event = new _pi_event ();
1300
- } catch (const std::bad_alloc &) {
1301
- return PI_OUT_OF_HOST_MEMORY;
1302
- } catch (...) {
1303
- return PI_ERROR_UNKNOWN;
1304
- }
1305
-
1306
- // At this point, CM already completed image-read (ReadSurface)
1307
- // operation. Therefore, 'event' corresponding to this operation
1308
- // is marked as dummy one and ignored during events-waiting.
1309
- (*Event)->IsDummyEvent = true ;
1311
+ *Event = RetEv.release ();
1310
1312
}
1311
1313
return PI_SUCCESS;
1312
1314
}
@@ -1360,25 +1362,39 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim,
1360
1362
}
1361
1363
}
1362
1364
1365
+ std::unique_ptr<_pi_event> RetEv{nullptr };
1366
+
1367
+ if (Event) {
1368
+ RetEv = std::unique_ptr<_pi_event>(new _pi_event ());
1369
+ RetEv->IsDummyEvent = true ;
1370
+ }
1371
+
1363
1372
switch (WorkDim) {
1364
1373
case 1 :
1365
1374
InvokeImpl<1 >::invoke (Kernel, GlobalWorkOffset, GlobalWorkSize,
1366
1375
LocalWorkSize);
1367
- return PI_SUCCESS ;
1376
+ break ;
1368
1377
1369
1378
case 2 :
1370
1379
InvokeImpl<2 >::invoke (Kernel, GlobalWorkOffset, GlobalWorkSize,
1371
1380
LocalWorkSize);
1372
- return PI_SUCCESS ;
1381
+ break ;
1373
1382
1374
1383
case 3 :
1375
1384
InvokeImpl<3 >::invoke (Kernel, GlobalWorkOffset, GlobalWorkSize,
1376
1385
LocalWorkSize);
1377
- return PI_SUCCESS ;
1386
+ break ;
1378
1387
1379
1388
default :
1380
1389
DIE_NO_IMPLEMENTATION;
1390
+ break ;
1381
1391
}
1392
+
1393
+ if (Event) {
1394
+ *Event = RetEv.release ();
1395
+ }
1396
+
1397
+ return PI_SUCCESS;
1382
1398
}
1383
1399
1384
1400
pi_result piextKernelCreateWithNativeHandle (pi_native_handle, pi_context, bool ,
0 commit comments