---
title: GetSubBlockIdx
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendcopapi/atlasascendc_api_07_0663.html
sourcePath: /source/zh/canncommercial/900/API/ascendcopapi/atlasascendc_api_07_0663.html
indexId: fd72288c59d4f9e696d38f415262423526225ee4eb649c545f9ee63f3c369d2676
---
# GetSubBlockIdx

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | x |
| Atlas 推理系列产品 AI Core | x |
| Atlas 推理系列产品 Vector Core | x |
| Atlas 训练系列产品 | x |


#### 功能说明

获取当前AIV核的ID。分离架构下，一个AI Core由Cube Core（AIC）和Vector Core（AIV）按照一定比例1：N进行组合，其中N个AIV的子核ID分别为0, 1, ..., N-1。

Matmul::GetSubBlockIdx()与基础API接口AscendC::GetSubBlockIdx()的区别在于，Matmul::GetSubBlockIdx()用于获取当前AIV核在当前AI Core分组中的ID，而AscendC::GetSubBlockIdx()获取的是AIV核在所有AI Core分组中的逻辑ID。例如，有10组AI Core，AIC与AIV的比例为1:2，共20个AIV核。调用Matmul::GetSubBlockIdx()时，20个AIV的获取结果依次为0, 1, 0, 1, 0, 1, ..., 0, 1。调用AscendC::GetSubBlockIdx()时，20个AIV的获取结果依次为0, 1, 2, 3, 4, 5, ..., 18, 19。


#### 函数原型

```
__aicore__  inline uint8_t GetSubBlockIdx()
```


#### 参数说明

无


#### 返回值说明

当前AIV核的ID。


#### 约束说明

- 该接口仅支持在分离架构下使用，否则返回随机值。
- 在分离架构中，AIV核的ID会在  REGIST_MATMUL_OBJ()
接口内部自动初始化和赋值。因此，需要在调用REGIST_MATMUL_OBJ()接口之后，再调用本接口，以获取正确的ID。
- 若在算子程序中调用  SetSubBlockIdx()
后， GetSubBlockIdx()接口将返回由SetSubBlockIdx接口设置的ID值。


#### 调用示例

```
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> aType; 
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> bType; 
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> cType; 
typedef AscendC::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> biasType; 

AscendC::Matmul<aType, bType, cType, biasType, CFG_NORM> mm;
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.GetSubBlockIdx(); // 获取子核ID
```
