Skip to content

Dtrace json output of control instrumentation to reduce overhead at hwcontext destructor - #103

Open
garimadhaked wants to merge 6 commits into
Xilinx:masterfrom
garimadhaked:dtrace_json_output
Open

Dtrace json output of control instrumentation to reduce overhead at hwcontext destructor #103
garimadhaked wants to merge 6 commits into
Xilinx:masterfrom
garimadhaked:dtrace_json_output

Conversation

@garimadhaked

Copy link
Copy Markdown
Collaborator

Summary
Improves the aie_dtrace plugin's JSON dump output for AIE bandwidth/counter profiling on VE2.

Enable coalesced JSON dtrace_dump output by default. The plugin now turns on JSON-format output and in-memory result coalescing, so each hw-context teardown produces a single dtrace_dump_ctx__.json instead of many per-inference files.
Emit sequential per-counter keys in the CT file. Each counter read is now assigned a sequential result variable (_0, _1, _2, …) instead of a shared _ throwaway. Since the dtrace engine keys each JSON entry by the read_reg result variable name, this makes every counter show up as its own key ("_0", "_1", …) in probe order, rather than collapsing into a single _ entry. Counter semantics (row/counter/channel/direction/event) remain described in the COUNTER_METADATA comment block. Applied to both writeCTFile and writeBandwidthCTFile.

Example JSON output
"jprobe:aie_runtime_control.asm:uc0:line8": { "ts_0": 182936, "_0": 123, "_1": 245, "...": "...", "_15": 0 }

Testing done

  • Build XRT and run a VE2 VAIML design with aie_dtrace + CT enabled.
  • run vart app with multiple apps having multiple hwctx and run with multiple inferences
  • Confirm a single coalesced dtrace_dump_ctx__*.json per context.
  • Confirm each probe block contains _0…_N keys matching the counter count/order in COUNTER_METADATA.

garimadhaked and others added 6 commits July 30, 2026 04:40
…gin.

Apply Debug.dtrace_output_json_format and dtrace_coalesce_result before XRT
initializes dtrace so results are emitted as coalesced JSON on hw context teardown.

Co-authored-by: Cursor <cursoragent@cursor.com>
The dtrace engine drops the CT COUNTER_METADATA comment block from the JSON
output, so the JSON dump lacked the per-counter metadata that the python dump
carries. Rather than modifying the aiebu dtrace engine, keep the change in the
xdp plugin: capture the metadata during CT generation and inject it into the
JSON dump on hw context teardown (finish_flush_device -> endPollforDevice ->
finalizeDtraceDump), which runs after core writes dtrace_dump_ctx_<slot>_*.json.

Also make the metadata a single source of truth so the python (CT comment) and
JSON metadata are identical for every bandwidth metric set, and keep each
counter as a distinct JSON key via self-describing read_reg variable names.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move the JSON dtrace_dump counter-metadata injection out of the VE2 impl
into aie_dtrace/util (invoked via the plugin callback) and rework the
emitted format so post-processing stays cheap:

- Emit a single shared "counters" array (deduped by counter number, per-tile
  "col" dropped) plus a compact per-microcontroller "uc" map (col_start/
  col_end) instead of duplicating per-tile counter blocks.
- Write counter_metadata once at the top level of the coalesced dump rather
  than into every inference's begin block (all inferences share the config).
- Shorten counter variable names to c<col>_n<ctr> and shorten probe keys to
  uc<N>:<line>, reducing CT file size and dtrace runtime/output overhead.

buildBandwidthMetadataJson remains the single source of truth for both the
python CT comment and the injected JSON metadata.

Co-authored-by: Cursor <cursoragent@cursor.com>
The dtrace JSON dump keys each counter by the read_reg result variable name.
The CT writer used "_" for every counter read, which collapses all counters
into a single "_" JSON key. Assign a sequential result variable (_0, _1, _2,
...) per counter instead, so each counter appears as its own key ("_0", "_1",
...) in probe order. Counter semantics remain described by the COUNTER_METADATA
block. Applied to both writeCTFile and writeBandwidthCTFile.

Co-authored-by: Cursor <cursoragent@cursor.com>
@garimadhaked garimadhaked changed the title Dtrace json output Dtrace json output of control instrumentation to reduce overhead at hwcontext destructor Aug 7, 2026
@garimadhaked
garimadhaked requested a review from jvillarre August 7, 2026 10:17
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