Skip to content

Commit

Permalink
Add a CTAD to ChunkSpan from a Chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Dec 13, 2024
1 parent 0f8473c commit 3621b75
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/ddc/chunk_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,22 @@ ChunkSpan(KokkosView const& view, DiscreteDomain<DDims...> domain)
detail::kokkos_to_mdspan_layout_t<typename KokkosView::array_layout>,
typename KokkosView::memory_space>;

template <class ElementType, class SupportType, class Allocator>
ChunkSpan(Chunk<ElementType, SupportType, Allocator>& other)
-> ChunkSpan<
ElementType,
SupportType,
Kokkos::layout_right,
typename Allocator::memory_space>;

template <class ElementType, class SupportType, class Allocator>
ChunkSpan(Chunk<ElementType, SupportType, Allocator> const& other)
-> ChunkSpan<
const ElementType,
SupportType,
Kokkos::layout_right,
typename Allocator::memory_space>;

template <
class ElementType,
class SupportType,
Expand Down
12 changes: 12 additions & 0 deletions tests/chunk_span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT

#include <type_traits>
#include <utility>

#include <ddc/ddc.hpp>

Expand Down Expand Up @@ -33,3 +34,14 @@ TEST(ChunkSpan1DTest, ConstructionFromChunk)
EXPECT_TRUE((std::is_constructible_v<ChunkSpanX<const double>, ChunkX<double>&>));
EXPECT_TRUE((std::is_constructible_v<ChunkSpanX<const double>, ChunkX<double> const&>));
}

TEST(ChunkSpan1DTest, CTAD)
{
ChunkX<int> chk("chk", DDomX(DElemX(0), DVectX(0)));
EXPECT_TRUE((std::is_same_v<
decltype(ddc::ChunkSpan(chk)),
ddc::ChunkSpan<int, DDomX, Kokkos::layout_right, Kokkos::HostSpace>>));
EXPECT_TRUE((std::is_same_v<
decltype(ddc::ChunkSpan(std::as_const(chk))),
ddc::ChunkSpan<const int, DDomX, Kokkos::layout_right, Kokkos::HostSpace>>));
}

0 comments on commit 3621b75

Please sign in to comment.