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

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1311 into main
ambroseautomation commented 2026-11-24 21:41:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T21:41:14Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480804217 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1311). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T21:41:14Z. --- ## 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T23:48:13Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147811548 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1311#issuecomment-7147811548). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-24T23:48:13Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1311
No description provided.