17
17
18
18
#include < sycl/sycl.hpp>
19
19
20
+ #include < condition_variable>
21
+
20
22
using ::testing::HasSubstr;
21
23
using namespace sycl ;
22
24
XPTI_CALLBACK_API bool queryReceivedNotifications (uint16_t &TraceType,
@@ -460,11 +462,29 @@ TEST_F(QueueApiFailures, QueueHostTaskFail) {
460
462
Test (STD_EXCEPTION);
461
463
}
462
464
463
- TEST_F (QueueApiFailures, DISABLED_QueueKernelAsync) {
465
+ std::mutex m;
466
+ std::condition_variable cv;
467
+ bool EnqueueKernelLaunchCalled = false ;
468
+
469
+ pi_result redefinedEnqueueKernelLaunchWithStatus (
470
+ pi_queue queue, pi_kernel kernel, pi_uint32 work_dim,
471
+ const size_t *global_work_offset, const size_t *global_work_size,
472
+ const size_t *local_work_size, pi_uint32 num_events_in_wait_list,
473
+ const pi_event *event_wait_list, pi_event *event) {
474
+ {
475
+ std::lock_guard lk (m);
476
+ EnqueueKernelLaunchCalled = true ;
477
+ }
478
+ cv.notify_one ();
479
+ return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
480
+ }
481
+
482
+ TEST_F (QueueApiFailures, QueueKernelAsync) {
464
483
MockPlugin.redefine <detail::PiApiKind::piEnqueueKernelLaunch>(
465
- redefinedEnqueueKernelLaunch );
484
+ redefinedEnqueueKernelLaunchWithStatus );
466
485
MockPlugin.redefine <detail::PiApiKind::piPluginGetLastError>(
467
486
redefinedPluginGetLastError);
487
+
468
488
sycl::queue Q (default_selector (), silentAsyncHandler);
469
489
bool ExceptionCaught = false ;
470
490
event EventToDepend;
@@ -487,6 +507,7 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
487
507
ExceptionCaught = true ;
488
508
}
489
509
EXPECT_FALSE (ExceptionCaught);
510
+
490
511
try {
491
512
Q.submit (
492
513
[&](handler &Cgh) {
@@ -502,8 +523,11 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
502
523
TestLock.unlock ();
503
524
504
525
// Need to wait till host task enqueue kernel to check code location report.
505
- using namespace std ::chrono_literals;
506
- std::this_thread::sleep_for (10ms);
526
+ {
527
+ std::unique_lock lk (m);
528
+ cv.wait (lk, [] { return EnqueueKernelLaunchCalled; });
529
+ }
530
+
507
531
try {
508
532
Q.wait ();
509
533
} catch (...) {
0 commit comments