Skip to content

Commit 54fcf80

Browse files
[SYCL] Fix and reenable unit test for xpti_trace (#9587)
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent 1dce70f commit 54fcf80

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

sycl/unittests/xpti_trace/QueueApiFailures.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include <sycl/sycl.hpp>
1919

20+
#include <condition_variable>
21+
2022
using ::testing::HasSubstr;
2123
using namespace sycl;
2224
XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType,
@@ -460,11 +462,29 @@ TEST_F(QueueApiFailures, QueueHostTaskFail) {
460462
Test(STD_EXCEPTION);
461463
}
462464

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) {
464483
MockPlugin.redefine<detail::PiApiKind::piEnqueueKernelLaunch>(
465-
redefinedEnqueueKernelLaunch);
484+
redefinedEnqueueKernelLaunchWithStatus);
466485
MockPlugin.redefine<detail::PiApiKind::piPluginGetLastError>(
467486
redefinedPluginGetLastError);
487+
468488
sycl::queue Q(default_selector(), silentAsyncHandler);
469489
bool ExceptionCaught = false;
470490
event EventToDepend;
@@ -487,6 +507,7 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
487507
ExceptionCaught = true;
488508
}
489509
EXPECT_FALSE(ExceptionCaught);
510+
490511
try {
491512
Q.submit(
492513
[&](handler &Cgh) {
@@ -502,8 +523,11 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
502523
TestLock.unlock();
503524

504525
// 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+
507531
try {
508532
Q.wait();
509533
} catch (...) {

0 commit comments

Comments
 (0)