Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@ jobs:
container: ghcr.io/gridtools/gridtools-base:${{ matrix.compiler }}
strategy:
matrix:
compiler: [gcc-8, gcc-9, gcc-10, gcc-11, gcc-12, gcc-13, clang-11, clang-12, clang-13, clang-14, clang-15, clang-16, clang-14-cuda-11, gcc-10-cuda-11.8, gcc-11-cuda-12.0, gcc-12-cuda-12.3, gcc-12-cuda-12.4, base-rocm-6.2.2, gcc-10-hpx, nvhpc-23.3, nvhpc-23.9]
build_type: [debug, release]
exclude:
- compiler: gcc-8
build_type: debug
- compiler: gcc-9
build_type: debug
- compiler: gcc-10
build_type: debug
- compiler: gcc-11
build_type: debug
- compiler: clang-13
build_type: debug
- compiler: clang-14
build_type: debug
- compiler: gcc-10-hpx
build_type: debug
compiler: [gcc-13, clang-16, clang-14-cuda-11, gcc-12-cuda-12.4, base-rocm-6.2.2, gcc-10-hpx, nvhpc-23.9]
build_type: [release]
steps:
- uses: actions/checkout@v2
- name: setup environment
Expand All @@ -38,7 +23,7 @@ jobs:
echo "OMP_NUM_THREADS=$(nproc)" >> $GITHUB_ENV
- name: build
run: |
python3 pyutils/driver.py -vv build -b ${{ matrix.build_type }} -o $(pwd)/build -i $(pwd)/install -t perftests
python3 pyutils/driver.py -vv build -b ${{ matrix.build_type }} -o $(pwd)/build -i $(pwd)/install
- name: run tests
# no GPUs available -> no tests (for nvhpc we could run cpu, but we currently don't expose that option in pyutils/driver.py)
if: (!contains(matrix.compiler, 'cuda') && !contains(matrix.compiler, 'rocm') && !contains(matrix.compiler, 'nvhpc'))
Expand Down
16 changes: 8 additions & 8 deletions tests/regression/icosahedral/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ namespace {
run(spec,
stencil_backend_t(),
TypeParam ::make_grid(),
TypeParam ::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal),
TypeParam ::icosahedral_make_storage(edges(), repo.dual_edge_length),
TypeParam ::icosahedral_make_storage(edges(), repo.u),
TypeParam ::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal()),
TypeParam ::icosahedral_make_storage(edges(), repo.dual_edge_length()),
TypeParam ::icosahedral_make_storage(edges(), repo.u()),
out);
TypeParam::verify(repo.curl_u, out, eq<TypeParam>);
TypeParam::verify(repo.curl_u(), out, eq<TypeParam>);
}

GT_REGRESSION_TEST(curl_flow_convention, icosahedral_test_environment<2>, stencil_backend_t) {
Expand All @@ -54,10 +54,10 @@ namespace {
run_single_stage(curl_functor_flow_convention(),
stencil_backend_t(),
TypeParam ::make_grid(),
TypeParam ::icosahedral_make_storage(edges(), repo.u),
TypeParam ::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal),
TypeParam ::icosahedral_make_storage(edges(), repo.dual_edge_length),
TypeParam ::icosahedral_make_storage(edges(), repo.u()),
TypeParam ::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal()),
TypeParam ::icosahedral_make_storage(edges(), repo.dual_edge_length()),
out);
TypeParam ::verify(repo.curl_u, out, eq<TypeParam>);
TypeParam ::verify(repo.curl_u(), out, eq<TypeParam>);
}
} // namespace
16 changes: 8 additions & 8 deletions tests/regression/icosahedral/div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ namespace {
run(spec,
stencil_backend_t(),
TypeParam ::make_grid(),
TypeParam ::icosahedral_make_storage(edges(), repo.u),
TypeParam ::icosahedral_make_storage(edges(), repo.edge_length),
TypeParam ::icosahedral_make_storage(cells(), repo.cell_area_reciprocal),
TypeParam ::icosahedral_make_storage(edges(), repo.u()),
TypeParam ::icosahedral_make_storage(edges(), repo.edge_length()),
TypeParam ::icosahedral_make_storage(cells(), repo.cell_area_reciprocal()),
out);
TypeParam ::verify(repo.div_u, out);
TypeParam ::verify(repo.div_u(), out);
}

GT_REGRESSION_TEST(div_flow_convention, icosahedral_test_environment<2>, stencil_backend_t) {
Expand All @@ -47,10 +47,10 @@ namespace {
run_single_stage(div_functor_flow_convention_connectivity(),
stencil_backend_t(),
TypeParam::make_grid(),
TypeParam ::icosahedral_make_storage(edges(), repo.u),
TypeParam ::icosahedral_make_storage(edges(), repo.edge_length),
TypeParam ::icosahedral_make_storage(cells(), repo.cell_area_reciprocal),
TypeParam ::icosahedral_make_storage(edges(), repo.u()),
TypeParam ::icosahedral_make_storage(edges(), repo.edge_length()),
TypeParam ::icosahedral_make_storage(cells(), repo.cell_area_reciprocal()),
out);
TypeParam ::verify(repo.div_u, out);
TypeParam ::verify(repo.div_u(), out);
}
} // namespace
32 changes: 16 additions & 16 deletions tests/regression/icosahedral/lap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ namespace {
run(spec,
stencil_backend_t(),
TypeParam::make_grid(),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length),
TypeParam::icosahedral_make_storage(cells(), repo.cell_area_reciprocal),
TypeParam::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length),
TypeParam::icosahedral_make_storage(edges(), repo.u),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length()),
TypeParam::icosahedral_make_storage(cells(), repo.cell_area_reciprocal()),
TypeParam::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal()),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length()),
TypeParam::icosahedral_make_storage(edges(), repo.u()),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length_reciprocal()),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length_reciprocal()),
out);
TypeParam::verify(TypeParam::icosahedral_make_storage(edges(), repo.lap), out);
TypeParam::verify(TypeParam::icosahedral_make_storage(edges(), repo.lap()), out);
}

GT_REGRESSION_TEST(lap_flow_convention, icosahedral_test_environment<2>, stencil_backend_t) {
Expand Down Expand Up @@ -125,14 +125,14 @@ namespace {
run(spec,
stencil_backend_t(),
TypeParam::make_grid(),
TypeParam::icosahedral_make_storage(edges(), repo.u),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length),
TypeParam::icosahedral_make_storage(cells(), repo.cell_area_reciprocal),
TypeParam::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length_reciprocal),
TypeParam::icosahedral_make_storage(edges(), repo.u()),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length()),
TypeParam::icosahedral_make_storage(cells(), repo.cell_area_reciprocal()),
TypeParam::icosahedral_make_storage(vertices(), repo.dual_area_reciprocal()),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length()),
TypeParam::icosahedral_make_storage(edges(), repo.dual_edge_length_reciprocal()),
TypeParam::icosahedral_make_storage(edges(), repo.edge_length_reciprocal()),
out);
TypeParam::verify(TypeParam::icosahedral_make_storage(edges(), repo.lap), out);
TypeParam::verify(TypeParam::icosahedral_make_storage(edges(), repo.lap()), out);
}
} // namespace
151 changes: 84 additions & 67 deletions tests/regression/icosahedral/operators_repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <cassert>
#include <cmath>
#include <functional>

