Skip to content

[SYCL] target enumeration SYCL 2020 update: deprecate global_buffer #4588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 24, 2021
Merged
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
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/access/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace sycl {
namespace access {

enum class target {
global_buffer = 2014,
global_buffer __SYCL2020_DEPRECATED("use 'target::device' instead") = 2014,
constant_buffer = 2015,
local = 2016,
image = 2017,
Expand Down Expand Up @@ -137,7 +137,7 @@ template <access::target accessTarget> struct TargetToAS {
};

#ifdef __ENABLE_USM_ADDR_SPACE__
template <> struct TargetToAS<access::target::global_buffer> {
template <> struct TargetToAS<access::target::device> {
constexpr static access::address_space AS =
access::address_space::global_device_space;
};
Expand Down
59 changes: 31 additions & 28 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class AccessorPrivateProxy;

template <typename DataT, int Dimensions = 1,
access::mode AccessMode = access::mode::read_write,
access::target AccessTarget = access::target::global_buffer,
access::target AccessTarget = access::target::device,
access::placeholder IsPlaceholder = access::placeholder::false_t,
typename PropertyListT = ext::oneapi::accessor_property_list<>>
class accessor;
Expand Down Expand Up @@ -271,6 +271,9 @@ class accessor_common {

constexpr static bool IsHostBuf = AccessTarget == access::target::host_buffer;

// 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.
constexpr static bool IsGlobalBuf =
AccessTarget == access::target::global_buffer;

Expand Down Expand Up @@ -1605,9 +1608,9 @@ class accessor :
return getQualifiedPtr() + LinearIndex;
}

template <access::target AccessTarget_ = AccessTarget,
typename = detail::enable_if_t<AccessTarget_ ==
access::target::global_buffer>>
template <
access::target AccessTarget_ = AccessTarget,
typename = detail::enable_if_t<AccessTarget_ == access::target::device>>
global_ptr<DataT> get_pointer() const {
const size_t LinearIndex = getLinearIndex(id<AdjustedDim>());
return global_ptr<DataT>(getQualifiedPtr() + LinearIndex);
Expand Down Expand Up @@ -1638,137 +1641,137 @@ class accessor :

template <typename DataT, int Dimensions, typename AllocatorT>
accessor(buffer<DataT, Dimensions, AllocatorT>)
-> accessor<DataT, Dimensions, access::mode::read_write,
target::global_buffer, access::placeholder::true_t>;
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::true_t>;

template <typename DataT, int Dimensions, typename AllocatorT,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, access::mode::read_write,
target::global_buffer, access::placeholder::true_t,
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::true_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type1>(target::device),
access::placeholder::true_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type1>(target::device),
access::placeholder::true_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type2>(target::device),
access::placeholder::true_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type2>(target::device),
access::placeholder::true_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::global_buffer),
detail::deduceAccessTarget<Type2, Type3>(target::device),
access::placeholder::true_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::global_buffer),
detail::deduceAccessTarget<Type2, Type3>(target::device),
access::placeholder::true_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename Type4>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3, Type4)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::global_buffer),
detail::deduceAccessTarget<Type3, Type4>(target::device),
access::placeholder::true_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename Type4, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, Type1, Type2, Type3, Type4,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::global_buffer),
detail::deduceAccessTarget<Type3, Type4>(target::device),
access::placeholder::true_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler)
-> accessor<DataT, Dimensions, access::mode::read_write,
target::global_buffer, access::placeholder::false_t>;
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, access::mode::read_write,
target::global_buffer, access::placeholder::false_t,
-> accessor<DataT, Dimensions, access::mode::read_write, target::device,
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type1>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type1>(),
detail::deduceAccessTarget<Type1, Type1>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type1>(target::device),
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type2>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type1, Type2>(),
detail::deduceAccessTarget<Type1, Type2>(target::global_buffer),
detail::deduceAccessTarget<Type1, Type2>(target::device),
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::global_buffer),
detail::deduceAccessTarget<Type2, Type3>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type2, Type3>(),
detail::deduceAccessTarget<Type2, Type3>(target::global_buffer),
detail::deduceAccessTarget<Type2, Type3>(target::device),
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;

Expand All @@ -1777,15 +1780,15 @@ template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
Type4)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::global_buffer),
detail::deduceAccessTarget<Type3, Type4>(target::device),
access::placeholder::false_t>;

