UnPack
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Unpacks the lower or upper half of the input MaskReg into the output MaskReg based on the selected least significant bit or most significant bit mode. The unpacking expands each bit into 2 bits, with the high bit zeroed.
Prototype
template <HighLowPart part = HighLowPart::LOWEST> __simd_callee__ inline void UnPack(MaskReg& dst, MaskReg& src);
Parameters
Parameter |
Description |
|---|---|
part |
Enum, including:
|
Parameter |
Description |
|---|---|
dst |
Destination operand. |
src |
Source operand. |
Returns
None
Restrictions
None
Examples
template <typename T>
__simd_vf__ inline void UnpackVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg;
AscendC::Reg::MaskReg maskFull = AscendC::Reg::CreateMask<T, AscendC::Reg::MaskPattern::ALL>();
AscendC::Reg::MaskReg mask0;
AscendC::Reg::MaskReg mask1;
AscendC::Reg::UnPack<AscendC::Reg::HighLowPart::LOWEST>(mask0, maskFull);
for (uint16_t i = 0; i < repeatTimes; ++i) {
mask1 = AscendC::Reg::UpdateMask<T>(count);
AscendC::Reg::LoadAlign(srcReg, srcAddr + i * oneRepeatSize);
AscendC::Reg::Adds(srcReg, srcReg, 0, mask0);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, srcReg, mask1);
}
}
Parent topic: MaskReg Computation