-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL] Rewrite some E2E tests into unit-tests #15877
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| // REQUIRES: gpu && linux && (opencl || level_zero) | ||
|
|
||
| // RUN: %{build} -o %t.out | ||
| // RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 SYCL_UR_TRACE=2 %{run} %t.out | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 %{run} %t.out | ||
|
|
||
| // Test to check that we can compile and link a kernel bundle for multiple | ||
| // devices and run the kernel on each device. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,3 +119,20 @@ TEST(KernelBuildOptions, KernelBundleBasic) { | |
| auto LinkBundle = sycl::link(ObjBundle, ObjBundle.get_devices()); | ||
| EXPECT_EQ(BuildOpts, "-link-img"); | ||
| } | ||
|
|
||
| TEST(KernelBuildOptions, ESIMDParallelForBasic) { | ||
| sycl::unittest::UrMock<> Mock; | ||
| sycl::platform Plt = sycl::platform(); | ||
| setupCommonMockAPIs(Mock); | ||
|
|
||
| const sycl::device Dev = Plt.get_devices()[0]; | ||
| sycl::queue Queue{Dev}; | ||
|
|
||
| Queue.submit([&](sycl::handler &cgh) { | ||
| cgh.parallel_for<BuildOptsTestKernel>( | ||
| sycl::range{1024}, [=](sycl::id<1>) /* SYCL_ESIMD_KERNEL */ {}); | ||
| }); | ||
|
|
||
| EXPECT_EQ(BuildOpts, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow cool! |
||
| "-compile-img -vc-codegen -disable-finalizer-msg -link-img"); | ||
| } | ||
| 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); | ||
| } |
| 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 | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for ESIMD reviewers: even though the test also does some computations in kernels, I assume that they are not unique to this test and was merely done to avoid submitting an empty kernel or just by copying an existing test as a baseline.
Therefore, I'm completely removing it in favor of unit-test-level checks that we pass the right JIT compilation flag down to UR program build APIs.
Please speak up if you disagree and the test should still be preserved for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the computation is definitely not important, the point of the test is to check the flag to IGC.