24 #ifdef ALPAKA_ACC_SYCL_ENABLED
32 template<
typename TDim,
typename TView,
typename TExtent>
33 struct TaskSetSyclBase
35 using ExtentSize = Idx<TExtent>;
36 using DstSize = Idx<TView>;
39 template<
typename TViewFwd>
40 TaskSetSyclBase(TViewFwd&& view, std::uint8_t
const&
byte, TExtent
const& extent)
43 , m_extentWidthBytes(m_extent.back() * static_cast<ExtentSize>(sizeof(
Elem)))
49 , m_dstMemNative(reinterpret_cast<std::uint8_t*>(
getPtrNative(view)))
53 if constexpr(TDim::value > 1)
54 ALPAKA_ASSERT(m_extentWidthBytes <= m_dstPitchBytes[TDim::value - 2]);
57 # if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
58 auto printDebug() const ->
void
60 std::cout << __func__ <<
" e: " << this->m_extent <<
" ewb: " << this->m_extentWidthBytes
61 <<
" de: " << this->m_dstExtent <<
" dptr: " <<
reinterpret_cast<void*
>(this->m_dstMemNative)
62 <<
" dpitchb: " << this->m_dstPitchBytes << std::endl;
66 std::uint8_t
const m_byte;
67 Vec<TDim, ExtentSize>
const m_extent;
68 ExtentSize
const m_extentWidthBytes;
69 # if(!defined(NDEBUG)) || (ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL)
70 Vec<TDim, DstSize>
const m_dstExtent;
72 Vec<TDim, DstSize>
const m_dstPitchBytes;
73 std::uint8_t*
const m_dstMemNative;
74 static constexpr
auto is_sycl_task =
true;
78 template<
typename TDim,
typename TView,
typename TExtent>
79 struct TaskSetSycl :
public TaskSetSyclBase<TDim, TView, TExtent>
81 using DimMin1 =
DimInt<TDim::value - 1u>;
82 using typename TaskSetSyclBase<TDim, TView, TExtent>::ExtentSize;
83 using typename TaskSetSyclBase<TDim, TView, TExtent>::DstSize;
85 using TaskSetSyclBase<TDim, TView, TExtent>::TaskSetSyclBase;
87 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
91 # if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
96 Vec<DimMin1, ExtentSize>
const extentWithoutInnermost(subVecBegin<DimMin1>(this->m_extent));
97 Vec<DimMin1, DstSize>
const dstPitchBytesWithoutInnermost(subVecBegin<DimMin1>(this->m_dstPitchBytes));
100 std::vector<sycl::event> events;
101 events.reserve(
static_cast<std::size_t
>(extentWithoutInnermost.prod()));
103 if(
static_cast<std::size_t
>(this->m_extent.prod()) != 0u)
106 extentWithoutInnermost,
107 [&](Vec<DimMin1, ExtentSize>
const& idx)
109 events.push_back(queue.memset(
110 this->m_dstMemNative + (castVec<DstSize>(idx) * dstPitchBytesWithoutInnermost).sum(),
112 static_cast<std::size_t
>(this->m_extentWidthBytes),
118 return queue.ext_oneapi_submit_barrier(events);
123 template<
typename TView,
typename TExtent>
124 struct TaskSetSycl<
DimInt<1u>, TView, TExtent> :
public TaskSetSyclBase<DimInt<1u>, TView, TExtent>
126 using TaskSetSyclBase<DimInt<1u>, TView, TExtent>::TaskSetSyclBase;
128 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
132 # if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
135 if(
static_cast<std::size_t
>(this->m_extent.prod()) != 0u)
138 reinterpret_cast<void*
>(this->m_dstMemNative),
140 static_cast<std::size_t
>(this->m_extentWidthBytes),
145 return queue.ext_oneapi_submit_barrier();
151 template<
typename TView,
typename TExtent>
152 struct TaskSetSycl<
DimInt<0u>, TView, TExtent>
154 using ExtentSize = Idx<TExtent>;
155 using Scalar = Vec<DimInt<0u>, ExtentSize>;
156 using DstSize = Idx<TView>;
159 template<
typename TViewFwd>
160 TaskSetSycl(TViewFwd&& view, std::uint8_t
const&
byte, [[maybe_unused]] TExtent
const& extent)
162 , m_dstMemNative(reinterpret_cast<std::uint8_t*>(
getPtrNative(view)))
169 # if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
170 auto printDebug() const ->
void
172 std::cout << __func__ <<
" e: " << Scalar() <<
" ewb: " <<
sizeof(
Elem) <<
" de: " << Scalar()
173 <<
" dptr: " <<
reinterpret_cast<void*
>(m_dstMemNative) <<
" dpitchb: " << Scalar()
178 auto operator()(sycl::queue& queue, std::vector<sycl::event>
const& requirements)
const -> sycl::event
182 # if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
185 return queue.memset(
reinterpret_cast<void*
>(m_dstMemNative), m_byte,
sizeof(
Elem), requirements);
188 std::uint8_t
const m_byte;
189 std::uint8_t*
const m_dstMemNative;
190 static constexpr
auto is_sycl_task =
true;
198 template<
typename TDim,
typename TPlatform>
199 struct CreateTaskMemset<TDim, DevGenericSycl<TPlatform>>
201 template<
typename TExtent,
typename TView>
202 static auto createTaskMemset(TView& view, std::uint8_t
const&
byte, TExtent
const& extent)
203 -> alpaka::detail::TaskSetSycl<TDim, TView, TExtent>
205 return alpaka::detail::TaskSetSycl<TDim, TView, TExtent>(view,
byte, 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_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getExtents(T const &object) -> Vec< Dim< T >, Idx< T >>
ALPAKA_FN_HOST auto getPitchesInBytes(TView const &view) -> Vec< Dim< TView >, Idx< TView >>
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.
std::integral_constant< std::size_t, N > DimInt
ALPAKA_FN_HOST auto createTaskMemset(TViewFwd &&view, std::uint8_t const &byte, TExtent const &extent)
Create a memory set task.