Skip to content

Commit cb5ef36

Browse files
authored
[SYCL] [E2E] Fix free funcs tests (intel#17742)
This patch: * enables free function tests * re-writes them in terms of `sycl::ext::oneapi::this_work_item` (instead of, now deprecated, `sycl::ext::oneapi::experimental::this_id` and friends) * fixes build failure caused by the removal of `core_sg_supported` * removes a test from `free_function_queries.cpp` as it was only checking correct translation between old and new spelling of the extension
1 parent 94760db commit cb5ef36

File tree

3 files changed

+28
-87
lines changed

3 files changed

+28
-87
lines changed
Lines changed: 26 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// FIXME: Investigate OS-agnostic failures
2-
// UNSUPPORTED: true
31
// RUN: %{build} -o %t.out
4-
// RUN: %{run} %t.out
5-
6-
// UNSUPPORTED: windows
7-
// The failure is caused by intel/llvm#5213
2+
// With awkward sizes (such as 1030) make sure that there is no range rounding,
3+
// so `get_global_id` returns correct values.
4+
// RUN: env SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING=1 %{run} %t.out
85

96
//==- free_function_queries.cpp - SYCL free function queries test -=//
107
//
@@ -29,7 +26,7 @@ int main() {
2926

3027
{
3128
constexpr int checks_number{3};
32-
int results[checks_number]{};
29+
int results[checks_number]{41, 42, 43};
3330
{
3431
sycl::buffer<int> buf(data, sycl::range<1>(n));
3532
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
@@ -42,12 +39,12 @@ int main() {
4239
sycl::access::target::device>
4340
results_acc(results_buf.get_access<sycl::access::mode::write>(cgh));
4441
cgh.parallel_for<class IdTest>(n, [=](sycl::id<1> i) {
45-
auto that_id = sycl::ext::oneapi::experimental::this_id<1>();
46-
results_acc[0] = that_id == i;
42+
auto that_id = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
43+
results_acc[0] = that_id.get_global_id() == i;
4744

48-
auto that_item = sycl::ext::oneapi::experimental::this_item<1>();
49-
results_acc[1] = that_item.get_id() == i;
50-
results_acc[2] = that_item.get_range() == sycl::range<1>(n);
45+
auto that_item = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
46+
results_acc[1] = that_item.get_global_id() == i;
47+
results_acc[2] = that_item.get_global_range() == sycl::range<1>(n);
5148
acc[i]++;
5249
});
5350
});
@@ -63,7 +60,7 @@ int main() {
6360

6461
{
6562
constexpr int checks_number{2};
66-
int results[checks_number]{};
63+
int results[checks_number]{41, 42};
6764
{
6865
sycl::buffer<int> buf(data, sycl::range<1>(n));
6966
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
@@ -78,10 +75,10 @@ int main() {
7875
cgh.parallel_for<class ItemTest>(n, [=](auto i) {
7976
static_assert(std::is_same<decltype(i), sycl::item<1>>::value,
8077
"lambda arg type is unexpected");
81-
auto that_id = sycl::ext::oneapi::experimental::this_id<1>();
82-
results_acc[0] = i.get_id() == that_id;
83-
auto that_item = sycl::ext::oneapi::experimental::this_item<1>();
84-
results_acc[1] = i == that_item;
78+
auto that_id = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
79+
results_acc[0] = that_id.get_global_id() == i;
80+
auto that_item = sycl::ext::oneapi::this_work_item::get_nd_item<1>();
81+
results_acc[1] = that_item.get_global_id() == i;
8582
acc[i]++;
8683
});
8784
});
@@ -96,8 +93,11 @@ int main() {
9693
}
9794

9895
{
96+
// Make sure that we ignore global offset warning.
97+
#pragma GCC diagnostic push
98+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9999
constexpr int checks_number{2};
100-
int results[checks_number]{};
100+
int results[checks_number]{41, 42};
101101
{
102102
sycl::buffer<int> buf(data, sycl::range<1>(n));
103103
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
@@ -112,11 +112,13 @@ int main() {
112112
results_acc(results_buf.get_access<sycl::access::mode::write>(cgh));
113113
cgh.parallel_for<class ItemOffsetTest>(
114114
sycl::range<1>{n}, offset, [=](sycl::item<1, true> i) {
115-
auto that_id = sycl::ext::oneapi::experimental::this_id<1>();
116-
results_acc[0] = i.get_id() == that_id;
117-
auto that_item = sycl::ext::oneapi::experimental::this_item<1>();
118-
results_acc[1] = i == that_item;
119-
acc[that_item.get_linear_id()]++;
115+
auto that_id =
116+
sycl::ext::oneapi::this_work_item::get_nd_item<1>();
117+
results_acc[0] = i.get_id() == that_id.get_global_id();
118+
auto that_item =
119+
sycl::ext::oneapi::this_work_item::get_nd_item<1>();
120+
results_acc[1] = i == that_item.get_global_id();
121+
acc[that_item.get_global_linear_id()]++;
120122
});
121123
});
122124
}
@@ -127,51 +129,6 @@ int main() {
127129
for (auto val : results) {
128130
assert(val == 1);
129131
}
130-
}
131-
132-
{
133-
constexpr int checks_number{5};
134-
int results[checks_number]{};
135-
{
136-
sycl::buffer<int> buf(data, sycl::range<1>(n));
137-
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
138-
sycl::queue q;
139-
sycl::nd_range<1> NDR(sycl::range<1>{n}, sycl::range<1>{2});
140-
q.submit([&](sycl::handler &cgh) {
141-
sycl::accessor<int, 1, sycl::access::mode::write,
142-
sycl::access::target::device>
143-
acc(buf.get_access<sycl::access::mode::write>(cgh));
144-
sycl::accessor<int, 1, sycl::access::mode::write,
145-
sycl::access::target::device>
146-
results_acc(results_buf.get_access<sycl::access::mode::write>(cgh));
147-
cgh.parallel_for<class NdItemTest>(NDR, [=](auto nd_i) {
148-
static_assert(std::is_same<decltype(nd_i), sycl::nd_item<1>>::value,
149-
"lambda arg type is unexpected");
150-
auto that_nd_item =
151-
sycl::ext::oneapi::this_work_item::get_nd_item<1>();
152-
results_acc[0] = that_nd_item == nd_i;
153-
auto nd_item_group = that_nd_item.get_group();
154-
results_acc[1] =
155-
nd_item_group ==
156-
sycl::ext::oneapi::this_work_item::get_work_group<1>();
157-
auto nd_item_id = that_nd_item.get_global_id();
158-
results_acc[2] =
159-
nd_item_id == sycl::ext::oneapi::experimental::this_id<1>();
160-
auto that_item = sycl::ext::oneapi::experimental::this_item<1>();
161-
results_acc[3] = nd_item_id == that_item.get_id();
162-
results_acc[4] =
163-
that_nd_item.get_global_range() == that_item.get_range();
164-
165-
acc[that_nd_item.get_global_id(0)]++;
166-
});
167-
});
168-
}
169-
++counter;
170-
for (int i = 0; i < n; i++) {
171-
assert(data[i] == counter);
172-
}
173-
for (auto val : results) {
174-
assert(val == 1);
175-
}
132+
#pragma GCC diagnostic pop
176133
}
177134
}

sycl/test-e2e/Basic/free_function_queries/free_function_queries_sub_group.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
// FIXME: Investigate OS-agnostic failures
2-
// UNSUPPORTED: true
3-
// UNSUPPORTED: cuda || hip
4-
// CUDA and HIP compilation and runtime do not yet support sub-groups.
5-
//
61
// RUN: %{build} -o %t.out
72
// RUN: %{run} %t.out
83

9-
// UNSUPPORTED: windows
10-
// The failure is caused by intel/llvm#5213
11-
124
//==- free_function_queries_sub_group.cpp - SYCL free queries for sub group -=//
135
//
146
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -31,15 +23,11 @@ int main() {
3123
int counter{0};
3224
{
3325
constexpr int checks_number{4};
34-
int results[checks_number]{};
26+
int results[checks_number]{41, 42, 43, 44};
3527
{
3628
sycl::buffer<int> buf(data, sycl::range<1>(n));
3729
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
3830
sycl::queue q;
39-
if (!core_sg_supported(q.get_device())) {
40-
std::cout << "Skipping test" << std::endl;
41-
return 0;
42-
}
4331
sycl::nd_range<1> NDR(sycl::range<1>{n}, sycl::range<1>{2});
4432
q.submit([&](sycl::handler &cgh) {
4533
sycl::accessor<int, 1, sycl::access::mode::write,

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

Lines changed: 1 addition & 5 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: 280
57+
// NUMBER-OF-UNSUPPORTED-WITHOUT-INFO: 276
5858
//
5959
// List of improperly UNSUPPORTED tests.
6060
// Remove the CHECK once the test has been properly UNSUPPORTED.
@@ -86,10 +86,6 @@
8686
// CHECK-NEXT: Assert/check_resource_leak.cpp
8787
// CHECK-NEXT: Basic/buffer/buffer_create.cpp
8888
// CHECK-NEXT: Basic/build_log.cpp
89-
// CHECK-NEXT: Basic/free_function_queries/free_function_queries.cpp
90-
// CHECK-NEXT: Basic/free_function_queries/free_function_queries.cpp
91-
// CHECK-NEXT: Basic/free_function_queries/free_function_queries_sub_group.cpp
92-
// CHECK-NEXT: Basic/free_function_queries/free_function_queries_sub_group.cpp
9389
// CHECK-NEXT: Basic/gpu_max_wgs_error.cpp
9490
// CHECK-NEXT: Basic/group_async_copy.cpp
9591
// CHECK-NEXT: Basic/host-task-dependency.cpp

0 commit comments

Comments
 (0)