11 #ifdef ALPAKA_ACC_SYCL_ENABLED
13 # include <sycl/sycl.hpp>
18 template<
typename TDim,
typename TIdx>
19 class WorkDivGenericSycl :
public interface::Implements<ConceptWorkDiv, WorkDivGenericSycl<TDim, TIdx>>
21 static_assert(TDim::value > 0,
"The SYCL work division must have a dimension greater than zero.");
24 using WorkDivBase = WorkDivGenericSycl;
26 WorkDivGenericSycl(Vec<TDim, TIdx>
const& threadElemExtent, sycl::nd_item<TDim::value> work_item)
27 : m_threadElemExtent{threadElemExtent}
28 , m_item_workdiv{work_item}
32 Vec<TDim, TIdx>
const& m_threadElemExtent;
33 sycl::nd_item<TDim::value> m_item_workdiv;
40 template<
typename TDim,
typename TIdx>
41 struct DimType<WorkDivGenericSycl<TDim, TIdx>>
47 template<
typename TDim,
typename TIdx>
48 struct IdxType<WorkDivGenericSycl<TDim, TIdx>>
54 template<
typename TDim,
typename TIdx>
55 struct GetWorkDiv<WorkDivGenericSycl<TDim, TIdx>, origin::Grid, unit::Blocks>
58 static auto getWorkDiv(WorkDivGenericSycl<TDim, TIdx>
const& workDiv) -> Vec<TDim, TIdx>
60 if constexpr(TDim::value == 0)
61 return
Vec<TDim, TIdx>{};
62 else if constexpr(TDim::value == 1)
63 return
Vec<TDim, TIdx>{
static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(0))};
64 else if constexpr(TDim::value == 2)
66 return Vec<TDim, TIdx>{
67 static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(1)),
68 static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(0))};
72 return Vec<TDim, TIdx>{
73 static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(2)),
74 static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(1)),
75 static_cast<TIdx
>(workDiv.m_item_workdiv.get_group_range(0))};
81 template<
typename TDim,
typename TIdx>
82 struct GetWorkDiv<WorkDivGenericSycl<TDim, TIdx>, origin::Block, unit::Threads>
85 static auto getWorkDiv(WorkDivGenericSycl<TDim, TIdx>
const& workDiv) -> Vec<TDim, TIdx>
87 if constexpr(TDim::value == 0)
88 return
Vec<TDim, TIdx>{};
89 else if constexpr(TDim::value == 1)
90 return
Vec<TDim, TIdx>{
static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(0))};
91 else if constexpr(TDim::value == 2)
93 return Vec<TDim, TIdx>{
94 static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(1)),
95 static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(0))};
99 return Vec<TDim, TIdx>{
100 static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(2)),
101 static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(1)),
102 static_cast<TIdx
>(workDiv.m_item_workdiv.get_local_range(0))};
108 template<
typename TDim,
typename TIdx>
109 struct GetWorkDiv<WorkDivGenericSycl<TDim, TIdx>, origin::Thread, unit::Elems>
112 static auto getWorkDiv(WorkDivGenericSycl<TDim, TIdx>
const& workDiv) -> Vec<TDim, TIdx>
114 return workDiv.m_threadElemExtent;
The alpaka accelerator library.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getWorkDiv(TWorkDiv const &workDiv) -> Vec< Dim< TWorkDiv >, Idx< TWorkDiv >>
Get the extent requested.
ALPAKA_FN_HOST_ACC Vec(TFirstIndex &&, TRestIndices &&...) -> Vec< DimInt< 1+sizeof...(TRestIndices)>, std::decay_t< TFirstIndex >>