GetDataBlockSizeInBytes
Supported Products
Product |
Supported/Unsupported |
|---|---|
√ |
|
√ |
|
x |
|
√ |
|
x |
|
√ |
Function Usage
Obtains the size (in byte) of a data block of the current chip version. You can calculate the values of the repeatTime, DataBlock Stride, and Repeat Stride parameters to be transferred in the API instruction based on the size of the data block.
Prototype
1 | __aicore__ inline constexpr int16_t GetDataBlockSizeInBytes() |
Parameters
None
Return Value Description
Size (in byte) of a data block of the current chip version
Constraints
None
Example
The following example uses the data block size obtained by calling GetDataBlockSizeInBytes to calculate the value of repeatTime:
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); // A total of 512 elements are computed. The value of repeatTime is obtained by dividing the total number of elements by the number of elements involved in each repeat. uint8_t repeatTime = 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, repeatTime, { 1, 1, 1, 8, 8, 8 }); |
Parent topic: System Variable Access