Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions sycl/include/sycl/access/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED, __SY...

#ifdef __SYCL_DEVICE_ONLY__
#include <type_traits>
Expand Down Expand Up @@ -106,8 +106,14 @@ template <access_mode mode, target trgt> struct mode_target_tag_t {
inline constexpr mode_tag_t<access_mode::read> read_only{};
inline constexpr mode_tag_t<access_mode::read_write> read_write{};
inline constexpr mode_tag_t<access_mode::write> write_only{};

// access::target::constant_buffer is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
__SYCL2020_DEPRECATED("use 'read_only' instead")
inline constexpr mode_target_tag_t<access_mode::read, target::constant_buffer>
read_constant{};
__SYCL_SUPPRESS_DEPRECATED_POP

inline constexpr mode_target_tag_t<access_mode::read, target::host_task>
read_only_host_task;
inline constexpr mode_target_tag_t<access_mode::read_write, target::host_task>
Expand All @@ -117,15 +123,6 @@ inline constexpr mode_target_tag_t<access_mode::write, target::host_task>

namespace detail {

constexpr bool isTargetHostAccess(access::target T) {
return T == access::target::host_buffer || T == access::target::host_image;
}

constexpr bool modeNeedsOldData(access::mode m) {
return m == access::mode::read || m == access::mode::write ||
m == access::mode::read_write || m == access::mode::atomic;
}

constexpr bool modeWritesNewData(access::mode m) {
return m != access::mode::read;
}
Expand Down Expand Up @@ -160,10 +157,14 @@ template <> struct TargetToAS<access::target::local> {
access::address_space::local_space;
};

// access::target::constant_buffer and address_space::constant_space are
// deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <> struct TargetToAS<access::target::constant_buffer> {
constexpr static access::address_space AS =
access::address_space::constant_space;
};
__SYCL_SUPPRESS_DEPRECATED_POP

template <typename ElementType, access::address_space addressSpace>
struct DecoratedType;
Expand All @@ -183,6 +184,8 @@ struct DecoratedType<ElementType, access::address_space::global_space> {
using type = __OPENCL_GLOBAL_AS__ ElementType;
};

// access::address_space::constant_space is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <typename ElementType>
struct DecoratedType<ElementType, access::address_space::constant_space> {
// Current implementation of address spaces handling leads to possibility
Expand All @@ -196,6 +199,7 @@ struct DecoratedType<ElementType, access::address_space::constant_space> {
using type = __OPENCL_GLOBAL_AS__ ElementType;
#endif
};
__SYCL_SUPPRESS_DEPRECATED_POP

template <typename ElementType>
struct DecoratedType<ElementType, access::address_space::local_space> {
Expand Down Expand Up @@ -226,10 +230,13 @@ template <class T> struct deduce_AS_impl<__OPENCL_LOCAL_AS__ T> {
access::address_space::local_space;
};

// access::address_space::constant_space is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <class T> struct deduce_AS_impl<__OPENCL_CONSTANT_AS__ T> {
static constexpr access::address_space value =
access::address_space::constant_space;
};
__SYCL_SUPPRESS_DEPRECATED_POP

template <class T>
struct deduce_AS
Expand Down
53 changes: 52 additions & 1 deletion sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ class accessor_common {
protected:
constexpr static access::address_space AS = TargetToAS<AccessTarget>::AS;

// access::target::host_buffer is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
constexpr static bool IsHostBuf = AccessTarget == access::target::host_buffer;
__SYCL_SUPPRESS_DEPRECATED_POP

constexpr static bool IsHostTask = AccessTarget == access::target::host_task;
// SYCL2020 4.7.6.9.4.3
// IsPlaceHolder template parameter has no bearing on whether the accessor
Expand All @@ -304,6 +308,9 @@ class accessor_common {
// placeholder either. Otherwise, the accessor is a placeholder.
constexpr static bool IsPlaceH = !IsHostBuf;

// access::target::global_buffer, constant_buffer and
// access::mode::discard_write, discard_read_write, atomic are deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
// TODO: SYCL 2020 deprecates four of the target enum values
// and replaces them with 2 (device and host_task). May want
// to change these constexpr.
Expand All @@ -326,6 +333,7 @@ class accessor_common {
AccessMode == access::mode::read_write;

constexpr static bool IsAccessAtomic = AccessMode == access::mode::atomic;
__SYCL_SUPPRESS_DEPRECATED_POP

using RefType = detail::const_if_const_AS<AS, DataT> &;
using ConstRefType = const DataT &;
Expand Down Expand Up @@ -398,6 +406,8 @@ constexpr access::mode deduceAccessMode() {
return access::mode::write;
}

// access::target::constant_buffer is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
if constexpr (std::is_same_v<
MayBeTag1,
mode_target_tag_t<access::mode::read,
Expand All @@ -408,6 +418,7 @@ constexpr access::mode deduceAccessMode() {
access::target::constant_buffer>>) {
return access::mode::read;
}
__SYCL_SUPPRESS_DEPRECATED_POP

if constexpr (std::is_same_v<MayBeTag1,
mode_target_tag_t<access::mode::read,
Expand All @@ -432,6 +443,8 @@ constexpr access::mode deduceAccessMode() {

template <typename MayBeTag1, typename MayBeTag2>
constexpr access::target deduceAccessTarget(access::target defaultTarget) {
// access::target::constant_buffer is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
if constexpr (std::is_same_v<
MayBeTag1,
mode_target_tag_t<access::mode::read,
Expand All @@ -442,6 +455,7 @@ constexpr access::target deduceAccessTarget(access::target defaultTarget) {
access::target::constant_buffer>>) {
return access::target::constant_buffer;
}
__SYCL_SUPPRESS_DEPRECATED_POP

if constexpr (
std::is_same_v<MayBeTag1, mode_target_tag_t<access::mode::read,
Expand Down Expand Up @@ -603,6 +617,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
friend sycl::detail::ImplUtils;

protected:
// access::target::global_buffer, constant_buffer, host_buffer are deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
static_assert((AccessTarget == access::target::global_buffer ||
AccessTarget == access::target::constant_buffer ||
AccessTarget == access::target::host_buffer ||
Expand All @@ -615,6 +631,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
(AccessTarget == access::target::constant_buffer &&
AccessMode == access::mode::read),
"Access mode can be only read for constant buffers");
__SYCL_SUPPRESS_DEPRECATED_POP

static_assert(detail::IsPropertyListT<PropertyListT>::value,
"PropertyListT must be accessor_property_list");
Expand Down Expand Up @@ -679,6 +696,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
static access::mode getAdjustedMode(const PropertyListT &PropertyList) {
access::mode AdjustedMode = AccessMode;

// property::noinit and access::mode::discard_write, discard_read_write
// are deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
if (PropertyList.template has_property<property::no_init>() ||
PropertyList.template has_property<property::noinit>()) {
if (AdjustedMode == access::mode::write) {
Expand All @@ -687,6 +707,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
AdjustedMode = access::mode::discard_read_write;
}
}
__SYCL_SUPPRESS_DEPRECATED_POP

return AdjustedMode;
}
Expand Down Expand Up @@ -1666,6 +1687,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
return *(getQualifiedPtr() + LinearIndex);
}

// access_mode::atomic is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <int Dims = Dimensions,
typename = std::enable_if_t<AccessMode != access_mode::atomic &&
!IsAccessReadOnly && Dims == 0>>
Expand All @@ -1681,6 +1704,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
*getQualifiedPtr() = std::move(Other);
return *this;
}
__SYCL_SUPPRESS_DEPRECATED_POP

template <int Dims = Dimensions,
typename = std::enable_if_t<(Dims > 0) &&
Expand All @@ -1690,6 +1714,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
return getQualifiedPtr()[LinearIndex];
}

// access::mode::atomic and sycl::atomic are deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <int Dims = Dimensions>
operator typename std::enable_if_t<
Dims == 0 && AccessMode == access::mode::atomic, atomic<DataT, AS>>()
Expand All @@ -1716,11 +1742,16 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
return atomic<DataT, AS>(multi_ptr<DataT, AS, access::decorated::yes>(
getQualifiedPtr() + LinearIndex));
}
__SYCL_SUPPRESS_DEPRECATED_POP

template <int Dims = Dimensions, typename = std::enable_if_t<(Dims > 1)>>
auto operator[](size_t Index) const {
return AccessorSubscript<Dims - 1>(*this, Index);
}

// access::target::host_buffer, constant_buffer and constant_ptr are
// deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <access::target AccessTarget_ = AccessTarget,
typename = std::enable_if_t<
(AccessTarget_ == access::target::host_buffer) ||
Expand All @@ -1746,6 +1777,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
constant_ptr<DataT> get_pointer() const {
return constant_ptr<DataT>(getPointerAdjusted());
}
__SYCL_SUPPRESS_DEPRECATED_POP

template <access::decorated IsDecorated,
access::target AccessTarget_ = AccessTarget,
Expand All @@ -1765,6 +1797,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :

// accessor::has_property for runtime properties is only available in host
// code. This restriction is not listed in the core spec and will be added in

// future versions.
template <typename Property>
typename std::enable_if_t<
Expand Down Expand Up @@ -2052,6 +2085,8 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler &, Type1, Type2, Type3,
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

// access::target::local is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
/// Local accessor
///
/// \ingroup sycl_api_acc
Expand All @@ -2069,6 +2104,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
using AccessorCommonT =
detail::accessor_common<DataT, Dimensions, AccessMode,
access::target::local, IsPlaceholder>;
__SYCL_SUPPRESS_DEPRECATED_POP

using AccessorCommonT::AS;

Expand Down Expand Up @@ -2171,6 +2207,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
using reference = DataT &;
using const_reference = const DataT &;

// access::target::local is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <int Dims = Dimensions, typename = std::enable_if_t<Dims == 0>>
local_accessor_base(handler &, const detail::code_location CodeLoc =
detail::code_location::current())
Expand Down Expand Up @@ -2241,6 +2279,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
}
#endif

__SYCL_SUPPRESS_DEPRECATED_POP
size_t get_size() const { return getSize().size() * sizeof(DataT); }

__SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead")
Expand Down Expand Up @@ -2274,6 +2313,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
return getQualifiedPtr()[Index];
}

// access::mode::atomic and sycl::atomic are deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <int Dims = Dimensions>
operator typename std::enable_if_t<
Dims == 0 && AccessMode == access::mode::atomic, atomic<DataT, AS>>()
Expand All @@ -2298,6 +2339,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
return atomic<DataT, AS>(multi_ptr<DataT, AS, access::decorated::yes>(
getQualifiedPtr() + Index));
}
__SYCL_SUPPRESS_DEPRECATED_POP

template <int Dims = Dimensions, typename = std::enable_if_t<(Dims > 1)>>
typename AccessorCommonT::template AccessorSubscript<
Expand All @@ -2316,6 +2358,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
};

// TODO: Remove deprecated specialization once no longer needed
// access::target::local is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
class __SYCL_EBO __SYCL_SPECIAL_CLASS accessor<
Expand All @@ -2325,6 +2369,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS accessor<
accessor<DataT, Dimensions, AccessMode, access::target::local,
IsPlaceholder>> {

__SYCL_SUPPRESS_DEPRECATED_POP

using local_acc =
local_accessor_base<DataT, Dimensions, AccessMode, IsPlaceholder>;

Expand Down Expand Up @@ -2547,6 +2593,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
friend class ext::oneapi::experimental::dynamic_local_accessor;
};

// access::target::host_buffer is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <typename DataT, int Dimensions = 1,
access_mode AccessMode = access_mode::read_write>
class __SYCL_EBO host_accessor
Expand All @@ -2573,12 +2621,12 @@ class __SYCL_EBO host_accessor
id<AdjustedDim> Offset) {
AccessorT::__init(Ptr, AccessRange, MemRange, Offset);
}

#ifndef __SYCL_DEVICE_ONLY__
host_accessor(const detail::AccessorImplPtr &Impl)
: accessor<DataT, Dimensions, AccessMode, target::host_buffer,
access::placeholder::false_t>{Impl} {}
#endif // __SYCL_DEVICE_ONLY__
__SYCL_SUPPRESS_DEPRECATED_POP

public:
host_accessor() : AccessorT() {}
Expand Down Expand Up @@ -2721,6 +2769,8 @@ class __SYCL_EBO host_accessor
: host_accessor(BufferRef, CommandGroupHandler, AccessRange, AccessOffset,
PropertyList, CodeLoc) {}

// access_mode::atomic is deprecated.
__SYCL_SUPPRESS_DEPRECATED_PUSH
template <int Dims = Dimensions,
typename = std::enable_if_t<AccessMode != access_mode::atomic &&
!IsAccessReadOnly && Dims == 0>>
Expand All @@ -2737,6 +2787,7 @@ class __SYCL_EBO host_accessor
*AccessorT::getQualifiedPtr() = std::move(Other);
return *this;
}
__SYCL_SUPPRESS_DEPRECATED_POP

// implicit conversion between const / non-const types for read only accessors
template <typename DataT_,
Expand Down
Loading
Loading