Skip to content

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

Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:ut-pto2-ring-scheduler
Open

Add: unit tests for PTO2 scheduler core data structures and hot-paths#643
chenshengxin2026 wants to merge 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 A2A3 scheduler 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:

  • 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 -L no_hardware --output-on-failure
  • All new and modified test binaries pass

@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
The PTO2 A2A3 scheduler 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 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.
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.

1 participant