#include <gridtools/common/defs.hpp>
#include <gridtools/stencil/frontend/icosahedral/location_type.hpp>
Expand All @@ -24,8 +23,6 @@ class operators_repository {
using edges = gridtools::stencil::icosahedral::edges;
using vertices = gridtools::stencil::icosahedral::vertices;

using fun_t = std::function<double(int, int, int, int)>;

size_t m_d1, m_d2;

const double PI = std::atan(1) * 4;
Expand All @@ -38,70 +35,90 @@ class operators_repository {
double y(int j) const { return j * 1. / m_d2; }

public:
fun_t u = [this](int i, int j, int k, int c) {
auto t = PI * (x<edges>(i, c) + 1.5 * y(j));
return k + 2 * (2 + cos(t) + sin(2 * t));
};

fun_t edge_length = [this](int i, int j, int, int c) {
auto t = PI * (x<edges>(i, c) + 1.5 * y(j));
return 2.95 + (2 + cos(t) + sin(2 * t)) / 4;
};

fun_t edge_length_reciprocal = [this](int i, int j, int k, int c) { return 1 / edge_length(i, j, k, c); };

fun_t cell_area_reciprocal = [this](int i, int j, int, int c) {
auto xx = x<cells>(i, c);
auto yy = y(j);
return 1 / (2.53 + (2 + cos(PI * (1.5 * xx + 2.5 * yy)) + sin(2 * PI * (xx + 1.5 * yy))) / 4);
};

fun_t dual_area_reciprocal = [this](int i, int j, int, int c) {
auto xx = x<vertices>(i, c);
auto yy = y(j);
return 1 / (1.1 + (2 + cos(PI * (1.5 * xx + yy)) + sin(1.5 * PI * (xx + 1.5 * yy))) / 4);
};

fun_t dual_edge_length = [this](int i, int j, int, int c) {
auto xx = x<edges>(i, c);
auto yy = y(j);
return 2.2 + (2 + cos(PI * (xx + 2.5 * yy)) + sin(2 * PI * (xx + 3.5 * yy))) / 4;
};

fun_t dual_edge_length_reciprocal = [this](int i, int j, int k, int c) { return 1 / dual_edge_length(i, j, k, c); };

fun_t div_u = [this](int i, int j, int k, int c) {
double res = 0;
int e = 0;
for (auto &&neighbour : gridtools::neighbours_of<cells, edges>(i, j, k, c)) {
res += (c == 0 ? 1 : -1) * neighbour.call(u) * neighbour.call(edge_length);
++e;
}
return res * cell_area_reciprocal(i, j, k, c);
};

fun_t curl_u = [this](int i, int j, int k, int c) {
double res = 0;
int e = 0;
for (auto &&neighbour : gridtools::neighbours_of<vertices, edges>(i, j, k, c)) {
res += (e % 2 ? 1 : -1) * neighbour.call(u) * neighbour.call(dual_edge_length);
++e;
}
return res * dual_area_reciprocal(i, j, k, c);
};

fun_t lap = [this](int i, int j, int k, int c) {
auto neighbours_ec = gridtools::neighbours_of<edges, cells>(i, j, k, c);
assert(neighbours_ec.size() == 2);
auto grad_n =
(neighbours_ec[1].call(div_u) - neighbours_ec[0].call(div_u)) * dual_edge_length_reciprocal(i, j, k, c);

auto neighbours_vc = gridtools::neighbours_of<edges, vertices>(i, j, k, c);
assert(neighbours_vc.size() == 2);
auto grad_tau =
(neighbours_vc[1].call(curl_u) - neighbours_vc[0].call(curl_u)) * edge_length_reciprocal(i, j, k, c);
return grad_n - grad_tau;
};
auto u() const {
return [this](int i, int j, int k, int c) {
auto t = PI * (x<edges>(i, c) + 1.5 * y(j));
return k + 2 * (2 + cos(t) + sin(2 * t));
};
}

auto edge_length() const {
return [this](int i, int j, int, int c) {
auto t = PI * (x<edges>(i, c) + 1.5 * y(j));
return 2.95 + (2 + cos(t) + sin(2 * t)) / 4;
};
}

auto edge_length_reciprocal() const {
return [this](int i, int j, int k, int c) { return 1 / edge_length()(i, j, k, c); };
}

auto cell_area_reciprocal() const {
return [this](int i, int j, int, int c) {
auto xx = x<cells>(i, c);
auto yy = y(j);
return 1 / (2.53 + (2 + cos(PI * (1.5 * xx + 2.5 * yy)) + sin(2 * PI * (xx + 1.5 * yy))) / 4);
};
}

auto dual_area_reciprocal() const {
return [this](int i, int j, int, int c) {
auto xx = x<vertices>(i, c);
auto yy = y(j);
return 1 / (1.1 + (2 + cos(PI * (1.5 * xx + yy)) + sin(1.5 * PI * (xx + 1.5 * yy))) / 4);
};
}

auto dual_edge_length() const {
return [this](int i, int j, int, int c) {
auto xx = x<edges>(i, c);
auto yy = y(j);
return 2.2 + (2 + cos(PI * (xx + 2.5 * yy)) + sin(2 * PI * (xx + 3.5 * yy))) / 4;
};
}

auto dual_edge_length_reciprocal() const {
return [this](int i, int j, int k, int c) { return 1 / dual_edge_length()(i, j, k, c); };
}

auto div_u() const {
return [this](int i, int j, int k, int c) {
double res = 0;
int e = 0;
for (auto &&neighbour : gridtools::neighbours_of<cells, edges>(i, j, k, c)) {
res += (c == 0 ? 1 : -1) * neighbour.call(u()) * neighbour.call(edge_length());
++e;
}
return res * cell_area_reciprocal()(i, j, k, c);
};
}

auto curl_u() const {
return [this](int i, int j, int k, int c) {
double res = 0;
int e = 0;
for (auto &&neighbour : gridtools::neighbours_of<vertices, edges>(i, j, k, c)) {
res += (e % 2 ? 1 : -1) * neighbour.call(u()) * neighbour.call(dual_edge_length());
++e;
}
return res * dual_area_reciprocal()(i, j, k, c);
};
}

auto lap() const {
return [this](int i, int j, int k, int c) {
auto neighbours_ec = gridtools::neighbours_of<edges, cells>(i, j, k, c);
assert(neighbours_ec.size() == 2);
auto grad_n = (neighbours_ec[1].call(div_u()) - neighbours_ec[0].call(div_u())) *
dual_edge_length_reciprocal()(i, j, k, c);

auto neighbours_vc = gridtools::neighbours_of<edges, vertices>(i, j, k, c);
assert(neighbours_vc.size() == 2);
auto grad_tau = (neighbours_vc[1].call(curl_u()) - neighbours_vc[0].call(curl_u())) *
edge_length_reciprocal()(i, j, k, c);
return grad_n - grad_tau;
};
}

operators_repository(size_t d1, size_t d2) : m_d1(d1), m_d2(d2) {}
};
10 changes: 10 additions & 0 deletions tests/unit_tests/common/test_int_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ namespace gridtools {
auto testee = int_vector::multiply(vec, 2_c);

using testee_t = decltype(testee);
#ifndef __NVCC__
static_assert(element_at<a, testee_t>::value == 2);
#endif
EXPECT_EQ(4, at_key<b>(testee));
}

Expand All @@ -109,7 +111,9 @@ namespace gridtools {
EXPECT_EQ(1, at_key<a>(testee));
using testee_t = decltype(testee);
static_assert(!has_key<testee_t, b>());
#ifndef __NVCC__
static_assert(element_at<c, testee_t>::value == 2);
#endif
}

TEST(unary_ops, smoke) {
Expand All @@ -121,14 +125,18 @@ namespace gridtools {

EXPECT_EQ(-1, at_key<a>(testee));
using testee_t = decltype(testee);
#ifndef __NVCC__
static_assert(element_at<b, testee_t>::value == 0);
static_assert(element_at<c, testee_t>::value == -2);
#endif

auto testee2 = +vec;
EXPECT_EQ(1, at_key<a>(testee2));
using testee2_t = decltype(testee2);
#ifndef __NVCC__
static_assert(element_at<b, testee2_t>::value == 0);
static_assert(element_at<c, testee2_t>::value == 2);
#endif
}

TEST(minus_op, smoke) {
Expand All @@ -141,7 +149,9 @@ namespace gridtools {

EXPECT_EQ(0, at_key<a>(testee));
using testee_t = decltype(testee);
#ifndef __NVCC__
static_assert(element_at<b, testee_t>::value == 1);
#endif
EXPECT_EQ(-3, at_key<c>(testee));
}
} // namespace
Expand Down
Loading