-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
953c6c1
commit d02f2c1
Showing
12 changed files
with
315 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
#include "ddc/chunk_common.hpp" | ||
#include "ddc/chunk_span.hpp" | ||
|
||
namespace ddc { | ||
|
||
/** Copy the content of a chunk span into another | ||
* @param[out] dst the chunk span in which to copy | ||
* @param[in] src the chunk span from which to copy | ||
* @return dst as a ChunkSpan | ||
*/ | ||
template < | ||
class ElementTypeDst, | ||
class SupportDst, | ||
class LayoutDst, | ||
class MemorySpaceDst, | ||
class ElementTypeSrc, | ||
class SupportSrc, | ||
class LayoutSrc, | ||
class MemorySpaceSrc> | ||
KOKKOS_FUNCTION auto deepcopy( | ||
ChunkSpan<ElementTypeDst, SupportDst, LayoutDst, MemorySpaceDst> const& dst, | ||
ChunkSpan<ElementTypeSrc, SupportSrc, LayoutSrc, MemorySpaceSrc> const& src) noexcept | ||
{ | ||
using ChunkDst = ChunkSpan<ElementTypeDst, SupportDst, LayoutDst, MemorySpaceDst>; | ||
using ChunkSrc = ChunkSpan<ElementTypeSrc, SupportSrc, LayoutSrc, MemorySpaceSrc>; | ||
static_assert( | ||
std::is_assignable_v<chunk_reference_t<ChunkDst>, chunk_reference_t<ChunkSrc>>, | ||
"Not assignable"); | ||
KOKKOS_ASSERT(dst.domain().extents() == src.domain().extents()); | ||
KOKKOS_ASSERT( | ||
(Kokkos::SpaceAccessibility<DDC_CURRENT_KOKKOS_SPACE, MemorySpaceSrc>::accessible)); | ||
KOKKOS_ASSERT( | ||
(Kokkos::SpaceAccessibility<DDC_CURRENT_KOKKOS_SPACE, MemorySpaceDst>::accessible)); | ||
for_each(dst.domain(), [&dst, &src](typename SupportDst::discrete_element_type const& elem) { | ||
dst(elem) = src(elem); | ||
}); | ||
return dst; | ||
} | ||
|
||
} // namespace ddc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
#include "ddc/chunk_span.hpp" | ||
#include "ddc/detail/macros.hpp" | ||
#include "ddc/for_each.hpp" | ||
|
||
namespace ddc { | ||
|
||
/** Fill a chunk span with a given value | ||
* @param[out] dst the chunk span in which to copy | ||
* @param[in] value the value to fill `dst` | ||
* @return dst as a ChunkSpan | ||
*/ | ||
template <class ElementType, class Support, class Layout, class MemorySpace, class T> | ||
KOKKOS_FUNCTION auto fill( | ||
ChunkSpan<ElementType, Support, Layout, MemorySpace> const& dst, | ||
T const& value) noexcept | ||
{ | ||
static_assert( | ||
std::is_assignable_v< | ||
chunk_reference_t<ChunkSpan<ElementType, Support, Layout, MemorySpace>>, | ||
T>, | ||
"Not assignable"); | ||
KOKKOS_ASSERT((Kokkos::SpaceAccessibility<DDC_CURRENT_KOKKOS_SPACE, MemorySpace>::accessible)); | ||
for_each(dst.domain(), [&dst, &value](typename Support::discrete_element_type const& elem) { | ||
dst(elem) = value; | ||
}); | ||
return dst; | ||
} | ||
|
||
} // namespace ddc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.