21#include "../Concepts.hpp"
31namespace single_pass {
47template <
typename T,
typename TransFunc>
51 local_state.get_time_dependent_value(i)
52 } -> std::same_as<typename TransFunc::TimeDependentValue>;
64template <
typename T,
typename TransFunc>
67 std::constructible_from<typename T::LocalState, T const &>;
84template <
typename T,
typename TransFunc>
87 std::constructible_from<T, TransFunc, uindex_t, uindex_t> &&
89 std::constructible_from<typename T::KernelArgument, T &, sycl::handler &, uindex_t, uindex_t>;
98template <
typename T,
typename TransFunc, uindex_t max_n_iterations>
115 template <stencil::concepts::TransitionFunction TransFunc, uindex_t max_n_iterations>
117 using TDV =
typename TransFunc::TimeDependentValue;
120 : trans_func(trans_func) {}
125 : trans_func(global_state.trans_func), iteration_offset(iteration_offset) {}
130 return trans_func.get_time_dependent_value(iteration_offset + i_iteration);
134 TransFunc trans_func;
139 TransFunc trans_func;
153 template <stencil::concepts::TransitionFunction TransFunc, uindex_t max_n_iterations>
155 using TDV =
typename TransFunc::TimeDependentValue;
158 : trans_func(trans_func) {}
163 : trans_func(global_state.trans_func), iteration_offset(iteration_offset) {}
167 for (
uindex_t i = 0; i < max_n_iterations; i++) {
168 values[i] = kernel_argument.trans_func.get_time_dependent_value(
169 kernel_argument.iteration_offset + i);
174 return values[i_iteration];
178 TDV values[max_n_iterations];
182 TransFunc trans_func;
187 TransFunc trans_func;
201 template <stencil::concepts::TransitionFunction TransFunc, uindex_t max_n_iterations>
204 using TDV =
typename TransFunc::TimeDependentValue;
207 : function(function), iteration_offset(iteration_offset),
208 value_buffer(sycl::range<1>(n_iterations)) {
209 sycl::host_accessor ac(value_buffer, sycl::read_write);
210 for (
uindex_t i = 0; i < n_iterations; i++) {
211 ac[i] = function.get_time_dependent_value(iteration_offset + i);
216 : function(other.function), iteration_offset(other.iteration_offset),
217 value_buffer(other.value_buffer) {}
223 assert(n_iterations <= max_n_iterations);
224 assert(i_iteration >= global_state.iteration_offset);
225 assert(i_iteration + n_iterations <=
226 global_state.iteration_offset + global_state.value_buffer.get_range()[0]);
228 sycl::range<1> access_range(n_iterations);
229 sycl::id<1> access_offset(i_iteration - global_state.iteration_offset);
230 ac = sycl::accessor<TDV, 1, sycl::access::mode::read>(
231 global_state.value_buffer, cgh, access_range, access_offset);
237 std::min(max_n_iterations,
uindex_t(kernel_argument.ac.get_range()[0]));
239 for (
uindex_t i = 0; i < n_values; i++)
240 values[i] = kernel_argument.ac[i];
246 TDV values[max_n_iterations];
250 sycl::accessor<TDV, 1, sycl::access::mode::read> ac;
256 sycl::buffer<TDV, 1> value_buffer;
GlobalState(TransFunc function, uindex_t iteration_offset, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:206
typename TransFunc::TimeDependentValue TDV
Definition SinglePassStrategies.hpp:204
GlobalState(GlobalState const &other)
Definition SinglePassStrategies.hpp:215
A technical definition of a stencil transition function.
Definition Concepts.hpp:62
The requirements for a TDV system's global state.
Definition SinglePassStrategies.hpp:85
The requirements for a TDV kernel argument.
Definition SinglePassStrategies.hpp:65
The requirements for a pass-local TDV system state.
Definition SinglePassStrategies.hpp:48
Requirements for a TDV implementation strategy.
Definition SinglePassStrategies.hpp:99
Definition AccessorSubscript.hpp:24
BOOST_PP_CAT(BOOST_PP_CAT(uint, STENCIL_INDEX_WIDTH), _t) uindex_t
An unsigned integer of configurable width.
Definition Index.hpp:42
KernelArgument(GlobalState &global_state, sycl::handler &cgh, uindex_t iteration_offset, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:123
TDV get_time_dependent_value(uindex_t i_iteration) const
Definition SinglePassStrategies.hpp:129
typename TransFunc::TimeDependentValue TDV
Definition SinglePassStrategies.hpp:117
GlobalState(TransFunc trans_func, uindex_t iteration_offset, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:119
A TDV implementation strategy that inlines the TDV function into the transition function.
Definition SinglePassStrategies.hpp:114
LocalState(KernelArgument const &kernel_argument)
Definition SinglePassStrategies.hpp:166
TDV get_time_dependent_value(uindex_t i_iteration) const
Definition SinglePassStrategies.hpp:173
KernelArgument(GlobalState &global_state, sycl::handler &cgh, uindex_t iteration_offset, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:161
GlobalState(TransFunc trans_func, uindex_t iteration_offset, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:157
typename TransFunc::TimeDependentValue TDV
Definition SinglePassStrategies.hpp:155
A TDV implementation strategy that precomputes TDVs on the device.
Definition SinglePassStrategies.hpp:152
LocalState(KernelArgument const &kernel_argument)
Definition SinglePassStrategies.hpp:235
TDV get_time_dependent_value(uindex_t i) const
Definition SinglePassStrategies.hpp:243
KernelArgument(GlobalState &global_state, sycl::handler &cgh, uindex_t i_iteration, uindex_t n_iterations)
Definition SinglePassStrategies.hpp:220
A TDV implementation strategy that precomputes TDVs on the host.
Definition SinglePassStrategies.hpp:200