27#ifdef ALPAKA_ACC_SYCL_ENABLED
35 template<
typename TDim,
typename TView,
typename TExtent,
typename TValue>
36 struct TaskFillSyclBase
38 using ExtentSize = Idx<TExtent>;
39 using DstSize = Idx<TView>;
42 template<
typename TViewFwd>
43 TaskFillSyclBase(TViewFwd&& view, TValue
const& value, TExtent
const& extent)
46 , m_extentWidth(m_extent.back())
54 if constexpr(TDim::value > 1)
56 m_extentWidth *
static_cast<ExtentSize
>(
sizeof(Elem)) <= m_dstPitchBytes[TDim::value - 2]);
59# if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
60 auto printDebug() const ->
void
62 std::cout << __func__ <<
" e: " << m_extent <<
" ew: " << m_extentWidth <<
" de: " << m_dstExtent
63 <<
" dptr: " <<
reinterpret_cast<void*
>(m_dstMemNative) <<
" dpitchb: " << m_dstPitchBytes
69 Vec<TDim, ExtentSize>
const m_extent;
70 ExtentSize
const m_extentWidth;
71# if(!defined(NDEBUG)) || (ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
72 Vec<TDim, DstSize>
const m_dstExtent;
74 Vec<TDim, DstSize>
const m_dstPitchBytes;
75 Elem*
const m_dstMemNative;
77 static constexpr auto is_sycl_task =
true;
80 template<
typename TDim,
typename TView,
typename TExtent,
typename TValue>
81 struct TaskFillSycl :
public TaskFillSyclBase<TDim, TView, TExtent, TValue>
83 using Base = TaskFillSyclBase<TDim, TView, TExtent, TValue>;
85 using typename Base::DstSize;
86 using typename Base::ExtentSize;
87 using DimMin1 =
DimInt<TDim::value - 1u>;
89 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
92# if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
95 Vec<DimMin1, ExtentSize>
const extentWithoutInnermost(subVecBegin<DimMin1>(this->m_extent));
96 Vec<DimMin1, DstSize>
const dstPitchBytesWithoutInnermost(subVecBegin<DimMin1>(this->m_dstPitchBytes));
98 std::vector<sycl::event> events;
99 events.reserve(
static_cast<std::size_t
>(extentWithoutInnermost.prod()));
101 if(
static_cast<std::size_t
>(this->m_extent.prod()) != 0u)
103 using Elem = std::remove_cvref_t<
decltype(this->m_value)>;
106 extentWithoutInnermost,
107 [&](Vec<DimMin1, ExtentSize>
const& idx)
109 auto offsetBytes = (castVec<DstSize>(idx) * dstPitchBytesWithoutInnermost).sum();
110 Elem* ptr =
reinterpret_cast<Elem*
>(
111 reinterpret_cast<std::uint8_t*
>(this->m_dstMemNative) + offsetBytes);
113 assert(this->m_extentWidth >= 0);
115 events.push_back(queue.fill<TValue>(
118 static_cast<std::size_t
>(this->m_extentWidth),
124 return queue.ext_oneapi_submit_barrier(events);
128 template<
typename TView,
typename TExtent,
typename TValue>
129 struct TaskFillSycl<
DimInt<1u>, TView, TExtent, TValue>
130 :
public TaskFillSyclBase<DimInt<1u>, TView, TExtent, TValue>
132 using Base = TaskFillSyclBase<DimInt<1u>, TView, TExtent, TValue>;
135 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
138# if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
141 if(
static_cast<std::size_t
>(this->m_extent.prod()) != 0u)
144 this->m_dstMemNative,
146 static_cast<std::size_t
>(this->m_extentWidth),
151 return queue.ext_oneapi_submit_barrier();
156 template<
typename TView,
typename TExtent,
typename TValue>
157 struct TaskFillSycl<
DimInt<0u>, TView, TExtent, TValue>
161 template<
typename TViewFwd>
162 TaskFillSycl(TViewFwd&& view, TValue
const& value, [[maybe_unused]] TExtent
const& extent)
170 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
173 return queue.fill(m_dstMemNative, m_value, 1, requirements);
176 TValue
const m_value;
177 Elem*
const m_dstMemNative;
178 static constexpr auto is_sycl_task =
true;
185 template<
typename TDim,
typename TPlatform>
186 struct CreateTaskFill<TDim, DevGenericSycl<TPlatform>>
188 template<
typename TExtent,
typename TView,
typename TValue>
189 static auto createTaskFill(TView& view, TValue
const& value, TExtent
const& extent)
190 -> alpaka::detail::TaskFillSycl<TDim, TView, TExtent, TValue>
192 return alpaka::detail::TaskFillSycl<TDim, TView, TExtent, TValue>(view, value, extent);
#define ALPAKA_ASSERT(...)
The assert can be explicit disabled by defining NDEBUG.
#define ALPAKA_DEBUG
Set the minimum log level if it is not defined.
#define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE
#define ALPAKA_DEBUG_FULL
The full debug level.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto all(TWarp const &warp, std::int32_t predicate) -> std::int32_t
Evaluates predicate for all active threads of the warp and returns non-zero if and only if predicate ...
The alpaka accelerator library.
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