Skip to content

Commit 1f76efc

Browse files
authored
[SYCL] Accessor tags, CTAD and host_accessor (#1838)
This patch adds the implementation of [SYCL_INTEL_accessor_simplification](#1498) extension. It adds: - `host_accessor` - `read_only`, `write_only`, `read_write`, `read_constant` tags - `noinit` property - a number of constructors for both buffer `accessor` and `host_accessor` to utilize newly added tags and properties for usage simplification Most use cases for `accessor` has no longer need for specifying template arguments and rely on deduction guides and corresponding tags. `sycl::access::target` is now accessible from `sycl::target` and `sycl::access::mode` from `sycl::access_mode`
1 parent 358ec04 commit 1f76efc

File tree

6 files changed

+633
-45
lines changed

6 files changed

+633
-45
lines changed

sycl/include/CL/sycl/access/access.hpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88
#pragma once
99

10+
#include <CL/sycl/detail/common.hpp>
1011
#include <CL/sycl/detail/defines.hpp>
1112

1213
__SYCL_INLINE_NAMESPACE(cl) {
@@ -47,7 +48,43 @@ enum class address_space : int {
4748
local_space
4849
};
4950

50-
} // namespace access
51+
} // namespace access
52+
53+
using access::target;
54+
using access_mode = access::mode;
55+
56+
template <access_mode mode> struct mode_tag_t {
57+
explicit mode_tag_t() = default;
58+
};
59+
60+
template <access_mode mode, target trgt> struct mode_target_tag_t {
61+
explicit mode_target_tag_t() = default;
62+
};
63+
64+
#if __cplusplus > 201402L
65+
66+
inline constexpr mode_tag_t<access_mode::read> read_only{};
67+
inline constexpr mode_tag_t<access_mode::read_write> read_write{};
68+
inline constexpr mode_tag_t<access_mode::write> write_only{};
69+
inline constexpr mode_target_tag_t<access_mode::read, target::constant_buffer>
70+
read_constant{};
71+
72+
#else
73+
74+
namespace {
75+
76+
constexpr const auto &read_only =
77+
sycl::detail::InlineVariableHelper<mode_tag_t<access_mode::read>>::value;
78+
constexpr const auto &read_write = sycl::detail::InlineVariableHelper<
79+
mode_tag_t<access_mode::read_write>>::value;
80+
constexpr const auto &write_only =
81+
sycl::detail::InlineVariableHelper<mode_tag_t<access_mode::write>>::value;
82+
constexpr const auto &read_constant = sycl::detail::InlineVariableHelper<
83+
mode_target_tag_t<access_mode::read, target::constant_buffer>>::value;
84+
85+
} // namespace
86+
87+
#endif
5188

5289
namespace detail {
5390

0 commit comments

Comments
 (0)