21 #ifndef RAJA_policy_sycl_kernel_SyclKernel_HPP
22 #define RAJA_policy_sycl_kernel_SyclKernel_HPP
24 #include "RAJA/config.hpp"
26 #if defined(RAJA_ENABLE_SYCL)
31 #include "camp/camp.hpp"
55 RAJA::Pattern::forall,
56 detail::get_launch<async0>::value,
66 template<
typename LaunchConfig,
typename... EnclosedStmts>
68 :
public internal::Statement<LaunchConfig, EnclosedStmts...>
75 template<
typename... EnclosedStmts>
76 using SyclKernel = SyclKernelExt<sycl_launch<false>, EnclosedStmts...>;
82 template<
typename... EnclosedStmts>
83 using SyclKernelAsync = SyclKernelExt<sycl_launch<true>, EnclosedStmts...>;
93 template<
typename Data,
typename Exec>
94 void SyclKernelLauncher(Data data, ::sycl::nd_item<3> item)
97 using data_t = camp::decay<Data>;
98 data_t private_data = data;
101 Exec::exec(private_data, item,
true);
108 template<
bool IsTriviallyCopyable,
109 typename LaunchPolicy,
113 struct SyclLaunchHelper;
120 template<
bool async0,
typename StmtList,
typename Data,
typename Types>
121 struct SyclLaunchHelper<false, sycl_launch<async0>, StmtList, Data, Types>
123 using Self = SyclLaunchHelper;
125 static constexpr
bool async = async0;
128 internal::sycl_statement_list_executor_t<StmtList, Data, Types>;
129 using data_t = camp::decay<Data>;
131 static void launch(Data&& data,
132 internal::LaunchDims launch_dims,
142 data_t* m_data = (data_t*)::sycl::malloc_device(
sizeof(data_t), *qu);
143 qu->memcpy(m_data, &data,
sizeof(data_t)).wait();
145 qu->submit([&](::sycl::handler& h) {
146 h.parallel_for(launch_dims.fit_nd_range(qu),
147 [=](::sycl::nd_item<3> item) {
148 SyclKernelLauncher<Data, executor_t>(*m_data, item);
152 ::sycl::free(m_data, *qu);
161 template<
bool async0,
typename StmtList,
typename Data,
typename Types>
162 struct SyclLaunchHelper<true, sycl_launch<async0>, StmtList, Data, Types>
164 using Self = SyclLaunchHelper;
166 static constexpr
bool async = async0;
169 internal::sycl_statement_list_executor_t<StmtList, Data, Types>;
170 using data_t = camp::decay<Data>;
172 static void launch(Data&& data,
173 internal::LaunchDims launch_dims,
178 qu->submit([&](::sycl::handler& h) {
179 h.parallel_for(launch_dims.fit_nd_range(qu),
180 [=](::sycl::nd_item<3> item) {
181 SyclKernelLauncher<Data, executor_t>(data, item);
195 template<
typename LaunchConfig,
typename... EnclosedStmts,
typename Types>
196 struct StatementExecutor<
197 statement::SyclKernelExt<LaunchConfig, EnclosedStmts...>,
202 using StatementType =
203 statement::SyclKernelExt<LaunchConfig, EnclosedStmts...>;
205 template<
typename Data>
206 static inline void exec(Data&& data)
209 using data_t = camp::decay<Data>;
211 sycl_statement_list_executor_t<stmt_list_t, data_t, Types>;
212 using launch_t = SyclLaunchHelper<std::is_trivially_copyable<data_t>::value,
213 LaunchConfig, stmt_list_t, data_t, Types>;
215 camp::resources::Sycl res = data.get_resource();
216 ::sycl::queue* q = res.get_queue();
222 LaunchDims launch_dims = executor_t::calculateDimensions(data);
Header file defining prototypes for routines used to manage memory for SYCL reductions and other oper...
Header file for common RAJA internal macro definitions.
#define RAJA_UNUSED_ARG(x)
Definition: macros.hpp:97
camp::list< Stmts... > StatementList
Definition: StatementList.hpp:41
Definition: AlignedRangeIndexSetBuilders.cpp:35
void launch(LaunchParams const &launch_params, ReduceParams &&... rest_of_launch_args)
Definition: launch_core.hpp:268
Header file for statement wrappers and executors.
Header file for kernel lambda executor.
RAJA header file containing user interface for RAJA::kernel.
RAJA header file containing constructs used to run kernel traversals on GPU with SYCL.
Definition: PolicyBase.hpp:75
Header file containing RAJA SYCL policy definitions.
Header file for RAJA type definitions.