asc_vf_call【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持Atlas 200I/500 A2 推理产品不支持Atlas 推理系列产品AI Core不支持Atlas 推理系列产品Vector Core不支持Atlas 训练系列产品不支持功能说明在SIMD编程场景下使用。用于启动SIMD VFVector Function子任务。函数原型template auto funcPtr, typename... Args __aicore__ inline void asc_vf_call(Args ...args)参数说明表1模板参数说明参数名描述funcPtr用于指定SIMD入口核函数。Args定义可变参数用于传递实参到SIMD入口核函数。表2参数说明参数名输入/输出描述args输入可变参数用于传递实参到SIMD入口核函数。返回值说明无约束说明asc_vf_call启动SIMD VF子任务时子任务函数不能是类的成员函数推荐使用普通函数或类静态函数且入口函数必须使用__simd_vf__修饰宏。asc_vf_call启动SIMD VF子任务时传递的参数只支持裸指针常见基本数据类型。不支持传递结构体数组等。调用示例使用SIMD VF函数对UB数据做加法计算。// SIMD函数 template typename T __simd_vf__ inline void AddVF( __ubuf__ T* dstAddr, __ubuf__ T* src0Addr, __ubuf__ T* src1Addr, uint32_t count, uint16_t oneRepeatSize, uint16_t repeatTimes) { AscendC::Reg::RegTensorT src0Reg; AscendC::Reg::RegTensorT src1Reg; AscendC::Reg::RegTensorT dstReg; AscendC::Reg::MaskReg mask; for (uint16_t i 0; i repeatTimes; i) { mask AscendC::Reg::UpdateMaskT(count); AscendC::Reg::LoadAlign(src0Reg, src0Addr i * oneRepeatSize); AscendC::Reg::LoadAlign(src1Reg, src1Addr i * oneRepeatSize); AscendC::Reg::Add(dstReg, src0Reg, src1Reg, mask); AscendC::Reg::StoreAlign(dstAddr i * oneRepeatSize, dstReg, mask); } } template typename T __aicore__ inline void Compute() { AscendC::LocalTensorT dst outQueueZ.AllocTensorT(); AscendC::LocalTensorT src0 inQueueX.DeQueT(); AscendC::LocalTensorT src1 inQueueY.DeQueT(); constexpr uint16_t oneRepeatSize AscendC::GetVecLen() / sizeof(T); uint32_t count 512; // 向上取整计算循环次数 uint16_t repeatTimes AscendC::CeilDivision(count, oneRepeatSize); __ubuf__ T* dstAddr (__ubuf__ T*)dst.GetPhyAddr(); __ubuf__ T* src0Addr (__ubuf__ T*)src0.GetPhyAddr(); __ubuf__ T* src1Addr (__ubuf__ T*)src1.GetPhyAddr(); asc_vf_callAddVFT(dstAddr, src0Addr, src1Addr, count, oneRepeatSize, repeatTimes); outQueueZ.EnQue(dst); inQueueX.FreeTensor(src0); inQueueY.FreeTensor(src1); }【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考