Skip to content

Commit

Permalink
Merge branch 'EinsteinToolkit:main' into gpu-aware-mpi
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi authored Dec 3, 2024
2 parents 6849eb0 + 4844efa commit 3c2ce33
Show file tree
Hide file tree
Showing 776 changed files with 5,021 additions and 13,982 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: CI
# Control when the workflow will run
on:
push:
pull_request:
# `pull_request` is disabled because we already build for all pushes
# pull_request:
# Allow running this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -23,6 +24,8 @@ jobs:
exclude:
- {accelerator: rocm, real-precision: real32}
- {accelerator: oneapi, real-precision: real32}
- {accelerator: oneapi, mode: debug} # uses too much disk space?
- {accelerator: rocm, mode: debug} # uses too much memory?
- {real-precision: real32, mode: optimize}
env:
ACCELERATOR: ${{matrix.accelerator}}
Expand All @@ -38,12 +41,6 @@ jobs:
# Check out the repository under $GITHUB_WORKSPACE, so our job can access it
- uses: actions/checkout@v4

# # Check out the documentation and test results
# - uses: actions/checkout@v3
# with:
# ref: gh-pages
# path: gh-pages

- name: Log the triggering commit
run: echo ${{github.event.client_payload.trigger}}

Expand All @@ -52,16 +49,8 @@ jobs:

- name: Build Cactus
run: /bin/bash $GITHUB_WORKSPACE/scripts/build.sh
# The oneAPI setup does not build yet
continue-on-error: ${{matrix.accelerator == 'oneapi'}}

- name: Test Cactus
# We cannot run on accelerators. Debug builds run too slowly.
if: ${{matrix.accelerator == 'cpu' && matrix.mode == 'optimize'}}
# We cannot run on accelerators. Single precision output is not accurate enough. Debug builds run too slowly.
if: ${{matrix.accelerator == 'cpu' && matrix.real-precision == 'real64' && matrix.mode == 'optimize'}}
run: /bin/bash $GITHUB_WORKSPACE/scripts/test.sh

# Set exit code based on test status
- name: Set exit code
# Only look at the test results for `carpetx-cpu-real64` runs
if: ${{matrix.accelerator == 'cpu' && matrix.real-precision == 'real64' && matrix.mode == 'optimize' && env.TESTS_FAILED == 'True'}}
run: exit 1
44 changes: 32 additions & 12 deletions ADMBaseX/schedule.ccl
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
# Schedule definitions for thorn ADMBaseX

