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}
0 commit comments