Skip to content

Commit 4020878

Browse files
authored
Merge branch 'main' into fix-bootgen-pie-explicit-flags
2 parents 5ce8ff1 + 373ec1e commit 4020878

3 files changed

Lines changed: 66 additions & 3 deletions

File tree

python/iron/dataflow/tile_dma.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from ...dialects.aie import (
3232
EndOp, # pyright: ignore[reportAttributeAccessIssue]
3333
dma_bd, # pyright: ignore[reportAttributeAccessIssue]
34+
dma_bd_packet, # pyright: ignore[reportAttributeAccessIssue]
3435
dma_start,
3536
mem,
3637
memtile_dma,
@@ -250,10 +251,15 @@ def _body(block):
250251
bd_kwargs["offset"] = bd.offset
251252
if bd.length is not None:
252253
bd_kwargs["len"] = bd.length
253-
if bd.packet is not None:
254-
bd_kwargs["packet"] = bd.packet
255254
if bd.dimensions is not None:
256255
bd_kwargs["dimensions"] = bd.dimensions
256+
# A packet header must be a distinct aie.dma_bd_packet op
257+
# placed BEFORE the aie.dma_bd: the CDO/xclbin backends
258+
# (AIERT / AIETargetXAIEV2) read the header only from that
259+
# op, not from a `packet` attribute on the dma_bd.
260+
if bd.packet is not None:
261+
pkt_type, pkt_id = bd.packet
262+
dma_bd_packet(pkt_type, pkt_id)
257263
dma_bd(bd.buffer.op, **bd_kwargs)
258264
for rel in bd.releases:
259265
rel.emit()

test/python/bd_packet.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (C) 2026 Advanced Micro Devices, Inc.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# RUN: %python %s | FileCheck %s
5+
6+
"""Test that Bd.packet emits a distinct aie.dma_bd_packet op BEFORE the
7+
aie.dma_bd, rather than a `packet` attribute on the dma_bd. The CDO/xclbin
8+
backends (AIERT, AIETargetXAIEV2) read the packet header only from the
9+
dma_bd_packet op, so the header must be emitted as that op to reach hardware."""
10+
11+
import numpy as np
12+
13+
from aie.iron import Bd, Buffer, DmaChannel, Program, Runtime, TileDma
14+
from aie.iron.device import NPU2Col1, Tile
15+
from aie.dialects._aie_enum_gen import AIETileType, DMAChannelDir
16+
17+
18+
def emit_packet_bd():
19+
n = 256
20+
vector_ty = np.ndarray[(n,), np.dtype[np.int32]]
21+
22+
compute_tile = Tile(col=0, row=2, tile_type=AIETileType.CoreTile)
23+
buf = Buffer(tile=compute_tile, type=vector_ty, name="pkt_buf")
24+
25+
tile_dma = TileDma(
26+
tile=compute_tile,
27+
channels=[
28+
DmaChannel(
29+
direction=DMAChannelDir.MM2S,
30+
channel=0,
31+
bds=[
32+
Bd(
33+
buffer=buf,
34+
offset=0,
35+
length=n,
36+
packet=(0, 5),
37+
next="self",
38+
),
39+
],
40+
),
41+
],
42+
)
43+
44+
rt = Runtime()
45+
rt.add_tile_dma(tile_dma)
46+
with rt.sequence(vector_ty) as _:
47+
pass
48+
49+
return Program(NPU2Col1(), rt).resolve_program()
50+
51+
52+
# The packet header is a distinct op emitted immediately before the dma_bd,
53+
# and the dma_bd itself carries no packet attribute.
54+
# CHECK: aie.dma_bd_packet(0, 5)
55+
# CHECK-NEXT: aie.dma_bd({{.*}} : memref<256xi32>, 0, 256)
56+
# CHECK-NOT: aie.dma_bd({{.*}}packet
57+
print(emit_packet_bd())

third_party/aie_api

Submodule aie_api updated 280 files

0 commit comments

Comments
 (0)