Skip to content

Commit 15929c6

Browse files
[SYCL] Properties must be a properties list in group_load/store (#16422)
Before this patch we were failing with more obscure errors like ``` no member named 'has_property' in ...property_value<...data_placement_key...> ```
1 parent 51008bf commit 15929c6

File tree

5 files changed

+150
-117
lines changed

5 files changed

+150
-117
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_group_load_store.asciidoc

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ in the group.
9999
* Value type of `InputIteratorT` must be convertible to `OutputT`.
100100
* Value type of `InputIteratorT` and `OutputT` must be trivially copyable
101101
and default constructible.
102+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
102103

103104
_Effects_: Loads single element from `in_iter` to `out` by using the `g` group
104105
object to identify memory location as `in_iter` + `g.get_local_linear_id()`.
@@ -129,6 +130,7 @@ in the group.
129130
* Value type of `InputIteratorT` must be convertible to `OutputT`.
130131
* Value type of `InputIteratorT` and `OutputT` must be trivially copyable
131132
and default constructible.
133+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
132134

133135
_Effects_: Loads `N` elements from `in_iter` to `out`
134136
using the `g` group object.
@@ -165,6 +167,7 @@ work-group or sub-group.
165167
* Value type of `InputIteratorT` must be convertible to `OutputT`.
166168
* Value type of `InputIteratorT` and `OutputT` must be trivially copyable
167169
and default constructible.
170+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
168171

169172
_Effects_: Loads `ElementsPerWorkItem` elements from `in_iter` to `out`
170173
using the `g` group object.
@@ -204,6 +207,7 @@ in the group.
204207
* `InputT` must be convertible to value type of `OutputIteratorT`.
205208
* `InputT` and value type of `OutputIteratorT` must be trivially copyable
206209
and default constructible.
210+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
207211

208212
_Effects_: Stores single element `in` to `out_iter` by using the `g` group
209213
object to identify memory location as `out_iter` + `g.get_local_linear_id()`
@@ -235,6 +239,7 @@ in the group.
235239
* `InputT` must be convertible to value type of `OutputIteratorT`.
236240
* `InputT` and value type of `OutputIteratorT` must be trivially copyable
237241
and default constructible.
242+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
238243

239244
_Effects_: Stores `N` elements from `in` vec to `out_iter`
240245
using the `g` group object.
@@ -273,6 +278,7 @@ work-group or sub-group.
273278
* `InputT` must be convertible to value type of `OutputIteratorT`.
274279
* `InputT` and value type of `OutputIteratorT` must be trivially copyable
275280
and default constructible.
281+
* `Properties` is an instance of `sycl::ext::oneapi::experimental::properties`
276282

277283
_Effects_: Stores `ElementsPerWorkItem` elements from `in` span to `out_iter`
278284
using the `g` group object.
@@ -370,7 +376,7 @@ Specifies data layout used in group_load/store for `sycl::vec` or fixed-size
370376
arrays functions.
371377

372378
Example:
373-
`group_load(g, input, output_span, data_placement_blocked);`
379+
`group_load(g, input, output_span, properties{data_placement_blocked});`
374380

375381
=== Optimization Properties
376382

@@ -398,7 +404,7 @@ inline constexpr contiguous_memory_key::value_t contiguous_memory;
398404
----
399405

400406
For example, we can assert that `input` is a contiguous iterator:
401-
`group_load(g, input, output_span, contiguous_memory);`
407+
`group_load(g, input, output_span, properties{contiguous_memory});`
402408

403409
If `input` isn't a contiguous iterator, the behavior is undefined.
404410

@@ -432,7 +438,7 @@ inline constexpr full_group_key::value_t full_group;
432438

433439
For example, we can assert that there is no uneven group partition,
434440
so the implementation can rely on `get_max_local_range()` range size:
435-
`group_load(sg, input, output_span, full_group);`
441+
`group_load(sg, input, output_span, properties{full_group});`
436442

437443
If partition is uneven the behavior is undefined.
438444

@@ -466,11 +472,13 @@ q.submit([&](sycl::handler& cgh) {
466472
auto offset = g.get_group_id(0) * g.get_local_range(0) *
467473
items_per_thread;
468474
469-
sycl_exp::group_load(g, input + offset, sycl::span{ data }, sycl_exp::contiguous_memory);
475+
auto props = sycl_exp::properties{sycl_exp::contiguous_memory};
476+
477+
sycl_exp::group_load(g, input + offset, sycl::span{ data }, props);
470478
471479
// Work with data...
472480
473-
sycl_exp::group_store(g, output + offset, sycl::span{ data }, sycl_exp::contiguous_memory);
481+
sycl_exp::group_store(g, output + offset, sycl::span{ data }, props);
474482
});
475483
});
476484
----
@@ -546,11 +554,13 @@ q.submit([&](sycl::handler& cgh) {
546554
sycl_exp::group_with_scratchpad gh{ g,
547555
sycl::span{ buf_ptr, temp_memory_size } };
548556
549-
sycl_exp::group_load(gh, input + offset, sycl::span{ data }, sycl_exp::contiguous_memory);
557+
auto props = sycl_exp::properties{sycl_exp::contiguous_memory};
558+
559+
sycl_exp::group_load(gh, input + offset, sycl::span{ data }, props);
550560
551561
// Work with data...
552562
553-
sycl_exp::group_store(gh, output + offset, sycl::span{ data }, sycl_exp::contiguous_memory);
563+
sycl_exp::group_store(gh, output + offset, sycl::span{ data }, props);
554564
});
555565
});
556566
----
@@ -583,11 +593,13 @@ q.submit([&](sycl::handler& cgh) {
583593
sycl_exp::group_with_scratchpad gh{ g,
584594
sycl::span{ buf_ptr, temp_memory_size } };
585595
586-
sycl_exp::group_load(gh, input + offset, sycl::span{ data }, sycl_exp::data_placement_striped);
596+
auto striped = sycl_exp::properties{sycl_exp::data_placement_striped};
597+
598+
sycl_exp::group_load(gh, input + offset, sycl::span{ data }, striped);
587599
588600
// Work with data...
589601
590-
sycl_exp::group_store(gh, output + offset, sycl::span{ data }, sycl_exp::data_placement_striped);
602+
sycl_exp::group_store(gh, output + offset, sycl::span{ data }, striped);
591603
});
592604
});
593605
----

