ClearSpr
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Clears a specified special-purpose register.
Prototype
template <SpecialPurposeReg spr> __simd_callee__ inline void ClearSpr()
Parameters
Parameter |
Description |
|---|---|
spr |
Special-purpose register, which is of the SpecialPurposeReg enum class. |
Returns
None
Constraints
None
Example
In the following example, the Gather Reg vector computation API stores the total number of bytes of valid elements to the AR. Before the for loop starts in the macro function, ClearSpr clears the 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);
}
}
Parent topic: System Variable Access