template <typename DataT, int Dimensions, typename AllocatorT, typename Type1,
typename Type2, typename Type3, typename Type4, typename... PropsT>
accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
Type4, const ext::oneapi::accessor_property_list<PropsT...> &)
-> accessor<DataT, Dimensions, detail::deduceAccessMode<Type3, Type4>(),
detail::deduceAccessTarget<Type3, Type4>(target::global_buffer),
detail::deduceAccessTarget<Type3, Type4>(target::device),
access::placeholder::false_t,
ext::oneapi::accessor_property_list<PropsT...>>;
#endif
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/CL/sycl/backend/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ template <> struct interop<backend::cuda, event> { using type = CUevent; };
template <> struct interop<backend::cuda, program> { using type = CUmodule; };

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::cuda, accessor<DataT, Dimensions, AccessMode,
access::target::global_buffer,
access::placeholder::false_t>> {
struct interop<backend::cuda,
accessor<DataT, Dimensions, AccessMode, access::target::device,
access::placeholder::false_t>> {
using type = CUdeviceptr;
};

Expand Down
6 changes: 3 additions & 3 deletions sycl/include/CL/sycl/backend/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ template <> struct interop<backend::opencl, program> {
template <> struct interop<backend::opencl, event> { using type = cl_event; };

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::opencl, accessor<DataT, Dimensions, AccessMode,
access::target::global_buffer,
access::placeholder::false_t>> {
struct interop<backend::opencl,
accessor<DataT, Dimensions, AccessMode, access::target::device,
access::placeholder::false_t>> {
using type = cl_mem;
};

Expand Down
6 changes: 2 additions & 4 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ class buffer {
return impl->template get_allocator<AllocatorT>();
}

template <access::mode Mode,
access::target Target = access::target::global_buffer>
template <access::mode Mode, access::target Target = access::target::device>
accessor<T, dimensions, Mode, Target, access::placeholder::false_t,
ext::oneapi::accessor_property_list<>>
get_access(handler &CommandGroupHandler) {
Expand All @@ -291,8 +290,7 @@ class buffer {
ext::oneapi::accessor_property_list<>>(*this);
}

template <access::mode mode,
access::target target = access::target::global_buffer>
template <access::mode mode, access::target target = access::target::device>
accessor<T, dimensions, mode, target, access::placeholder::false_t,
ext::oneapi::accessor_property_list<>>
get_access(handler &commandGroupHandler, range<dimensions> accessRange,
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ class __SYCL_EXPORT handler {
#endif // __SYCL_DEVICE_ONLY__

constexpr static bool isConstOrGlobal(access::target AccessTarget) {
return AccessTarget == access::target::global_buffer ||
return AccessTarget == access::target::device ||
AccessTarget == access::target::constant_buffer;
}

Expand Down
4 changes: 1 addition & 3 deletions sycl/include/CL/sycl/interop_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class interop_handle {
access::mode Mode, access::target Target, access::placeholder IsPlh>
backend_return_t<Backend, buffer<DataT, Dims>>
get_native_mem(const accessor<DataT, Dims, Mode, Target, IsPlh> &Acc) const {
// TODO: the method is available when the target is target::device. Add it
// to the assert below when target::device enum is created.
static_assert(Target == access::target::global_buffer ||
static_assert(Target == access::target::device ||
Target == access::target::constant_buffer,
"The method is available only for target::device accessors");
#ifndef __SYCL_DEVICE_ONLY__
Expand Down
34 changes: 15 additions & 19 deletions sycl/include/CL/sycl/multi_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
_Space == Space &&
(Space == access::address_space::global_space ||
Space == access::address_space::global_device_space)>>
multi_ptr(
accessor<ElementType, dimensions, Mode, access::target::global_buffer,
isPlaceholder, PropertyListT>
Accessor) {
multi_ptr(accessor<ElementType, dimensions, Mode, access::target::device,
isPlaceholder, PropertyListT>
Accessor) {
m_Pointer = (pointer_t)(Accessor.get_pointer().get());
}

Expand Down Expand Up @@ -166,10 +165,9 @@ template <typename ElementType, access::address_space Space> class multi_ptr {
(Space == access::address_space::global_space ||
Space == access::address_space::global_device_space) &&
std::is_const<ET>::value && std::is_same<ET, ElementType>::value>>
multi_ptr(
accessor<typename detail::remove_const_t<ET>, dimensions, Mode,
access::target::global_buffer, isPlaceholder, PropertyListT>
Accessor)
multi_ptr(accessor<typename detail::remove_const_t<ET>, dimensions, Mode,
access::target::device, isPlaceholder, PropertyListT>
Accessor)
: multi_ptr(Accessor.get_pointer()) {}

// Only if Space == local_space and element type is const
Expand Down Expand Up @@ -382,10 +380,9 @@ template <access::address_space Space> class multi_ptr<void, Space> {
_Space == Space &&
(Space == access::address_space::global_space ||
Space == access::address_space::global_device_space)>>
multi_ptr(
accessor<ElementType, dimensions, Mode, access::target::global_buffer,
access::placeholder::false_t, PropertyListT>
Accessor)
multi_ptr(accessor<ElementType, dimensions, Mode, access::target::device,
access::placeholder::false_t, PropertyListT>
Accessor)
: multi_ptr(Accessor.get_pointer()) {}

// Only if Space == local_space
Expand Down Expand Up @@ -503,10 +500,9 @@ class multi_ptr<const void, Space> {
_Space == Space &&
(Space == access::address_space::global_space ||
Space == access::address_space::global_device_space)>>
multi_ptr(
accessor<ElementType, dimensions, Mode, access::target::global_buffer,
access::placeholder::false_t, PropertyListT>
Accessor)
multi_ptr(accessor<ElementType, dimensions, Mode, access::target::device,
access::placeholder::false_t, PropertyListT>
Accessor)
: multi_ptr(Accessor.get_pointer()) {}

// Only if Space == local_space
Expand Down Expand Up @@ -557,9 +553,9 @@ class multi_ptr<const void, Space> {
#ifdef __cpp_deduction_guides
template <int dimensions, access::mode Mode, access::placeholder isPlaceholder,
typename PropertyListT, class T>
multi_ptr(accessor<T, dimensions, Mode, access::target::global_buffer,
isPlaceholder, PropertyListT>)
->multi_ptr<T, access::address_space::global_space>;
multi_ptr(accessor<T, dimensions, Mode, access::target::device, isPlaceholder,
PropertyListT>)
-> multi_ptr<T, access::address_space::global_space>;
template <int dimensions, access::mode Mode, access::placeholder isPlaceholder,
typename PropertyListT, class T>
multi_ptr(accessor<T, dimensions, Mode, access::target::constant_buffer,
Expand Down
Loading