SCHEDULE GROUP ADMBaseX_InitialData AT initial
{
} "Schedule group for calculating ADM initial data"
if (CCTK_IsThornActive("ODESolvers")) {

SCHEDULE GROUP ADMBaseX_InitialData IN ODESolvers_Initial
{
} "Schedule group for calculating ADM initial data"

SCHEDULE GROUP ADMBaseX_InitialGauge AT initial AFTER ADMBaseX_InitialData
{
} "Schedule group for the ADM initial gauge condition"
SCHEDULE GROUP ADMBaseX_InitialGauge IN ODESolvers_Initial AFTER ADMBaseX_InitialData
{
} "Schedule group for the ADM initial gauge condition"

SCHEDULE GROUP ADMBaseX_PostInitial AT initial AFTER (ADMBaseX_InitialData ADMBaseX_InitialGauge)
{
} "Schedule group for modifying the ADM initial data, such as e.g. adding noise"
SCHEDULE GROUP ADMBaseX_PostInitial IN ODESolvers_Initial AFTER (ADMBaseX_InitialData ADMBaseX_InitialGauge)
{
} "Schedule group for modifying the ADM initial data, such as e.g. adding noise"

if (CCTK_IsThornActive("ODESolvers")) {
SCHEDULE GROUP ADMBaseX_SetADMVars IN ODESolvers_PostStep
{
} "Set ADM variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMRHS IN ODESolvers_PostStep
{
} "Set ADM RHS variables in this group"

} else {

SCHEDULE GROUP ADMBaseX_SetADMVars AT post_recover_variables
{
} "Set ADM variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMRHS AT post_recover_variables
{
} "Set ADM RHS variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMVars AT postregrid
{
} "Set ADM variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMVars AT poststep
SCHEDULE GROUP ADMBaseX_SetADMRHS AT postregrid
{
} "Set ADM RHS variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMVars AT postrestrict
{
} "Set ADM variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMRHS AT postregrid
SCHEDULE GROUP ADMBaseX_SetADMRHS AT postrestrict
{
} "Set ADM RHS variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMVars AT poststep
{
} "Set ADM variables in this group"

SCHEDULE GROUP ADMBaseX_SetADMRHS AT poststep
{
} "Set ADM RHS variables in this group"

}

if (CCTK_EQUALS(initial_data, "Cartesian Minkowski")) {
Expand Down
6 changes: 6 additions & 0 deletions Algo/test/test_roots.par
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ ActiveThorns = "

Cactus::presync_mode = "mixed-error"
Cactus::cctk_itlast = 0

IO::out_fileinfo = "axis labels"
IO::parfile_write = no

CarpetX::out_metadata = no

16 changes: 12 additions & 4 deletions Arith/src/defs.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ template <> struct nan<double> {

// An explicitly unrolled for loop

template <int imin, int imax, int istep = 1, typename F,
enable_if_t<(istep > 0 ? imin >= imax : imin <= imax)> * = nullptr>
template <
int imin, int imax, int istep = 1, typename F,
std::enable_if_t<(istep > 0 ? imin >= imax : imin <= imax)> * = nullptr>
constexpr ARITH_INLINE ARITH_DEVICE ARITH_HOST void unroll_for(const F &f) {
// done: do nothing
}

template <int imin, int imax, int istep = 1, typename F,
enable_if_t<!(istep > 0 ? imin >= imax : imin <= imax)> * = nullptr>
template <
int imin, int imax, int istep = 1, typename F,
std::enable_if_t<!(istep > 0 ? imin >= imax : imin <= imax)> * = nullptr>
constexpr ARITH_INLINE ARITH_DEVICE ARITH_HOST void unroll_for(const F &f) {
f(imin);
unroll_for<imin + istep, imax, istep>(f);
Expand Down Expand Up @@ -206,6 +208,12 @@ constexpr ARITH_INLINE ARITH_DEVICE ARITH_HOST T flipsign(const T &x,
return copysign(T(1), y) * x;
}

// Return 1/x
template <typename T>
constexpr ARITH_INLINE ARITH_DEVICE ARITH_HOST T inv(const T &x) {
return T(1) / x;
}

// A max function that returns nan when any argument is nan
template <typename T>
constexpr ARITH_INLINE ARITH_DEVICE ARITH_HOST T max1(const T &x, const T &y) {
Expand Down
153 changes: 146 additions & 7 deletions Arith/src/simd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cctk.h>

#include <cassert>
#include <cmath>

namespace Arith {

Expand All @@ -25,17 +26,34 @@ std::size_t get_memop_count() {
return count;
}

template <typename T> constexpr bool isequal(const simd<T> x, const T a) {
return all(x == a);
}
template <typename T> constexpr bool isequal(const simdl<T> x, const bool a) {
return all(x == a);
}
template <typename T> constexpr bool isapprox(const simd<T> x, const T a) {
return all(fabs(x - a) < 1.0e-14);
}

void check(const bool isgood) {
if (isgood)
return;
CCTK_ERROR("Test failure");
}

void TestSIMD() {
// nvcc V11.1.74 doesn't accept this as "constexpr" values
#ifndef __CUDACC__
typedef simd<CCTK_REAL> realv;
using real = CCTK_REAL;
using realv = simd<real>;

realv x;
realv y = 0;
realv z = zero<realv>();

assert(all(y == 0));
assert(all(y == z));
check(all(y == 0));
check(all(y == z));

realv a = 2;
realv b = 3;
Expand All @@ -45,10 +63,131 @@ void TestSIMD() {
realv r1 = mulsub(a, b, c);
realv r2 = negmuladd(a, b, c);
realv r3 = negmulsub(a, b, c);
assert(all(r0 == muladd(2, 3, 4)));
assert(all(r1 == mulsub(2, 3, 4)));
assert(all(r2 == negmuladd(2, 3, 4)));
assert(all(r3 == negmulsub(2, 3, 4)));
check(all(r0 == muladd(2, 3, 4)));
check(all(r1 == mulsub(2, 3, 4)));
check(all(r2 == negmuladd(2, 3, 4)));
check(all(r3 == negmulsub(2, 3, 4)));

real s = 2;
real t = 2;
real u = 4;

check(isequal(+a, +s));
check(isequal(-a, -s));

check(isequal(a + b, s + t));
check(isequal(a - b, s - t));
check(isequal(a * b, s * t));
check(isequal(a / b, s / t));
check(isequal(s + b, s + t));
check(isequal(s - b, s - t));
check(isequal(s * b, s * t));
check(isequal(s / b, s / t));
check(isequal(a + t, s + t));
check(isequal(a - t, s - t));
check(isequal(a * t, s * t));
check(isequal(a / t, s / t));

check(isequal(a == b, s == t));
check(isequal(a != b, s != t));
check(isequal(a < b, s < t));
check(isequal(a > b, s > t));
check(isequal(a <= b, s <= t));
check(isequal(a >= b, s >= t));
check(isequal(s == b, s == t));
check(isequal(s != b, s != t));
check(isequal(s < b, s < t));
check(isequal(s > b, s > t));
check(isequal(s <= b, s <= t));
check(isequal(s >= b, s >= t));
check(isequal(a == t, s == t));
check(isequal(a != t, s != t));
check(isequal(a < t, s < t));
check(isequal(a > t, s > t));
check(isequal(a <= t, s <= t));
check(isequal(a >= t, s >= t));

check(isapprox(abs(a), abs(s)));
check(isapprox(acos(a), acos(s)));
check(isapprox(acosh(a), acosh(s)));
check(allisfinite(a) == allisfinite(s));
check(anyisnan(a) == anyisnan(s));
check(isapprox(asin(a), asin(s)));
check(isapprox(asinh(a), asinh(s)));
check(isapprox(atan(a), atan(s)));
check(isapprox(atanh(a), atanh(s)));
check(isapprox(cbrt(a), cbrt(s)));
// check(isapprox(cis(a), cis(s)));
// check(isapprox(cispi(a), cispi(s)));
check(isapprox(copysign(a, b), copysign(s, t)));
check(isapprox(cos(a), cos(s)));
check(isapprox(cosh(a), cosh(s)));
check(isapprox(cospi(a), cos(CCTK_REAL(M_PI) * s)));
check(isapprox(exp(a), exp(s)));
check(isapprox(exp10(a), pow(CCTK_REAL(10), s)));
check(isapprox(exp2(a), exp2(s)));
check(isapprox(fabs(a), fabs(s)));
check(isapprox(flipsign(a, b), flipsign(s, t)));
check(isapprox(fmax(a, b), fmax(s, t)));
check(isapprox(fmax(a, t), fmax(s, t)));
check(isapprox(fmax(s, b), fmax(s, t)));
check(isapprox(fmin(a, b), fmin(s, t)));
check(isapprox(fmin(a, t), fmin(s, t)));
check(isapprox(fmin(s, b), fmin(s, t)));
check(isapprox(hypot(a, b), hypot(s, t)));
check(isapprox(inv(a), inv(s)));
check(isequal(isfinite(a), isfinite(s)));
check(isequal(isinf(a), isinf(s)));
check(isequal(isnan(a), isnan(s)));
check(isapprox(log(a), log(s)));
check(isapprox(log10(a), log10(s)));
check(isapprox(log2(a), log2(s)));
check(isapprox(max(a, b), max(s, t)));
check(isapprox(max(a, t), max(s, t)));
check(isapprox(max(s, b), max(s, t)));
check(isapprox(min(a, b), min(s, t)));
check(isapprox(min(a, t), min(s, t)));
check(isapprox(min(s, b), min(s, t)));
check(isapprox(muladd(a, b, c), muladd(s, t, u)));
check(isapprox(muladd(a, b, u), muladd(s, t, u)));
check(isapprox(muladd(a, t, c), muladd(s, t, u)));
check(isapprox(muladd(a, t, u), muladd(s, t, u)));
check(isapprox(muladd(s, b, c), muladd(s, t, u)));
check(isapprox(muladd(s, b, u), muladd(s, t, u)));
check(isapprox(muladd(s, t, c), muladd(s, t, u)));
check(isapprox(mulsub(a, b, c), mulsub(s, t, u)));
check(isapprox(mulsub(a, b, u), mulsub(s, t, u)));
check(isapprox(mulsub(a, t, c), mulsub(s, t, u)));
check(isapprox(mulsub(a, t, u), mulsub(s, t, u)));
check(isapprox(mulsub(s, b, c), mulsub(s, t, u)));
check(isapprox(mulsub(s, b, u), mulsub(s, t, u)));
check(isapprox(mulsub(s, t, c), mulsub(s, t, u)));
check(isapprox(negmuladd(a, b, c), negmuladd(s, t, u)));
check(isapprox(negmuladd(a, b, u), negmuladd(s, t, u)));
check(isapprox(negmuladd(a, t, c), negmuladd(s, t, u)));
check(isapprox(negmuladd(a, t, u), negmuladd(s, t, u)));
check(isapprox(negmuladd(s, b, c), negmuladd(s, t, u)));
check(isapprox(negmuladd(s, b, u), negmuladd(s, t, u)));
check(isapprox(negmuladd(s, t, c), negmuladd(s, t, u)));
check(isapprox(negmulsub(a, b, c), negmulsub(s, t, u)));
check(isapprox(negmulsub(a, b, u), negmulsub(s, t, u)));
check(isapprox(negmulsub(a, t, c), negmulsub(s, t, u)));
check(isapprox(negmulsub(a, t, u), negmulsub(s, t, u)));
check(isapprox(negmulsub(s, b, c), negmulsub(s, t, u)));
check(isapprox(negmulsub(s, b, u), negmulsub(s, t, u)));
check(isapprox(negmulsub(s, t, c), negmulsub(s, t, u)));
check(isapprox(pow(a, b), pow(s, t)));
check(isapprox(pow(a, t), pow(s, t)));
check(isapprox(pow(s, b), pow(s, t)));
check(isequal(signbit(a), signbit(s)));
check(isapprox(sin(a), sin(s)));
check(isapprox(sinh(a), sinh(s)));
check(isapprox(sinpi(a), sin(CCTK_REAL(M_PI) * s)));
check(isapprox(sqrt(a), sqrt(s)));
check(isapprox(tan(a), tan(s)));
check(isapprox(tanh(a), tanh(s)));
// check(isapprox(tanpi(a), tanpi(s)));

#endif
}

Expand Down
Loading

0 comments on commit 3c2ce33

Please sign in to comment.