Skip to content

DisableDmaAtomic

产品支持情况​

  • Ascend 950PR&950DT系列产品:支持
  • Atlas A3系列产品:支持
  • Atlas A2系列产品:支持
  • Atlas 200I/500 A2推理产品:支持
  • Atlas推理系列产品AI Core:支持
  • Atlas推理系列产品Vector Core:不支持
  • Atlas训练系列产品:支持

功能说明​

头文件路径为:"basic_api/kernel_operator_set_atomic_intf.h"。

关闭数据搬运随路原子操作功能,后续执行数据搬运时,GM中原始数据将被新搬运数据完全覆盖。

函数原型​

C++
__aicore__ inline void DisableDmaAtomic()

参数说明​

无

返回值说明​

无

约束说明​

SetAtomicAdd、SetAtomicMax、SetAtomicMin使用完成后,通过DisableDmaAtomic清空原子操作的状态,以免影响后续相关指令功能。

调用示例​

C++
AscendC::LocalMemAllocator<AscendC::Hardware::UB> ubAllocator;
AscendC::LocalTensor<T> srcLocal = ubAllocator.Alloc<T, SIZE>();

AscendC::DisableDmaAtomic();
AscendC::DataCopy(srcLocal, srcGlobal, SIZE);
AscendC::SetFlag<AscendC::HardEvent::MTE2_MTE3>(EVENT_ID0);
AscendC::WaitFlag<AscendC::HardEvent::MTE2_MTE3>(EVENT_ID0);
AscendC::SyncAll();

// 开启原子累加,将Unified Buffer(UB)数据原子累加到GM
AscendC::SetAtomicAdd<T>();
AscendC::DataCopy(dstGlobal, srcLocal, SIZE);

// 关闭原子累加
AscendC::DisableDmaAtomic();

完整样例请参考DataMovementWithAtomicOperations样例。

免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区。