GetDataBlockSizeInBytes

Function Usage

Obtains the size (in byte) of a data block of the current chip version. You can calculate the values of repeatTimes, dataBlockStride, and repeatStride to be passed in the API command based on the data block size.

Prototype

1
__aicore__ inline constexpr int16_t GetDataBlockSizeInBytes()

Parameters

None

Returns

Size (in byte) of a data block of the current chip version

Availability

Atlas Training Series Product

Constraints

None

Example

In the following example, the value of repeatTimes is calculated based on the value of data block obtained through GetDataBlockSizeInBytes.

1
2
3
4
5
6
7
8
int16_t dataBlockSize = AscendC::GetDataBlockSizeInBytes();
// Each repeat involves eight data blocks. 8 * dataBlockSize / sizeof(half) can be calculated. mask is configured to enable all elements in the iteration to participate in the calculation.
uint64_t mask = 8 * dataBlockSize / sizeof(half);
// Divide a total of 512 elements by the number of elements involved in each repeat to obtain the value of repeatTimes.
uint8_t repeatTimes = 512 / mask; 
// dstBlkStride, src0BlkStride, src1BlkStride = 1. Data is continuously read and written in a single iteration.
// dstRepStride, src0RepStride, src1RepStride = 8. Data is continuously read and written between adjacent iterations.
AscendC::Add(dstLocal, src0Local, src1Local, mask, repeatTimes, { 1, 1, 1, 8, 8, 8 });