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

[LowerToAIE] Add support for DMA chains #1000

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

jtuyls
Copy link
Collaborator

@jtuyls jtuyls commented Dec 23, 2024

Adds support for lowering amdaie.npu.circular_dma_cpy_nd to a chain of aie.dma_bd operations. This is needed becaused low-level DMA BD configurations currently don't support a zero stride.

For example:

amdaie.npu.circular_dma_cpy_nd %some_connection([] [] [], [0, 0, 0] [2, 32, 32] [0, 64, 1])

contains an outer dimension with zero stride, which describes a repetition, and if this is not the common repetition count of all connections operating on a logical objectFifo, this is lowered to a chain of dma_bd operations to implement the zero stride:

^bb3:  // 2 preds: ^bb2, ^bb4
  aie.use_lock(%lock_0_1_0, AcquireGreaterEqual, 1)
  aie.dma_bd(%buffer_0_1 : memref<4096xi32, 1 : i32>) {dimensions = #aie<bd_dim_layout_array[<size = 32, stride = 64>, <size = 32, stride = 1>]>, len = 1024 : i32}
  aie.next_bd ^bb4
^bb4:  // pred: ^bb3
  aie.dma_bd(%buffer_0_1 : memref<4096xi32, 1 : i32>) {dimensions = #aie<bd_dim_layout_array[<size = 32, stride = 64>, <size = 32, stride = 1>]>, len = 1024 : i32}
  aie.use_lock(%lock_0_1, Release, 1)
  aie.next_bd ^bb3

Note how the first block contains a lock acquire operation, but no lock release operation as it needs to hand off to the second block before releasing a lock to create the DMA chain.

Copy link
Contributor

@Yu-Zhewen Yu-Zhewen 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 nit

Co-authored-by: Zhewen Yu <[email protected]>
@jtuyls jtuyls merged commit 6fae427 into nod-ai:main Dec 24, 2024
7 checks passed
@jtuyls jtuyls deleted the lower-to-aie-repetition-count branch December 24, 2024 22:14
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