Non-contiguous Aligned Data Move-out
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Indicates the Reg vector computation data movement interface, and is used to move non-contiguous aligned data from RegTensor to UB (in the unit of data block).
Prototype
// Normal scenario: template <typename T = DefaultType, DataCopyMode dataMode, typename U> __simd_callee__ inline void StoreAlign(__ubuf__ T* dstAddr, U& srcReg, uint32_t dataBlockStride, MaskReg& mask); // POST_MODE_UPDATE scenario template <typename T = DefaultType, DataCopyMode dataMode, PostLiteral postMode, typename U> __simd_callee__ inline void StoreAlign(__ubuf__ T*& dstAddr, U& srcReg, uint32_t dataBlockStride, uint32_t repeatStride, MaskReg& mask);
Parameters
DataCopyMode Value |
Description |
|---|---|
DATA_BLOCK_COPY |
It is used to select the movement mode in the non-contiguous alignment scenario. Currently, only the data block movement mode is supported, that is, data is moved by data block. |
Parameter |
Input/Output |
Description |
|---|---|---|
T |
Input |
Template parameter. The supported data types are b8, b16, and b32. |
postMode |
Input |
This parameter controls whether to enable post update. The value is of the PostLiteral type. |
U |
Input |
RegTensor type, for example, RegTensor<half>. It is automatically inferred by the compiler and does not need to be specified. |
srcReg |
Input |
Source operand, which is of the RegTensor type. |
dstAddr |
Input |
Start address of the destination operand in the UB. |
dataBlockStride |
Input |
The interval between adjacent data blocks moved in a single operation (defined as the distance between the head of one data block and the head of the next). The unit is data block. |
repeatStride |
Input |
The meaning of repeatStride is different under the POST_MODE_NORMAL and POST_MODE_UPDATE scenarios.
|
mask |
Input |
MaskReg type, indicating which elements are valid during the movement. When the 32 bits in a data block are 0, no error is reported even if the UB is out of bounds. |
Returns
None
Restrictions
None
Examples
__simd_vf__ inline void Compute(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg;
AscendC::Reg::MaskReg mask = AscendC::Reg::CreateMask<T>();
for (uint16_t i = 0; i < repeatTimes; ++i) {
AscendC::Reg::LoadAlign<T, AscendC::Reg::DataCopyMode::DATA_BLOCK_COPY, AscendC::Reg::PostLiteral::POST_MODE_UPDATE>(srcReg, srcAddr, 1, i * 8, mask);
AscendC::Reg::StoreAlign<T, AscendC::Reg::DataCopyMode::DATA_BLOCK_COPY, AscendC::Reg::PostLiteral::POST_MODE_UPDATE>(dstAddr, srcReg, 1, i * 8, mask);
}
}