Skip to content
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
7 changes: 4 additions & 3 deletions include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,15 @@ class ChunkSpan : public ChunkCommon<ElementType, SupportType, LayoutStridedPoli
KOKKOS_FUNCTION constexpr auto operator[](
DiscreteElement<QueryDDims...> const& slice_spec) const
{
assert(select<QueryDDims...>(this->m_domain).contains(slice_spec));
using detail::TypeSeq;
using QueryDDom = typename detail::RebindDomain<SupportType, TypeSeq<QueryDDims...>>::type;
assert(QueryDDom(this->m_domain).contains(slice_spec));
slicer<to_type_seq_t<SupportType>> const slicer;
auto subview = slicer(
this->allocation_mdspan(),
ddc::DiscreteDomain<QueryDDims...>(this->m_domain).distance_from_front(slice_spec));
QueryDDom(this->m_domain).distance_from_front(slice_spec));
using layout_type = typename decltype(subview)::layout_type;
using extents_type = typename decltype(subview)::extents_type;
using detail::TypeSeq;
using OutTypeSeqDDims
= type_seq_remove_t<to_type_seq_t<SupportType>, TypeSeq<QueryDDims...>>;
using OutDDom = typename detail::RebindDomain<SupportType, OutTypeSeqDDims>::type;
Expand Down
9 changes: 8 additions & 1 deletion tests/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ TEST(Chunk2DTest, SliceCoordXOutOfBounds)
ChunkXY<double> chunk(dom_x_y);

char const* const death_msg
= R"rgx([Aa]ssert.*select<QueryDDims...>\(this->m_domain\).contains\(slice_spec\))rgx";
= R"rgx([Aa]ssert.*QueryDDom\(this->m_domain\).contains\(slice_spec\))rgx";

EXPECT_DEATH(chunk[dom_x.front() - 1], death_msg);
EXPECT_DEATH(chunk[dom_x.back() + 1], death_msg);
Expand Down Expand Up @@ -684,3 +684,10 @@ TEST(ChunkStridedDiscreteDomain, Constructor)
EXPECT_EQ(chk(lbound_x_y), 2);
EXPECT_EQ(chk(lbound_x_y + DVectXY(10, 10)), 2);
}

TEST(ChunkStridedDiscreteDomain, Slice)
{
ddc::StridedDiscreteDomain<DDimX, DDimY> const dom(lbound_x_y, nelems_x_y, DVectXY(10, 10));
ddc::Chunk chk("", dom, ddc::HostAllocator<int>());
EXPECT_EQ(chk(lbound_x_y), chk[lbound_x_y]());
}