Finalize
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function
Instructs the server to exit after the current communication task is complete.
Prototype
1 2 | template <bool sync = true> __aicore__ inline void Finalize() |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
sync |
Input |
Whether to wait for the communication on the server to complete. The value is of the bool type. The options are as follows:
|
Returns
None
Restrictions
- Before calling this API, ensure that the InitV2 and SetCcTilingV2 APIs have been called.
- When this API is called on the AIC or AIV core, the calling core must be the same as that of the corresponding Prepare API.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | REGISTER_TILING_DEFAULT(ReduceScatterCustomTilingData); // ReduceScatterCustomTilingData is a structure defined in the operator header file. GET_TILING_DATA_WITH_STRUCT(ReduceScatterCustomTilingData, tilingData, tilingGM); Hccl hccl; GM_ADDR contextGM = AscendC::GetHcclContext<0>(); // In the kernel of the AscendC custom operator, obtain the HCCL context through this method. hccl.InitV2(contextGM, &tilingData); hccl.SetCcTilingV2(offsetof(ReduceScatterCustomTilingData, mc2CcTiling)); if (AscendC::g_coreType == AIC) { HcclHandle handleId = hccl.ReduceScatter(sendBuf, recvBuf, 100, HcclDataType::HCCL_DATA_TYPE_INT8, HcclReduceOp::HCCL_REDUCE_SUM, 10); hccl.Commit(handleId ); //Notify the server that the ReduceScatter task can be executed. for (uint8_t i=0; i<10; i++) { hccl.Wait(handleId); // Blocking API. Wait until the ReduceScatter task is complete. } hccl.Finalize<true>(); // If there are no other communication tasks to follow, notify the server to exit after executing the above ReduceScatter task. } |