41 #include <type_traits>
43 #ifdef ALPAKA_ACC_SYCL_ENABLED
45 # include <sycl/sycl.hpp>
49 template<
concepts::Tag TTag,
typename TAcc,
typename TDim,
typename TIdx,
typename TKernelFnObj,
typename... TArgs>
50 class TaskKernelGenericSycl;
55 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
57 :
public WorkDivGenericSycl<TDim, TIdx>
58 ,
public gb::IdxGbGenericSycl<TDim, TIdx>
59 ,
public bt::IdxBtGenericSycl<TDim, TIdx>
60 ,
public AtomicHierarchy<AtomicGenericSycl, AtomicGenericSycl, AtomicGenericSycl>
61 ,
public math::MathGenericSycl
62 ,
public BlockSharedMemDynGenericSycl
63 ,
public BlockSharedMemStGenericSycl
64 ,
public BlockSyncGenericSycl<TDim>
65 ,
public IntrinsicGenericSycl
66 ,
public MemFenceGenericSycl
67 # ifdef ALPAKA_DISABLE_VENDOR_RNG
68 ,
public rand::RandDefault
70 ,
public rand::RandGenericSycl<TDim>
72 ,
public warp::WarpGenericSycl<TDim>
73 ,
public interface::Implements<ConceptAcc, AccGenericSycl<TTag, TDim, TIdx>>
75 static_assert(TDim::value > 0,
"The SYCL accelerator must have a dimension greater than zero.");
78 AccGenericSycl(AccGenericSycl
const&) =
delete;
79 AccGenericSycl(AccGenericSycl&&) =
delete;
80 auto operator=(AccGenericSycl
const&) -> AccGenericSycl& =
delete;
81 auto operator=(AccGenericSycl&&) -> AccGenericSycl& =
delete;
84 Vec<TDim, TIdx>
const& threadElemExtent,
85 sycl::nd_item<TDim::value> work_item,
86 sycl::local_accessor<std::byte> dyn_shared_acc,
87 sycl::local_accessor<std::byte> st_shared_acc)
88 : WorkDivGenericSycl<TDim, TIdx>{threadElemExtent, work_item}
89 , gb::IdxGbGenericSycl<TDim, TIdx>{work_item}
90 , bt::IdxBtGenericSycl<TDim, TIdx>{work_item}
91 , BlockSharedMemDynGenericSycl{dyn_shared_acc}
92 , BlockSharedMemStGenericSycl{st_shared_acc}
93 , BlockSyncGenericSycl<TDim>{work_item}
94 # ifndef ALPAKA_DISABLE_VENDOR_RNG
95 , rand::RandGenericSycl<TDim>{work_item}
97 , warp::WarpGenericSycl<TDim>{work_item}
106 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
107 struct AccType<AccGenericSycl<TTag, TDim, TIdx>>
109 using type = AccGenericSycl<TTag, TDim, TIdx>;
113 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
114 struct IsSingleThreadAcc<AccGenericSycl<TTag, TDim, TIdx>> : std::false_type
119 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
120 struct IsMultiThreadAcc<AccGenericSycl<TTag, TDim, TIdx>> : std::true_type
125 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
126 struct GetAccDevProps<AccGenericSycl<TTag, TDim, TIdx>>
128 static auto getAccDevProps(DevGenericSycl<TTag>
const& dev) -> AccDevProps<TDim, TIdx>
130 auto const device = dev.getNativeHandle().first;
131 auto const max_threads_dim
132 = device.template get_info<sycl::info::device::max_work_item_sizes<TDim::value>>();
133 Vec<TDim, TIdx> max_threads_dim_vec{};
134 for(
int i = 0; i < static_cast<int>(TDim::value); i++)
135 max_threads_dim_vec[i] = alpaka::core::clipCast<TIdx>(max_threads_dim[i]);
137 alpaka::core::clipCast<TIdx>(device.template get_info<sycl::info::device::max_compute_units>()),
139 getExtentVecEnd<TDim>(
Vec<DimInt<3u>, TIdx>(
149 alpaka::core::clipCast<TIdx>(device.template get_info<sycl::info::device::max_work_group_size>()),
155 device.template get_info<sycl::info::device::local_mem_size>(),
162 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
163 struct GetAccName<AccGenericSycl<TTag, TDim, TIdx>>
167 return std::string(
"Acc") + core::demangled<TTag>.substr(__builtin_strlen(
"alpaka::Tag")) +
"<"
168 + std::to_string(TDim::value) +
"," + core::demangled<TIdx> +
">";
173 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
174 struct DevType<AccGenericSycl<TTag, TDim, TIdx>>
176 using type = DevGenericSycl<TTag>;
180 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
181 struct DimType<AccGenericSycl<TTag, TDim, TIdx>>
192 typename TKernelFnObj,
194 struct CreateTaskKernel<AccGenericSycl<TTag, TDim, TIdx>, TWorkDiv, TKernelFnObj, TArgs...>
196 static auto createTaskKernel(TWorkDiv
const& workDiv, TKernelFnObj
const& kernelFnObj, TArgs&&... args)
198 return TaskKernelGenericSycl<TTag, AccGenericSycl<TTag, TDim, TIdx>, TDim, TIdx, TKernelFnObj, TArgs...>{
201 std::forward<TArgs>(args)...};
206 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
207 struct PlatformType<AccGenericSycl<TTag, TDim, TIdx>>
209 using type = PlatformGenericSycl<TTag>;
213 template<concepts::Tag TTag,
typename TDim,
typename TIdx>
214 struct IdxType<AccGenericSycl<TTag, TDim, TIdx>>
ALPAKA_NO_HOST_ACC_WARNING static constexpr ALPAKA_FN_HOST_ACC auto all(TVal const &val) -> Vec< TDim, TVal >
Single value constructor.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto max(T const &max_ctx, Tx const &x, Ty const &y)
Returns the larger of two arguments. NaNs are treated as missing data (between a NaN and a numeric va...
The alpaka accelerator library.
ALPAKA_FN_HOST auto getAccDevProps(TDev const &dev) -> AccDevProps< Dim< TAcc >, Idx< TAcc >>
ALPAKA_FN_HOST auto createTaskKernel(TWorkDiv const &workDiv, TKernelFnObj const &kernelFnObj, TArgs &&... args)
Creates a kernel execution task.
ALPAKA_FN_HOST auto getMemBytes(TDev const &dev) -> std::size_t
ALPAKA_FN_HOST_ACC Vec(TFirstIndex &&, TRestIndices &&...) -> Vec< DimInt< 1+sizeof...(TRestIndices)>, std::decay_t< TFirstIndex >>
alpaka::meta::InheritFromList< alpaka::meta::Unique< std::tuple< TGridAtomic, TBlockAtomic, TThreadAtomic, interface::Implements< ConceptAtomicGrids, TGridAtomic >, interface::Implements< ConceptAtomicBlocks, TBlockAtomic >, interface::Implements< ConceptAtomicThreads, TThreadAtomic > >> > AtomicHierarchy
build a single class to inherit from different atomic implementations
static ALPAKA_FN_HOST auto getAccName() -> std::string