StencilStream v3.0.0
SYCL-based Stencil Simulation Framework Targeting FPGAs
Loading...
Searching...
No Matches
Concepts.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2020-2024 Jan-Oliver Opdenhövel, Paderborn Center for Parallel Computing, Paderborn
3 * University
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the “Software”), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23#pragma once
24#include "Index.hpp"
25#include "Stencil.hpp"
26
27#include <concepts>
28#include <type_traits>
29
30namespace stencil {
31namespace concepts {
32
61template <typename T>
63 std::semiregular<typename T::Cell> && std::copyable<typename T::TimeDependentValue> &&
64
65 std::same_as<decltype(T::stencil_radius), const uindex_t> && (T::stencil_radius >= 1) &&
66 std::same_as<decltype(T::n_subiterations), const uindex_t> && (T::n_subiterations >= 1) &&
67
68 requires(T const &trans_func,
69 Stencil<typename T::Cell, T::stencil_radius, typename T::TimeDependentValue> const
70 &stencil) {
71 { trans_func(stencil) } -> std::same_as<typename T::Cell>;
72 } &&
73 requires(T const &trans_func, uindex_t i_iteration) {
74 {
75 trans_func.get_time_dependent_value(i_iteration)
76 } -> std::same_as<typename T::TimeDependentValue>;
77 };
78
85template <typename Accessor, typename Cell>
86concept GridAccessor = requires(Accessor ac, uindex_t c, uindex_t r) {
87 { ac[sycl::id<2>(c, r)] } -> std::same_as<Cell &>;
88 { ac[c][r] } -> std::same_as<Cell &>;
89};
90
114template <typename G, typename Cell>
115concept Grid = requires(G &grid, sycl::buffer<Cell, 2> buffer, uindex_t c, uindex_t r, Cell cell) {
116 { G(c, r) } -> std::same_as<G>;
117 { G(sycl::range<2>(c, r)) } -> std::same_as<G>;
118 { G(buffer) } -> std::same_as<G>;
119 { grid.copy_from_buffer(buffer) } -> std::same_as<void>;
120 { grid.copy_to_buffer(buffer) } -> std::same_as<void>;
121 { grid.get_grid_width() } -> std::convertible_to<uindex_t>;
122 { grid.get_grid_height() } -> std::convertible_to<uindex_t>;
123 { grid.make_similar() } -> std::same_as<G>;
124 {
125 typename G::template GridAccessor<sycl::access::mode::read_write>(grid)
127};
128
155template <typename SU, typename TF, typename G>
157 // Test construction and update call.
158 requires(SU stencil_update, G &grid, typename SU::Params params) {
159 { SU(params) } -> std::same_as<SU>;
160 { stencil_update.get_params() } -> std::same_as<typename SU::Params &>;
161 { stencil_update(grid) } -> std::same_as<G>;
162 } &&
163 // Test existance of parameter fields
164 requires(typename SU::Params params) {
165 { params.transition_function } -> std::same_as<TF &>;
166 { params.halo_value } -> std::same_as<typename TF::Cell &>;
167 { params.iteration_offset } -> std::same_as<uindex_t &>;
168 { params.n_iterations } -> std::same_as<uindex_t &>;
169 { params.device } -> std::same_as<sycl::device &>;
170 } && TransitionFunction<TF> && Grid<G, typename TF::Cell> &&
171 (std::is_class<typename SU::Params>::value);
172
173} // namespace concepts
174} // namespace stencil
An accessor for a two-dimensional grid.
Definition Concepts.hpp:86
A regular grid of cells.
Definition Concepts.hpp:115
A grid updater that repeatedly applies stencil updates to each cell.
Definition Concepts.hpp:156
A technical definition of a stencil transition function.
Definition Concepts.hpp:62
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