Skip to content

Commit 241201f

Browse files
[SYCL][Docs] Add accessor property list to handler::require (#19797)
This commit adds the extension accessor property list type to the type of accessor in the handler::require signature. This allows for the extension property lists to be used with placeholder accessors. Fixes #3536. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 84518c1 commit 241201f

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

sycl/doc/extensions/supported/sycl_ext_oneapi_accessor_properties.asciidoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,20 @@ class accessor {
335335
...
336336
```
337337

338+
The `handler::require` function is modified to reflect this type change:
339+
340+
```c++
341+
namespace sycl {
342+
class handler {
343+
public:
344+
template <typename DataT, int Dimensions, access_mode AccessMode,
345+
target AccessTarget, access::placeholder IsPlaceholder,
346+
typename property_listT>
347+
void require(accessor<DataT, Dimensions, AccessMode, AccessTarget, IsPlaceholder, property_listT> acc);
348+
};
349+
} // namespace sycl
350+
```
351+
338352
Modify the code listing to add variants of all the accessor constructors that take a property_list
339353
that instead take an accessor_property_list:
340354

sycl/include/sycl/handler.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,11 @@ class __SYCL_EXPORT handler {
15881588
///
15891589
/// \param Acc is a SYCL accessor describing required memory region.
15901590
template <typename DataT, int Dims, access::mode AccMode,
1591-
access::target AccTarget, access::placeholder isPlaceholder>
1592-
void require(accessor<DataT, Dims, AccMode, AccTarget, isPlaceholder> Acc) {
1591+
access::target AccTarget, access::placeholder isPlaceholder,
1592+
typename propertyListT>
1593+
void require(
1594+
accessor<DataT, Dims, AccMode, AccTarget, isPlaceholder, propertyListT>
1595+
Acc) {
15931596
if (Acc.is_placeholder())
15941597
associateWithHandler(&Acc, AccTarget);
15951598
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
4+
#include <sycl/detail/core.hpp>
5+
6+
constexpr int Val = 42;
7+
8+
int main() {
9+
sycl::queue Q;
10+
int OutVal = 0;
11+
{
12+
sycl::buffer<int> Buffer(&OutVal, sycl::range{1});
13+
sycl::accessor Acc(Buffer, sycl::ext::oneapi::accessor_property_list{
14+
sycl::ext::oneapi::no_alias});
15+
Q.submit([&](sycl::handler &CGH) {
16+
CGH.require(Acc);
17+
CGH.single_task([=]() { Acc[0] = Val; });
18+
});
19+
}
20+
assert(OutVal == Val);
21+
return 0;
22+
}

0 commit comments

Comments
 (0)