9#include <Kokkos_Macros.hpp>
11#include "chunk_span.hpp"
12#include "chunk_traits.hpp"
13#include "parallel_for_each.hpp"
22 class LayoutStridedPolicy,
25class TransformKokkosLambdaAdapter
27 ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace> m_chunk;
32 explicit TransformKokkosLambdaAdapter(
33 ChunkSpan<ElementType, SupportType, LayoutStridedPolicy, MemorySpace>
const& chunk,
34 Functor
const& functor)
40 KOKKOS_FUNCTION
void operator()(
41 typename SupportType::discrete_element_type
const i)
const noexcept
43 ElementType& value = m_chunk(i);
44 value = m_functor(
static_cast<ElementType
const&>(value));
51
52
53
54
55
56template <
class ChunkDst,
class UnaryTransformOp>
59 static_assert(is_borrowed_chunk_v<ChunkDst>);
61 "ddc_parallel_transform_default",
63 detail::TransformKokkosLambdaAdapter(
65 std::forward<UnaryTransformOp>(transform)));
66 return dst.span_view();
70
71
72
73
74
75
76template <
class ExecSpace,
class ChunkDst,
class UnaryTransformOp>
78 ExecSpace
const& execution_space,
80 UnaryTransformOp&& transform)
82 static_assert(is_borrowed_chunk_v<ChunkDst>);
84 "ddc_parallel_transform_default",
87 detail::TransformKokkosLambdaAdapter(
89 std::forward<UnaryTransformOp>(transform)));
90 return dst.span_view();
The top-level namespace of DDC.
auto parallel_transform(ExecSpace const &execution_space, ChunkDst &&dst, UnaryTransformOp &&transform)
Transform a borrowed chunk with a given transform functor.
auto parallel_transform(ChunkDst &&dst, UnaryTransformOp &&transform)
Transform a borrowed chunk with a given transform functor.