MoveMask

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Reads the mask value from the special register SPR{MASK1, MASK0} and writes the value to the function return value MaskReg based on the data type format.

Prototype

template <typename T> 
__simd_callee__ inline MaskReg MoveMask()

Parameters

Table 1 Parameters in the template

Parameter

Description

T

Data type, which determines the format of the mask value to be written.

  • For the b16 type, the complete 128-bit {MASK1, MASK0} data is read, each bit is copied to 2 bits, and the result is written to the function return value MaskReg.
  • For the b32 type, the 64-bit MASK0 data is read, and each bit is replicated into 4 bits before being written to the function return value, MaskReg.

Returns

MaskReg read from the special register.

Restrictions

None

Examples

template <typename T>
__simd_vf__ inline void MoveMaskVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
    AscendC::Reg::RegTensor<T> srcReg;
    AscendC::Reg::MaskReg addMask = AscendC::Reg::MoveMask<T>();
    AscendC::Reg::MaskReg mask;
    for (uint16_t i = 0; i < repeatTimes; ++i) {
        mask = AscendC::Reg::UpdateMask<T>(count);
        AscendC::Reg::LoadAlign(srcReg, srcAddr + i * oneRepeatSize);
        AscendC::Reg::Adds(srcReg, srcReg, 0, addMask);
        AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, srcReg, mask);
    }
}