GetVecLen
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Obtains the vector length (VL) of RegTensor.
Prototype
1 | __aicore__ inline constexpr uint32_t GetVecLen() |
Parameters
None
Returns
Vector length, in bytes.
Restrictions
None
Example
The following example shows how to obtain the number of iterations using GetVecLen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | template <typename T> __aicore__ inline void AddCustomImpl(__local_mem__ T *dst, __local_mem__ T *src0, __local_mem__ T *src1, uint32_t calCount) { AscendC::Reg::RegTensor<T> reg0; AscendC::Reg::RegTensor<T> reg1; AscendC::Reg::RegTensor<T> reg2; AscendC::Reg::MaskReg mask; constexpr uint32_t repeatElm = AscendC::GetVecLen() / sizeof(T); uint16_t repeatTime = AscendC::CeilDivision(calCount, repeatElm); for (uint16_t i = 0; i < repeatTime; ++i) { mask = AscendC::Reg::UpdateMask<T>(calCount); AscendC::Reg::LoadAlign(reg0, src0 + i * repeatElm); AscendC::Reg::LoadAlign(reg1, src1 + i * repeatElm); AscendC::Reg::Add(reg2, reg0, reg1, mask); AscendC::Reg::StoreAlign(dst + i * repeatElm, reg2, mask); } } |
Parent topic: Tool Functions