Skip to content

Commit 6a19720

Browse files
[SYCL] Added regression test for non uniform work group size. (#2681)
Signed-off-by: Eugene T Damiba <eugene.t.damiba@intel.com> Co-authored-by: Alexander Batashev <alexbatashev@outlook.com>
1 parent 28df843 commit 6a19720

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
3+
// XFAIL: opencl
4+
// REQUIRES: level_zero
5+
//==------- non-uniform-wk-gp-test.cpp -------==//
6+
// This is a diagnostic test which verifies that
7+
// for loops with non-uniform work groups size
8+
// errors are handled correctly.
9+
//==------------------------------------------==//
10+
11+
#include <CL/sycl.hpp>
12+
#include <iostream>
13+
14+
using namespace cl::sycl;
15+
16+
int test() {
17+
try {
18+
queue q = queue();
19+
auto device = q.get_device();
20+
auto deviceName = device.get_info<cl::sycl::info::device::name>();
21+
std::cout << " Device Name: " << deviceName << std::endl;
22+
23+
const int N = 1;
24+
q.submit([&](handler &cgh) {
25+
cl::sycl::stream kernelout(108 * 64 + 128, 64, cgh);
26+
cgh.parallel_for<class test_kernel>(
27+
nd_range<3>(range<3>{1, 1, N}, range<3>{1, 1, 16}),
28+
[=](nd_item<3> itm) {
29+
kernelout << "Coordinates: " << itm.get_global_id()
30+
<< cl::sycl::endl;
31+
});
32+
});
33+
34+
} catch (sycl::runtime_error &E) {
35+
if (std::string(E.what()).find(
36+
"Specified local size doesn't match the required work-group size "
37+
"specified in the program source") != std::string::npos) {
38+
std::cout << E.what() << std::endl;
39+
std::cout << "Test passed: caught the expected error." << std::endl;
40+
return 0;
41+
} else {
42+
std::cout << E.what() << std::endl;
43+
std::cout << "Test failed: received error is incorrect." << std::endl;
44+
return 1;
45+
}
46+
}
47+
48+
std::cout << "Test passed: results are correct." << std::endl;
49+
return 0;
50+
}
51+
52+
int main() {
53+
54+
int pltCount = 0, ret;
55+
for (const auto &plt : platform::get_platforms()) {
56+
if (!plt.has(aspect::host)) {
57+
std::cout << "Platform #" << pltCount++ << ":" << std::endl;
58+
if (plt.get_backend() == backend::level_zero) {
59+
std::cout << "Backend: Level Zero" << std::endl;
60+
ret = test();
61+
}
62+
}
63+
std::cout << std::endl;
64+
}
65+
return 0;
66+
}

0 commit comments

Comments
 (0)