一句话让Agent变成昇腾专家,不必再找人问了。评测入口:
(To Agent)请按这个开源仓接入昇腾图谱 https://gitcode.com/agent0/kg-tools

SIMT 的入门结论(910B 不支持、950 才有)前一篇文章已经讲过。这篇深化 950PR 上 SIMT 真正的差异点:scatter 写、远端原子、GM 直读直写——这些是 SIMD 侧难以等价表达的能力。

一、为什么 scatter/atomic 只能上 SIMT

决策树第一条就是它:出现 atomicAdd 或 scatter-write → SIMT,因为 SIMD 无法做线程级原子操作(SetAtomicAdd 随路原子只覆盖规整搬运)。间接寻址 arr[index[i]] 同理——SIMD 的 DataCopy 需要连续地址。950PR 远端原子是硬件原生:write add/max/min 覆盖 FP32/FP16/BF16/S32/U32/S64/U64,CAS/EXCH 覆盖 U32/S32/U64;BF16+FP16 的 atomic add 直接硬件支持,正是 bf16/fp16 scatter-add 算子的底座。

二、GM 直读直写:省掉 UB 中转

SIMT 线程可直接访问 xGmAddr[rowIdx / k * cols] 读源数据,不需要先把 x 搬进 UB。线程遍历范式:

auto threadIdx = static_cast<int32_t>(Simt::GetThreadIdx());
auto threadNum = static_cast<int32_t>(Simt::GetThreadNum());
for (auto i = threadIdx; i < elementNum; i += threadNum) { ... }

MoeInitRoutingV3 实测(950PR,64 Vector Core):直方图从标量串行 20.267 降到 8.447(2.40x)——把"串行传递 lastIndex"拆成每个位置独立检测专家 ID 跳变点,多线程并行判边界;Gather 场景第一维 64 线程离散并行、第二维 32 线程连续访问。但官方也明说边界:SIMT 从 GM 直读到 UB 的带宽不如 SIMD MTE2 搬入,H 较小的离散小包才占优,H 大时多 Buffer 的 SIMD 可能反超——别把 SIMT 当万能搬运。

三、工程约束(踩坑高发)

  1. __simt_vf__ 函数内自定义子函数必须带 __simt_callee__,与 __simd_callee__ 不可混用。
  2. 线程数必须是 constexpr 编译期常量,LAUNCH_BOUND(N)Simt::Dim3(N) 用同一个 N;禁止从 tilingData 读线程数。
  3. SIMT 要为 DCache 让空间:context->SetLocalMemorySize(ubsize - DCACHE_SIZE),典型 DCACHE_SIZE=128KB。
  4. 多核交换数据时 SetScheduleMode(1) 同步模式 + workspace。
  5. 纯 SIMT 算子直接用 GM_ADDR 参数,避免 GlobalTensor 中转。

排查:结果偶发错乱先查 DCache 一致性(Scalar 写 GM 后需 DataCacheCleanAndInvalid);编译报子函数修饰符错误就是第 1 条。


昇腾知识图谱如何检索示例

  • 检索主题: 950PR SIMT 进阶:scatter/atomic/GM 直读的专属能力
  • 检索关键词: [“AscendC SIMT scatter add atomic add GM direct read write Ascend950”, “950PR SIMT GetThreadIdx”]
  • 内容节点: [“cannsamples_samples_2performance_moeinitroutingstory_readme_simt_getthreadidx”, “cannbotskills_pluginscommunity_ascendcportorchestrator_kb_okf_runbooks_operatoroptimization_simtsimddecisiontree_step_1_atomicadd_scatter_write”, “cannbotskills_pluginscommunity_ascendcportorchestrator_kb_okf_runbooks_hardware_targetascend950pr_simt_atomicadd”, “cannbotskills_ops_ascendcregistryinvoketemplate_references_simtengineeringguide_线程遍历_getthreadidx_getthreadnum”]
  • 召回情况: top1 “MoeInitRoutingV3算子性能优化实践与效果分析” score 0.9311;SIMT 工程差异指南经 GetThreadIdx query 命中 score 0.9340
Logo

作为“人工智能6S店”的官方数字引擎,为AI开发者与企业提供一个覆盖软硬件全栈、一站式门户。

更多推荐