Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 8a5cbce

Browse files
authored
[SYCL] Add test to check correct diagnostics for invalid wgsize (#1611)
Add tests for new improved diagnostics introduced in intel/llvm#8378.
1 parent ecf4ccc commit 8a5cbce

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

SYCL/Basic/gpu_max_wgs_error.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out -fno-sycl-id-queries-fit-in-int
2+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
3+
4+
#include <numeric>
5+
#include <sycl/sycl.hpp>
6+
7+
using namespace sycl;
8+
9+
const std::string expected_msg =
10+
"Total number of work-items in a work-group cannot exceed";
11+
12+
template <int N>
13+
void check(range<N> global, range<N> local, bool expect_fail = false) {
14+
queue q;
15+
try {
16+
q.submit([&](handler &cgh) {
17+
cgh.parallel_for(nd_range<N>(global, local), [=](nd_item<N> item) {});
18+
});
19+
assert(!expect_fail && "Exception expected");
20+
} catch (nd_range_error e) {
21+
if (expect_fail) {
22+
std::string msg = e.what();
23+
assert(msg.rfind(expected_msg, 0) == 0 && "Unexpected error message");
24+
} else {
25+
throw e;
26+
}
27+
}
28+
}
29+
30+
int main() {
31+
queue q;
32+
device d = q.get_device();
33+
id<2> max_2 = d.get_info<sycl::info::device::max_work_item_sizes<2>>();
34+
check(range<2>(max_2[0], max_2[1]), range<2>(max_2[0], max_2[1]), true);
35+
36+
id<3> max_3 = d.get_info<sycl::info::device::max_work_item_sizes<3>>();
37+
check(range<3>(max_3[0], max_3[1], max_3[2]),
38+
range<3>(max_3[0], max_3[1], max_3[2]), true);
39+
}

0 commit comments

Comments
 (0)