GetRuntimeUBSize

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Obtains the runtime UB size, in bytes. Developers can calculate the number of cycles based on the UB size.

Prototype

1
__aicore__ inline uint32_t GetRuntimeUBSize()

Parameters

None

Returns

Runtime UB size, in bytes.

Under the Atlas 350 Accelerator Card architecture, in mixed SIMD and SIMT scenarios, the maximum UB size is 216 KB; in non-mixed SIMD and SIMT scenarios, the return value is fixed at 248 KB.

Restrictions

None

Example

This example shows how to calculate the value of tileNum based on the UB size obtained by calling GetRuntimeUBSize.

1
2
3
4
5
6
7
// Define the total length of data to be processed (number of elements).
uint32_t totalLength = 126976;
// GetRuntimeUBSize() / 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::GetRuntimeUBSize() / sizeof(half) / 2;
// Number of tiles to be iterated: 126976/63488 = 2
uint32_t tileNum = totalLength / tileLength;