Skip to content

[SYCL] Fix and reenable unit test for xpti_trace #9587

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

Merged
merged 4 commits into from
Jun 1, 2023
Merged
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
32 changes: 28 additions & 4 deletions sycl/unittests/xpti_trace/QueueApiFailures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <sycl/sycl.hpp>

#include <condition_variable>

using ::testing::HasSubstr;
using namespace sycl;
XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType,
Expand Down Expand Up @@ -461,11 +463,29 @@ TEST_F(QueueApiFailures, QueueHostTaskFail) {
Test(STD_EXCEPTION);
}

TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
std::mutex m;
std::condition_variable cv;
bool EnqueueKernelLaunchCalled = false;

pi_result redefinedEnqueueKernelLaunchWithStatus(
pi_queue queue, pi_kernel kernel, pi_uint32 work_dim,
const size_t *global_work_offset, const size_t *global_work_size,
const size_t *local_work_size, pi_uint32 num_events_in_wait_list,
const pi_event *event_wait_list, pi_event *event) {
{
std::lock_guard lk(m);
EnqueueKernelLaunchCalled = true;
}
cv.notify_one();
return PI_ERROR_PLUGIN_SPECIFIC_ERROR;
}

TEST_F(QueueApiFailures, QueueKernelAsync) {
MockPlugin.redefine<detail::PiApiKind::piEnqueueKernelLaunch>(
redefinedEnqueueKernelLaunch);
redefinedEnqueueKernelLaunchWithStatus);
MockPlugin.redefine<detail::PiApiKind::piPluginGetLastError>(
redefinedPluginGetLastError);

sycl::queue Q(default_selector(), silentAsyncHandler);
bool ExceptionCaught = false;
event EventToDepend;
Expand All @@ -488,6 +508,7 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
ExceptionCaught = true;
}
EXPECT_FALSE(ExceptionCaught);

try {
Q.submit(
[&](handler &Cgh) {
Expand All @@ -503,8 +524,11 @@ TEST_F(QueueApiFailures, DISABLED_QueueKernelAsync) {
TestLock.unlock();

// Need to wait till host task enqueue kernel to check code location report.
using namespace std::chrono_literals;
std::this_thread::sleep_for(10ms);
{
std::unique_lock lk(m);
cv.wait(lk, [] { return EnqueueKernelLaunchCalled; });
}

try {
Q.wait();
} catch (...) {
Expand Down