Skip to content

[Profiler] Remove precursory compile-invoke in profiler run to make profiler robust to group2seq#2609

Open
ayakayorihiro wants to merge 14 commits intomainfrom
profiler/remove-compile-invoke
Open

[Profiler] Remove precursory compile-invoke in profiler run to make profiler robust to group2seq#2609
ayakayorihiro wants to merge 14 commits intomainfrom
profiler/remove-compile-invoke

Conversation

@ayakayorihiro
Copy link
Contributor

@ayakayorihiro ayakayorihiro commented Jan 9, 2026

This PR makes the profiler's instrumentation approach robust to all intra-component optimization passes. (It's not yet robust to inline - will make an issue about this.)

For a long time, the profiler-specific compiler pipeline relied on having compile-invoke run before profiler-specific passes (uniquefy-enables and profiler-instrumentation). Since we can only instrument within groups (except for continuous assignments), by having compile-invoke run at the very beginning, we were able to instrument when invokes were happening. However, this precursory run of compile-invoke caused cycle discrepancies with group2seq ( #2470 ) and failure in inline (since structural enables of cells cannot be inlined).

As always, any feedback will be very appreciated!

Approach

In order for us to instrument invokes without having to run compile-invoke, we decided to use invoke with comb groups. Specifically, for each invoke, we attach a special comb group in uniquefy-enables, which will be populated with probe wires in profiler-instrumentation. For example, in inline.futil we have:

control { ...
  invoke exp0(base = a_read0_0.out, exp = const3.out)(); 
... }

after running uniquefy-enables, we get:

wires { ...
    comb group invoke_exp00UG { } // new comb group specific to the particular invoke
}
control { ...
  invoke exp0(base = a_read0_0.out, exp = const3.out)() with invoke_exp00UG; 
... }

and then after running profiler-instrumentation we get:

wires { ...
    comb group invoke_exp00UG {
      invoke_exp00UG___main_group_probe.in = 1'd1;
      exp0___invoke_exp00UG___main_cell_probe.in = 1'd1;
    }
}
control { ...
  invoke exp0(base = a_read0_0.out, exp = const3.out)() with invoke_exp00UG; 
... }

Notes

This approach fully assumes that uniquefy-enables will always be followed by profiler-instrumentation (and profiler-instrumentation will always be preceded by uniquefy-enables) since uniquefy-enables adds an empty group. But I think this is ok for now since both passes will only be used under profiling!

@ayakayorihiro ayakayorihiro self-assigned this Jan 9, 2026
@ayakayorihiro ayakayorihiro added the C: calyx-profiler Profiling Calyx programs label Jan 9, 2026
@ayakayorihiro ayakayorihiro force-pushed the profiler/remove-compile-invoke branch from 2b68f17 to a5d4807 Compare January 9, 2026 22:40
@ayakayorihiro ayakayorihiro marked this pull request as ready for review January 9, 2026 22:43
@github-actions
Copy link
Contributor

This pull request has not seen activity in 14 days and is being marked as stale. If you're continuing work on this, please reply and state how to get this PR in a mergeable state or what issues it is blocked on. If the PR is not ready for review, please mark it as a draft. The PR will be closed in 7 days if there is no further activity.

@ayakayorihiro
Copy link
Contributor Author

I'll take another close look at this PR next week; if it looks alright I will merge!

@github-actions github-actions bot removed the S: Stale label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: calyx-profiler Profiling Calyx programs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant