Skip to content

Commit

Permalink
Remove dead workarounds for unsupported access_mode::atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Apr 11, 2023
1 parent 234e3d2 commit b29b339
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
2 changes: 2 additions & 0 deletions include/accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ class accessor<DataT, Dims, Mode, target::host_task> : public detail::accessor_b
friend struct detail::accessor_testspy;

public:
static_assert(Mode != access_mode::atomic, "access_mode::atomic is not supported.");

template <target Target = target::host_task, typename Functor>
accessor(const buffer<DataT, Dims>& buff, handler& cgh, Functor rmfn) {
static_assert(!std::is_same_v<Functor, range<Dims>>, "The accessor constructor overload for master-access tasks (now called 'host tasks') has "
Expand Down
43 changes: 0 additions & 43 deletions include/workaround.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,46 +42,3 @@

#define CELERITY_WORKAROUND(impl) (CELERITY_WORKAROUND_##impl == 1)
#define CELERITY_WORKAROUND_LESS_OR_EQUAL(impl, ...) (CELERITY_WORKAROUND(impl) && CELERITY_WORKAROUND_VERSION_LESS_OR_EQUAL(__VA_ARGS__))


namespace celerity::detail {

// "normal" accessors return T& references to data, whereas atomic accessors return sycl::atomic<T> pointer wrappers. decltype(auto) is not enough to give
// ranged_sycl_access() a correct generic return type, so we specify it manually through the following trait.

template <typename T, sycl::access_mode Mode, sycl::access::target Target>
struct access_value_trait {
using type = T;
using reference = T&;
};

template <typename T, sycl::access::target Target>
struct access_value_trait<T, sycl::access_mode::read, Target> {
using type = const T;
using reference = const T&;
};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // mode::atomic and target::local are deprecated

template <typename T, sycl::access::target Target>
struct access_value_trait<T, sycl::access_mode::atomic, Target> {
using type = T;
using reference = sycl::atomic<T, sycl::access::address_space::global_space>;
};

template <typename T>
struct access_value_trait<T, sycl::access_mode::atomic, sycl::access::target::local> {
using type = T;
using reference = sycl::atomic<T, sycl::access::address_space::local_space>;
};

#pragma GCC diagnostic pop

template <typename T, sycl::access_mode Mode, sycl::access::target Target>
using access_value_type = typename access_value_trait<T, Mode, Target>::type;

template <typename T, sycl::access_mode Mode, sycl::access::target Target>
using access_value_reference = typename access_value_trait<T, Mode, Target>::reference;

} // namespace celerity::detail

0 comments on commit b29b339

Please sign in to comment.