tests: cache and parallelize form_coverage_check control runs #1520

Merged
tedin7 merged 2 commits from upstream-pr/1527 into main 2026-11-24 15:38:51 +00:00
tedin7 commented 2026-11-24 13:40:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:40:35Z.


Cache and parallelize tests/pixel_aot_check.check_controls across tests/form_coverage_check.py with zero dropped assertions and set-identical ACCEPTED coverage.

Summary

  • tests/form_coverage_check.py:
    • Save and restore pixel.ACCEPTED in check_plain_bitscan_forms (with try ... finally) so it no longer clears the set populated by pixel.check_controls.
    • Add _controls_accepted() to run pixel.check_controls once per process and reuse the cached frozenset across check_shader_records, check_swap_coverage, and check_pk_fmac_coverage.
  • tests/pixel_aot_check.py:
    • Split the independent no-arg sub-checks and sharded binary16 arithmetic reference grid out of _check_controls_inline(directory) and run them via concurrent.futures.ProcessPoolExecutor in check_controls(directory) while the parent executes the inline body, collecting ACCEPTED sets deterministically across workers with a clean serial fallback (X2W_SERIAL_CONTROLS=1, single-core, or pool creation failure).

Verification

Commit under test: x2w-opt-form-coverage on origin/main (1ca0dec1).

  • Baseline (origin/main before change, python -B tests/form_coverage_check.py):
    • 75.017s (exit 0, form coverage checks passed)
  • After (python -B tests/form_coverage_check.py, 2x back-to-back on 16-core Linux):
    • Clean run: 11.574s (exit 0, form coverage checks passed)
    • Back-to-back under machine load (load average: 16.91): 14.050s and 17.400s (both exit 0, form coverage checks passed)
  • python -B tests/pixel_aot_check.py: 6.379s (exit 0)
  • Direct set-equality verification (check_controls(..., parallel=False) vs check_controls(..., parallel=True) vs form_coverage_check._controls_accepted()):
    • SET_IDENTICAL=True count=788 (serial=24.525s, parallel=5.219s)
  • python -B tests/docs_links_check.py: passed (16 Markdown files and 340 links)
  • python -B tests/bidi_controls_check.py: passed (1239 tracked source, script and build/CI files: no bidirectional controls)
  • git diff --check origin/main..HEAD: passed

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583099138 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:40:35Z. --- Cache and parallelize `tests/pixel_aot_check.check_controls` across `tests/form_coverage_check.py` with zero dropped assertions and set-identical `ACCEPTED` coverage. ### Summary - `tests/form_coverage_check.py`: - Save and restore `pixel.ACCEPTED` in `check_plain_bitscan_forms` (with `try ... finally`) so it no longer clears the set populated by `pixel.check_controls`. - Add `_controls_accepted()` to run `pixel.check_controls` once per process and reuse the cached `frozenset` across `check_shader_records`, `check_swap_coverage`, and `check_pk_fmac_coverage`. - `tests/pixel_aot_check.py`: - Split the independent no-arg sub-checks and sharded binary16 arithmetic reference grid out of `_check_controls_inline(directory)` and run them via `concurrent.futures.ProcessPoolExecutor` in `check_controls(directory)` while the parent executes the inline body, collecting `ACCEPTED` sets deterministically across workers with a clean serial fallback (`X2W_SERIAL_CONTROLS=1`, single-core, or pool creation failure). ### Verification Commit under test: `x2w-opt-form-coverage` on `origin/main` (`1ca0dec1`). - Baseline (`origin/main` before change, `python -B tests/form_coverage_check.py`): - `75.017s` (`exit 0`, `form coverage checks passed`) - After (`python -B tests/form_coverage_check.py`, 2x back-to-back on 16-core Linux): - Clean run: `11.574s` (`exit 0`, `form coverage checks passed`) - Back-to-back under machine load (`load average: 16.91`): `14.050s` and `17.400s` (both `exit 0`, `form coverage checks passed`) - `python -B tests/pixel_aot_check.py`: `6.379s` (`exit 0`) - Direct set-equality verification (`check_controls(..., parallel=False)` vs `check_controls(..., parallel=True)` vs `form_coverage_check._controls_accepted()`): - `SET_IDENTICAL=True count=788` (`serial=24.525s`, `parallel=5.219s`) - `python -B tests/docs_links_check.py`: passed (`16 Markdown files and 340 links`) - `python -B tests/bidi_controls_check.py`: passed (`1239 tracked source, script and build/CI files: no bidirectional controls`) - `git diff --check origin/main..HEAD`: passed AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 15:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T14:30:54Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4daf98481

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041100303 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#pullrequestreview-6041100303). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T14:30:54Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `a4daf98481` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 15:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:44:16Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041371917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#pullrequestreview-6041371917). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T14:44:16Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-24 15:02:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:23:28Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit a4daf98481cedba25989ed41391c11a89c7dbfe7:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 6): 34.16s (configure 1.85s)
    • Test (ctest --preset dev -R '^pixel_aot_warp$' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (13.98s: pixel_aot_warp 13.90s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 6): 45.20s (configure 1.93s)
    • Test (ctest --preset release -R '^pixel_aot_warp$' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (12.84s: pixel_aot_warp 12.76s)
  • Windows Python checks (spawn):
    • tests/form_coverage_check.py: passed (18.02s)
    • tests/pixel_aot_check.py: passed (9.56s)
  • Linux timings & parity:
    • tests/form_coverage_check.py: 75.0s baseline -> 16.90s / 14.60s back-to-back (exit 0, form coverage checks passed)
    • tests/pixel_aot_check.py: 5.86s (exit 0)
    • check_controls(..., parallel=False) vs check_controls(..., parallel=True): identical ACCEPTED set (788 forms), 27.88s serial -> 7.34s parallel
    • Failure-propagation control: worker ValueError raises RuntimeError naming the failing sub-task and cancels pending futures
  • Hardening:
    • Rebased onto latest origin/main
    • Capped ProcessPoolExecutor max_workers at 61 to respect Windows _MAX_WINDOWS_WORKERS on >61-core hosts
    • Cancel pending futures immediately if _check_controls_inline or any worker sub-check fails

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134296170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#issuecomment-7134296170). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T14:23:28Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `a4daf98481cedba25989ed41391c11a89c7dbfe7`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 6`): `34.16s` (configure `1.85s`) - Test (`ctest --preset dev -R '^pixel_aot_warp$' --parallel 4 --no-tests=error --output-on-failure`): **1/1 passed** (`13.98s`: `pixel_aot_warp` `13.90s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 6`): `45.20s` (configure `1.93s`) - Test (`ctest --preset release -R '^pixel_aot_warp$' --parallel 4 --no-tests=error --output-on-failure`): **1/1 passed** (`12.84s`: `pixel_aot_warp` `12.76s`) - **Windows Python checks (`spawn`)**: - `tests/form_coverage_check.py`: passed (`18.02s`) - `tests/pixel_aot_check.py`: passed (`9.56s`) - **Linux timings & parity**: - `tests/form_coverage_check.py`: `75.0s` baseline -> `16.90s` / `14.60s` back-to-back (`exit 0`, `form coverage checks passed`) - `tests/pixel_aot_check.py`: `5.86s` (`exit 0`) - `check_controls(..., parallel=False)` vs `check_controls(..., parallel=True)`: identical `ACCEPTED` set (`788` forms), `27.88s` serial -> `7.34s` parallel - Failure-propagation control: worker `ValueError` raises `RuntimeError` naming the failing sub-task and cancels pending futures - **Hardening**: - Rebased onto latest `origin/main` - Capped `ProcessPoolExecutor` `max_workers` at `61` to respect Windows `_MAX_WINDOWS_WORKERS` on >61-core hosts - Cancel pending futures immediately if `_check_controls_inline` or any worker sub-check fails AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 15:02:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T14:23:41Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:30:57.481959Z a4daf98 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134301849 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#issuecomment-7134301849). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T14:23:41Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a4daf98481cedba25989ed41391c11a89c7dbfe7","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T14:30:57.481959Z">2026-11-24T14:30:57.481959Z</relative-time> | `a4daf98` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-24 15:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T14:30:55Z.

Code review location: tests/pixel_aot_check.py; line 15789

@@ -15708,13 +15662,142 @@ def check_controls(directory):
     must_reject(translate, base_m24[:lgkm] + ["v_mul_u32_u24_e64 v20, s44, 2"] + base_m24[lgkm:])
     wqm = base_m24.index("s_wqm_b64 exec, exec") + 1
     must_reject(translate, base_m24[:wqm] + ["v_mul_hi_i32_i24_e64 v20, 1, 2"] + base_m24[wqm:])
-    check_int16_vop3_controls()
-    check_int16_ternary_controls()
-    check_f16_arith_controls()
-    check_f16_round_controls()
-    check_f16_fmac_ldexp_controls()
-    check_f16_cvt_int_controls()
-    check_f16_to_int_controls()
+
+
+_CONTROL_SUBCHECKS = (
+    "check_unbound_operand_diagnostics",
+    "check_dpp_cvt_refusals",
+    "check_dpp_f16_contract_controls",
+    "check_smem_pointer_controls",
+    "check_masked_controls",
+    "check_masked_mov_close_controls",
+    "check_masked_else_controls",
+    "check_scc_skip_controls",
+    "check_cmpx_controls",
+    "check_shift64_controls",
+    "check_region_body_controls",
+    "check_region_wait_controls",
+    "check_region_scalar_alu_controls",
+    "check_region_scalar_load_controls",
+    "check_pk_fmac_controls",
+    "check_title_load_controls",
+    "check_ds_swizzle_controls",
+    "check_ds_nop_controls",
+    "check_f16_denorm_controls",
+    "check_vopc_e32_destination",
+    "check_bit_controls",
+    "check_scheduling_hints",
+    "check_mode_register_controls",
+    "check_constant_descriptor_bounds",
+    "check_scalar_constant_reads",
+    "check_three_constant_buffers",
+    "check_affine_coordinates",
+    "check_scalar_helpers_with_vector_arithmetic",
+    "check_scalar_pair_reads",
+    "check_readfirstlane_controls",
+    "check_flat_scratch_controls",
+    "check_nc_integer_lowering",
+    "check_e64_integer_lowering",
+    "check_carry_out_lowering",
+    "check_carry_in_lowering",
+    "check_mad64_lowering",
+    "check_cvt_f64_int_lowering",
+    "check_cvt_f64_f32_lowering",
+    "check_sdwa_integer_lowering",
+    "check_pack_int16_lowering",
+    "check_sat_pack_u8_lowering",
+    "check_pack_b32_lowering",
+    "check_sad_lowering",
+    "check_scalar_controls",
+    "check_three_way_templates",
+    "check_sdwa_unary_lowering",
+    "check_s_version",
+    "check_e64_approx_lowering",
+    "check_mac_legacy_lowering",
+    "check_dpp_vop3_only_refused",
+    "check_cmp64_controls",
+    "check_cmpf64_controls",
+    "check_int16_vop3_controls",
+    "check_int16_ternary_controls",
+    "check_f16_arith_controls",
+    "check_f16_round_controls",
+    "check_f16_fmac_ldexp_controls",
+    "check_f16_cvt_int_controls",
+    "check_f16_to_int_controls",
+)
+
+_PRIORITY_SUBCHECKS = (
+    "check_s_version",
+    "check_f16_round_controls",
+    "check_f16_fmac_ldexp_controls",
+    "check_f16_cvt_int_controls",
+    "check_f16_to_int_controls",
+)
+
+
+def _control_tasks():
+    """Return parallel control tasks ordered longest-first to avoid tail stragglers."""
+    grid_shards = 4
+    tasks = [("f16_arith_grid", (i, grid_shards)) for i in range(grid_shards)]
+    tasks.extend(("fn", name) for name in _PRIORITY_SUBCHECKS)
+    tasks.append(("f16_arith_controls_no_ref", None))
+    tasks.append(("f16_arith_ref_head", None))
+    special = set(_PRIORITY_SUBCHECKS) | {"check_f16_arith_controls"}
+    tasks.extend(("fn", name) for name in _CONTROL_SUBCHECKS if name not in special)
+    return tasks
+
+
+def _run_control_subcheck(task):
+    """Execute one independent control sub-task in a worker and return its accepted words."""
+    ACCEPTED.clear()
+    kind, arg = task
+    if kind == "fn":
+        globals()[arg]()
+    elif kind == "f16_arith_controls_no_ref":
+        check_f16_arith_controls(run_reference=False)
+    elif kind == "f16_arith_ref_head":
+        check_f16_arith_reference(run_grid=False)
+    elif kind == "f16_arith_grid":
+        slice_index, slice_count = arg
+        _check_f16_arith_reference_grid(slice_index, slice_count)
+    else:
+        raise ValueError(f"Unknown control sub-task: {kind!r}")
+    return set(ACCEPTED)
+
+
+def _run_controls_serial():
+    for name in _CONTROL_SUBCHECKS:
+        globals()[name]()
+
+
+def check_controls(directory, *, parallel=True):
+    tasks = _control_tasks()
+    cpu_count = os.cpu_count() or 1
+    # ProcessPoolExecutor on Windows enforces max_workers <= 61 (_MAX_WINDOWS_WORKERS).
+    workers = min(cpu_count, len(tasks), 61)
+    if not parallel or workers <= 1 or os.environ.get("X2W_SERIAL_CONTROLS") == "1":
+        _check_controls_inline(directory)
+        _run_controls_serial()
+        return
+    try:
+        executor = concurrent.futures.ProcessPoolExecutor(max_workers=workers)
+    except (OSError, PermissionError, NotImplementedError):
+        _check_controls_inline(directory)
+        _run_controls_serial()
+        return
+    with executor:
+        futures = [(task, executor.submit(_run_control_subcheck, task)) for task in tasks]

P2 Badge Extend the serial fallback to lazy worker startup

When worker creation is denied or a process limit is exhausted, this submission raises instead of taking the serial fallback: ProcessPoolExecutor starts workers lazily in submit(), outside the constructor-only exception handler. Reproduced on Linux/Python 3.12 in an unprivileged process with RLIMIT_NPROC=(0, 0): the parent commit passes with 788 accepted forms, but this commit raises BlockingIOError(11, 'Resource temporarily unavailable'); explicit serial mode also passes under the same limit. Consequently, the default pixel-control and form-coverage checks regress on these hosts. Include initial submission and worker startup in the startup-failure fallback while continuing to propagate actual check failures.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4681496473 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#discussion_r4681496473). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T14:30:55Z. **Code review location:** `tests/pixel_aot_check.py`; line 15789 ~~~~diff @@ -15708,13 +15662,142 @@ def check_controls(directory): must_reject(translate, base_m24[:lgkm] + ["v_mul_u32_u24_e64 v20, s44, 2"] + base_m24[lgkm:]) wqm = base_m24.index("s_wqm_b64 exec, exec") + 1 must_reject(translate, base_m24[:wqm] + ["v_mul_hi_i32_i24_e64 v20, 1, 2"] + base_m24[wqm:]) - check_int16_vop3_controls() - check_int16_ternary_controls() - check_f16_arith_controls() - check_f16_round_controls() - check_f16_fmac_ldexp_controls() - check_f16_cvt_int_controls() - check_f16_to_int_controls() + + +_CONTROL_SUBCHECKS = ( + "check_unbound_operand_diagnostics", + "check_dpp_cvt_refusals", + "check_dpp_f16_contract_controls", + "check_smem_pointer_controls", + "check_masked_controls", + "check_masked_mov_close_controls", + "check_masked_else_controls", + "check_scc_skip_controls", + "check_cmpx_controls", + "check_shift64_controls", + "check_region_body_controls", + "check_region_wait_controls", + "check_region_scalar_alu_controls", + "check_region_scalar_load_controls", + "check_pk_fmac_controls", + "check_title_load_controls", + "check_ds_swizzle_controls", + "check_ds_nop_controls", + "check_f16_denorm_controls", + "check_vopc_e32_destination", + "check_bit_controls", + "check_scheduling_hints", + "check_mode_register_controls", + "check_constant_descriptor_bounds", + "check_scalar_constant_reads", + "check_three_constant_buffers", + "check_affine_coordinates", + "check_scalar_helpers_with_vector_arithmetic", + "check_scalar_pair_reads", + "check_readfirstlane_controls", + "check_flat_scratch_controls", + "check_nc_integer_lowering", + "check_e64_integer_lowering", + "check_carry_out_lowering", + "check_carry_in_lowering", + "check_mad64_lowering", + "check_cvt_f64_int_lowering", + "check_cvt_f64_f32_lowering", + "check_sdwa_integer_lowering", + "check_pack_int16_lowering", + "check_sat_pack_u8_lowering", + "check_pack_b32_lowering", + "check_sad_lowering", + "check_scalar_controls", + "check_three_way_templates", + "check_sdwa_unary_lowering", + "check_s_version", + "check_e64_approx_lowering", + "check_mac_legacy_lowering", + "check_dpp_vop3_only_refused", + "check_cmp64_controls", + "check_cmpf64_controls", + "check_int16_vop3_controls", + "check_int16_ternary_controls", + "check_f16_arith_controls", + "check_f16_round_controls", + "check_f16_fmac_ldexp_controls", + "check_f16_cvt_int_controls", + "check_f16_to_int_controls", +) + +_PRIORITY_SUBCHECKS = ( + "check_s_version", + "check_f16_round_controls", + "check_f16_fmac_ldexp_controls", + "check_f16_cvt_int_controls", + "check_f16_to_int_controls", +) + + +def _control_tasks(): + """Return parallel control tasks ordered longest-first to avoid tail stragglers.""" + grid_shards = 4 + tasks = [("f16_arith_grid", (i, grid_shards)) for i in range(grid_shards)] + tasks.extend(("fn", name) for name in _PRIORITY_SUBCHECKS) + tasks.append(("f16_arith_controls_no_ref", None)) + tasks.append(("f16_arith_ref_head", None)) + special = set(_PRIORITY_SUBCHECKS) | {"check_f16_arith_controls"} + tasks.extend(("fn", name) for name in _CONTROL_SUBCHECKS if name not in special) + return tasks + + +def _run_control_subcheck(task): + """Execute one independent control sub-task in a worker and return its accepted words.""" + ACCEPTED.clear() + kind, arg = task + if kind == "fn": + globals()[arg]() + elif kind == "f16_arith_controls_no_ref": + check_f16_arith_controls(run_reference=False) + elif kind == "f16_arith_ref_head": + check_f16_arith_reference(run_grid=False) + elif kind == "f16_arith_grid": + slice_index, slice_count = arg + _check_f16_arith_reference_grid(slice_index, slice_count) + else: + raise ValueError(f"Unknown control sub-task: {kind!r}") + return set(ACCEPTED) + + +def _run_controls_serial(): + for name in _CONTROL_SUBCHECKS: + globals()[name]() + + +def check_controls(directory, *, parallel=True): + tasks = _control_tasks() + cpu_count = os.cpu_count() or 1 + # ProcessPoolExecutor on Windows enforces max_workers <= 61 (_MAX_WINDOWS_WORKERS). + workers = min(cpu_count, len(tasks), 61) + if not parallel or workers <= 1 or os.environ.get("X2W_SERIAL_CONTROLS") == "1": + _check_controls_inline(directory) + _run_controls_serial() + return + try: + executor = concurrent.futures.ProcessPoolExecutor(max_workers=workers) + except (OSError, PermissionError, NotImplementedError): + _check_controls_inline(directory) + _run_controls_serial() + return + with executor: + futures = [(task, executor.submit(_run_control_subcheck, task)) for task in tasks] ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Extend the serial fallback to lazy worker startup** When worker creation is denied or a process limit is exhausted, this submission raises instead of taking the serial fallback: `ProcessPoolExecutor` starts workers lazily in `submit()`, outside the constructor-only exception handler. Reproduced on Linux/Python 3.12 in an unprivileged process with `RLIMIT_NPROC=(0, 0)`: the parent commit passes with 788 accepted forms, but this commit raises `BlockingIOError(11, 'Resource temporarily unavailable')`; explicit serial mode also passes under the same limit. Consequently, the default pixel-control and form-coverage checks regress on these hosts. Include initial submission and worker startup in the startup-failure fallback while continuing to propagate actual check failures. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 15:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:44:16Z.

Code review location: tests/pixel_aot_check.py; line 15789

@@ -15708,13 +15662,142 @@ def check_controls(directory):
     must_reject(translate, base_m24[:lgkm] + ["v_mul_u32_u24_e64 v20, s44, 2"] + base_m24[lgkm:])
     wqm = base_m24.index("s_wqm_b64 exec, exec") + 1
     must_reject(translate, base_m24[:wqm] + ["v_mul_hi_i32_i24_e64 v20, 1, 2"] + base_m24[wqm:])
-    check_int16_vop3_controls()
-    check_int16_ternary_controls()
-    check_f16_arith_controls()
-    check_f16_round_controls()
-    check_f16_fmac_ldexp_controls()
-    check_f16_cvt_int_controls()
-    check_f16_to_int_controls()
+
+
+_CONTROL_SUBCHECKS = (
+    "check_unbound_operand_diagnostics",
+    "check_dpp_cvt_refusals",
+    "check_dpp_f16_contract_controls",
+    "check_smem_pointer_controls",
+    "check_masked_controls",
+    "check_masked_mov_close_controls",
+    "check_masked_else_controls",
+    "check_scc_skip_controls",
+    "check_cmpx_controls",
+    "check_shift64_controls",
+    "check_region_body_controls",
+    "check_region_wait_controls",
+    "check_region_scalar_alu_controls",
+    "check_region_scalar_load_controls",
+    "check_pk_fmac_controls",
+    "check_title_load_controls",
+    "check_ds_swizzle_controls",
+    "check_ds_nop_controls",
+    "check_f16_denorm_controls",
+    "check_vopc_e32_destination",
+    "check_bit_controls",
+    "check_scheduling_hints",
+    "check_mode_register_controls",
+    "check_constant_descriptor_bounds",
+    "check_scalar_constant_reads",
+    "check_three_constant_buffers",
+    "check_affine_coordinates",
+    "check_scalar_helpers_with_vector_arithmetic",
+    "check_scalar_pair_reads",
+    "check_readfirstlane_controls",
+    "check_flat_scratch_controls",
+    "check_nc_integer_lowering",
+    "check_e64_integer_lowering",
+    "check_carry_out_lowering",
+    "check_carry_in_lowering",
+    "check_mad64_lowering",
+    "check_cvt_f64_int_lowering",
+    "check_cvt_f64_f32_lowering",
+    "check_sdwa_integer_lowering",
+    "check_pack_int16_lowering",
+    "check_sat_pack_u8_lowering",
+    "check_pack_b32_lowering",
+    "check_sad_lowering",
+    "check_scalar_controls",
+    "check_three_way_templates",
+    "check_sdwa_unary_lowering",
+    "check_s_version",
+    "check_e64_approx_lowering",
+    "check_mac_legacy_lowering",
+    "check_dpp_vop3_only_refused",
+    "check_cmp64_controls",
+    "check_cmpf64_controls",
+    "check_int16_vop3_controls",
+    "check_int16_ternary_controls",
+    "check_f16_arith_controls",
+    "check_f16_round_controls",
+    "check_f16_fmac_ldexp_controls",
+    "check_f16_cvt_int_controls",
+    "check_f16_to_int_controls",
+)
+
+_PRIORITY_SUBCHECKS = (
+    "check_s_version",
+    "check_f16_round_controls",
+    "check_f16_fmac_ldexp_controls",
+    "check_f16_cvt_int_controls",
+    "check_f16_to_int_controls",
+)
+
+
+def _control_tasks():
+    """Return parallel control tasks ordered longest-first to avoid tail stragglers."""
+    grid_shards = 4
+    tasks = [("f16_arith_grid", (i, grid_shards)) for i in range(grid_shards)]
+    tasks.extend(("fn", name) for name in _PRIORITY_SUBCHECKS)
+    tasks.append(("f16_arith_controls_no_ref", None))
+    tasks.append(("f16_arith_ref_head", None))
+    special = set(_PRIORITY_SUBCHECKS) | {"check_f16_arith_controls"}
+    tasks.extend(("fn", name) for name in _CONTROL_SUBCHECKS if name not in special)
+    return tasks
+
+
+def _run_control_subcheck(task):
+    """Execute one independent control sub-task in a worker and return its accepted words."""
+    ACCEPTED.clear()
+    kind, arg = task
+    if kind == "fn":
+        globals()[arg]()
+    elif kind == "f16_arith_controls_no_ref":
+        check_f16_arith_controls(run_reference=False)
+    elif kind == "f16_arith_ref_head":
+        check_f16_arith_reference(run_grid=False)
+    elif kind == "f16_arith_grid":
+        slice_index, slice_count = arg
+        _check_f16_arith_reference_grid(slice_index, slice_count)
+    else:
+        raise ValueError(f"Unknown control sub-task: {kind!r}")
+    return set(ACCEPTED)
+
+
+def _run_controls_serial():
+    for name in _CONTROL_SUBCHECKS:
+        globals()[name]()
+
+
+def check_controls(directory, *, parallel=True):
+    tasks = _control_tasks()
+    cpu_count = os.cpu_count() or 1
+    # ProcessPoolExecutor on Windows enforces max_workers <= 61 (_MAX_WINDOWS_WORKERS).
+    workers = min(cpu_count, len(tasks), 61)
+    if not parallel or workers <= 1 or os.environ.get("X2W_SERIAL_CONTROLS") == "1":
+        _check_controls_inline(directory)
+        _run_controls_serial()
+        return
+    try:
+        executor = concurrent.futures.ProcessPoolExecutor(max_workers=workers)
+    except (OSError, PermissionError, NotImplementedError):
+        _check_controls_inline(directory)
+        _run_controls_serial()
+        return
+    with executor:
+        futures = [(task, executor.submit(_run_control_subcheck, task)) for task in tasks]

Fixed in 1ed17b653be6eb6ba628cf1c3911d75ec55e7ea0.

check_controls() now wraps executor.submit() in the startup-failure fallback handler: if lazy worker/thread creation fails during submission (e.g. BlockingIOError under RLIMIT_NPROC or PermissionError), any already-submitted futures are cancelled, the pool exits cleanly via with executor:, and the inline + serial control checks run to completion. Actual worker check failures from future.result() still cancel pending futures and propagate as RuntimeError without falling back to serial.

Verified locally:

  • Partial worker spawn failure (BlockingIOError on 2nd Process.start with real ProcessPoolExecutor) falls back cleanly and validates all 788 accepted forms; worker AssertionError propagates without serial fallback.
  • Linux: tests/pixel_aot_check.py and tests/form_coverage_check.py pass.
  • Windows Server 2025 (MSVC 14.44.35207 + D3D12 WARP, Debug & Release /O2): tests/form_coverage_check.py (16.1s), tests/pixel_aot_check.py (8.9s), and pixel_aot_warp / pixel_aot_f16_arith_warp pass (2/2 Debug, 2/2 Release).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4681701585 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1527#discussion_r4681701585). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T14:44:16Z. **Code review location:** `tests/pixel_aot_check.py`; line 15789 ~~~~diff @@ -15708,13 +15662,142 @@ def check_controls(directory): must_reject(translate, base_m24[:lgkm] + ["v_mul_u32_u24_e64 v20, s44, 2"] + base_m24[lgkm:]) wqm = base_m24.index("s_wqm_b64 exec, exec") + 1 must_reject(translate, base_m24[:wqm] + ["v_mul_hi_i32_i24_e64 v20, 1, 2"] + base_m24[wqm:]) - check_int16_vop3_controls() - check_int16_ternary_controls() - check_f16_arith_controls() - check_f16_round_controls() - check_f16_fmac_ldexp_controls() - check_f16_cvt_int_controls() - check_f16_to_int_controls() + + +_CONTROL_SUBCHECKS = ( + "check_unbound_operand_diagnostics", + "check_dpp_cvt_refusals", + "check_dpp_f16_contract_controls", + "check_smem_pointer_controls", + "check_masked_controls", + "check_masked_mov_close_controls", + "check_masked_else_controls", + "check_scc_skip_controls", + "check_cmpx_controls", + "check_shift64_controls", + "check_region_body_controls", + "check_region_wait_controls", + "check_region_scalar_alu_controls", + "check_region_scalar_load_controls", + "check_pk_fmac_controls", + "check_title_load_controls", + "check_ds_swizzle_controls", + "check_ds_nop_controls", + "check_f16_denorm_controls", + "check_vopc_e32_destination", + "check_bit_controls", + "check_scheduling_hints", + "check_mode_register_controls", + "check_constant_descriptor_bounds", + "check_scalar_constant_reads", + "check_three_constant_buffers", + "check_affine_coordinates", + "check_scalar_helpers_with_vector_arithmetic", + "check_scalar_pair_reads", + "check_readfirstlane_controls", + "check_flat_scratch_controls", + "check_nc_integer_lowering", + "check_e64_integer_lowering", + "check_carry_out_lowering", + "check_carry_in_lowering", + "check_mad64_lowering", + "check_cvt_f64_int_lowering", + "check_cvt_f64_f32_lowering", + "check_sdwa_integer_lowering", + "check_pack_int16_lowering", + "check_sat_pack_u8_lowering", + "check_pack_b32_lowering", + "check_sad_lowering", + "check_scalar_controls", + "check_three_way_templates", + "check_sdwa_unary_lowering", + "check_s_version", + "check_e64_approx_lowering", + "check_mac_legacy_lowering", + "check_dpp_vop3_only_refused", + "check_cmp64_controls", + "check_cmpf64_controls", + "check_int16_vop3_controls", + "check_int16_ternary_controls", + "check_f16_arith_controls", + "check_f16_round_controls", + "check_f16_fmac_ldexp_controls", + "check_f16_cvt_int_controls", + "check_f16_to_int_controls", +) + +_PRIORITY_SUBCHECKS = ( + "check_s_version", + "check_f16_round_controls", + "check_f16_fmac_ldexp_controls", + "check_f16_cvt_int_controls", + "check_f16_to_int_controls", +) + + +def _control_tasks(): + """Return parallel control tasks ordered longest-first to avoid tail stragglers.""" + grid_shards = 4 + tasks = [("f16_arith_grid", (i, grid_shards)) for i in range(grid_shards)] + tasks.extend(("fn", name) for name in _PRIORITY_SUBCHECKS) + tasks.append(("f16_arith_controls_no_ref", None)) + tasks.append(("f16_arith_ref_head", None)) + special = set(_PRIORITY_SUBCHECKS) | {"check_f16_arith_controls"} + tasks.extend(("fn", name) for name in _CONTROL_SUBCHECKS if name not in special) + return tasks + + +def _run_control_subcheck(task): + """Execute one independent control sub-task in a worker and return its accepted words.""" + ACCEPTED.clear() + kind, arg = task + if kind == "fn": + globals()[arg]() + elif kind == "f16_arith_controls_no_ref": + check_f16_arith_controls(run_reference=False) + elif kind == "f16_arith_ref_head": + check_f16_arith_reference(run_grid=False) + elif kind == "f16_arith_grid": + slice_index, slice_count = arg + _check_f16_arith_reference_grid(slice_index, slice_count) + else: + raise ValueError(f"Unknown control sub-task: {kind!r}") + return set(ACCEPTED) + + +def _run_controls_serial(): + for name in _CONTROL_SUBCHECKS: + globals()[name]() + + +def check_controls(directory, *, parallel=True): + tasks = _control_tasks() + cpu_count = os.cpu_count() or 1 + # ProcessPoolExecutor on Windows enforces max_workers <= 61 (_MAX_WINDOWS_WORKERS). + workers = min(cpu_count, len(tasks), 61) + if not parallel or workers <= 1 or os.environ.get("X2W_SERIAL_CONTROLS") == "1": + _check_controls_inline(directory) + _run_controls_serial() + return + try: + executor = concurrent.futures.ProcessPoolExecutor(max_workers=workers) + except (OSError, PermissionError, NotImplementedError): + _check_controls_inline(directory) + _run_controls_serial() + return + with executor: + futures = [(task, executor.submit(_run_control_subcheck, task)) for task in tasks] ~~~~ --- Fixed in `1ed17b653be6eb6ba628cf1c3911d75ec55e7ea0`. `check_controls()` now wraps `executor.submit()` in the startup-failure fallback handler: if lazy worker/thread creation fails during submission (e.g. `BlockingIOError` under `RLIMIT_NPROC` or `PermissionError`), any already-submitted futures are cancelled, the pool exits cleanly via `with executor:`, and the inline + serial control checks run to completion. Actual worker check failures from `future.result()` still cancel pending futures and propagate as `RuntimeError` without falling back to serial. Verified locally: - Partial worker spawn failure (`BlockingIOError` on 2nd `Process.start` with real `ProcessPoolExecutor`) falls back cleanly and validates all 788 accepted forms; worker `AssertionError` propagates without serial fallback. - Linux: `tests/pixel_aot_check.py` and `tests/form_coverage_check.py` pass. - Windows Server 2025 (MSVC 14.44.35207 + D3D12 WARP, Debug & Release `/O2`): `tests/form_coverage_check.py` (16.1s), `tests/pixel_aot_check.py` (8.9s), and `pixel_aot_warp` / `pixel_aot_f16_arith_warp` pass (2/2 Debug, 2/2 Release). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 16:03:01 +00:00
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
R0Y00/Xbox2Windows!1520
No description provided.