SetAtomicMin(ISASI)
产品支持情况
功能说明
原子操作函数,设置后续从VECOUT传输到GM的数据是否执行原子比较,将待拷贝的内容和GM已有内容进行比较,将最小值写入GM。
可通过设置模板参数来设定不同的数据类型。
函数原型
template <typename T>
__aicore__ inline void SetAtomicMin()
参数说明
表 1 模板参数说明
返回值说明
无
约束说明
使用完后,建议通过DisableDmaAtomic关闭原子最小操作,以免影响后续相关指令功能。
调用示例
#include "kernel_operator.h"
uint32_t size = 256;
AscendC::LocalTensor<half> dst0Local = queueDst0.DeQue<half>();
AscendC::LocalTensor<half> dst1Local = queueDst1.DeQue<half>();
AscendC::DataCopy(dstGlobal, dst1Local, size);
AscendC::PipeBarrier<PIPE_MTE3>();
AscendC::SetAtomicMin<half>();
AscendC::DataCopy(dstGlobal, dst0Local, size);
queueDst0.FreeTensor(dst0Local);
queueDst1.FreeTensor(dst1Local);
AscendC::DisableDmaAtomic();
每个核的输入数据为:
Src0: [1,1,1,1,1,...,1] // 256个1
Src1: [2,2,2,2,2,...,2] // 256个2
最终输出数据: [1,1,1,1,1,...,1] // 256个1