产品 |
是否支持 |
|---|---|
Ascend 950PR/Ascend 950DT |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
获取运行时UB空间的大小,单位为byte。开发者根据UB的大小来计算循环次数等参数值。
1 | __aicore__ inline uint32_t GetRuntimeUBSize() |
无
运行时UB空间的大小,单位为字节。
Ascend 950PR/Ascend 950DT架构下,SIMD与SIMT混合场景中,获取到的UB大小上限为216KB,非SIMD与SIMT混合场景返回值为固定值248KB。
无
本调用示例通过GetRuntimeUBSize获取的UB空间大小,来计算tileNum的值。
1 2 3 4 5 6 7 8 9 10 11 | // totalLength为待处理的总数据长度 (元素个数) this->totalLength = totalLength; // GetRuntimeUBSize() / sizeof(half) -> 计算 UB 能容纳多少个 half 类型元素 // 除2 -> 预留 50% 的 UB 空间 if (totalLength > AscendC::GetRuntimeUBSize() / sizeof(half) / 2) { this->tileLength = AscendC::GetRuntimeUBSize() / sizeof(half) / 2; } else { // 防止分片大小超过实际数据总量 this->tileLength = this->totalLength; } // 需要迭代的分片数量 this->tileNum = this->totalLength / this->tileLength; |