host_cpu: move gta6rt's AVX preflight decision into a testable preflight() (OLD-9915) #1311

Closed
leonida/mandy
ambroseautomation wants to merge 0 commits from carry/old-9915-host-cpu-preflight into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

ambroseautomation commented 2026-11-24 21:41:14 +00:00

Summary

Coordination item: OLD-9915 (carry-forward of old-pr/9915, preserving original author Sunkiller-qc).

Problem & Root Cause

gta6rt's AVX / host CPU preflight decision (checking missing ISA features, respecting dry_run, and formatting the refusal message) lived inline in runtime/src/main.cpp, so it could not be unit-tested directly against synthetic feature masks.

Implementation

  • Moves the preflight decision into host_cpu::preflight(...) in runtime/src/host_cpu.h and runtime/src/host_cpu.cpp, returning whether startup should proceed and any refusal message.
  • Updates runtime/src/main.cpp to call host_cpu::preflight(...).
  • Extends runtime/test/host_cpu_test.cpp to test preflight() directly across synthetic feature combinations and dry_run modes.

Tests Run

Environment: Windows 11 Pro 64-bit, Visual Studio 18 Community (cl.exe x64, /std:c++20 /W4 /WX).

  • cl /nologo /std:c++20 /EHsc /W4 /WX /Iruntime/src runtime/test/host_cpu_test.cpp runtime/src/host_cpu.cpp + host_cpu_test.exe — PASS (host: 0 missing feature(s), host_cpu_test: all passed)
  • .\scripts\build_runtime.ps1 -jobs 8 — PASS (runtime/build/gta6rt.exe built cleanly)
  • python -I scripts/check_no_game_data.py runtime/src/host_cpu.cpp runtime/src/host_cpu.h runtime/src/main.cpp runtime/test/host_cpu_test.cpp — PASS

Disclosure

AI-assisted: yes (carry-forward, rebase onto current main, and local MSVC build/test verification; original implementation by Sunkiller-qc).

## Summary Coordination item: `OLD-9915` (carry-forward of `old-pr/9915`, preserving original author `Sunkiller-qc`). ### Problem & Root Cause `gta6rt`'s AVX / host CPU preflight decision (checking missing ISA features, respecting `dry_run`, and formatting the refusal message) lived inline in `runtime/src/main.cpp`, so it could not be unit-tested directly against synthetic feature masks. ### Implementation - Moves the preflight decision into `host_cpu::preflight(...)` in `runtime/src/host_cpu.h` and `runtime/src/host_cpu.cpp`, returning whether startup should proceed and any refusal message. - Updates `runtime/src/main.cpp` to call `host_cpu::preflight(...)`. - Extends `runtime/test/host_cpu_test.cpp` to test `preflight()` directly across synthetic feature combinations and `dry_run` modes. ## Tests Run Environment: Windows 11 Pro 64-bit, Visual Studio 18 Community (`cl.exe` x64, `/std:c++20 /W4 /WX`). - `cl /nologo /std:c++20 /EHsc /W4 /WX /Iruntime/src runtime/test/host_cpu_test.cpp runtime/src/host_cpu.cpp` + `host_cpu_test.exe` — PASS (`host: 0 missing feature(s)`, `host_cpu_test: all passed`) - `.\scripts\build_runtime.ps1 -jobs 8` — PASS (`runtime/build/gta6rt.exe` built cleanly) - `python -I scripts/check_no_game_data.py runtime/src/host_cpu.cpp runtime/src/host_cpu.h runtime/src/main.cpp runtime/test/host_cpu_test.cpp` — PASS ## Disclosure AI-assisted: yes (carry-forward, rebase onto current `main`, and local MSVC build/test verification; original implementation by Sunkiller-qc).
whoalin1 commented 2026-11-24 23:48:13 +00:00

Verified on Windows host (AI-assisted review), commit 6bb811398, MSVC RelWithDebInfo Ninja build.

  • Rebuilt runtime incrementally (vcvars64 + Ninja, 22 targets) — clean, no new warnings.
  • runtime/build/host_cpu_test.exe: "host: 0 missing feature(s) / all passed" — the new preflight() cases all pass: --dry-run and LEONIDA_SKIP_CPU_CHECK=1 skip the CPU probe entirely (fake_missing call count stays 0), --init/--run on a missing-AVX fake host returns kExitCode with message() text, null error pointer tolerated.
  • main.cpp refactor is behaviour-preserving: init || run maps to starts_game, and check_skipped() is only consulted inside preflight when starts_game is true — same short-circuit as before, so --dry-run still doesn't read the environment.
  • No GPU-visible behaviour (startup CPU gate only); ctest host_cpu entry is the test binary itself, which I ran directly.

Verdict: LGTM.

Verified on Windows host (AI-assisted review), commit 6bb811398, MSVC RelWithDebInfo Ninja build. - Rebuilt runtime incrementally (vcvars64 + Ninja, 22 targets) — clean, no new warnings. - `runtime/build/host_cpu_test.exe`: "host: 0 missing feature(s) / all passed" — the new preflight() cases all pass: --dry-run and LEONIDA_SKIP_CPU_CHECK=1 skip the CPU probe entirely (fake_missing call count stays 0), --init/--run on a missing-AVX fake host returns kExitCode with message() text, null error pointer tolerated. - main.cpp refactor is behaviour-preserving: `init || run` maps to starts_game, and check_skipped() is only consulted inside preflight when starts_game is true — same short-circuit as before, so --dry-run still doesn't read the environment. - No GPU-visible behaviour (startup CPU gate only); ctest host_cpu entry is the test binary itself, which I ran directly. Verdict: LGTM.
Sign in to join this conversation.
No description provided.