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
78 changes: 78 additions & 0 deletions .github/workflows/fp-stability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: FP Stability

# Runs the Verrou-based floating-point stability suite.
#
# What it tests (./mfc.sh fp-stability):
# sod_strong 1-D Sod shock, p_L/p_R=100,000, ideal gas
# 25 cells, 5 steps, WENO5 + HLLC
# Compares density & energy vs. threshold 1e-10
# Probes: HLLC xi-factor cancellation near sonic contact
# (s_L - vel_L)/(s_L - s_S) when s_L ≈ s_S
#
# water_stiffened 1-D water shock, stiffened EOS (pi_inf=4046)
# 25 cells, 5 steps, WENO5 + HLLC
# Compares density & pressure vs. threshold 1e-10
# Probes: pressure-recovery cancellation p=(E-pi_inf)/gamma
# loses ~4 decimal digits when pi_inf/p_right ~ 40,000
#
# For each case: 1 nearest-rounding reference run + N random-rounding runs.
# PASS if max L∞ deviation across all N samples stays below threshold.
#
# Verrou (Valgrind 3.26.0 + edf-hpc/verrou@a58d434) is built once and cached.
# Build takes ~20 min uncached; cached runs restore in ~30 s.

on:
push:
workflow_dispatch:

jobs:
fp-stability:
name: Floating-Point Stability (Verrou)
runs-on: ubuntu-latest

steps:
- name: Clone
uses: actions/checkout@v4

- name: Cache Verrou
id: cache-verrou
uses: actions/cache@v4
with:
path: ~/.local/verrou
key: verrou-a58d434-valgrind-3.26.0-${{ runner.os }}

- name: Install system dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y \
build-essential automake python3 libc6-dbg \
cmake gfortran

- name: Build Verrou
if: steps.cache-verrou.outputs.cache-hit != 'true'
run: |
cd /tmp
wget -q https://sourceware.org/pub/valgrind/valgrind-3.26.0.tar.bz2
tar xf valgrind-3.26.0.tar.bz2

git clone https://github.com/edf-hpc/verrou.git
git -C verrou checkout a58d434

# Merge Verrou into Valgrind source tree and patch
cp -r verrou valgrind-3.26.0/verrou
cd valgrind-3.26.0
cat verrou/valgrind.*diff | patch -p1

./autogen.sh
./configure --enable-only64bit --prefix="$HOME/.local/verrou"
make -j"$(nproc)"
make install

- name: Verify Verrou
run: ~/.local/verrou/bin/valgrind --version

- name: Build MFC (debug, serial)
run: ./mfc.sh build -t pre_process simulation --no-mpi --debug -j"$(nproc)"

- name: Run FP Stability Suite
run: ./mfc.sh fp-stability -N 5
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ docs/documentation/parameters.md
/tests/*/**
!/tests/*/golden.txt
!/tests/*/golden-metadata.txt
!/tests/fp_stability/**

# NVIDIA Nsight Compute
*.nsys-rep
Expand Down
33 changes: 33 additions & 0 deletions tests/fp_stability/cases/sod_strong/pre_process.inp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/fp_stability/cases/sod_strong/simulation.inp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions tests/fp_stability/cases/water_stiffened/pre_process.inp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/fp_stability/cases/water_stiffened/simulation.inp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions toolchain/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def __run():
from mfc import params_cmd

params_cmd.params()
elif cmd == "fp-stability":
from mfc import fp_stability

fp_stability.fp_stability()


if __name__ == "__main__":
Expand Down
60 changes: 60 additions & 0 deletions toolchain/mfc/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,65 @@
include_common=["targets", "mfc_config", "jobs", "verbose", "debug_log"],
)

FP_STABILITY_COMMAND = Command(
name="fp-stability",
help="Run floating-point stability tests using Verrou.",
description=(
"Runs each registered test case N times under Verrou's random IEEE-754 "
"rounding mode and compares against a nearest-rounding reference run. "
"Reports the max L∞ deviation and PASS/FAIL against per-case thresholds.\n\n"
"Requires a Verrou-enabled Valgrind at $VERROU_HOME/bin/valgrind "
"(defaults to $HOME/.local/verrou). The simulation and pre_process "
"binaries must be serial (no-MPI, no-GPU) debug builds.\n\n"
"Current test cases:\n"
" sod_strong 1-D Sod p_L/p_R=100,000 — HLLC xi-factor cancellation\n"
" water_stiffened 1-D water shock (pi_inf=4046) — pressure-recovery cancellation\n"
),
include_common=["mfc_config", "verbose", "debug_log"],
arguments=[
Argument(
name="sim-binary",
help="Path to a serial simulation binary (debug, no-MPI). Auto-discovered from build/install/ if omitted.",
default=None,
metavar="PATH",
),
Argument(
name="pre-binary",
help="Path to a serial pre_process binary (no-MPI). Auto-discovered from build/install/ if omitted.",
default=None,
metavar="PATH",
),
Argument(
name="verrou-binary",
help="Path to a Verrou-enabled valgrind binary. Defaults to $VERROU_HOME/bin/valgrind or $HOME/.local/verrou/bin/valgrind.",
default=None,
metavar="PATH",
),
Argument(
name="samples",
short="N",
help="Number of random-rounding simulation runs per test case.",
type=int,
default=5,
metavar="N",
),
],
examples=[
Example("./mfc.sh fp-stability", "Auto-discover binaries and run all cases"),
Example(
"./mfc.sh fp-stability --sim-binary build/install/abc123/bin/simulation",
"Specify simulation binary explicitly",
),
Example("./mfc.sh fp-stability -N 10", "Run 10 random-rounding samples per case"),
],
key_options=[
("--sim-binary PATH", "Serial simulation binary (debug, no-MPI)"),
("--pre-binary PATH", "Serial pre_process binary"),
("--verrou-binary PATH", "Verrou-enabled valgrind"),
("-N, --samples N", "Random-rounding samples per case (default: 5)"),
],
)

VIZ_COMMAND = Command(
name="viz",
help="Visualize post-processed MFC output.",
Expand Down Expand Up @@ -1372,6 +1431,7 @@
BENCH_DIFF_COMMAND,
COUNT_COMMAND,
COUNT_DIFF_COMMAND,
FP_STABILITY_COMMAND,
],
common_sets=[
COMMON_TARGETS,
Expand Down
Loading
Loading