Skip to content

Commit e8ed134

Browse files
[SYCL] moving kernel_compiler sycl cache testing to its own test. (#16727)
moving kernel_compiler sycl cache testing to its own test. Also updating some of the 'unsupported-intended' information. This also increments the #include <sycl.hpp> counter, not because the new test does that (it does not), but the kernel string it contains does and that's incorrectly getting picked up by the no_sycl_in_hpp test.
1 parent f12546b commit e8ed134

File tree

8 files changed

+140
-59
lines changed

8 files changed

+140
-59
lines changed

sycl/test-e2e/KernelCompiler/kernel_compiler_opencl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
// REQUIRES: ocloc && (opencl || level_zero)
1010
// UNSUPPORTED: accelerator
11+
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.
1112

1213
// -- Test the kernel_compiler with OpenCL source.
1314
// RUN: %{build} -o %t.out

sycl/test-e2e/KernelCompiler/kernel_compiler_sycl.cpp

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
// REQUIRES: (opencl || level_zero)
10-
// UNSUPPORTED: accelerator
10+
// REQUIRES: aspect-usm_device_allocations
1111

12-
// Flaky timeout on CPU. Enable when fixed.
13-
// Depends on SPIR-V Backend & run-time drivers version.
14-
// UNSUPPORTED: spirv-backend && cpu
15-
// UNSUPPORTED-TRACKER: CMPLRLLVM-64705
12+
// UNSUPPORTED: accelerator
13+
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.
1614

1715
// -- Test the kernel_compiler with SYCL source.
1816
// RUN: %{build} -o %t.out
@@ -23,28 +21,6 @@
2321
// RUN: %{run} %t.out
2422
// RUN: %{l0_leak_check} %{run} %t.out
2523

26-
// -- Test again, with caching.
27-
// 'reading-from-cache' is just a string we pass to differentiate between the
28-
// two runs.
29-
30-
// DEFINE: %{cache_vars} = %{l0_leak_check} env SYCL_CACHE_PERSISTENT=1 SYCL_CACHE_TRACE=5 SYCL_CACHE_DIR=%t/cache_dir
31-
// RUN: rm -rf %t/cache_dir
32-
// RUN: %{cache_vars} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-WRITTEN-TO-CACHE
33-
// RUN: %{cache_vars} %t.out reading-from-cache 2>&1 | FileCheck %s --check-prefixes=CHECK-READ-FROM-CACHE
34-
35-
// -- Add leak check.
36-
// RUN: rm -rf %t/cache_dir
37-
// RUN: %{l0_leak_check} %{cache_vars} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-WRITTEN-TO-CACHE
38-
// RUN: %{l0_leak_check} %{cache_vars} %t.out reading-from-cache 2>&1 | FileCheck %s --check-prefixes=CHECK-READ-FROM-CACHE
39-
40-
// CHECK-WRITTEN-TO-CACHE: [Persistent Cache]: enabled
41-
// CHECK-WRITTEN-TO-CACHE-NOT: [kernel_compiler Persistent Cache]: using cached binary
42-
// CHECK-WRITTEN-TO-CACHE: [kernel_compiler Persistent Cache]: binary has been cached
43-
44-
// CHECK-READ-FROM-CACHE: [Persistent Cache]: enabled
45-
// CHECK-READ-FROM-CACHE-NOT: [kernel_compiler Persistent Cache]: binary has been cached
46-
// CHECK-READ-FROM-CACHE: [kernel_compiler Persistent Cache]: using cached binary
47-
4824
#include <sycl/detail/core.hpp>
4925
#include <sycl/kernel_bundle.hpp>
5026
#include <sycl/usm.hpp>
@@ -149,7 +125,7 @@ void test_1(sycl::queue &Queue, sycl::kernel &Kernel, int seed) {
149125
sycl::free(usmPtr, Queue);
150126
}
151127

152-
void test_build_and_run(bool readingFromCache) {
128+
void test_build_and_run() {
153129
namespace syclex = sycl::ext::oneapi::experimental;
154130
using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
155131
using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
@@ -192,12 +168,8 @@ void test_build_and_run(bool readingFromCache) {
192168
syclex::properties{syclex::build_options{flags}, syclex::save_log{&log},
193169
syclex::registered_kernel_names{"ff_templated<int>"}});
194170

195-
// If the kernel was restored from cache, there will not have been
196-
// any warning issued by the compilation of the kernel.
197-
if (!readingFromCache) {
198-
assert(log.find("warning: 'this_nd_item<1>' is deprecated") !=
199-
std::string::npos);
200-
}
171+
assert(log.find("warning: 'this_nd_item<1>' is deprecated") !=
172+
std::string::npos);
201173

202174
// clang-format off
203175

@@ -311,23 +283,8 @@ void test_esimd() {
311283
}
312284

313285
int main(int argc, char *argv[]) {
314-
namespace syclex = sycl::ext::oneapi::experimental;
315-
bool readingFromCache = false;
316-
317-
// Check if the argument is present
318-
if (argc > 1) {
319-
std::string argument(argv[1]);
320-
if (argument == "reading-from-cache") {
321-
readingFromCache = true;
322-
} else if (argument == "available") {
323-
sycl::device d;
324-
bool avail = d.ext_oneapi_can_compile(syclex::source_language::sycl);
325-
return avail;
326-
}
327-
}
328-
329286
#ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
330-
test_build_and_run(readingFromCache);
287+
test_build_and_run();
331288
test_error();
332289
test_esimd();
333290
#else

sycl/test-e2e/KernelCompiler/kernel_compiler_sycl_jit.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
// REQUIRES: (opencl || level_zero)
10+
// REQUIRES: aspect-usm_device_allocations
11+
1012
// UNSUPPORTED: accelerator
13+
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.
1114

1215
// RUN: %{build} -o %t.out
1316
// RUN: %{run} %t.out 1

sycl/test-e2e/KernelCompiler/multi_device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// REQUIRES: (opencl || level_zero) && ocloc
22
// UNSUPPORTED: accelerator
3+
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.
34

45
// RUN: %{build} -o %t.out
56
// RUN: env NEOReadDebugKeys=1 CreateMultipleRootDevices=3 %{run} %t.out
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//==- sycl_and_cache.cpp - cache works with kernel_compiler sycl ----------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: (opencl || level_zero)
10+
// REQUIRES: aspect-usm_device_allocations
11+
12+
// UNSUPPORTED: accelerator
13+
// UNSUPPORTED-INTENDED: while accelerator is AoT only, this cannot run there.
14+
15+
// -- Test the kernel_compiler with SYCL source.
16+
// RUN: %{build} -o %t.out
17+
18+
// -- Run with caching.
19+
20+
// DEFINE: %{cache_vars} = %{l0_leak_check} env SYCL_CACHE_PERSISTENT=1 SYCL_CACHE_TRACE=5 SYCL_CACHE_DIR=%t/cache_dir
21+
// RUN: rm -rf %t/cache_dir
22+
// RUN: %{cache_vars} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-WRITTEN-TO-CACHE
23+
// RUN: %{cache_vars} %t.out 2>&1 | FileCheck %s --check-prefixes=CHECK-READ-FROM-CACHE
24+
25+
// CHECK-WRITTEN-TO-CACHE: [Persistent Cache]: enabled
26+
// CHECK-WRITTEN-TO-CACHE-NOT: [kernel_compiler Persistent Cache]: using cached binary
27+
// CHECK-WRITTEN-TO-CACHE: [kernel_compiler Persistent Cache]: binary has been cached
28+
29+
// CHECK-READ-FROM-CACHE: [Persistent Cache]: enabled
30+
// CHECK-READ-FROM-CACHE-NOT: [kernel_compiler Persistent Cache]: binary has been cached
31+
// CHECK-READ-FROM-CACHE: [kernel_compiler Persistent Cache]: using cached binary
32+
33+
#include <sycl/detail/core.hpp>
34+
#include <sycl/kernel_bundle.hpp>
35+
#include <sycl/usm.hpp>
36+
37+
// TODO: remove SYCL_EXTERNAL once it is no longer needed.
38+
auto constexpr SYCLSource = R"===(
39+
#include <sycl/sycl.hpp>
40+
41+
int AddEm(int a, int b){
42+
return a + b + 5;
43+
}
44+
45+
// use extern "C" to avoid name mangling
46+
extern "C" SYCL_EXTERNAL SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((sycl::ext::oneapi::experimental::nd_range_kernel<1>))
47+
void ff_cp(int *ptr) {
48+
49+
// intentionally using deprecated routine, as opposed to this_work_item::get_nd_item<1>()
50+
sycl::nd_item<1> Item = sycl::ext::oneapi::experimental::this_nd_item<1>();
51+
52+
sycl::id<1> GId = Item.get_global_id();
53+
ptr[GId.get(0)] = AddEm(GId.get(0), 37);
54+
}
55+
)===";
56+
57+
void test_1(sycl::queue &Queue, sycl::kernel &Kernel, int seed) {
58+
constexpr int Range = 10;
59+
int *usmPtr = sycl::malloc_shared<int>(Range, Queue);
60+
int start = 3;
61+
62+
sycl::nd_range<1> R1{{Range}, {1}};
63+
64+
bool Passa = true;
65+
66+
memset(usmPtr, 0, Range * sizeof(int));
67+
Queue.submit([&](sycl::handler &Handler) {
68+
Handler.set_arg(0, usmPtr);
69+
Handler.parallel_for(R1, Kernel);
70+
});
71+
Queue.wait();
72+
73+
for (int i = 0; i < Range; i++) {
74+
std::cout << usmPtr[i] << "=" << (i + seed) << " ";
75+
assert(usmPtr[i] == i + seed);
76+
}
77+
std::cout << std::endl;
78+
79+
sycl::free(usmPtr, Queue);
80+
}
81+
82+
void test_build_and_run() {
83+
namespace syclex = sycl::ext::oneapi::experimental;
84+
using source_kb = sycl::kernel_bundle<sycl::bundle_state::ext_oneapi_source>;
85+
using exe_kb = sycl::kernel_bundle<sycl::bundle_state::executable>;
86+
87+
sycl::queue q;
88+
sycl::context ctx = q.get_context();
89+
90+
bool ok =
91+
q.get_device().ext_oneapi_can_compile(syclex::source_language::sycl);
92+
if (!ok) {
93+
std::cout << "Apparently this device does not support SYCL source "
94+
"kernel bundle extension: "
95+
<< q.get_device().get_info<sycl::info::device::name>()
96+
<< std::endl;
97+
return;
98+
}
99+
100+
// Create from source.
101+
source_kb kbSrc = syclex::create_kernel_bundle_from_source(
102+
ctx, syclex::source_language::sycl, SYCLSource);
103+
104+
// Compilation of empty prop list, no devices.
105+
exe_kb kbExe = syclex::build(kbSrc);
106+
107+
// extern "C" was used, so the name "ff_cp" is not mangled and can be used
108+
// directly.
109+
sycl::kernel k = kbExe.ext_oneapi_get_kernel("ff_cp");
110+
111+
// Test the kernels.
112+
test_1(q, k, 37 + 5); // ff_cp seeds 37. AddEm will add 5 more.
113+
}
114+
115+
int main(int argc, char *argv[]) {
116+
117+
#ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
118+
test_build_and_run();
119+
#else
120+
static_assert(false, "Kernel Compiler feature test macro undefined");
121+
#endif
122+
return 0;
123+
}

sycl/test-e2e/KernelCompiler/sycl_device_flags.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
// REQUIRES: level_zero
10-
// UNSUPPORTED: windows
10+
// REQUIRES: aspect-usm_device_allocations
1111

12-
// IGC shader dump not available on Windows.
12+
// UNSUPPORTED: windows
13+
// UNSUPPORTED-INTENDED: IGC shader dump not available on Windows.
1314

1415
// RUN: %{build} -o %t.out
1516
// RUN: env IGC_DumpToCustomDir=%T.dump IGC_ShaderDumpEnable=1 NEO_CACHE_PERSISTENT=0 %{run} %t.out %T.dump/

sycl/test/e2e_test_requirements/no-unsupported-without-info.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
// tests to match the required format and in that case you should just update
5555
// (i.e. reduce) the number and the list below.
5656
//
57-
// NUMBER-OF-UNSUPPORTED-WITHOUT-INFO: 414
57+
// NUMBER-OF-UNSUPPORTED-WITHOUT-INFO: 409
5858
//
5959
// List of improperly UNSUPPORTED tests.
6060
// Remove the CHECK once the test has been properly UNSUPPORTED.
@@ -283,11 +283,6 @@
283283
// CHECK-NEXT: KernelAndProgram/spec_constants_after_link.cpp
284284
// CHECK-NEXT: KernelAndProgram/spec_constants_after_link.cpp
285285
// CHECK-NEXT: KernelAndProgram/undefined-symbol.cpp
286-
// CHECK-NEXT: KernelCompiler/kernel_compiler_opencl.cpp
287-
// CHECK-NEXT: KernelCompiler/kernel_compiler_sycl.cpp
288-
// CHECK-NEXT: KernelCompiler/kernel_compiler_sycl_jit.cpp
289-
// CHECK-NEXT: KernelCompiler/multi_device.cpp
290-
// CHECK-NEXT: KernelCompiler/sycl_device_flags.cpp
291286
// CHECK-NEXT: LLVMIntrinsicLowering/bitreverse.cpp
292287
// CHECK-NEXT: LLVMIntrinsicLowering/sub_byte_bitreverse.cpp
293288
// CHECK-NEXT: Matrix/SG32/element_wise_abc.cpp

sycl/test/e2e_test_requirements/no_sycl_hpp_in_e2e_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// CHECK-DAG: README.md
77
// CHECK-DAG: lit.cfg.py
88
//
9-
// CHECK-NUM-MATCHES: 5
9+
// CHECK-NUM-MATCHES: 6
1010
//
1111
// This test verifies that `<sycl/sycl.hpp>` isn't used in E2E tests. Instead,
1212
// fine-grained includes should used, see

0 commit comments

Comments
 (0)