Skip to content

Commit c229fdc

Browse files
committed
Refactor dep gen and l2 swimlane collectors to common
1 parent 789e6ec commit c229fdc

23 files changed

Lines changed: 86 additions & 3628 deletions

File tree

docs/dfx/dep_gen.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ list; only the dep_gen replay graph loses the tail.
358358
| Layer | File | Role |
359359
| ----- | ---- | ---- |
360360
| Shared-mem layout | `src/{a2a3,a5}/platform/include/common/dep_gen.h` | `DepGenRecord` (4672 B base, cache-line aligned, ≤64 inline explicit_deps, per-task `block_num`) + `DepGenOverflowRecord` chain view (≤582 deps per slot) + SPSC ring + per-thread ready queue. Byte-identical layout across platforms. |
361-
| AICPU writer | `src/{a2a3,a5}/platform/{include,shared}/aicpu/dep_gen_collector_aicpu.{h,cpp}` | Single-instance write path; weak-fallback exported to host build. a5 reuses the a2a3 source verbatim — the writer accesses its own device-side view of shared memory, independent of how host↔device transport is implemented. |
362-
| Host collector | `src/{a2a3,a5}/platform/{include/host,shared/host}/dep_gen_collector.{h,cpp}` | `ProfilerBase<DepGenCollector, DepGenModule>` — drains ring → `records_` vector. On a5 (no SVM) it uses the base `alloc_paired_buffer`, which malloc's a host shadow + `copy_to_device`'s it and registers it via `add_malloc_shadow` so teardown can free it; `reconcile_counters` explicitly `copy_from_device`'s the BufferState before reading, and `finalize` lets `BufferPoolManager::clear_mappings()` release all shadows as the single source of truth. |
361+
| AICPU writer | `src/{a2a3,a5}/platform/include/aicpu/dep_gen_collector_aicpu.h`, `src/common/platform/shared/aicpu/dep_gen_collector_aicpu.cpp` | Single-instance write path; weak-fallback exported to host build. Both platforms share the same writer implementation — the writer accesses its own device-side view of shared memory, independent of how host↔device transport is implemented. |
362+
| Host collector | `src/common/platform/include/host/dep_gen_collector.h`, `src/common/platform/shared/host/dep_gen_collector.cpp` | `ProfilerBase<DepGenCollector, DepGenModule>` — drains ring → `records_` vector. On non-SVM platforms it uses the base `alloc_paired_buffer`, which malloc's a host shadow + `copy_to_device`'s it and registers it via `add_malloc_shadow` so teardown can free it; `reconcile_counters` explicitly `copy_from_device`'s the BufferState before reading, and `finalize` lets `BufferPoolManager::clear_mappings()` release all shadows as the single source of truth. |
363363
| Capture call site | `src/{a2a3,a5}/runtime/tensormap_and_ringbuffer/runtime/pto_orchestrator.cpp` `submit_task_common` | One conditional block that snapshots inputs into the ring when `is_dep_gen_enabled()`; fires for both `submit_task` and `submit_dummy_task`. The schema carries `kernel_ids[3] = {aic, aiv0, aiv1}` so the swimlane post-processor can resolve `task_id → kernel` from `deps.json` at level=1 where the AICore record is the sole device-side identity source. Inactive subslots stay at `INVALID_KERNEL_ID = -1`. It also carries the SPMD logical block num (`block_num` on a2a3, `core_num` on a5's launch spec) as `tasks[].block_num`. |
364364
| Replay | `src/{a2a3,a5}/runtime/tensormap_and_ringbuffer/host/dep_gen_replay.{h,cpp}` | Pure CPU; runs dual-pass differential replay — `compute_task_fanin` (oracle) + inlined STEP A/B mirror (annotated) against two `PTO2TensorMap` instances. Emits `deps.json` when both passes agree per record. Platform-agnostic — a5 reuses the a2a3 source verbatim. |
365365
| Device-runner hookup | `src/{a2a3,a5}/platform/{onboard,sim}/host/device_runner.cpp` | post-`reconcile_counters` calls `dep_gen_replay_emit_deps_json(records.data(), records.size(), deps_path)` |

docs/dfx/l2-swimlane-profiling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ export_swimlane_json() ← writes <output_prefix>/l2_swimlane_record
708708
finalize(unregister, free)
709709
```
710710

711-
[`L2SwimlaneCollector`](../src/a2a3/platform/include/host/l2_swimlane_collector.h)
711+
[`L2SwimlaneCollector`](../src/common/platform/include/host/l2_swimlane_collector.h)
712712
on a2a3 inherits from
713713
[`profiling_common::ProfilerBase<L2SwimlaneCollector, L2SwimlaneModule>`](../src/common/platform/include/host/profiler_base.h):
714714
the base class owns split mgmt threads, collector shards, and the
@@ -838,7 +838,7 @@ l2_swimlane_collector_.export_swimlane_json()
838838
l2_swimlane_collector_.finalize()
839839
```
840840

841-
[`L2SwimlaneCollector`](../src/a5/platform/include/host/l2_swimlane_collector.h)
841+
[`L2SwimlaneCollector`](../src/common/platform/include/host/l2_swimlane_collector.h)
842842
on a5 inherits the same CRTP base
843843
([`profiling_common::ProfilerBase`](../src/common/platform/include/host/profiler_base.h))
844844
as a2a3 and parameterizes

docs/hardware/cache-coherency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Two separate concerns, often conflated:
9696
`rmb()` between the COND check and the slot reads.
9797

9898
Concretely, the L2 swimlane staging-slot read in
99-
`src/{a2a3,a5}/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp` does
99+
`src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp` does
100100
**not** call `cache_invalidate_range` on the slot, but it **does** call
101101
`rmb()` before reading `slot->task_id` and the timing fields. All of
102102
those fields are AICore writes covered by the AICore-side `dcci` in

docs/profiling-framework.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ the required members are:
177177

178178
The Module structs are defined alongside their collectors in
179179
[pmu_collector.h](../src/a2a3/platform/include/host/pmu_collector.h),
180-
[l2_swimlane_collector.h](../src/a2a3/platform/include/host/l2_swimlane_collector.h),
181-
[dep_gen_collector.h](../src/a2a3/platform/include/host/dep_gen_collector.h),
180+
[l2_swimlane_collector.h](../src/common/platform/include/host/l2_swimlane_collector.h),
181+
[dep_gen_collector.h](../src/common/platform/include/host/dep_gen_collector.h),
182182
[tensor_dump_collector.h](../src/common/platform/include/host/tensor_dump_collector.h),
183183
and
184184
[scope_stats_collector.h](../src/common/platform/include/host/scope_stats_collector.h)
@@ -336,13 +336,13 @@ Existing collectors are the canonical examples:
336336

337337
- [`PmuCollector`](../src/a2a3/platform/include/host/pmu_collector.h)
338338
— single kind, per-core instances. See [pmu-profiling.md](dfx/pmu-profiling.md).
339-
- [`DepGenCollector`](../src/a2a3/platform/include/host/dep_gen_collector.h)
339+
- [`DepGenCollector`](../src/common/platform/include/host/dep_gen_collector.h)
340340
— single kind, one instance. See [dep_gen.md](dfx/dep_gen.md).
341341
- [`TensorDumpCollector`](../src/common/platform/include/host/tensor_dump_collector.h)
342342
— single kind, per-AICPU-thread instances. See [args-dump.md](dfx/args-dump.md).
343343
- [`ScopeStatsCollector`](../src/common/platform/include/host/scope_stats_collector.h)
344344
— single kind, one instance. See [scope-stats.md](dfx/scope-stats.md).
345-
- [`L2SwimlaneCollector`](../src/a2a3/platform/include/host/l2_swimlane_collector.h)
345+
- [`L2SwimlaneCollector`](../src/common/platform/include/host/l2_swimlane_collector.h)
346346
— four kinds (AICPU task, scheduler phase, orchestrator phase, AICore
347347
task), per-core / per-thread instances; the canonical multi-kind example. See
348348
[l2-swimlane-profiling.md](dfx/l2-swimlane-profiling.md).

src/a2a3/platform/include/host/dep_gen_collector.h

Lines changed: 0 additions & 294 deletions
This file was deleted.

0 commit comments

Comments
 (0)