已合并
fix(a2a3): give the V2C ring its own base in a bidirectional TPipe #1438
puff_the_magic_dragon创建于 15 天前
fix(a2a3): give the V2C ring its own base in a bidirectional TPipe #1438
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 puff_the_magic_dragon 的贡献)15 天前 创建了 pull request,commit d3c36d33
Ppuff_the_magic_dragon
15 天前 关联了issue:[Bug-Report|缺陷反馈]: A2A3 DIR_BOTH TPipe: the C2V and V2C rings alias the same GM slots
15 天前 关联了issue:[Bug-Report|缺陷反馈]: A2A3 DIR_BOTH TPipe: the C2V and V2C rings alias the same GM slots
atomgit-bot
15 天前 评论:
15 天前 评论:
变更摘要
此 PR 修复了 A2A3 架构下 DIR_BOTH(双向)TPipe 中 C2V 和 V2C 两个环因共享同一 GM 缓冲区基址而互相覆盖数据的 bug。通过在 TPipe 构造函数中为 V2C 环设置 entryOffset(值为 SlotNum * SlotSize),使 C2V 环从偏移 0 开始、V2C 环从 SLOT_NUM * SLOT_SIZE 开始,两者不再重叠。同时更新了双向 ST 测试用例的缓冲区大小分配,使其容纳两个完整的环。
主要改动
TPipe构造函数新增 V2C 偏移设置:在include/pto/npu/a2a3/TPush.hpp的TPipe构造函数中,针对is_both模式,通过setEntryOffset为 V2C 环设置基址偏移量SlotNum * SlotSize,其中 Cube 端设置 Consumer 偏移、Vector 端设置 Producer 偏移,确保双向传输的两环在 GM 中物理隔离。- 双向 ST 测试缓冲区扩容:
tests/npu/a2a3/src/st/testcase/tpushpop_dir_both/main.cpp中fifoFileSize从2 * M * N * sizeof(T)改为4 * M * N * sizeof(T)(即2 * SLOT_NUM * SLOT_SIZE),以匹配现在两个环的实际内存需求,避免 V2C 环写入越界。


atomgit-bot
15 天前 评论:
15 天前 评论:
15 天前 添加了label:cann-cla/no
此处折叠了53条消息 查看更多
10 天前 添加了label:ci-pipeline-passed
csjlchen
10 天前 评论:
10 天前 评论:
/lgtm


代码行星
10 天前 评论:
10 天前 评论:
/approve


10 天前 添加了label:lgtmapproved
10 天前 合入了pull request
描述
On A2A3 both directions of a
DIR_BOTHTPipeaddressed the shared GM buffer as(tileIndex % SLOT_NUM) * SLOT_SIZE + entryOffset, andentryOffsetwas never set for thatdirection mode — so the C2V and V2C rings occupied the same slots and silently overwrote
each other's tiles once more than one tile was in flight. Wrong results, no fault, no hang.
The
entryOffsetmechanism already exists and is wired through all thirteen addressing sites(
Producer::setEntryOffsetatTPush.hpp:96,Consumer::setEntryOffsetat:316); nothingcalled it, because the
TPipeconstructor at:470had an empty body.This sets the V2C ring base there for
is_both— the consumer under__DAV_CUBE__, theproducer under
__DAV_VEC__— giving the layout the TPUSH/TPOP design note specifies: C2V atoffset 0, V2C at
SLOT_NUM * SLOT_SIZE, total2 * SLOT_NUM * SLOT_SIZE. Both terms arecompile-time constants, so the generated address arithmetic is unchanged in cost.
The bidirectional ST case allocated
2 * M * N * sizeof(T)= exactly one ring(
tpushpop_dir_both/main.cpp:47); it is sized for two here, as the frontend now must.Ordering. This needs a frontend that allocates
2 * SLOT_NUM * SLOT_SIZEfor abidirectional pipe. pypto currently sizes it as one ring, and that half must ship first, or
this fix writes the V2C ring past the end of the allocation. (On the GitHub mirror the
frontend half is
hw-native-sys/pypto#2269.)关联的Issue
Fixes #516
Mirrored from GitHub, where this is hw-native-sys/pto-isa#227 against
#226.
测试
Atlas A2/A3, fp32, at the stock ring depth of 4, no DSL overrides, with both halves
applied:
DIR_BOTHrepro (issue #516), C=16, N ∈ {2,4,5,6,7,8,16} × 3 dispatchesThe
tpushpop_dir_bothST case passes both before and after: it is a single round trip, sothe data dependency serialises the overwrite behind the read. Exposing the defect needs two
tiles in flight in opposite directions, which needs a loop — hence the repro in the issue.
文档更新
None. The layout this implements is the one already described in the TPUSH/TPOP design note;
no document changes.
类型标签