Skip to content

Commit 0bfd34e

Browse files
authored
[SYCL] Add support multidimensional subscript for atomic accessor (#3473)
Signed-off-by: mdimakov <[email protected]>
1 parent b141285 commit 0bfd34e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sycl/include/CL/sycl/accessor.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ class accessor_common {
288288
constexpr static bool IsAccessReadWrite =
289289
AccessMode == access::mode::read_write;
290290

291+
constexpr static bool IsAccessAtomic = AccessMode == access::mode::atomic;
292+
291293
using RefType = detail::const_if_const_AS<AS, DataT> &;
292294
using ConstRefType = const DataT &;
293295
using PtrType = detail::const_if_const_AS<AS, DataT> *;
@@ -327,6 +329,14 @@ class accessor_common {
327329
return MAccessor[MIDs];
328330
}
329331

332+
template <int CurDims = SubDims>
333+
typename detail::enable_if_t<CurDims == 1 && IsAccessAtomic,
334+
atomic<DataT, AS>>
335+
operator[](size_t Index) const {
336+
MIDs[Dims - CurDims] = Index;
337+
return MAccessor[MIDs];
338+
}
339+
330340
template <int CurDims = SubDims,
331341
typename = detail::enable_if_t<CurDims == 1 && IsAccessReadOnly>>
332342
ConstRefType operator[](size_t Index) const {

0 commit comments

Comments
 (0)