Skip to content

CI: bump pinned pto-isa for PTOAS v0.55 - #1644

Merged
ChaoZheng109 merged 12 commits into
hw-native-sys:mainfrom
Little-oil:support/bump-pinned-pto-isa-v0-55
Aug 11, 2026
Merged

ChaoZheng109 merged 12 commits into
hw-native-sys:mainfrom
Little-oil:support/bump-pinned-pto-isa-v0-55

Conversation

@Little-oil

@Little-oil Little-oil commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Advance pto_isa.pin to 0cefc9a5, based on current GitCode master and providing the PTOAS v0.55 soft SYNCALL interface.
  • Keep SDMA workspace sizing constants in a host-safe header and preserve explicitly selected CPU simulator roles.
  • Qualify the dispatch DCCI cache-line arguments for the updated PTO-ISA interface.
  • Remove duplicate TADDDEQRELU.* documentation paths that collide with the manifest-managed TAddDeqRelu.* paths on case-insensitive filesystems.
  • Fetch the exact pinned SHA and fall back from the GitHub mirror to the canonical GitCode repository while a pin is awaiting upstream merge.

PTO-ISA source branch: https://gitcode.com/Youhezhen/pto-isa/tree/fix/sdma-host-header

PTO-ISA upstream MR: https://gitcode.com/cann/pto-isa/merge_requests/1424

Testing

  • PTO-ISA full CPU simulator suite with GCC 15 — passed.
  • PTO-ISA GitCode pipeline on the host/CPU fixes — 17/17 checks passed; the updated case-safe head is being revalidated.
  • Simpler editable install, including host and simulator runtime builds — passed.
  • Cold managed checkout: GitHub mirror miss → canonical GitCode fallback → exact pinned, clean HEAD — passed.
  • Python unit suite: 1029 passed, 15 skipped.
  • PTO-ISA resolver unit tests: 23 passed.
  • ep_dispatch_combine on a2a3sim and a5sim — passed.
  • Profiling smoke matrix: 2 architectures × 6 macro combinations — passed.
  • Pre-commit on all changed Simpler files — passed.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a9768ad4-6356-4b18-9a3a-f2b078a15827

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The pull request updates the pinned PTO-ISA revision in pto_isa.pin.

Changes

PTO-ISA revision

Layer / File(s) Summary
Update ISA revision pin
pto_isa.pin
The pinned ISA commit changes to f24f7b736b689cc107b9eb2d362be6a7718fcc99.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Poem

A rabbit checks the pinned line,
One ISA hash now shines.
The build hops to its new place,
With commit speed and steady grace.
Carrots celebrate the trace! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the pinned pto-isa update for PTOAS v0.55.
Description check ✅ Passed The description directly explains the pto_isa pin update, compatibility objectives, implementation details, and validation results.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Little-oil Little-oil closed this Aug 3, 2026
@Little-oil Little-oil reopened this Aug 3, 2026
@Little-oil Little-oil changed the title CI: bump pinned pto-isa to f24f7b73 CI: bump pinned pto-isa for PTOAS v0.55 Aug 4, 2026
drizzlezyk pushed a commit to hicann/pto-isa that referenced this pull request Aug 6, 2026
Co-authored-by: Youhezhen<youhezhen@huawei.com>



# message auto-generated for no-merge-commit merge:
!1424 merge fix/sdma-host-header into master

fix: keep SDMA host headers CPU-safe

Created-by: Youhezhen
Commit-by: Youhezhen
Merged-by: cann-robot
Description: ## 背景

本 MR 为 [hw-native-sys/simpler#1644](hw-native-sys/simpler#1644) 提供可固定依赖的 PTO-ISA revision,解决以下问题:

1. host 侧 SDMA workspace manager 间接包含 device-only 类型,导致普通 C++ host 编译失败;
2. CPU simulator 会无条件补齐 CUBE/VECTOR 两种角色,使显式的单角色编译同时启用两套实现并产生重复定义;
3. CPU stub 缺少设备侧已有的 `dcci_dst_t` 类型,三参数 `dcci` 调用无法在 CPU simulator 编译;
4. 仓库中存在仅大小写不同的 `TADDDEQRELU.*` / `TAddDeqRelu.*` 路径,macOS 的大小写不敏感文件系统会让 checkout 持续处于 dirty 状态。

## 修改说明

### 1. 将 SDMA workspace 常量拆到 host-safe header

涉及文件:

- `include/pto/comm/async_common/sdma_constants.hpp`
- `include/pto/comm/async_common/async_types.hpp`
- `include/pto/comm/async/sdma/sdma_workspace_manager.hpp`

**为什么改:** `sdma_workspace_manager.hpp` 是 host 侧代码,实际只需要 workspace 大小常量;原先包含 `async_types.hpp` 会同时引入 `__gm__`、`__ubuf__` 等 device-only 类型和定义,扩大 host 编译依赖并触发编译错误。

**怎么改:** 新增只依赖 `<cstdint>` 的轻量 header,将四个 workspace layout 常量移入其中;device 侧的 `async_types.hpp` 继续包含该 header,host manager 则直接包含它。

```diff
-#include "pto/comm/async_common/async_types.hpp"
+#include "pto/comm/async_common/sdma_constants.hpp"
```

```cpp
// sdma_constants.hpp:host/device 均可安全包含
constexpr uint32_t kSdmaContextWorkspaceBytes = 16U * 1024U;
constexpr uint32_t kSdmaFlagPayloadBytesPerGroup = 512U;
constexpr uint32_t kSdmaMaxChannelGroups = 48U;
constexpr uint32_t kSdmaWorkspaceBytes =
    kSdmaContextWorkspaceBytes + kSdmaMaxChannelGroups * kSdmaFlagPayloadBytesPerGroup;
```

这样不改变常量的 namespace、名称或计算方式,只切断 host header 对 device 类型定义的依赖。

### 2. 保留 CPU simulator 显式选择的执行角色

涉及文件:`include/pto/common/arch_macro.hpp`

**为什么改:** 原逻辑在定义 `__CPU_SIM` 后,会分别补齐缺失的 `__DAV_CUBE__` 和 `__DAV_VEC__`。因此调用方即使显式指定 CUBE-only 或 VECTOR-only,另一个角色仍会被自动打开,同一翻译单元可能同时编译两套 role-specific 实现并产生重复定义。

**怎么改:** 仅当两种角色都未指定时,才保留 PTO standalone CPU tests 所需的双角色默认值;只要调用方已经指定任意一种角色,就原样保留。

```diff
-#if defined(__CPU_SIM)
-#ifndef __DAV_CUBE__
+#if defined(__CPU_SIM) && !defined(__DAV_CUBE__) && !defined(__DAV_VEC__)
 #define __DAV_CUBE__
-#endif
-#ifndef __DAV_VEC__
 #define __DAV_VEC__
 #endif
-#endif
```

结果是:

- 未指定角色:仍同时提供 CUBE/VECTOR stub,保持现有 PTO CPU tests 行为;
- 显式指定 CUBE:只编译 CUBE;
- 显式指定 VECTOR:只编译 VECTOR。

### 3. 补齐 CPU simulator 的 `dcci_dst_t`

涉及文件:`include/pto/common/cpu_stub.hpp`

**为什么改:** device 代码可使用 `dcci_dst_t::CACHELINE_OUT` 作为三参数 `dcci` 的 destination mode,但 CPU stub 只有 `cache_line_t` 和三参数函数签名,没有对应类型,导致同一份 kernel 在 CPU simulator 编译失败。

**怎么改:** 在 CPU stub 中增加与 device API 同名的最小占位类型;其值保持为 `0`,符合 simulator 中 cache 操作为 no-op 的既有语义。

```cpp
struct dcci_dst_t {
    static constexpr int CACHELINE_OUT = 0;
};
```

这只补齐编译期接口,不改变 CPU simulator 的运行时 cache 行为。

### 4. 删除 macOS 上发生大小写碰撞的重复文档路径

涉及路径:

```text
删除:docs/figures/isa/TADDDEQRELU.svg
删除:docs/isa/TADDDEQRELU.md
删除:docs/isa/TADDDEQRELU_zh.md
保留:docs/figures/isa/TAddDeqRelu.svg
保留:docs/isa/TAddDeqRelu.md
保留:docs/isa/TAddDeqRelu_zh.md
```

**为什么改:** 两组文件在 Linux 上可共存,但在默认大小写不敏感的 macOS 文件系统上会映射到同一路径。checkout 后 Git 会持续报告伪修改;并发准备 PTO-ISA checkout 时还可能反复重建目录,最终表现为随机缺少 header。

**怎么改:** 保留与 `docs/isa/manifest.yaml` 中 `instruction: TAddDeqRelu` 一致、且被当前文档引用的 CamelCase 路径,删除旧的全大写重复路径。指令 C++ 名称 `TADDDEQRELU` 不变,仅规范文档文件名。

## 兼容性

- SDMA workspace 常量的名称、值和 namespace 均未改变;
- CPU simulator 未显式选择角色时的默认行为未改变;
- NPU/device 实现和 `TADDDEQRELU` 指令接口未改变;
- 文档内容仍由 canonical `TAddDeqRelu.*` 文件保留。

## 验证

- GitCode pipeline:17/17 通过;
- PTO-ISA full CPU simulator suite(GCC 15):通过;
- Simpler `ep_dispatch_combine`:a2a3sim、a5sim 通过;
- Simpler profiling flags smoke:2 个架构 × 6 组配置通过;
- case-fold 路径冲突扫描:0 个冲突;
- pre-commit:除本机 `/tmp` OAT 安装锁权限问题外其余 hooks 通过,OAT 及全部检查已由远端 pipeline 复验通过。


See merge request: cann/pto-isa!1424
github-actions Bot pushed a commit to Crystal-wzy/pto-isa that referenced this pull request Aug 6, 2026
Co-authored-by: Youhezhen<youhezhen@huawei.com>



# message auto-generated for no-merge-commit merge:
!1424 merge fix/sdma-host-header into master

fix: keep SDMA host headers CPU-safe

Created-by: Youhezhen
Commit-by: Youhezhen
Merged-by: cann-robot
Description: ## 背景

本 MR 为 [hw-native-sys/simpler#1644](hw-native-sys/simpler#1644) 提供可固定依赖的 PTO-ISA revision,解决以下问题:

1. host 侧 SDMA workspace manager 间接包含 device-only 类型,导致普通 C++ host 编译失败;
2. CPU simulator 会无条件补齐 CUBE/VECTOR 两种角色,使显式的单角色编译同时启用两套实现并产生重复定义;
3. CPU stub 缺少设备侧已有的 `dcci_dst_t` 类型,三参数 `dcci` 调用无法在 CPU simulator 编译;
4. 仓库中存在仅大小写不同的 `TADDDEQRELU.*` / `TAddDeqRelu.*` 路径,macOS 的大小写不敏感文件系统会让 checkout 持续处于 dirty 状态。

## 修改说明

### 1. 将 SDMA workspace 常量拆到 host-safe header

涉及文件:

- `include/pto/comm/async_common/sdma_constants.hpp`
- `include/pto/comm/async_common/async_types.hpp`
- `include/pto/comm/async/sdma/sdma_workspace_manager.hpp`

**为什么改:** `sdma_workspace_manager.hpp` 是 host 侧代码,实际只需要 workspace 大小常量;原先包含 `async_types.hpp` 会同时引入 `__gm__`、`__ubuf__` 等 device-only 类型和定义,扩大 host 编译依赖并触发编译错误。

**怎么改:** 新增只依赖 `<cstdint>` 的轻量 header,将四个 workspace layout 常量移入其中;device 侧的 `async_types.hpp` 继续包含该 header,host manager 则直接包含它。

```diff
-#include "pto/comm/async_common/async_types.hpp"
+#include "pto/comm/async_common/sdma_constants.hpp"
```

```cpp
// sdma_constants.hpp:host/device 均可安全包含
constexpr uint32_t kSdmaContextWorkspaceBytes = 16U * 1024U;
constexpr uint32_t kSdmaFlagPayloadBytesPerGroup = 512U;
constexpr uint32_t kSdmaMaxChannelGroups = 48U;
constexpr uint32_t kSdmaWorkspaceBytes =
    kSdmaContextWorkspaceBytes + kSdmaMaxChannelGroups * kSdmaFlagPayloadBytesPerGroup;
```

这样不改变常量的 namespace、名称或计算方式,只切断 host header 对 device 类型定义的依赖。

### 2. 保留 CPU simulator 显式选择的执行角色

涉及文件:`include/pto/common/arch_macro.hpp`

**为什么改:** 原逻辑在定义 `__CPU_SIM` 后,会分别补齐缺失的 `__DAV_CUBE__` 和 `__DAV_VEC__`。因此调用方即使显式指定 CUBE-only 或 VECTOR-only,另一个角色仍会被自动打开,同一翻译单元可能同时编译两套 role-specific 实现并产生重复定义。

**怎么改:** 仅当两种角色都未指定时,才保留 PTO standalone CPU tests 所需的双角色默认值;只要调用方已经指定任意一种角色,就原样保留。

```diff
-#if defined(__CPU_SIM)
-#ifndef __DAV_CUBE__
+#if defined(__CPU_SIM) && !defined(__DAV_CUBE__) && !defined(__DAV_VEC__)
 #define __DAV_CUBE__
-#endif
-#ifndef __DAV_VEC__
 #define __DAV_VEC__
 #endif
-#endif
```

结果是:

- 未指定角色:仍同时提供 CUBE/VECTOR stub,保持现有 PTO CPU tests 行为;
- 显式指定 CUBE:只编译 CUBE;
- 显式指定 VECTOR:只编译 VECTOR。

### 3. 补齐 CPU simulator 的 `dcci_dst_t`

涉及文件:`include/pto/common/cpu_stub.hpp`

**为什么改:** device 代码可使用 `dcci_dst_t::CACHELINE_OUT` 作为三参数 `dcci` 的 destination mode,但 CPU stub 只有 `cache_line_t` 和三参数函数签名,没有对应类型,导致同一份 kernel 在 CPU simulator 编译失败。

**怎么改:** 在 CPU stub 中增加与 device API 同名的最小占位类型;其值保持为 `0`,符合 simulator 中 cache 操作为 no-op 的既有语义。

```cpp
struct dcci_dst_t {
    static constexpr int CACHELINE_OUT = 0;
};
```

这只补齐编译期接口,不改变 CPU simulator 的运行时 cache 行为。

### 4. 删除 macOS 上发生大小写碰撞的重复文档路径

涉及路径:

```text
删除:docs/figures/isa/TADDDEQRELU.svg
删除:docs/isa/TADDDEQRELU.md
删除:docs/isa/TADDDEQRELU_zh.md
保留:docs/figures/isa/TAddDeqRelu.svg
保留:docs/isa/TAddDeqRelu.md
保留:docs/isa/TAddDeqRelu_zh.md
```

**为什么改:** 两组文件在 Linux 上可共存,但在默认大小写不敏感的 macOS 文件系统上会映射到同一路径。checkout 后 Git 会持续报告伪修改;并发准备 PTO-ISA checkout 时还可能反复重建目录,最终表现为随机缺少 header。

**怎么改:** 保留与 `docs/isa/manifest.yaml` 中 `instruction: TAddDeqRelu` 一致、且被当前文档引用的 CamelCase 路径,删除旧的全大写重复路径。指令 C++ 名称 `TADDDEQRELU` 不变,仅规范文档文件名。

## 兼容性

- SDMA workspace 常量的名称、值和 namespace 均未改变;
- CPU simulator 未显式选择角色时的默认行为未改变;
- NPU/device 实现和 `TADDDEQRELU` 指令接口未改变;
- 文档内容仍由 canonical `TAddDeqRelu.*` 文件保留。

## 验证

- GitCode pipeline:17/17 通过;
- PTO-ISA full CPU simulator suite(GCC 15):通过;
- Simpler `ep_dispatch_combine`:a2a3sim、a5sim 通过;
- Simpler profiling flags smoke:2 个架构 × 6 组配置通过;
- case-fold 路径冲突扫描:0 个冲突;
- pre-commit:除本机 `/tmp` OAT 安装锁权限问题外其余 hooks 通过,OAT 及全部检查已由远端 pipeline 复验通过。


See merge request: cann/pto-isa!1424
github-actions Bot pushed a commit to Crystal-wzy/pto-isa that referenced this pull request Aug 6, 2026
Co-authored-by: Youhezhen<youhezhen@huawei.com>



# message auto-generated for no-merge-commit merge:
!1424 merge fix/sdma-host-header into master

fix: keep SDMA host headers CPU-safe

Created-by: Youhezhen
Commit-by: Youhezhen
Merged-by: cann-robot
Description: ## 背景

本 MR 为 [hw-native-sys/simpler#1644](hw-native-sys/simpler#1644) 提供可固定依赖的 PTO-ISA revision,解决以下问题:

1. host 侧 SDMA workspace manager 间接包含 device-only 类型,导致普通 C++ host 编译失败;
2. CPU simulator 会无条件补齐 CUBE/VECTOR 两种角色,使显式的单角色编译同时启用两套实现并产生重复定义;
3. CPU stub 缺少设备侧已有的 `dcci_dst_t` 类型,三参数 `dcci` 调用无法在 CPU simulator 编译;
4. 仓库中存在仅大小写不同的 `TADDDEQRELU.*` / `TAddDeqRelu.*` 路径,macOS 的大小写不敏感文件系统会让 checkout 持续处于 dirty 状态。

## 修改说明

### 1. 将 SDMA workspace 常量拆到 host-safe header

涉及文件:

- `include/pto/comm/async_common/sdma_constants.hpp`
- `include/pto/comm/async_common/async_types.hpp`
- `include/pto/comm/async/sdma/sdma_workspace_manager.hpp`

**为什么改:** `sdma_workspace_manager.hpp` 是 host 侧代码,实际只需要 workspace 大小常量;原先包含 `async_types.hpp` 会同时引入 `__gm__`、`__ubuf__` 等 device-only 类型和定义,扩大 host 编译依赖并触发编译错误。

**怎么改:** 新增只依赖 `<cstdint>` 的轻量 header,将四个 workspace layout 常量移入其中;device 侧的 `async_types.hpp` 继续包含该 header,host manager 则直接包含它。

```diff
-#include "pto/comm/async_common/async_types.hpp"
+#include "pto/comm/async_common/sdma_constants.hpp"
```

```cpp
// sdma_constants.hpp:host/device 均可安全包含
constexpr uint32_t kSdmaContextWorkspaceBytes = 16U * 1024U;
constexpr uint32_t kSdmaFlagPayloadBytesPerGroup = 512U;
constexpr uint32_t kSdmaMaxChannelGroups = 48U;
constexpr uint32_t kSdmaWorkspaceBytes =
    kSdmaContextWorkspaceBytes + kSdmaMaxChannelGroups * kSdmaFlagPayloadBytesPerGroup;
```

这样不改变常量的 namespace、名称或计算方式,只切断 host header 对 device 类型定义的依赖。

### 2. 保留 CPU simulator 显式选择的执行角色

涉及文件:`include/pto/common/arch_macro.hpp`

**为什么改:** 原逻辑在定义 `__CPU_SIM` 后,会分别补齐缺失的 `__DAV_CUBE__` 和 `__DAV_VEC__`。因此调用方即使显式指定 CUBE-only 或 VECTOR-only,另一个角色仍会被自动打开,同一翻译单元可能同时编译两套 role-specific 实现并产生重复定义。

**怎么改:** 仅当两种角色都未指定时,才保留 PTO standalone CPU tests 所需的双角色默认值;只要调用方已经指定任意一种角色,就原样保留。

```diff
-#if defined(__CPU_SIM)
-#ifndef __DAV_CUBE__
+#if defined(__CPU_SIM) && !defined(__DAV_CUBE__) && !defined(__DAV_VEC__)
 #define __DAV_CUBE__
-#endif
-#ifndef __DAV_VEC__
 #define __DAV_VEC__
 #endif
-#endif
```

结果是:

- 未指定角色:仍同时提供 CUBE/VECTOR stub,保持现有 PTO CPU tests 行为;
- 显式指定 CUBE:只编译 CUBE;
- 显式指定 VECTOR:只编译 VECTOR。

### 3. 补齐 CPU simulator 的 `dcci_dst_t`

涉及文件:`include/pto/common/cpu_stub.hpp`

**为什么改:** device 代码可使用 `dcci_dst_t::CACHELINE_OUT` 作为三参数 `dcci` 的 destination mode,但 CPU stub 只有 `cache_line_t` 和三参数函数签名,没有对应类型,导致同一份 kernel 在 CPU simulator 编译失败。

**怎么改:** 在 CPU stub 中增加与 device API 同名的最小占位类型;其值保持为 `0`,符合 simulator 中 cache 操作为 no-op 的既有语义。

```cpp
struct dcci_dst_t {
    static constexpr int CACHELINE_OUT = 0;
};
```

这只补齐编译期接口,不改变 CPU simulator 的运行时 cache 行为。

### 4. 删除 macOS 上发生大小写碰撞的重复文档路径

涉及路径:

```text
删除:docs/figures/isa/TADDDEQRELU.svg
删除:docs/isa/TADDDEQRELU.md
删除:docs/isa/TADDDEQRELU_zh.md
保留:docs/figures/isa/TAddDeqRelu.svg
保留:docs/isa/TAddDeqRelu.md
保留:docs/isa/TAddDeqRelu_zh.md
```

**为什么改:** 两组文件在 Linux 上可共存,但在默认大小写不敏感的 macOS 文件系统上会映射到同一路径。checkout 后 Git 会持续报告伪修改;并发准备 PTO-ISA checkout 时还可能反复重建目录,最终表现为随机缺少 header。

**怎么改:** 保留与 `docs/isa/manifest.yaml` 中 `instruction: TAddDeqRelu` 一致、且被当前文档引用的 CamelCase 路径,删除旧的全大写重复路径。指令 C++ 名称 `TADDDEQRELU` 不变,仅规范文档文件名。

## 兼容性

- SDMA workspace 常量的名称、值和 namespace 均未改变;
- CPU simulator 未显式选择角色时的默认行为未改变;
- NPU/device 实现和 `TADDDEQRELU` 指令接口未改变;
- 文档内容仍由 canonical `TAddDeqRelu.*` 文件保留。

## 验证

- GitCode pipeline:17/17 通过;
- PTO-ISA full CPU simulator suite(GCC 15):通过;
- Simpler `ep_dispatch_combine`:a2a3sim、a5sim 通过;
- Simpler profiling flags smoke:2 个架构 × 6 组配置通过;
- case-fold 路径冲突扫描:0 个冲突;
- pre-commit:除本机 `/tmp` OAT 安装锁权限问题外其余 hooks 通过,OAT 及全部检查已由远端 pipeline 复验通过。


See merge request: cann/pto-isa!1424
github-actions Bot pushed a commit to Crystal-wzy/pto-isa that referenced this pull request Aug 6, 2026
Co-authored-by: Youhezhen<youhezhen@huawei.com>



# message auto-generated for no-merge-commit merge:
!1424 merge fix/sdma-host-header into master

fix: keep SDMA host headers CPU-safe

Created-by: Youhezhen
Commit-by: Youhezhen
Merged-by: cann-robot
Description: ## 背景

本 MR 为 [hw-native-sys/simpler#1644](hw-native-sys/simpler#1644) 提供可固定依赖的 PTO-ISA revision,解决以下问题:

1. host 侧 SDMA workspace manager 间接包含 device-only 类型,导致普通 C++ host 编译失败;
2. CPU simulator 会无条件补齐 CUBE/VECTOR 两种角色,使显式的单角色编译同时启用两套实现并产生重复定义;
3. CPU stub 缺少设备侧已有的 `dcci_dst_t` 类型,三参数 `dcci` 调用无法在 CPU simulator 编译;
4. 仓库中存在仅大小写不同的 `TADDDEQRELU.*` / `TAddDeqRelu.*` 路径,macOS 的大小写不敏感文件系统会让 checkout 持续处于 dirty 状态。

## 修改说明

### 1. 将 SDMA workspace 常量拆到 host-safe header

涉及文件:

- `include/pto/comm/async_common/sdma_constants.hpp`
- `include/pto/comm/async_common/async_types.hpp`
- `include/pto/comm/async/sdma/sdma_workspace_manager.hpp`

**为什么改:** `sdma_workspace_manager.hpp` 是 host 侧代码,实际只需要 workspace 大小常量;原先包含 `async_types.hpp` 会同时引入 `__gm__`、`__ubuf__` 等 device-only 类型和定义,扩大 host 编译依赖并触发编译错误。

**怎么改:** 新增只依赖 `<cstdint>` 的轻量 header,将四个 workspace layout 常量移入其中;device 侧的 `async_types.hpp` 继续包含该 header,host manager 则直接包含它。

```diff
-#include "pto/comm/async_common/async_types.hpp"
+#include "pto/comm/async_common/sdma_constants.hpp"
```

```cpp
// sdma_constants.hpp:host/device 均可安全包含
constexpr uint32_t kSdmaContextWorkspaceBytes = 16U * 1024U;
constexpr uint32_t kSdmaFlagPayloadBytesPerGroup = 512U;
constexpr uint32_t kSdmaMaxChannelGroups = 48U;
constexpr uint32_t kSdmaWorkspaceBytes =
    kSdmaContextWorkspaceBytes + kSdmaMaxChannelGroups * kSdmaFlagPayloadBytesPerGroup;
```

这样不改变常量的 namespace、名称或计算方式,只切断 host header 对 device 类型定义的依赖。

### 2. 保留 CPU simulator 显式选择的执行角色

涉及文件:`include/pto/common/arch_macro.hpp`

**为什么改:** 原逻辑在定义 `__CPU_SIM` 后,会分别补齐缺失的 `__DAV_CUBE__` 和 `__DAV_VEC__`。因此调用方即使显式指定 CUBE-only 或 VECTOR-only,另一个角色仍会被自动打开,同一翻译单元可能同时编译两套 role-specific 实现并产生重复定义。

**怎么改:** 仅当两种角色都未指定时,才保留 PTO standalone CPU tests 所需的双角色默认值;只要调用方已经指定任意一种角色,就原样保留。

```diff
-#if defined(__CPU_SIM)
-#ifndef __DAV_CUBE__
+#if defined(__CPU_SIM) && !defined(__DAV_CUBE__) && !defined(__DAV_VEC__)
 #define __DAV_CUBE__
-#endif
-#ifndef __DAV_VEC__
 #define __DAV_VEC__
 #endif
-#endif
```

结果是:

- 未指定角色:仍同时提供 CUBE/VECTOR stub,保持现有 PTO CPU tests 行为;
- 显式指定 CUBE:只编译 CUBE;
- 显式指定 VECTOR:只编译 VECTOR。

### 3. 补齐 CPU simulator 的 `dcci_dst_t`

涉及文件:`include/pto/common/cpu_stub.hpp`

**为什么改:** device 代码可使用 `dcci_dst_t::CACHELINE_OUT` 作为三参数 `dcci` 的 destination mode,但 CPU stub 只有 `cache_line_t` 和三参数函数签名,没有对应类型,导致同一份 kernel 在 CPU simulator 编译失败。

**怎么改:** 在 CPU stub 中增加与 device API 同名的最小占位类型;其值保持为 `0`,符合 simulator 中 cache 操作为 no-op 的既有语义。

```cpp
struct dcci_dst_t {
    static constexpr int CACHELINE_OUT = 0;
};
```

这只补齐编译期接口,不改变 CPU simulator 的运行时 cache 行为。

### 4. 删除 macOS 上发生大小写碰撞的重复文档路径

涉及路径:

```text
删除:docs/figures/isa/TADDDEQRELU.svg
删除:docs/isa/TADDDEQRELU.md
删除:docs/isa/TADDDEQRELU_zh.md
保留:docs/figures/isa/TAddDeqRelu.svg
保留:docs/isa/TAddDeqRelu.md
保留:docs/isa/TAddDeqRelu_zh.md
```

**为什么改:** 两组文件在 Linux 上可共存,但在默认大小写不敏感的 macOS 文件系统上会映射到同一路径。checkout 后 Git 会持续报告伪修改;并发准备 PTO-ISA checkout 时还可能反复重建目录,最终表现为随机缺少 header。

**怎么改:** 保留与 `docs/isa/manifest.yaml` 中 `instruction: TAddDeqRelu` 一致、且被当前文档引用的 CamelCase 路径,删除旧的全大写重复路径。指令 C++ 名称 `TADDDEQRELU` 不变,仅规范文档文件名。

## 兼容性

- SDMA workspace 常量的名称、值和 namespace 均未改变;
- CPU simulator 未显式选择角色时的默认行为未改变;
- NPU/device 实现和 `TADDDEQRELU` 指令接口未改变;
- 文档内容仍由 canonical `TAddDeqRelu.*` 文件保留。

## 验证

- GitCode pipeline:17/17 通过;
- PTO-ISA full CPU simulator suite(GCC 15):通过;
- Simpler `ep_dispatch_combine`:a2a3sim、a5sim 通过;
- Simpler profiling flags smoke:2 个架构 × 6 组配置通过;
- case-fold 路径冲突扫描:0 个冲突;
- pre-commit:除本机 `/tmp` OAT 安装锁权限问题外其余 hooks 通过,OAT 及全部检查已由远端 pipeline 复验通过。


See merge request: cann/pto-isa!1424
github-actions Bot pushed a commit to Crystal-wzy/pto-isa that referenced this pull request Aug 6, 2026
Co-authored-by: Youhezhen<youhezhen@huawei.com>



# message auto-generated for no-merge-commit merge:
!1424 merge fix/sdma-host-header into master

fix: keep SDMA host headers CPU-safe

Created-by: Youhezhen
Commit-by: Youhezhen
Merged-by: cann-robot
Description: ## 背景

本 MR 为 [hw-native-sys/simpler#1644](hw-native-sys/simpler#1644) 提供可固定依赖的 PTO-ISA revision,解决以下问题:

1. host 侧 SDMA workspace manager 间接包含 device-only 类型,导致普通 C++ host 编译失败;
2. CPU simulator 会无条件补齐 CUBE/VECTOR 两种角色,使显式的单角色编译同时启用两套实现并产生重复定义;
3. CPU stub 缺少设备侧已有的 `dcci_dst_t` 类型,三参数 `dcci` 调用无法在 CPU simulator 编译;
4. 仓库中存在仅大小写不同的 `TADDDEQRELU.*` / `TAddDeqRelu.*` 路径,macOS 的大小写不敏感文件系统会让 checkout 持续处于 dirty 状态。

## 修改说明

### 1. 将 SDMA workspace 常量拆到 host-safe header

涉及文件:

- `include/pto/comm/async_common/sdma_constants.hpp`
- `include/pto/comm/async_common/async_types.hpp`
- `include/pto/comm/async/sdma/sdma_workspace_manager.hpp`

**为什么改:** `sdma_workspace_manager.hpp` 是 host 侧代码,实际只需要 workspace 大小常量;原先包含 `async_types.hpp` 会同时引入 `__gm__`、`__ubuf__` 等 device-only 类型和定义,扩大 host 编译依赖并触发编译错误。

**怎么改:** 新增只依赖 `<cstdint>` 的轻量 header,将四个 workspace layout 常量移入其中;device 侧的 `async_types.hpp` 继续包含该 header,host manager 则直接包含它。

```diff
-#include "pto/comm/async_common/async_types.hpp"
+#include "pto/comm/async_common/sdma_constants.hpp"
```

```cpp
// sdma_constants.hpp:host/device 均可安全包含
constexpr uint32_t kSdmaContextWorkspaceBytes = 16U * 1024U;
constexpr uint32_t kSdmaFlagPayloadBytesPerGroup = 512U;
constexpr uint32_t kSdmaMaxChannelGroups = 48U;
constexpr uint32_t kSdmaWorkspaceBytes =
    kSdmaContextWorkspaceBytes + kSdmaMaxChannelGroups * kSdmaFlagPayloadBytesPerGroup;
```

这样不改变常量的 namespace、名称或计算方式,只切断 host header 对 device 类型定义的依赖。

### 2. 保留 CPU simulator 显式选择的执行角色

涉及文件:`include/pto/common/arch_macro.hpp`

**为什么改:** 原逻辑在定义 `__CPU_SIM` 后,会分别补齐缺失的 `__DAV_CUBE__` 和 `__DAV_VEC__`。因此调用方即使显式指定 CUBE-only 或 VECTOR-only,另一个角色仍会被自动打开,同一翻译单元可能同时编译两套 role-specific 实现并产生重复定义。

**怎么改:** 仅当两种角色都未指定时,才保留 PTO standalone CPU tests 所需的双角色默认值;只要调用方已经指定任意一种角色,就原样保留。

```diff
-#if defined(__CPU_SIM)
-#ifndef __DAV_CUBE__
+#if defined(__CPU_SIM) && !defined(__DAV_CUBE__) && !defined(__DAV_VEC__)
 #define __DAV_CUBE__
-#endif
-#ifndef __DAV_VEC__
 #define __DAV_VEC__
 #endif
-#endif
```

结果是:

- 未指定角色:仍同时提供 CUBE/VECTOR stub,保持现有 PTO CPU tests 行为;
- 显式指定 CUBE:只编译 CUBE;
- 显式指定 VECTOR:只编译 VECTOR。

### 3. 补齐 CPU simulator 的 `dcci_dst_t`

涉及文件:`include/pto/common/cpu_stub.hpp`

**为什么改:** device 代码可使用 `dcci_dst_t::CACHELINE_OUT` 作为三参数 `dcci` 的 destination mode,但 CPU stub 只有 `cache_line_t` 和三参数函数签名,没有对应类型,导致同一份 kernel 在 CPU simulator 编译失败。

**怎么改:** 在 CPU stub 中增加与 device API 同名的最小占位类型;其值保持为 `0`,符合 simulator 中 cache 操作为 no-op 的既有语义。

```cpp
struct dcci_dst_t {
    static constexpr int CACHELINE_OUT = 0;
};
```

这只补齐编译期接口,不改变 CPU simulator 的运行时 cache 行为。

### 4. 删除 macOS 上发生大小写碰撞的重复文档路径

涉及路径:

```text
删除:docs/figures/isa/TADDDEQRELU.svg
删除:docs/isa/TADDDEQRELU.md
删除:docs/isa/TADDDEQRELU_zh.md
保留:docs/figures/isa/TAddDeqRelu.svg
保留:docs/isa/TAddDeqRelu.md
保留:docs/isa/TAddDeqRelu_zh.md
```

**为什么改:** 两组文件在 Linux 上可共存,但在默认大小写不敏感的 macOS 文件系统上会映射到同一路径。checkout 后 Git 会持续报告伪修改;并发准备 PTO-ISA checkout 时还可能反复重建目录,最终表现为随机缺少 header。

**怎么改:** 保留与 `docs/isa/manifest.yaml` 中 `instruction: TAddDeqRelu` 一致、且被当前文档引用的 CamelCase 路径,删除旧的全大写重复路径。指令 C++ 名称 `TADDDEQRELU` 不变,仅规范文档文件名。

## 兼容性

- SDMA workspace 常量的名称、值和 namespace 均未改变;
- CPU simulator 未显式选择角色时的默认行为未改变;
- NPU/device 实现和 `TADDDEQRELU` 指令接口未改变;
- 文档内容仍由 canonical `TAddDeqRelu.*` 文件保留。

## 验证

- GitCode pipeline:17/17 通过;
- PTO-ISA full CPU simulator suite(GCC 15):通过;
- Simpler `ep_dispatch_combine`:a2a3sim、a5sim 通过;
- Simpler profiling flags smoke:2 个架构 × 6 组配置通过;
- case-fold 路径冲突扫描:0 个冲突;
- pre-commit:除本机 `/tmp` OAT 安装锁权限问题外其余 hooks 通过,OAT 及全部检查已由远端 pipeline 复验通过。


See merge request: cann/pto-isa!1424
@Little-oil
Little-oil force-pushed the support/bump-pinned-pto-isa-v0-55 branch from 64ba2a6 to b7fe191 Compare August 7, 2026 02:51
Youhezhen and others added 10 commits August 6, 2026 19:51
Qualify the dispatch DCCI cache-line arguments for the updated interface.
- migrate SDMA completion polling to post-done IDs
- carry A2/A3 post IDs through deferred completion state
- cover monotonic completion semantics with mailbox tests
- fetch the pinned PTO-ISA commit by exact SHA
- retain advertised-ref fallback for restrictive Git servers
- cover both resolver fetch paths with unit tests
- adapt host-build-graph SDMA completion to post IDs
- carry SDMA backend cookies through deferred completion
- retry CI after transient PTO-ISA fetch failure
- retry the complete GitHub PTO-ISA acquisition three times
- fall back to the GitCode mirror while preserving the exact pin
- increase the a2a3 unit-test job timeout from 30 to 45 minutes
@ChaoZheng109

Copy link
Copy Markdown
Collaborator

Review 随访:3 点(非阻塞)建议

基于对 #1644 的 review,以下是 3 点建议,均不阻塞合并。

1. a5 host_build_graph 的 SDMA backend 仍停留在旧 API(兄弟树不一致)

本 PR 已把 a2a3-HBG、a2a3-TM&RB、a5-TM&RB 三棵树迁移到新的 post-done-record API,但 a5 host_build_graph 的以下 3 个文件仍是旧 event-record API:

  • src/a5/runtime/host_build_graph/runtime/backend/sdma/sdma_completion_kernel.h — 仍用 PrepareEventCheck / GetEventRecord / UbTmpBuf
  • src/a5/runtime/host_build_graph/runtime/backend/sdma/sdma_completion_scheduler.h — 仍定义 SdmaEventRecord + poll/retire_sdma_event_record
  • src/a5/runtime/host_build_graph/runtime/pto_async_wait.h — sdma_event_record_poll_op 仍调旧名

当前不影响构建:全仓没有任何 example/test #include 这棵树的 sdma_completion_kernel.h(SDMA demo 只存在于 examples/{a2a3,a5}/tensormap_and_ringbuffer/),所以这段是未编译的死代码。但 a5 HBG 正处于活跃 bring-up,一旦给它加上 SDMA example,这段代码会立刻在 v0.55 pin 下编译失败。注意 a2a3-HBG 的同名文件(同样是当前死代码)本 PR 已一并迁移,所以 a5-HBG 是唯一被遗漏的兄弟树。

建议:一并迁移这 3 个文件以保持四棵树一致;或在描述里明确登记延后原因。

2. PR 描述里的 SHA 已过期

描述第一条写 advance pto_isa.pin to 4cf55905,但实际 pin 是 0cefc9a5(提交 b7fe1911 修改)。同步一下描述即可。

3. a5 aicore_completion_mailbox.h 注释 _pad[5] 与代码 _pad[3] 不符

a5 两棵树(host_build_graph / tensormap_and_ringbuffer)的 aicore_completion_mailbox.h 第 43 行注释仍写 _pad[5],而代码已是 _pad[3]。本 PR 已把 a2a3-HBG 同一处注释改成 _pad[3],a5 侧可顺手对齐。(此为既存漂移,非本 PR 引入。)

- migrate A5 host_build_graph SDMA completion to post-done records
- cover the A5 HBG completion path and align mailbox padding comments
@Little-oil

Copy link
Copy Markdown
Contributor Author

@ChaoZheng109 已按建议处理,感谢指出:

  1. 在 c1aaa35 中补齐了 a5 host_build_graph 的 SDMA post-done-record 适配。除评论列出的 3 个文件外,还把 64 位 post_id 作为 backend_cookie 贯通 DeferredCompletionEntry、mailbox、scheduler 和 CompletionCondition,避免只替换 API 后丢失 expected post ID。
  2. PR 描述中的 pin 已更新为 0cefc9a5。
  3. a5 两棵树的 mailbox padding 注释已对齐为 _pad[3]。

同时新增了 a5 HBG mailbox UT target;两套 a5 mailbox UT、a5 HBG runtime build,以及使用 HBG include 路径的 SDMA AICore kernel compile smoke 均已通过。

@ChaoZheng109
ChaoZheng109 merged commit 7a1b9b1 into hw-native-sys:main Aug 11, 2026
19 checks passed
@Little-oil
Little-oil deleted the support/bump-pinned-pto-isa-v0-55 branch August 11, 2026 07:17
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