GetUBSizeInBytes
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Obtains the UB size, in bytes. Developers can calculate the number of cycles based on the UB size.
Prototype
__aicore__ inline constexpr uint32_t GetUBSizeInBytes()
Parameters
None
Returns
UB size, in bytes.
Restrictions
None
Example
This example shows how to calculate the value of tileNum based on the UB size obtained by calling GetUBSizeInBytes.
// Define the total length of data to be processed (number of elements).
uint32_t totalLength = 16384;
// GetUBSizeInBytes() / sizeof(half) -> Calculate the number of half elements that the UB can accommodate.
// Divide by 2 -> Reserve 50% of the UB space.
uint32_t tileLength = AscendC::GetUBSizeInBytes() / sizeof(half) / 2;
// Prevent the tile size from exceeding the actual data volume.
if (totalLength < tileLength) {
tileLength = totalLength;
}
// Number of tiles to be iterated: 16384/63488 = 1
uint32_t tileNum = totalLength / tileLength;
Parent topic: Tool Functions