@@ -264,6 +264,45 @@ int main() {
264
264
passed &= verify (3 , range_length, ptr1,
265
265
[&](int i) -> int { return N_ITER * (1 + i + 5 ); });
266
266
}
267
+ {
268
+ // Testcase5
269
+ // - flexible range different from the physical one is used,
270
+ // get_logical_local_range and get_physical_local_range apis are tested
271
+ const int wi_chunk = 2 ;
272
+ constexpr size_t range_length =
273
+ N_WG * WG_SIZE_GREATER_THAN_PHYSICAL * wi_chunk;
274
+ std::unique_ptr<int []> data (new int [range_length]);
275
+ int *ptr = data.get ();
276
+
277
+ std::memset (ptr, 0 , range_length * sizeof (ptr[0 ]));
278
+ buffer<int , 1 > buf (ptr, range<1 >(range_length));
279
+ myQueue.submit ([&](handler &cgh) {
280
+ auto dev_ptr = buf.get_access <access::mode::read_write>(cgh);
281
+
282
+ cgh.parallel_for_work_group <class hpar_ranges >(
283
+ range<1 >(N_WG), range<1 >(WG_SIZE_PHYSICAL), [=](group<1 > g) {
284
+ for (int cnt = 0 ; cnt < N_ITER; cnt++) {
285
+ g.parallel_for_work_item (
286
+ range<1 >(WG_SIZE_GREATER_THAN_PHYSICAL), [&](h_item<1 > i) {
287
+ size_t wg_offset = WG_SIZE_GREATER_THAN_PHYSICAL *
288
+ wi_chunk * g.get_id (0 );
289
+ size_t wi_offset =
290
+ wg_offset +
291
+ i.get_logical_local_id ().get (0 ) * wi_chunk;
292
+ dev_ptr[wi_offset + 0 ] += i.get_logical_local_range ()[0 ];
293
+ dev_ptr[wi_offset + 1 ] += i.get_physical_local_range ()[0 ];
294
+ });
295
+ }
296
+ });
297
+ });
298
+ auto ptr1 = buf.get_access <access::mode::read>().get_pointer ();
299
+ passed &= verify (5 , range_length, ptr1, [&](int i) -> int {
300
+ int gold =
301
+ i % 2 == 0 ? WG_SIZE_GREATER_THAN_PHYSICAL : WG_SIZE_PHYSICAL;
302
+ gold *= N_ITER;
303
+ return gold;
304
+ });
305
+ }
267
306
} catch (cl::sycl::exception const &e) {
268
307
std::cout << " SYCL exception caught: " << e.what () << ' \n ' ;
269
308
return 2 ;
0 commit comments