AddrReg

Function Usage

Indicates an address register used to store address offsets. AddrReg is initialized through the CreateAddrReg API and then used to store address offsets in the loop. AddrReg is incremented based on the configured stride in each loop.

Prototype

// offset = index0 * stride0
template <typename T>
__simd_callee__ inline AddrReg CreateAddrReg(uint16_t index0, uint32_t stride0);
 
// offset = index0 * stride0 + index1 * stride1
template <typename T>
__simd_callee__ inline AddrReg CreateAddrReg(uint16_t index0, uint32_t stride0, uint16_t index1, uint32_t stride1);
 
// offset = index0 * stride0 + index1 * stride1 + index2 * stride2
template <typename T>
__simd_callee__ inline AddrReg CreateAddrReg(uint16_t index0, uint32_t stride0, uint16_t index1, uint32_t stride1, uint16_t index2, uint32_t stride2);

// offset = index0 * stride0 + index1 * stride1 + index2 * stride2 + index3 * stride3
template <typename T>
__simd_callee__ inline AddrReg CreateAddrReg(uint16_t index0, uint32_t stride0, uint16_t index1, uint32_t stride1, uint16_t index2, uint32_t stride2, uint16_t index3, uint32_t stride3);

Parameters

Parameter

Description

T

Template parameter. The supported data types are b8, b16, b32, and b64.

index0

Used as axis 1 during offset computation. (For the offset computation formula, see the comments.)

index1

Used as axis 2 during offset computation. (For the offset computation formula, see the comments.)

index2

Used as axis 3 during offset computation. (For the offset computation formula, see the comments.)

index3

Used as axis 4 during offset computation. (For the offset computation formula, see the comments.)

stride0

Address offset 1

stride1

Address offset 2

stride2

Address offset 3

stride3

Address offset 4

Availability

Atlas 350 Accelerator Card

Restrictions

None

Examples

__simd_vf__ inline void CreateAddrRegVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
    AscendC::Reg::MaskReg mask = AscendC::Reg::CreateMask<T>();
    AscendC::Reg::AddrReg aReg;
    for (uint16_t i = 0; i < repeatTimes; ++i) {
        aReg = AscendC::Reg::CreateAddrReg<T>(i, oneRepeatSize);
        AscendC::Reg::LoadAlign(mask, srcAddr, aReg);
        AscendC::Reg::StoreAlign(dstAddr, mask, aReg);
    }
}