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

Add logical objFifo placeholder op for connection reuse #709

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

jtuyls
Copy link
Collaborator

@jtuyls jtuyls commented Aug 27, 2024

Adds the amdaie.logicalobjectfifo.placeholder operation that represents a logical objectFifo to be filled in later. This enables reuse of connections/circular DMAs/physical AIE channels for different data packets, which helps with (fused) operations with more than 2 inputs. This is especially useful for reading from/writing to DDR.

Before this PR, the circular DMA connections would be always be tied to a HAL buffer on DDR/L3 and the control code NPU instruction could only change the addressing and not the input buffer:

%0 = hal.interface.binding.subspan layout(#pipeline_layout) set(0) 
  binding(0) alignment(64) offset(%c0) flags(ReadOnly) : memref<1024xi32>
%obj0 = amdaie.logicalobjectfifo.from_memref %0, {%tile_0_0} 
  : memref<1024xi32> -> !amdaie.logicalobjectfifo<memref<1024xi32>>
%1 = memref.alloc() : memref<1024xi32, 1 : i32> 
%obj1 = amdaie.logicalobjectfifo.from_memref %1, {%tile_0_1} 
  : memref<1024xi32, 1 : i32> -> !amdaie.logicalobjectfifo<memref<1024xi32, 1 : i32>>
%connection = amdaie.circular_dma_cpy_nd(%obj1[] [] [], %obj0[] [] []) 
  : (!amdaie.logicalobjectfifo<memref<1024xi32, 1 : i32>>, !amdaie.logicalobjectfifo<memref<1024xi32>>)
amdaie.controlcode {
      %npu_dma = amdaie.npu.dma_cpy_nd %connection([] [] [], [%c0, %c32] [%c32, %c32] [%c32, %c1])
      amdaie.end
    }

By introducing placeholders, the NPU dma operation can specify the actual logical objFifo to be used:

%0 = hal.interface.binding.subspan layout(#pipeline_layout) set(0) 
  binding(0) alignment(64) offset(%c0) flags(ReadOnly) : memref<1024xi32>
%1 = memref.alloc() : <1024xi32, 1 : i32>
%obj1 = amdaie.logicalobjectfifo.from_memref %1, {%tile_0_1}
  : memref<1024xi32, 1> -> !amdaie.logicalobjectfifo<memref<1024xi32, 1>>
%ph = amdaie.logicalobjectfifo.placeholder{} 
  : !amdaie.logicalobjectfifo<memref<2048xi32>>
%connection = amdaie.circular_dma_cpy_nd(%obj1[] [] [], %ph[] [] [])
  : (!amdaie.logicalobjectfifo<memref<1024xi32, 1>>, !amdaie.logicalobjectfifo<memref<1024xi32>>)
amdaie.controlcode {
  %obj0 = amdaie.logicalobjectfifo.from_memref %0, {%tile_0_0}
     : memref<1024xi32> -> !amdaie.logicalobjectfifo<memref<1024xi32>>
   %npu_dma = amdaie.npu.dma_cpy_nd %connection([] [] [],  %obj0[%c0, %c32] [%c32, %c32] [%c32, %c1]) 
     : source_type = !amdaie.logicalobjectfifo<memref<1024xi32>>
   amdaie.end
}

Copy link
Contributor

@Abhishek-Varma Abhishek-Varma left a comment

Choose a reason for hiding this comment

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

Great! A few small comments from my end. Not blocking this.

@jtuyls jtuyls force-pushed the logical-objectfifo-placeholder branch from 4840e39 to e5115da Compare August 27, 2024 11:29
@jtuyls jtuyls merged commit f8f31a8 into nod-ai:main Aug 27, 2024
6 checks passed
@jtuyls jtuyls deleted the logical-objectfifo-placeholder branch August 27, 2024 12:04
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