GetSubBlockIdx
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Obtains the ID of the current AIV. In the separated architecture, an AI Core consists of Cube Cores (AICs) and Vector Cores (AIVs) in a fixed ratio of 1:N. The IDs of the N AIVs are 0, 1, ..., and N-1, respectively.
The difference between Matmul::GetSubBlockIdx() and the basic API AscendC::GetSubBlockIdx() is that Matmul::GetSubBlockIdx() obtains the ID of the current AIV in the current AI Core group, while AscendC::GetSubBlockIdx() obtains the logical ID of the AIV in all AI Core groups. For example, there are 10 AI Core groups, and the ratio of AICs to AIVs is 1:2. There are 20 AIVs in total. When Matmul::GetSubBlockIdx() is called, the obtained IDs of the 20 AIVs are 0, 1, 0, 1, 0, 1, ..., 0, and 1 in sequence. When AscendC::GetSubBlockIdx() is called, the obtained IDs of the 20 AIVs are 0, 1, 2, 3, 4, 5, ..., 18, and 19 in sequence.
Prototype
1 | __aicore__ inline uint8_t GetSubBlockIdx() |
Parameters
None
Returns
ID of the current AIV.
Restrictions
- This API can be used only in the separated architecture. Otherwise, a random value is returned.
- In the separated architecture, the AIV ID is automatically initialized and assigned within the REGIST_MATMUL_OBJ() API. Therefore, you need to call this API after calling REGIST_MATMUL_OBJ() to obtain the correct ID.
- If SetSubBlockIdx() is called in the operator program, the GetSubBlockIdx() API will return the ID set by the SetSubBlockIdx API.
Example
1 2 3 4 5 6 7 8 | 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(); // Obtain the subcore ID. |