Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor address generation code in dataflow_api.h into seperate header #18257

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bgrady-tt
Copy link

Problem description

hw/inc/dataflow_api.h currently interleaves address generation helper functions and classes (InterleavedAddrGen, etc) and public async NoC APIS (e.g. noc_async_read) together.

address gen helper functions/classes
noc_async_api_calls
_more_ address gen helper functions/classes
noc_async_api_calls
....

This is specifically a blocker for writing profiling instrumentation macros within dataflow_api.h that need to write to DRAM via NoC themselves (#16494). The profiling macros use of InterleavedAddrGen must be fully defined before parsing dataflow_api.h, either necessitating (A) duplicating address generation code's functionality or (B) refactoring to break the circular dependency.

The degree of code duplication needed to implement (A) is very high and likely to be a maintenance burden/bug factory, so (B) seems the better option.

Absolutely open to changing naming, dir structure, you name it. I just need address generation include-able separately from the rest of the noc_async_ API.

What's changed

  • hw/inc/dataflow_api.h code is now split into two parts: dataflow_api.h and dataflow_api_addrgen.h

    • dataflow_api.h now depends on dataflow_api_addrgen.h
    • A single forward declaration of noc_async_read in dataflow_api_addrgen.h is required to make this split work. This requires code that uses InterleavedAddrGen::noc_async_read() to also include `dataflow_api.h as well. This is not required within kernel_profiler.hpp for instance.
    • I tried to be thorough and include all functions, extern vars, and other code that was address generation related into dataflow_api_addrgen.h. This wasn't strictly necessary to unblock Kernel profiler based NoC event tracing #16494, but I think its better structured.
  • tools/profiler/kernel_profiler.hpp no longer depends on dataflow_api.h, but instead dataflow_api_addrgen.h ! Some small, non-functional refactors in kernel profiler facilitate this.

  • firmware code i.e. hw/firmware/src/(brisc|ncrisc|erisc|...).cc must now include dataflow_api.h explicitly

    • dataflow_api.h was already unconditionally included transitively via tools/profiler/kernel_profiler.hpp

Checklist

@bgrady-tt bgrady-tt force-pushed the bgrady/dataflow_api_refactor branch from 853895c to 194ba02 Compare February 25, 2025 15:29
@bgrady-tt bgrady-tt force-pushed the bgrady/dataflow_api_refactor branch from 194ba02 to 4ab4c99 Compare February 25, 2025 15:32
Copy link
Contributor

@mo-tenstorrent mo-tenstorrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@tt-aho tt-aho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for doing this.

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.

4 participants