21 template<
typename TDim,
typename TView,
typename TExtent>
24 static_assert(TDim::value > 0);
30 static_assert(std::is_trivially_copyable_v<Elem>,
"Only trivially copyable types supported for fill");
32 template<
typename TViewFwd>
42 ALPAKA_ASSERT((castVec<DstSize>(m_extent) <= m_dstExtent).all());
43 if constexpr(TDim::value > 0)
45 ALPAKA_ASSERT(
static_cast<std::size_t
>(m_dstPitchBytes[TDim::value - 1]) >=
sizeof(
Elem));
46 ALPAKA_ASSERT(
static_cast<std::size_t
>(m_dstPitchBytes[TDim::value - 1]) %
alignof(
Elem) == 0);
48 if constexpr(TDim::value > 1)
50 for(
int dim = TDim::value - 2; dim >= 0; --dim)
53 static_cast<std::size_t
>(m_dstPitchBytes[dim])
54 >=
static_cast<std::size_t
>(m_dstPitchBytes[dim + 1] * m_dstExtent[dim + 1]));
55 ALPAKA_ASSERT(
static_cast<std::size_t
>(m_dstPitchBytes[dim]) %
alignof(
Elem) == 0);
58 ALPAKA_ASSERT(
reinterpret_cast<std::uintptr_t
>(m_dstMemNative) %
alignof(
Elem) == 0);
63 if(
static_cast<std::size_t
>(m_extent.prod()) != 0u)
70 std::uintptr_t offsetBytes =
static_cast<std::uintptr_t
>((idx * m_dstPitchBytes).sum());
71 Elem* elem =
reinterpret_cast<Elem*
>(__builtin_assume_aligned(
72 reinterpret_cast<std::uint8_t*
>(m_dstMemNative) + offsetBytes,
82#if(!defined(NDEBUG)) || (ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
86 Elem*
const m_dstMemNative;
90 template<
typename TView,
typename TExtent>
95 template<
typename TViewFwd>
96 TaskFillCpu(TViewFwd&& view,
Elem const& value, [[maybe_unused]] TExtent
const& extent)
102 ALPAKA_ASSERT(
reinterpret_cast<std::uintptr_t
>(m_dstMemNative) %
alignof(
Elem) == 0);
107 *m_dstMemNative = m_value;
112 Elem*
const m_dstMemNative;
119 template<
typename TDim>
120 struct CreateTaskFill<TDim, DevCpu>
122 template<
typename TExtent,
typename TViewFwd>
125 alpaka::Elem<std::remove_reference_t<TViewFwd>>
const& value,
126 TExtent
const& extent)
128 using TView = std::remove_reference_t<TViewFwd>;
131 std::is_trivially_copyable_v<Elem>,
132 "Only trivially copyable types are supported for fill");
#define ALPAKA_ASSERT(...)
The assert can be explicit disabled by defining NDEBUG.
The alpaka accelerator library.
typename trait::IdxType< T >::type Idx
ALPAKA_FN_HOST auto getPitchesInBytes(TView const &view) -> Vec< Dim< TView >, Idx< TView > >
ALPAKA_FN_HOST auto createTaskFill(TViewFwd &&view, TValue const &value, TExtent const &extent)
ALPAKA_FN_HOST auto getPtrNative(TView const &view) -> Elem< TView > const *
Gets the native pointer of the memory view.
std::remove_volatile_t< typename trait::ElemType< TView >::type > Elem
The element type trait alias template to remove the ::type.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getExtents(T const &object) -> Vec< Dim< T >, Idx< T > >
std::integral_constant< std::size_t, N > DimInt
ALPAKA_FN_HOST auto operator()() const noexcept -> void
alpaka::Elem< TView > Elem
TaskFillCpu(TViewFwd &&view, Elem const &value, TExtent const &extent)
The CPU device N-dimensional memory fill task.
ALPAKA_FN_HOST auto operator()() const -> void
Idx< TExtent > ExtentSize
TaskFillCpu(TViewFwd &&view, Elem const &value, TExtent const &extent)
alpaka::Elem< TView > Elem