build: -fno-math-errno -- drop unused errno side-effect on libm calls (~4% faster, output identical)#10
Open
carstenerickson wants to merge 1 commit into
Conversation
The ChromoPainter forward/backward inner loops call exp()/log() once per locus per donor -- the dominant transcendental cost in a paint. By default each scalar libm call also sets the global errno on a domain or range error. Nothing in the code reads errno after a math call (only the bundled zlib's I/O paths touch errno, which this flag does not affect), so that side effect is dead weight on the hot path. -fno-math-errno drops it. Measured ~4% faster on a single-recipient paint (chr11, ~3M SNPs, -s 0, 4 threads: 294 -> 282 s; 100k-SNP subset, best-of-3: 71.9 -> 68.8 s), with chunkcounts/chunklengths md5-identical to the unmodified build -- the flag changes only the errno write, not any result. This is not -ffast-math: finiteness guards and FP association are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Append
-fno-math-errnoto the projectOPTIMIZATIONflags -- one line inMakefile.am.Why
ChromoPainter's forward/backward inner loops call
exp()/log()once per locus per donor -- the dominant transcendental cost in a paint. By default each scalarlibmcall must also set the globalerrnoon a domain/range error. The code never readserrnoafter a math call, so that side effect is pure overhead on the hot path.-fno-math-errnodrops it.Why it is safe (no behavior change)
errnois never read after a math call. Audited the whole tree: zeroerrnoreferences in any ChromoPainter or finestructure source. The onlyerrnousers are the bundled zlib (cp/zutil.c,cp/gzguts.h), which read it for file-I/O errors ---fno-math-errnoaffects only libm math functions, not I/O, so zlib is untouched.errnoside effect only, not any computed value.chunkcountsandchunklengthsare md5-identical to the unmodified build on both a full chromosome and a subset (table below).-ffast-math. No-ffinite-math-only(NaN/Inf likelihood guards stay live), no reassociation, no-march.-funsafe-math-optimizationsis already inOPTIMIZATION; this removes only the remainingerrnobarrier.Measurement
AMD EPYC, gcc 11.4, 4 threads, single recipient vs the EUR donor panel,
-s 0. Same base built with and without the flag.-fno-math-errno-i 1)-i 10, best-of-3)Peak RSS unchanged.
Scope
One line in
Makefile.am(-fno-math-errnoappended toOPTIMIZATION). No source changes, no-march, no-ffast-math.