ClearSpr
产品支持情况
产品 |
是否支持 |
|---|---|
Atlas 350 加速卡 |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
功能说明
对指定的特殊寄存器进行清零。
函数原型
template <SpecialPurposeReg spr> __simd_callee__ inline void ClearSpr()
参数说明
参数名 |
描述 |
|---|---|
spr |
特殊寄存器,类型为SpecialPurposeReg枚举类。 |
返回值说明
无
约束说明
无。
调用示例
如下示例中Gather Reg矢量计算API会存储有效元素的总字节数到AR寄存器中,在宏函数内for循环开始前通过ClearSpr对AR寄存器进行清零。
template<typename T, typename U>
__simd_vf__ inline void VFDemo(__ubuf__ T* dstAddr, __ubuf__ T* src0Addr, __ubuf__ U* src1Addr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg0, dstReg;
AscendC::Reg::RegTensor<U> srcReg1;
AscendC::Reg::MaskReg mask;
AscendC::Reg::LoadAlign(srcReg1, src1Addr);
AscendC::Reg::ClearSpr<AscendC::SpecialPurposeReg::AR>();
for (uint16_t i = 0; i < repeatTimes; i++) {
mask = AscendC::Reg::UpdateMask<T>(count);
AscendC::Reg::LoadAlign(srcReg0, src0Addr + i * oneRepeatSize);
AscendC::Reg::Gather(dstReg, srcReg0, srcReg1);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
父主题: 系统变量访问