1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
/*
* GridTools
*
* Copyright (c) 2014-2023, ETH Zurich
* All rights reserved.
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <vector>
#include <gridtools/stencil/cartesian.hpp>
#include <stencil_select.hpp>
#include <test_environment.hpp>
namespace {
using namespace gridtools;
using namespace stencil;
using namespace cartesian;
struct prepare_tracers {
using data = inout_accessor<0>;
using data_nnow = in_accessor<1>;
using rho = in_accessor<2>;
using param_list = make_param_list<data, data_nnow, rho>;
template <typename Evaluation>
GT_FUNCTION static void apply(Evaluation eval) {
eval(data()) = eval(rho()) * eval(data_nnow());
}
};
GT_REGRESSION_TEST(advection_pdbott_prepare_tracers, test_environment<>, stencil_backend_t) {
std::vector<typename TypeParam::storage_type> in, out;
for (size_t i = 0; i < 11; ++i) {
out.push_back(TypeParam::make_storage());
in.push_back(TypeParam::make_storage(i));
}
auto comp = [&, grid = TypeParam::make_grid(), rho = TypeParam::make_const_storage(1.1)] {
expandable_run<2>(
[](auto out, auto in, auto rho) { return execute_parallel().stage(prepare_tracers(), out, in, rho); },
stencil_backend_t(),
grid,
out,
in,
rho);
};
comp();
for (size_t i = 0; i != out.size(); ++i)
TypeParam::verify([i](int, int, int) { return 1.1 * i; }, out[i]);
TypeParam::benchmark("advection_pdbott_prepare_tracers", comp);
}
} // namespace
|