Skip to content

Add: unit tests for PTO2 scheduler core data structures and hot-paths#643

Merged
ChaoZheng109 merged 1 commit intohw-native-sys:mainfrom
chenshengxin2026:ut-pto2-ring-scheduler
Apr 25, 2026
Merged

Add: unit tests for PTO2 scheduler core data structures and hot-paths#643
ChaoZheng109 merged 1 commit intohw-native-sys:mainfrom
chenshengxin2026:ut-pto2-ring-scheduler

Conversation

@chenshengxin2026
Copy link
Copy Markdown
Contributor

@chenshengxin2026 chenshengxin2026 commented Apr 22, 2026

Summary

The core data structures (task allocator, dep-list pool, fanin pool, SPSC queue, tensor map) and scheduling hot-paths (wire_task, on_mixed_task_complete, on_task_release, advance_ring_pointers) in the PTO2 scheduler (A2A3 and A5) previously had no unit test coverage. Bugs in these paths — off-by-one in wrap-around, stale fanin references, lost dependency edges — only surface under specific task-graph topologies and are extremely hard to diagnose at the system-test level.

This PR adds per-component unit tests, covering both A2A3 and A5 runtimes:

  • test_task_allocator — heap bump, wrap-around guard, flow-control window
  • test_task_state — slot lifecycle driven through src API, profiling CAS semantics
  • test_dep_list_pool / test_fanin_pool — ring allocation, overflow detection, tail advance
  • test_spsc_queue — cached-index SPSC correctness, wrap, capacity semantics
  • test_tensormap — hash distribution, overlap detection, lookup saturation
  • test_wiring — end-to-end wire → complete → release → advance cycle

These tests also serve as executable documentation of design contracts (e.g. heap_available reports max-not-sum, LIFO dispatch for cache locality, relaxed size() as a hint only).

Test plan

  • cmake -B tests/ut/cpp/build -S tests/ut/cpp && cmake --build tests/ut/cpp/build -j$(nproc)
  • ctest --test-dir tests/ut/cpp/build --output-on-failure
  • All new and modified test binaries pass (A2A3 and A5)

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chenshengxin2026 chenshengxin2026 changed the title Add: PTO2 ring buffer, scheduler & ready queue unit tests Refactor: rewrite PTO2 A2A3 unit tests around actual component APIs Apr 24, 2026
@chenshengxin2026 chenshengxin2026 force-pushed the ut-pto2-ring-scheduler branch 2 times, most recently from 5c8138d to bda9279 Compare April 24, 2026 04:22
@chenshengxin2026 chenshengxin2026 changed the title Refactor: rewrite PTO2 A2A3 unit tests around actual component APIs Add: unit tests for PTO2 scheduler core data structures and hot-paths Apr 24, 2026
@chenshengxin2026 chenshengxin2026 force-pushed the ut-pto2-ring-scheduler branch 2 times, most recently from bde9a7b to db248fd Compare April 24, 2026 09:34
Comment thread tests/ut/cpp/CMakeLists.txt Outdated
The PTO2 scheduler (A2A3 and A5) relies on several tightly coupled data
structures (task allocator, dep-list pool, fanin pool, SPSC queue, tensor
map) and hot-path functions (wire_task, on_mixed_task_complete,
on_task_release, advance_ring_pointers) that previously had no unit test
coverage. Bugs in these paths — off-by-one in wrap-around, stale fanin
references, lost dependency edges — surface only under specific
task-graph topologies and are extremely hard to diagnose at the
system-test level.

This change adds per-component tests, covering both A2A3 and A5 runtimes,
that exercise:
- task_allocator: heap bump, wrap-around guard, flow-control window
- task_state: slot lifecycle through src API, profiling CAS semantics
- dep_list_pool / fanin_pool: ring allocation, overflow, tail advance
- spsc_queue: cached-index SPSC correctness, wrap, capacity semantics
- tensormap: hash distribution, overlap detection, lookup saturation
- wiring: end-to-end wire → complete → release → advance cycle

These tests also serve as executable documentation of design contracts
(e.g. heap_available reports max-not-sum, LIFO dispatch for cache
locality, relaxed size() as a hint) that would otherwise exist only as
implicit assumptions in the source.
@ChaoZheng109 ChaoZheng109 merged commit ce9fa2e into hw-native-sys:main Apr 25, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants