Query

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

Queries the number of completed rounds of the communication task corresponding to handleId. A maximum of repeat rounds can be returned. 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 int32_t Query(HcclHandle handleId)

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

handleId

Input

ID of the corresponding communication task. Only the return value of the API corresponding to the Prepare primitive can be used.

1
using HcclHandle = int8_t;

Returns

  • Number of times that the communication task corresponding to handleId has been executed. The maximum value is repeat.
  • When an exception occurs during execution, –1 is returned.

Restrictions

  • Before calling this API, ensure that the InitV2 and SetCcTilingV2 APIs have been called.
  • The input parameter handleId can use only the return value of the Prepare primitive API.
  • 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
15
16
17
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>();  // Obtain the HCCL context on the kernel of the Ascend C custom operator.
hccl.InitV2(contextGM, &tilingData);
auto ret = hccl.SetCcTiling(offsetof(ReduceScatterCustomTilingData, mc2CcTiling));
if (ret != HCCL_SUCCESS) {
  return;
}
if (AscendC::g_coreType == AIC) {
    auto repeat = 10;
    HcclHandle handleId = hccl.ReduceScatter(sendBuf, recvBuf, 100, HcclDataType::HCCL_DATA_TYPE_INT8, HcclReduceOp::HCCL_REDUCE_SUM, repeat);
    hccl.Commit(handleId ); //Notify the server that the ReduceScatter task can be executed.
    int32_t finishedCount = hccl.Query(handleId);
    while (hccl.Query(handleId) < repeat) {} // Wait till the communication task corresponding to handleId is executed for repeat times.
    hccl.Finalize(); //If there are no other communication tasks to follow, notify the server to exit after executing the above ReduceScatter task.
}