1
- // FIXME: Investigate OS-agnostic failures
2
- // UNSUPPORTED: true
3
1
// 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
8
5
9
6
// ==- free_function_queries.cpp - SYCL free function queries test -=//
10
7
//
@@ -29,7 +26,7 @@ int main() {
29
26
30
27
{
31
28
constexpr int checks_number{3 };
32
- int results[checks_number]{};
29
+ int results[checks_number]{41 , 42 , 43 };
33
30
{
34
31
sycl::buffer<int > buf (data, sycl::range<1 >(n));
35
32
sycl::buffer<int > results_buf (results, sycl::range<1 >(checks_number));
@@ -42,12 +39,12 @@ int main() {
42
39
sycl::access::target::device>
43
40
results_acc (results_buf.get_access <sycl::access::mode::write>(cgh));
44
41
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;
47
44
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);
51
48
acc[i]++;
52
49
});
53
50
});
@@ -63,7 +60,7 @@ int main() {
63
60
64
61
{
65
62
constexpr int checks_number{2 };
66
- int results[checks_number]{};
63
+ int results[checks_number]{41 , 42 };
67
64
{
68
65
sycl::buffer<int > buf (data, sycl::range<1 >(n));
69
66
sycl::buffer<int > results_buf (results, sycl::range<1 >(checks_number));
@@ -78,10 +75,10 @@ int main() {
78
75
cgh.parallel_for <class ItemTest >(n, [=](auto i) {
79
76
static_assert (std::is_same<decltype (i), sycl::item<1 >>::value,
80
77
" 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 ;
85
82
acc[i]++;
86
83
});
87
84
});
@@ -96,8 +93,11 @@ int main() {
96
93
}
97
94
98
95
{
96
+ // Make sure that we ignore global offset warning.
97
+ #pragma GCC diagnostic push
98
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
99
99
constexpr int checks_number{2 };
100
- int results[checks_number]{};
100
+ int results[checks_number]{41 , 42 };
101
101
{
102
102
sycl::buffer<int > buf (data, sycl::range<1 >(n));
103
103
sycl::buffer<int > results_buf (results, sycl::range<1 >(checks_number));
@@ -112,11 +112,13 @@ int main() {
112
112
results_acc (results_buf.get_access <sycl::access::mode::write>(cgh));
113
113
cgh.parallel_for <class ItemOffsetTest >(
114
114
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 ()]++;
120
122
});
121
123
});
122
124
}
@@ -127,51 +129,6 @@ int main() {
127
129
for (auto val : results) {
128
130
assert (val == 1 );
129
131
}
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
176
133
}
177
134
}
0 commit comments