diff options
| author | Scott Gasch <[email protected]> | 2026-09-18 23:43:06 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2026-09-18 23:43:06 -0700 |
| commit | c5bd92a091de05af03c4c5d4842e5f8a54abefa5 (patch) | |
| tree | 60033289088c8bb1c0c1b88db30d7b4f32b35b64 /src/GNUmakefile | |
| parent | 91dc4a9393204104c06fa64a05be24d08feca0ef (diff) | |
Add -flto and -mtune=native to the release build
-flto: several functions (_RookAttacksBB/_BishopAttacksBB in
generate.c, and others from recent sessions) are declared FORCEINLINE
but non-static, exposed specifically so other translation units can
call them -- __attribute__((always_inline)) only actually forces
inlining within the TU that has the function body, so every cross-file
call was paying for a real call/ret instead of inlining without this.
Measured via the `bench` command (4 reps each, interleaved with a
non-LTO baseline): a clean, reproducible ~6.6% NPS improvement with
zero overlap between the two distributions (baseline 1643k-1661k nps,
LTO 1752k-1768k nps) -- not noise.
-mtune=native: tunes instruction scheduling/costs for the actual build
machine instead of a generic x86-64 target. Measured weaker and
noisier (~1.5%, some overlap with baseline) but real and free -- no
portability cost the way -march=native's newer-ISA-extension
dependency would carry.
precommit_check.sh (self-tests + DEBUG smoke test) passed clean with
both flags active.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Diffstat (limited to 'src/GNUmakefile')
| -rw-r--r-- | src/GNUmakefile | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile index e28649d..1784551 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -186,7 +186,23 @@ GIT_DIRTY := $(shell git diff --quiet 2>/dev/null || echo -dirty) # stringified whole into -DPROFILE="..." below for the "Make profile # used" trace line, and this value's embedded quotes broke that outer # string literal when it was included there. -CFLAGS = -DPROFILE="\"$(PROFILE)\"" -DGIT_COMMIT=\"$(GIT_COMMIT)$(GIT_DIRTY)\" $(PROFILE) -Wall -Wno-nan-infinity-disabled -Ifathom +# -flto: several functions (e.g. _RookAttacksBB/_BishopAttacksBB, +# generate.c) are declared FORCEINLINE but non-static, exposed +# specifically so other translation units (eval.c, searchsup.c, see.c) +# can call them -- __attribute__((always_inline)) only actually forces +# inlining within the TU that has the function body, so every +# cross-file call was paying for a real call/ret instead of inlining +# without this. Measured via the `bench` command (4 reps each, +# interleaved with a non-LTO baseline): a clean, reproducible ~6.6% NPS +# improvement with zero overlap between the two distributions (baseline +# 1643k-1661k nps, LTO 1752k-1768k nps) -- not noise. -mtune=native: +# tunes instruction scheduling/costs for the actual build machine +# rather than a generic x86-64 target; measured weaker and noisier +# (~1.5%, some overlap with baseline) but real and free (no +# portability cost the way -march=native's newer-ISA-extension +# dependency would have -- see the BMI2/PEXT-on-Zen2 caveat if anyone +# reaches for -march=native or PEXT-based magic bitboards later). +CFLAGS = -DPROFILE="\"$(PROFILE)\"" -DGIT_COMMIT=\"$(GIT_COMMIT)$(GIT_DIRTY)\" $(PROFILE) -Wall -Wno-nan-infinity-disabled -Ifathom -flto -mtune=native HEADERS = chess.h compiler.h FATHOM_CFLAGS = -std=gnu99 -O2 -Ifathom $(filter -m32 -m64,$(PROFILE)) @@ -228,7 +244,7 @@ endif all: $(BINARY) $(BINARY): $(OBJS) - $(CXX) $(PROFILE) -o $(BINARY) -Wall $(LIBRARIES) \ + $(CXX) $(PROFILE) -flto -o $(BINARY) -Wall $(LIBRARIES) \ $(OBJS) %.o: %.c $(HEADERS) |
