forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Rewrite some E2E tests into unit-tests (intel#15877)
The main idea behind this (and other PRs I will eventually submit) is that we shouldn't use `SYCL_UR_TRACE` in our unit-tests unless absolutely necessary (like testing shutdown sequence). The reason behind this is the fact that we have unit-tests infrastructure which is more than capable of ensuring that we called the right UR APIs with the right arguments. There is no need to waste our CI time on compiling and running the same test on different devices if we can easily test the same via our UR mock infrastructure.
- Loading branch information
1 parent
4add105
commit dd7446c
Showing
6 changed files
with
119 additions
and
160 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
sycl/test-e2e/ProgramManager/multi_device_bundle/compile_link.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
//==------------------- Barrier.cpp --- queue unit tests -------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <helpers/TestKernel.hpp> | ||
#include <helpers/UrMock.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
static unsigned NumOfEventsWaitWithBarrierCalls = 0; | ||
|
||
static ur_result_t redefined_urEnqueueEventsWaitWithBarrier(void *) { | ||
NumOfEventsWaitWithBarrierCalls++; | ||
|
||
return UR_RESULT_SUCCESS; | ||
} | ||
|
||
TEST(Queue, HandlerBarrier) { | ||
sycl::unittest::UrMock<> Mock; | ||
mock::getCallbacks().set_before_callback( | ||
"urEnqueueEventsWaitWithBarrier", | ||
&redefined_urEnqueueEventsWaitWithBarrier); | ||
NumOfEventsWaitWithBarrierCalls = 0; | ||
|
||
sycl::queue Q; | ||
|
||
Q.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
Q.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
|
||
Q.submit([&](sycl::handler &cgh) { cgh.ext_oneapi_barrier(); }); | ||
|
||
ASSERT_EQ(NumOfEventsWaitWithBarrierCalls, 1u); | ||
} | ||
|
||
TEST(Queue, ExtOneAPISubmitBarrier) { | ||
sycl::unittest::UrMock<> Mock; | ||
mock::getCallbacks().set_before_callback( | ||
"urEnqueueEventsWaitWithBarrier", | ||
&redefined_urEnqueueEventsWaitWithBarrier); | ||
NumOfEventsWaitWithBarrierCalls = 0; | ||
|
||
sycl::queue Q; | ||
|
||
Q.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
Q.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
|
||
Q.ext_oneapi_submit_barrier(); | ||
|
||
ASSERT_EQ(NumOfEventsWaitWithBarrierCalls, 1u); | ||
} | ||
|
||
TEST(Queue, HandlerBarrierWithWaitList) { | ||
sycl::unittest::UrMock<> Mock; | ||
mock::getCallbacks().set_before_callback( | ||
"urEnqueueEventsWaitWithBarrier", | ||
&redefined_urEnqueueEventsWaitWithBarrier); | ||
NumOfEventsWaitWithBarrierCalls = 0; | ||
|
||
sycl::queue Q1; | ||
sycl::queue Q2; | ||
sycl::queue Q3; | ||
|
||
auto E1 = Q1.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
auto E2 = Q2.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
|
||
Q3.submit([&](sycl::handler &cgh) { cgh.ext_oneapi_barrier({E1, E2}); }); | ||
|
||
ASSERT_EQ(NumOfEventsWaitWithBarrierCalls, 1u); | ||
} | ||
|
||
TEST(Queue, ExtOneAPISubmitBarrierWithWaitList) { | ||
sycl::unittest::UrMock<> Mock; | ||
mock::getCallbacks().set_before_callback( | ||
"urEnqueueEventsWaitWithBarrier", | ||
&redefined_urEnqueueEventsWaitWithBarrier); | ||
NumOfEventsWaitWithBarrierCalls = 0; | ||
|
||
sycl::queue Q1; | ||
sycl::queue Q2; | ||
sycl::queue Q3; | ||
|
||
auto E1 = Q1.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
auto E2 = Q2.submit( | ||
[&](sycl::handler &cgh) { cgh.single_task<TestKernel<1>>([=]() {}); }); | ||
|
||
Q3.ext_oneapi_submit_barrier({E1, E2}); | ||
|
||
ASSERT_EQ(NumOfEventsWaitWithBarrierCalls, 1u); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ add_sycl_unittest(QueueTests OBJECT | |
InOrderQueue.cpp | ||
InteropRetain.cpp | ||
Properties.cpp | ||
Barrier.cpp | ||
) |