GetDataBlockSizeInBytes
Product Support
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
√ |
|
x |
|
√ |
Function
Obtains the size (in byte) of a data block of the current chip version. You can calculate the values of parameters such as repeatTime, DataBlock Stride, and Repeat stride 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
Restrictions
None
Example
In the following example, the value of repeatTime 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 repeatTime. 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