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

[CtrlPkt] Generate connection operations in the overlay #1063

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

Yu-Zhewen
Copy link
Contributor

Instead of generating flow operations, we now directly insert connection operations into the overlay. The motivation behind this change is that these connection operations will be useful for generating control packet DMAs in subsequent steps.

@@ -32,11 +32,6 @@ void AMDAIEDialect::initializeAMDAIETypes() {
LogicalResult LogicalObjectFifoType::verify(
llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
mlir::MemRefType elementType, unsigned depth) {
if (llvm::any_of(elementType.getShape(), [](auto dimSize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The constraint has been removed because the control packet may require a dynamic shape, depending on the reconfiguration content. Additionally, if a device is reconfigured multiple times, the size of the control packet may vary with each reconfiguration.

reference: Xilinx/mlir-aie#1776

Comment on lines -890 to -891
passManager.addPass(createCSEPass());
passManager.addPass(createCanonicalizerPass());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a specific reason for this removal?

Copy link
Contributor Author

@Yu-Zhewen Yu-Zhewen Jan 28, 2025

Choose a reason for hiding this comment

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

They were initially introduced in #1012 only to tidy up the generated overlay. However, with this PR, both the generated connection and logicalobjectfifo.placeholder operations (which are marked as pure) are required for the later DMA generation. Also, I don’t think the CSE and Canonicalize here affect things like control code size anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, with this PR, both the generated connection and logicalobjectfifo.placeholder operations (which are marked as pure) are required for the later DMA generation.

Right, but the placeholders shouldn't be removed because they are used by the connections? Just making sure, if you keep the cse pass, it would still work, or would it break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in this case, the placeholders are kept but the connections are still eliminated since they don't have a user yet.

Copy link
Contributor Author

@Yu-Zhewen Yu-Zhewen Jan 28, 2025

Choose a reason for hiding this comment

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

Without canonicalize and cse, the generated code looks like this

%channel = amdaie.channel(%tile_0_0, 0, port_type = DMA, direction = MM2S)
%channel_0 = amdaie.channel(%tile_0_0, 0, port_type = CTRL, direction = S2MM)
%0 = amdaie.logicalobjectfifo.placeholder{%tile_0_0} : !amdaie.logicalobjectfifo<memref<?xi32>>
%1 = amdaie.logicalobjectfifo.placeholder{%tile_0_0} : !amdaie.logicalobjectfifo<memref<?xi32>>
%2 = amdaie.connection(%1 {%channel_0}, %0 {%channel}) {connection_type = #amdaie<connection_type Packet>} : (!amdaie.logicalobjectfifo<memref<?xi32>>, !amdaie.logicalobjectfifo<memref<?xi32>>)

%channel_1 = amdaie.channel(%tile_0_0, 1, port_type = DMA, direction = MM2S)
%channel_2 = amdaie.channel(%tile_0_1, 0, port_type = CTRL, direction = S2MM)
%3 = amdaie.logicalobjectfifo.placeholder{%tile_0_0} : !amdaie.logicalobjectfifo<memref<?xi32>>
%4 = amdaie.logicalobjectfifo.placeholder{%tile_0_1} : !amdaie.logicalobjectfifo<memref<?xi32>>
%5 = amdaie.connection(%4 {%channel_2}, %3 {%channel_1}) {connection_type = #amdaie<connection_type Packet>} : (!amdaie.logicalobjectfifo<memref<?xi32>>, !amdaie.logicalobjectfifo<memref<?xi32>>)

      .......

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, we will have to fix that at some point to make it stable, but that needs some further thought with the connection ops being pure, so not needed in this PR for me.

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

@Yu-Zhewen Yu-Zhewen merged commit 7a059cd into main Jan 28, 2025
7 checks passed
@Yu-Zhewen Yu-Zhewen deleted the zhewen_ctrl_overlay branch January 28, 2025 19:58
Yu-Zhewen added a commit that referenced this pull request Feb 16, 2025
… ops from Dead-Code Elimination (#1111)

Following the discussion in #1063, `connection` ops generated for the
control overlay do not initially have DMA users, as these are only added
later when the content of control packets is determined. However, since
`connection` ops are marked as pure in the IR, they can be wrongly
eliminated by CSE and Canonicalization if they have no users at that
stage.
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