Skip to content

Commit

Permalink
Remove deprecated template arguments from built-in range mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr authored and psalz committed Jul 13, 2023
1 parent f5e6510 commit 40a12a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 70 deletions.
42 changes: 5 additions & 37 deletions include/range_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,15 @@ namespace detail {

namespace access {

template <int Dims = 0>
struct one_to_one;

template <>
struct one_to_one<0> {
struct one_to_one {
template <int Dims>
subrange<Dims> operator()(const chunk<Dims>& chnk) const {
return chnk;
}
};

template <int Dims>
struct [[deprecated("Explicitly-dimensioned range mappers are deprecated, remove template arguments from celerity::one_to_one")]] one_to_one
: one_to_one<0>{};

one_to_one()->one_to_one<>;

template <int KernelDims, int BufferDims = KernelDims>
struct fixed;

template <int BufferDims>
struct fixed<BufferDims, BufferDims> {
struct fixed {
fixed(const subrange<BufferDims>& sr) : m_sr(sr) {}

template <int KernelDims>
Expand All @@ -180,19 +167,9 @@ namespace access {
subrange<BufferDims> m_sr;
};

template <int KernelDims, int BufferDims>
struct fixed : fixed<BufferDims, BufferDims> {
[[deprecated("Explicitly-dimensioned range mappers are deprecated, remove first template argument from celerity::fixed")]] //
fixed(const subrange<BufferDims>& sr)
: fixed<BufferDims, BufferDims>(sr) {}
};

template <int BufferDims>
fixed(subrange<BufferDims>) -> fixed<BufferDims>;

template <int Dims>
struct slice {
slice(size_t dim_idx) : m_dim_idx(dim_idx) { assert(dim_idx < Dims && "Invalid slice dimension index (starts at 0)"); }
explicit slice(const size_t dim_idx) : m_dim_idx(dim_idx) { assert(dim_idx < Dims && "Invalid slice dimension index (starts at 0)"); }

subrange<Dims> operator()(const chunk<Dims>& chnk, const range<Dims>& buffer_size) const {
subrange<Dims> result = chnk;
Expand All @@ -205,22 +182,13 @@ namespace access {
size_t m_dim_idx;
};

template <int KernelDims = 0, int BufferDims = KernelDims>
struct all;

template <>
struct all<0, 0> {
struct all {
template <int KernelDims, int BufferDims>
subrange<BufferDims> operator()(const chunk<KernelDims>&, const range<BufferDims>& buffer_size) const {
subrange<BufferDims> operator()(const chunk<KernelDims>& /* chnk */, const range<BufferDims>& buffer_size) const {
return {{}, buffer_size};
}
};

template <int KernelDims, int BufferDims>
struct [[deprecated("Explicitly-dimensioned range mappers are deprecated, remove template arguments from celerity::all")]] all : all<0, 0>{};

all()->all<>;

template <int Dims>
struct neighborhood {
neighborhood(size_t dim0) : m_dim0(dim0), m_dim1(0), m_dim2(0) {}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void test_copy(celerity::distr_queue& q) {

// Initialize on device
q.submit([&](celerity::handler& cgh) {
celerity::accessor acc{buf, cgh, celerity::access::one_to_one<>{}, celerity::write_only, celerity::no_init};
celerity::accessor acc{buf, cgh, celerity::access::one_to_one{}, celerity::write_only, celerity::no_init};
cgh.parallel_for<kernel_name<class init, Dims>>(buf.get_range(), [=](celerity::item<Dims> itm) { acc[itm] = itm.get_linear_id(); });
});

Expand All @@ -40,7 +40,7 @@ void test_copy(celerity::distr_queue& q) {

// Modify everything on device
q.submit([&](celerity::handler& cgh) {
celerity::accessor acc{buf, cgh, celerity::access::one_to_one<>{}, celerity::read_write};
celerity::accessor acc{buf, cgh, celerity::access::one_to_one{}, celerity::read_write};
cgh.parallel_for<kernel_name<class modify, Dims>>(buf.get_range(), [=](celerity::item<Dims> itm) { acc[itm] += 1; });
});

Expand Down
31 changes: 0 additions & 31 deletions test/runtime_deprecation_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,6 @@
namespace celerity {
namespace detail {

using celerity::access::all;
using celerity::access::fixed;
using celerity::access::one_to_one;

TEST_CASE("deprecated range mapper templates continue to work", "[range-mapper][deprecated]") {
const auto chunk1d = chunk<1>{1, 2, 3};
const auto chunk2d = chunk<2>{{1, 1}, {2, 2}, {3, 3}};
const auto chunk3d = chunk<3>{{1, 1, 1}, {2, 2, 2}, {3, 3, 3}};
const auto range1d = range<1>{4};
const auto range2d = range<2>{4, 4};
const auto range3d = range<3>{4, 4, 4};
const auto subrange1d = subrange<1>{{}, range1d};
const auto subrange2d = subrange<2>{{}, range2d};
const auto subrange3d = subrange<3>{{}, range3d};

CHECK(one_to_one<1>{}(chunk1d) == subrange{chunk1d});
CHECK(one_to_one<2>{}(chunk2d) == subrange{chunk2d});
CHECK(one_to_one<3>{}(chunk3d) == subrange{chunk3d});

CHECK(fixed<1, 3>{subrange3d}(chunk1d) == subrange3d);
CHECK(fixed<2, 2>{subrange2d}(chunk2d) == subrange2d);
CHECK(fixed<3, 1>{subrange1d}(chunk3d) == subrange1d);

CHECK(all<1>{}(chunk1d, range1d) == subrange1d);
CHECK(all<2>{}(chunk2d, range2d) == subrange2d);
CHECK(all<3>{}(chunk3d, range3d) == subrange3d);
CHECK(all<1, 3>{}(chunk1d, range3d) == subrange3d);
CHECK(all<2, 2>{}(chunk2d, range2d) == subrange2d);
CHECK(all<3, 1>{}(chunk3d, range1d) == subrange1d);
}

TEST_CASE_METHOD(test_utils::runtime_fixture,
"distr_queue::submit(allow_by_ref_t, ...) and creation of accessors/side-effects/reductions from const buffers/host-objects continues to work",
"[handler][deprecated]") {
Expand Down

0 comments on commit 40a12a4

Please sign in to comment.