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

[Router] Fix shim tile connections for non-DMA/NOC ports #1008

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

Yu-Zhewen
Copy link
Contributor

This fix addresses an issue in the shim tile circuit flow for non-DMA/NOC ports. Previously, the router was producing incorrect connections in the generated switchbox configuration.

For a shim tile circuit flow defined as:

aie.flow(%t00, CTRL : 0, %t00, SOUTH : 0)

The router incorrectly generated:

aie.switchbox(%t00) {
  aie.connect<SOUTH : 0, SOUTH : 0>
}

Instead, the correct output should be:

aie.switchbox(%t00) {
  aie.connect<CTRL : 0, SOUTH : 0>
}

A new router unit test has been added to validate this behavior.

// For Task Completion Tokens (TCTs).
aie.flow(%t00, CTRL : 0, %t00, SOUTH : 0)

// For Control Packets.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This new unit test also demonstrates the preconfigured control packet routes.

The plan is to automate the generation of these routes in an AMDAIE pass, which will be addressed in a separate PR.

reference: Xilinx/mlir-aie#1705

@Yu-Zhewen Yu-Zhewen requested a review from jtuyls January 6, 2025 17:41
Copy link
Collaborator

@jtuyls jtuyls left a comment

Choose a reason for hiding this comment

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

LGTM. Just one small question and one nit.

%t05 = aie.tile(0, 5)

// For Task Completion Tokens (TCTs).
aie.flow(%t00, CTRL : 0, %t00, SOUTH : 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be for the control response right?

Copy link
Contributor Author

@Yu-Zhewen Yu-Zhewen Jan 6, 2025

Choose a reason for hiding this comment

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

Xilinx/mlir-aie#1705 introduces a new pass to automatically insert the following two groups of flows:

(1) shim-DMA-to-tile-CTRL, handles sending control packets into each tile.

(2) tile-CTRL-to-shim-SOUTH, which is not specific for control packets, but instead to receive any TCT for DMA BD. This was previously handled by a hack in CDO generation, and mlir-aie relocates this feature into the new pass.

(we currently still have this hack)

// FIXME hack for TCT routing
// TODO copy-pasted: Support both channels
// TODO(max): find a way to keep track so that multiple calls don't
// rewrite/overwrite with same data.
if (tileLoc.row == 0) {
auto slvPortNum = 0;
auto mstrPortNum = 0;
TRY_XAIE_API_LOGICAL_RESULT(XAie_StrmConnCctEnable, devInst, tileLoc, CTRL,
slvPortNum, SOUTH, mstrPortNum);
}


There is also a possibility if we want to retrieve data from CTRL port, then we need to set up tile-CTRL-to-shim-DMA instead of tile-CTRL-to-shim-SOUTH. This is currently not covered by Xilinx/mlir-aie#1705, but an example has been provided to do so manually.

https://github.com/Xilinx/mlir-aie/blob/30300fadd08e0a6189f1f493ada7948d99241034/test/npu-xrt/add_one_ctrl_packet/aie.mlir#L32

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, this makes sense, thanks for the explanation! Are you intending to get rid of that hack as part of this control packet effort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I am currently working on a PR based on Xilinx/mlir-aie#1705, where I will also remove that hack

Comment on lines +642 to +644
deviceModel.isShimNOCorPLTile(srcTileLoc.col, srcTileLoc.row) &&
(srcBundle == StrmSwPortType::DMA ||
srcBundle == StrmSwPortType::NOC)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment here to explain in which cases this special connectivity is is needed in which not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Yu-Zhewen Yu-Zhewen merged commit 0ee8453 into main Jan 6, 2025
7 checks passed
@Yu-Zhewen Yu-Zhewen deleted the zhewen_router_shim branch January 6, 2025 21:49
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