InitV2

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product 's AI Core

x

Atlas inference product 's Vector Core

x

Atlas training products

x

Function

Initializes the HCCL client. By default, this API works on all cores. You can also specify a core by setting GetBlockIdx before calling this API.

Prototype

1
__aicore__ inline void InitV2(GM_ADDR context, const void *initTiling)

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

context

Input

Communication context, including information such as rankDim and rankID. Obtain context by calling the GetHcclContext API provided by the framework.

initTiling

Input

Address for initializing the Mc2InitTiling in the communicator. The Mc2InitTiling is computed on the Host. For details, see Table 1 Mc2InitTiling parameters. It is passed by the framework to the kernel function for use.

Returns

None

Restrictions

  • This API must be used together with the SetCcTilingV2 API.
  • When this API is called, the TilingData structure development method must be defined using the standard C++ syntax. For details, see Using the Standard C++ Syntax to Define the Tiling Structure.
  • The initTiling parameter passed to this API must not be a Global Memory address. It is recommended to use the GET_TILING_DATA_WITH_STRUCT API to obtain the stack address of TilingData.
  • This API does not support the initialization of multiple HCCL objects using the same context.

Example

Customize the TilingData structure:

1
2
3
4
5
class UserCustomTilingData {
    AscendC::tiling::Mc2InitTiling initTiling;
    AscendC::tiling::Mc2CcTiling tiling;
    CustomTiling param;
};
Create HCCL objects on all cores and call InitV2 for initialization.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
extern "C" __global__ __aicore__ void userKernel(GM_ADDR aGM, GM_ADDR workspaceGM, GM_ADDR tilingGM) {
    REGISTER_TILING_DEFAULT(UserCustomTilingData);
    GET_TILING_DATA_WITH_STRUCT(UserCustomTilingData,tilingData,tilingGM);

    GM_ADDR contextGM = AscendC::GetHcclContext<0>(); 
    Hccl hccl;
    hccl.InitV2(contextGM, &tilingData);
    hccl.SetCcTilingV2(offsetof(UserCustomTilingData, tiling));

    // Call the Prepare, Commit, Wait, and Finalize APIs of HCCL.
}