Skip to content
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

Add layout constraint #320

Merged
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
24 changes: 24 additions & 0 deletions include/ddc/mirror.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ auto create_mirror(
[[maybe_unused]] Space const& space,
ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
return Chunk(
src.domain(),
KokkosAllocator<std::remove_const_t<ElementType>, typename Space::memory_space>());
Expand All @@ -26,6 +29,9 @@ auto create_mirror(
template <class ElementType, class Support, class Layout, class MemorySpace>
auto create_mirror(ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
return Chunk(src.domain(), HostAllocator<std::remove_const_t<ElementType>>());
}

Expand All @@ -35,6 +41,9 @@ auto create_mirror_and_copy(
Space const& space,
ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
Chunk chunk = create_mirror(space, src);
parallel_deepcopy(space, chunk, src);
return chunk;
Expand All @@ -44,6 +53,9 @@ auto create_mirror_and_copy(
template <class ElementType, class Support, class Layout, class MemorySpace>
auto create_mirror_and_copy(ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
Chunk chunk = create_mirror(src);
parallel_deepcopy(chunk, src);
return chunk;
Expand All @@ -56,6 +68,9 @@ auto create_mirror_view(
Space const& space,
ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
if constexpr (Kokkos::SpaceAccessibility<Space, MemorySpace>::accessible) {
return src;
} else {
Expand All @@ -68,6 +83,9 @@ auto create_mirror_view(
template <class ElementType, class Support, class Layout, class MemorySpace>
auto create_mirror_view(ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
if constexpr (Kokkos::SpaceAccessibility<Kokkos::HostSpace, MemorySpace>::accessible) {
return src;
} else {
Expand All @@ -82,6 +100,9 @@ auto create_mirror_view_and_copy(
Space const& space,
ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
if constexpr (Kokkos::SpaceAccessibility<Space, MemorySpace>::accessible) {
return src;
} else {
Expand All @@ -94,6 +115,9 @@ auto create_mirror_view_and_copy(
template <class ElementType, class Support, class Layout, class MemorySpace>
auto create_mirror_view_and_copy(ChunkSpan<ElementType, Support, Layout, MemorySpace> const& src)
{
static_assert(
std::is_same_v<Layout, std::experimental::layout_right>,
"Only layout right is supported");
if constexpr (Kokkos::SpaceAccessibility<Kokkos::HostSpace, MemorySpace>::accessible) {
return src;
} else {
Expand Down