You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
safe-math: nvc/nvcc/clang still contract multiply-adds, and NvidiaCompiler drops all optimisation #3077
safe-math was defined (#1438, 2020) as "drop -ffast-math" (GCC: -fno-unsafe-math-optimizations; nvc:
drop -fast). Two consequences today:
Contraction is unspecified. GCC C99 never contracts; GCC C++ did until dsl: Print double-precision FD weights to 20 digits #3074 (-ffp-contract=off);
clang defaults to -ffp-contract=on; nvc++ fuses under -O2/-fast; nvcc defaults to --fmad=true. test_gradient_equivalence (fp64, safe-math) fails on OpenACC with -fast or -O2 (ratio 1.23) and on
CUDA by default (1.24), and passes with -Mnofma / --fmad=false. On an RTX 3090 fp64 FMA is worth
13-14% (OpenACC) and 31-39% (CUDA) of throughput, fp32 nothing, so a blanket "no contraction" is not free
on GPU.
NvidiaCompiler under safe-math appends nothing in place of -fast, so OpenACC safe-math builds are
effectively unoptimised: 0.3-0.5 GPts/s vs 9-15 with -fast on the same kernels (3D acoustic, 3090).
Question for maintainers: should safe-math promise "no contraction" on every backend (at the GPU fp64
cost), or should contraction be a separate, documented per-compiler setting that tests needing exact
cancellation opt into? Either way NvidiaCompiler should keep a safe optimisation level.
Activity