mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-22 13:05:57 +00:00
Run the game on x86-64-v2 CPUs without AVX2
-march=x86-64-v3 kept the port and the installer to CPUs with AVX2 and FMA. --cpu v2 compiles the generated code and the runtime for SSE4.2 instead. Without FMA3 the FP lowering calls fma/fmaf, so runtime/fma.c provides correctly rounded ones (musl, MIT) that honour MXCSR's rounding mode, FTZ and DAZ; the UCRT's software fallback rounds incorrectly by up to half an ulp. simd.h's fast paths keep their assumptions. The installer's host check asks for x86-64-v2 and selects libtotkrt.a or libtotkrt-v2.a; both release scripts build and ship the pair. The differential tests compile fma.c as well, so a --cflags=-march=x86-64-v2 run tests it. Tested on an i7-3770K (no AVX2, FMA or BMI) with an RTX 3060 Ti, game 1.4.3: the installer ran end to end, --selftest passed and play holds 40-60 fps at 1080p. fma and fmaf matched 152,288 exact vectors over two seeds, including ties, subnormals and every rounding mode, FTZ and DAZ combination. The v3 build is unchanged: fma.c is an empty translation unit there.
This commit is contained in:
1 parent
7d62cbfa85
commit
34b4faee7c
19 files changed
+402
-58
No files matched your search
@@ -249,11 +249,22 @@ static double now_s(void) { return (double)plat_now_ns() / 1e9; }
|
||||
static volatile int host_probe_hits;
|
||||
static void host_probe(Cpu *c) { host_probe_hits++; c->x[0] = 42; }
|
||||
|
||||
// The instruction set build_game.py --cpu compiled for: v3 (AVX2/FMA/BMI2, the default) or v2 (SSE4.2/POPCNT).
|
||||
#ifndef RT_CPU_LEVEL
|
||||
#define RT_CPU_LEVEL 3
|
||||
#endif
|
||||
|
||||
static void check_cpu(void) {
|
||||
__builtin_cpu_init();
|
||||
#if RT_CPU_LEVEL >= 3
|
||||
int ok = __builtin_cpu_supports("avx2") && __builtin_cpu_supports("fma") && __builtin_cpu_supports("bmi2");
|
||||
printf("cpu: x86-64-v3 (AVX2, FMA, BMI2) %s\n", ok ? "present" : "MISSING");
|
||||
CHECK(ok, "the lifted code is built for x86-64-v3");
|
||||
#else
|
||||
int ok = __builtin_cpu_supports("sse4.2") && __builtin_cpu_supports("popcnt");
|
||||
printf("cpu: x86-64-v2 (SSE4.2, POPCNT) %s\n", ok ? "present" : "MISSING");
|
||||
CHECK(ok, "the lifted code is built for x86-64-v2");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Layout: ascending, no overlap, below 2^39, and inside the window mem_init reserved.
|
||||
|
||||
Reference in new issue
Block a user