24#include "../Concepts.hpp"
25#include "../Stencil.hpp"
80 sycl::device
device = sycl::device();
112 GridImpl *pass_source = &source_grid;
113 GridImpl *pass_target = &swap_grid_b;
115 sycl::queue queue(params.
device);
116 auto walltime_start = std::chrono::high_resolution_clock::now();
119 for (
uindex_t i_subiter = 0; i_subiter < F::n_subiterations; i_subiter++) {
122 if (i_iter == 0 && i_subiter == 0) {
123 pass_source = &swap_grid_b;
124 pass_target = &swap_grid_a;
126 std::swap(pass_source, pass_target);
135 auto walltime_end = std::chrono::high_resolution_clock::now();
136 std::chrono::duration<double> walltime = walltime_end - walltime_start;
137 this->walltime += walltime.count();
187 using TDV =
typename F::TimeDependentValue;
190 queue.submit([&](sycl::handler &cgh) {
191 sycl::accessor source_ac(pass_source->get_buffer(), cgh, sycl::read_only);
192 sycl::accessor target_ac(pass_target->get_buffer(), cgh, sycl::write_only);
193 index_t grid_width = source_ac.get_range()[0];
194 index_t grid_height = source_ac.get_range()[1];
198 TDV tdv = transition_function.get_time_dependent_value(i_iter);
200 auto kernel = [=](sycl::id<2> id) {
201 StencilImpl
stencil(
ID(
id[0],
id[1]),
UID(grid_width, grid_height), i_iter,
204 for (
index_t rel_c = -stencil_radius; rel_c <= stencil_radius; rel_c++) {
205 for (
index_t rel_r = -stencil_radius; rel_r <= stencil_radius; rel_r++) {
208 bool within_grid = c >= 0 && r >= 0 && c < grid_width && r < grid_height;
209 stencil[
ID(rel_c, rel_r)] = (within_grid) ? source_ac[c][r] : halo_value;
213 target_ac[id] = transition_function(
stencil);
216 cgh.parallel_for(source_ac.get_range(), kernel);
The stencil buffer.
Definition Stencil.hpp:48
A grid class for the CPU backend.
Definition Grid.hpp:51
Grid make_similar() const
Create an new, uninitialized grid with the same size as the current one.
Definition Grid.hpp:169
uindex_t get_grid_height() const
Return the height, or number of rows, of the grid.
Definition Grid.hpp:164
uindex_t get_grid_width() const
Return the width, or number of columns, of the grid.
Definition Grid.hpp:159
A grid updater that applies an iterative stencil code to a grid.
Definition StencilUpdate.hpp:40
StencilUpdate(Params params)
Create a new stencil updater object.
Definition StencilUpdate.hpp:97
uindex_t get_n_processed_cells() const
Return the accumulated total number of cells processed by this updater.
Definition StencilUpdate.hpp:158
Grid< Cell > GridImpl
Shorthand for the used and supported grid type.
Definition StencilUpdate.hpp:46
Params & get_params()
Return a reference to the parameters.
Definition StencilUpdate.hpp:149
double get_walltime() const
Return the accumulated runtime of the updater, measured from the host side.
Definition StencilUpdate.hpp:166
GridImpl operator()(GridImpl &source_grid)
Compute a new grid based on the source grid, using the configured transition function.
Definition StencilUpdate.hpp:109
Definition AccessorSubscript.hpp:24
GenericID< uindex_t > UID
An unsigned, two-dimensional index.
Definition GenericID.hpp:80
BOOST_PP_CAT(BOOST_PP_CAT(uint, STENCIL_INDEX_WIDTH), _t) uindex_t
An unsigned integer of configurable width.
Definition Index.hpp:42
GenericID< index_t > ID
A signed, two-dimensional index.
Definition GenericID.hpp:75
BOOST_PP_CAT(BOOST_PP_CAT(int, STENCIL_INDEX_WIDTH), _t) index_t
A signed integer of configurable width.
Definition Index.hpp:56
Parameters for the stencil updater.
Definition StencilUpdate.hpp:51
uindex_t iteration_offset
The iteration index offset.
Definition StencilUpdate.hpp:70
Cell halo_value
The cell value to present for cells outside of the grid.
Definition StencilUpdate.hpp:62
bool blocking
Should the stencil updater block until completion, or return immediately after all kernels have been ...
Definition StencilUpdate.hpp:91
uindex_t n_iterations
The number of iterations to compute.
Definition StencilUpdate.hpp:75
sycl::device device
The device to use for computations.
Definition StencilUpdate.hpp:80
F transition_function
An instance of the transition function type.
Definition StencilUpdate.hpp:57