diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f4580c04c..00e7a8ba7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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')) diff --git a/tests/regression/icosahedral/curl.cpp b/tests/regression/icosahedral/curl.cpp index 002b774d7..48275c0e7 100644 --- a/tests/regression/icosahedral/curl.cpp +++ b/tests/regression/icosahedral/curl.cpp @@ -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::verify(repo.curl_u(), out, eq); } GT_REGRESSION_TEST(curl_flow_convention, icosahedral_test_environment<2>, stencil_backend_t) { @@ -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 ::verify(repo.curl_u(), out, eq); } } // namespace diff --git a/tests/regression/icosahedral/div.cpp b/tests/regression/icosahedral/div.cpp index bad4c3333..57a36c2b6 100644 --- a/tests/regression/icosahedral/div.cpp +++ b/tests/regression/icosahedral/div.cpp @@ -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) { @@ -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 diff --git a/tests/regression/icosahedral/lap.cpp b/tests/regression/icosahedral/lap.cpp index b953c24a6..4e078c692 100644 --- a/tests/regression/icosahedral/lap.cpp +++ b/tests/regression/icosahedral/lap.cpp @@ -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) { @@ -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 diff --git a/tests/regression/icosahedral/operators_repository.hpp b/tests/regression/icosahedral/operators_repository.hpp index 300b5b326..3ef49e57c 100644 --- a/tests/regression/icosahedral/operators_repository.hpp +++ b/tests/regression/icosahedral/operators_repository.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -24,8 +23,6 @@ class operators_repository { using edges = gridtools::stencil::icosahedral::edges; using vertices = gridtools::stencil::icosahedral::vertices; - using fun_t = std::function; - size_t m_d1, m_d2; const double PI = std::atan(1) * 4; @@ -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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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) {} }; diff --git a/tests/unit_tests/common/test_int_vector.cpp b/tests/unit_tests/common/test_int_vector.cpp index 63d560886..93a0dcc05 100644 --- a/tests/unit_tests/common/test_int_vector.cpp +++ b/tests/unit_tests/common/test_int_vector.cpp @@ -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::value == 2); +#endif EXPECT_EQ(4, at_key(testee)); } @@ -109,7 +111,9 @@ namespace gridtools { EXPECT_EQ(1, at_key(testee)); using testee_t = decltype(testee); static_assert(!has_key()); +#ifndef __NVCC__ static_assert(element_at::value == 2); +#endif } TEST(unary_ops, smoke) { @@ -121,14 +125,18 @@ namespace gridtools { EXPECT_EQ(-1, at_key(testee)); using testee_t = decltype(testee); +#ifndef __NVCC__ static_assert(element_at::value == 0); static_assert(element_at::value == -2); +#endif auto testee2 = +vec; EXPECT_EQ(1, at_key(testee2)); using testee2_t = decltype(testee2); +#ifndef __NVCC__ static_assert(element_at::value == 0); static_assert(element_at::value == 2); +#endif } TEST(minus_op, smoke) { @@ -141,7 +149,9 @@ namespace gridtools { EXPECT_EQ(0, at_key(testee)); using testee_t = decltype(testee); +#ifndef __NVCC__ static_assert(element_at::value == 1); +#endif EXPECT_EQ(-3, at_key(testee)); } } // namespace