CalcTschBlockDim

Function Usage

Computes the blockDim of the Cube and Vector fusion operators for the separated architecture. For Vector/Cube fusion operators, the operators are started based on the AIV and AIC combinations. blockDim is used to set the number of combinations to be started. For example, an AI processor has 40 Vector Cores and 20 Cube Cores, and a combination consists of two Vector Cores and one Cube Core. You are advised to set this parameter to 20. In this case, 20 combinations are started, that is, 40 Vector Cores and +20 Cube Cores. This API is used to automatically obtain a proper blockDim value.

After obtaining the value, use SetBlockDim to set blockDim.

Prototype

uint32_t CalcTschBlockDim(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) const;

Parameters

Parameter

Input/Output

Description

sliceNum

Input

Number of data slices.

aicCoreNum

Input

If cube computation APIs are used for operator implementation, pass the number returned by GetCoreNumAic. Otherwise, pass 0.

aivCoreNum

Input

If vector computation APIs are used for operator implementation, pass the number returned by GetCoreNumAiv. Otherwise, pass 0.

Returns

Number of cores used for underlying task scheduling

Constraints

None

Example

ge::graphStatus TilingXXX(gert::TilingContext* context) {
    auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
    auto aicNum = ascendcPlatform.GetCoreNumAic();
    auto aivNum = ascendcPlatform.GetCoreNumAiv();
    // ..Split data by aivNum and perform the calculation.
    uint32_t sliceNum = aivNum;
    context->SetBlockDim(ascendcPlatform.CalcTschBlockDim(sliceNum, aicNum, aivNum));
    return ret;
}