sycl/include/sycl/ext/oneapi/experimental/group_load_store.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ template <typename Group, typename InputIteratorT, typename OutputT,
233233
std::size_t ElementsPerWorkItem,
234234
typename Properties = decltype(properties())>
235235
std::enable_if_t<detail::verify_load_types<InputIteratorT, OutputT> &&
236-
detail::is_generic_group_v<Group>>
236+
detail::is_generic_group_v<Group> &&
237+
is_property_list_v<Properties>>
237238
group_load(Group g, InputIteratorT in_ptr,
238239
span<OutputT, ElementsPerWorkItem> out, Properties props = {}) {
239240
constexpr bool blocked = detail::isBlocked(props);
@@ -305,7 +306,8 @@ template <typename Group, typename InputT, std::size_t ElementsPerWorkItem,
305306
typename OutputIteratorT,
306307
typename Properties = decltype(properties())>
307308
std::enable_if_t<detail::verify_store_types<InputT, OutputIteratorT> &&
308-
detail::is_generic_group_v<Group>>
309+
detail::is_generic_group_v<Group> &&
310+
is_property_list_v<Properties>>
309311
group_store(Group g, const span<InputT, ElementsPerWorkItem> in,
310312
OutputIteratorT out_ptr, Properties props = {}) {
311313
constexpr bool blocked = detail::isBlocked(props);
@@ -352,7 +354,8 @@ group_store(Group g, const span<InputT, ElementsPerWorkItem> in,
352354
template <typename Group, typename InputIteratorT, typename OutputT,
353355
typename Properties = decltype(properties())>
354356
std::enable_if_t<detail::verify_load_types<InputIteratorT, OutputT> &&
355-
detail::is_generic_group_v<Group>>
357+
detail::is_generic_group_v<Group> &&
358+
is_property_list_v<Properties>>
356359
group_load(Group g, InputIteratorT in_ptr, OutputT &out,
357360
Properties properties = {}) {
358361
group_load(g, in_ptr, span<OutputT, 1>(&out, 1), properties);
@@ -362,7 +365,8 @@ group_load(Group g, InputIteratorT in_ptr, OutputT &out,
362365
template <typename Group, typename InputT, typename OutputIteratorT,
363366
typename Properties = decltype(properties())>
364367
std::enable_if_t<detail::verify_store_types<InputT, OutputIteratorT> &&
365-
detail::is_generic_group_v<Group>>
368+
detail::is_generic_group_v<Group> &&
369+
is_property_list_v<Properties>>
366370
group_store(Group g, const InputT &in, OutputIteratorT out_ptr,
367371
Properties properties = {}) {
368372
group_store(g, span<const InputT, 1>(&in, 1), out_ptr, properties);
@@ -372,7 +376,8 @@ group_store(Group g, const InputT &in, OutputIteratorT out_ptr,
372376
template <typename Group, typename InputIteratorT, typename OutputT, int N,
373377
typename Properties = decltype(properties())>
374378
std::enable_if_t<detail::verify_load_types<InputIteratorT, OutputT> &&
375-
detail::is_generic_group_v<Group>>
379+
detail::is_generic_group_v<Group> &&
380+
is_property_list_v<Properties>>
376381
group_load(Group g, InputIteratorT in_ptr, sycl::vec<OutputT, N> &out,
377382
Properties properties = {}) {
378383
group_load(g, in_ptr, span<OutputT, N>(&out[0], N), properties);
@@ -382,7 +387,8 @@ group_load(Group g, InputIteratorT in_ptr, sycl::vec<OutputT, N> &out,
382387
template <typename Group, typename InputT, int N, typename OutputIteratorT,
383388
typename Properties = decltype(properties())>
384389
std::enable_if_t<detail::verify_store_types<InputT, OutputIteratorT> &&
385-
detail::is_generic_group_v<Group>>
390+
detail::is_generic_group_v<Group> &&
391+
is_property_list_v<Properties>>
386392
group_store(Group g, const sycl::vec<InputT, N> &in, OutputIteratorT out_ptr,
387393
Properties properties = {}) {
388394
group_store(g, span<const InputT, N>(&in[0], N), out_ptr, properties);

0 commit comments

Comments
 (0)