LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_to_all - coll_all_to_all_v_pipeline_for_910_93_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 140 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 12 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "coll_all_to_all_v_pipeline_for_910_93_executor.h"
      12              : 
      13              : namespace hccl {
      14              : 
      15            0 : CollAlltoAllVPipelineFor91093::CollAlltoAllVPipelineFor91093(
      16            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      17            0 :     : CollAlltoAllExecutor(dispatcher, topoMatcher)
      18            0 : {}
      19              : 
      20              : HcclResult
      21            0 : CollAlltoAllVPipelineFor91093::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
      22              : {
      23            0 :     inputType = TransportMemType::CCL_INPUT;
      24            0 :     outputType = TransportMemType::CCL_OUTPUT;
      25            0 :     HCCL_INFO(
      26              :         "[CollAlltoAllVPipelineFor91093][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]", tag_.c_str(),
      27              :         inputType, outputType);
      28            0 :     return HCCL_SUCCESS;
      29              : }
      30              : 
      31            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcLevel1CommInfo(
      32              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      33              : {
      34              :     // level0 + level1 - Mesh建链
      35            0 :     CommParaInfo commParaCombineL1(COMM_COMBINE_L1, CommType::COMM_TAG_MESH);
      36            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaCombineL1, opTransport[COMM_COMBINE_L1], inputType, outputType));
      37            0 :     return HCCL_SUCCESS;
      38            0 : }
      39              : 
      40            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcLevel2CommInfo(
      41              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      42              : {
      43              :     // level2 - Mesh建链
      44            0 :     CommParaInfo commParaLevel2(COMM_LEVEL2, CommType::COMM_TAG_MESH);
      45            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel2, opTransport[COMM_LEVEL2], inputType, outputType));
      46            0 :     return HCCL_SUCCESS;
      47            0 : }
      48              : 
      49            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      50              : {
      51            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      52            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      53            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      54            0 :     CHK_RET(CalcLevel1CommInfo(inputType, outputType, opTransport));
      55            0 :     CHK_RET(CalcLevel2CommInfo(inputType, outputType, opTransport));
      56            0 :     return HCCL_SUCCESS;
      57              : }
      58              : 
      59            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcStreamNum(u32& streamNum)
      60              : {
      61            0 :     const u32 level0StreamNum = std::min(topoAttr_.deviceNumPerAggregation - 1, DEVICE_EIGHT);
      62            0 :     const u32 level2StreamNum = 1;                 // 先固定1条RDMA 流
      63            0 :     streamNum = level0StreamNum + level2StreamNum; // 最大流数量为9条, RDMA 1条, SDMA 最大8条
      64            0 :     HCCL_INFO(
      65              :         "[CollAlltoAllVPipelineFor91093]tag[%s] level0StreamNum[%u], level2StreamNum[%u], streamNum[%u]", tag_.c_str(),
      66              :         level0StreamNum, level2StreamNum, streamNum);
      67            0 :     return HCCL_SUCCESS;
      68              : }
      69              : 
      70            0 : HcclResult CollAlltoAllVPipelineFor91093::CalLocalSendRecvInfo(const OpParam& param, SendRecvInfo& info)
      71              : {
      72            0 :     if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALL) {
      73            0 :         CalcA2ASendRecvInfo(param, info);
      74            0 :     } else if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALLV) {
      75            0 :         CalcA2AvSendRecvInfo(param, info);
      76            0 :     } else if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALLVC) {
      77            0 :         CalcA2AvcSendRecvInfo(param, info);
      78              :     } else {
      79            0 :         HCCL_ERROR("[CollAlltoAllVPipelineFor91093] get invalid optype.");
      80            0 :         return HCCL_E_PARA;
      81              :     }
      82            0 :     return HCCL_SUCCESS;
      83              : }
      84              : 
      85            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcA2ASendRecvInfo(const OpParam& param, SendRecvInfo& info)
      86              : {
      87            0 :     const u32 userRankSize = topoAttr_.userRankSize;
      88            0 :     info.sendCounts.resize(userRankSize);
      89            0 :     info.sendDispls.resize(userRankSize);
      90            0 :     info.recvCounts.resize(userRankSize);
      91            0 :     info.recvDispls.resize(userRankSize);
      92            0 :     u64 sdispl = 0, rdispl = 0;
      93              : 
      94            0 :     for (u32 i = 0; i < userRankSize; i++) {
      95            0 :         info.sendCounts[i] = param.All2AllDataDes.sendCount;
      96            0 :         info.recvCounts[i] = param.All2AllDataDes.sendCount;
      97            0 :         info.sendDispls[i] = sdispl;
      98            0 :         info.recvDispls[i] = rdispl;
      99            0 :         sdispl += param.All2AllDataDes.sendCount;
     100            0 :         rdispl += param.All2AllDataDes.sendCount;
     101              :     }
     102            0 :     if (UNLIKELY(HcclCheckLogLevel(DLOG_DEBUG))) {
     103            0 :         for (u32 i = 0; i < userRankSize; i++) {
     104            0 :             HCCL_DEBUG(
     105              :                 "CalcA2ASendRecvInfo sendCounts[%d]=%ld, recvCounts[%d]=%ld, sdispls[%d]=%ld, rdispls[%d]=%ld", i,
     106              :                 info.sendCounts[i], i, info.recvCounts[i], i, info.sendDispls[i], i, info.recvDispls[i]);
     107              :         }
     108              :     }
     109            0 :     return HCCL_SUCCESS;
     110              : }
     111              : 
     112            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcA2AvSendRecvInfo(const OpParam& param, SendRecvInfo& info)
     113              : {
     114            0 :     const bool hasRecvInfo = param.All2AllDataDes.recvCounts != nullptr;
     115            0 :     const u32 userRankSize = topoAttr_.userRankSize;
     116              : 
     117            0 :     info.sendCounts.resize(userRankSize);
     118            0 :     info.sendDispls.resize(userRankSize);
     119              : 
     120            0 :     if (hasRecvInfo) {
     121            0 :         info.recvCounts.resize(userRankSize);
     122            0 :         info.recvDispls.resize(userRankSize);
     123              :     }
     124              : 
     125            0 :     for (u32 i = 0; i < userRankSize; ++i) {
     126            0 :         info.sendCounts[i] = *(static_cast<const u64*>(param.All2AllDataDes.sendCounts) + i);
     127            0 :         info.sendDispls[i] = *(static_cast<const u64*>(param.All2AllDataDes.sdispls) + i);
     128              : 
     129            0 :         if (hasRecvInfo) {
     130            0 :             info.recvCounts[i] = *(static_cast<const u64*>(param.All2AllDataDes.recvCounts) + i);
     131            0 :             info.recvDispls[i] = *(static_cast<const u64*>(param.All2AllDataDes.rdispls) + i);
     132              :         }
     133              :     }
     134              : 
     135            0 :     if (UNLIKELY(HcclCheckLogLevel(DLOG_INFO))) {
     136            0 :         for (u32 i = 0; i < userRankSize; i++) {
     137            0 :             HCCL_DEBUG(
     138              :                 "CalcA2AvSendRecvInfo sendCounts[%d]=%ld, recvCounts[%d]=%ld, sdispls[%d]=%ld, rdispls[%d]=%ld", i,
     139              :                 info.sendCounts[i], i, info.recvCounts[i], i, info.sendDispls[i], i, info.recvDispls[i]);
     140              :         }
     141              :     }
     142            0 :     return HCCL_SUCCESS;
     143              : }
     144              : 
     145            0 : HcclResult CollAlltoAllVPipelineFor91093::CalcA2AvcSendRecvInfo(const OpParam& param, SendRecvInfo& info)
     146              : {
     147            0 :     const u32 userRankSize = topoAttr_.userRankSize;
     148            0 :     const u32 userRank = topoAttr_.userRank;
     149            0 :     info.sendCounts.resize(userRankSize);
     150            0 :     info.sendDispls.resize(userRankSize);
     151            0 :     info.recvCounts.resize(userRankSize);
     152            0 :     info.recvDispls.resize(userRankSize);
     153            0 :     u64 sdispl = 0, rdispl = 0;
     154              : 
     155            0 :     u64* sendCountMatrix = static_cast<u64*>(param.All2AllDataDes.sendCountMatrix);
     156            0 :     for (u32 i = 0; i < userRankSize; i++) {
     157            0 :         info.sendCounts[i] = *(sendCountMatrix + userRank * userRankSize + i);
     158            0 :         info.recvCounts[i] = *(sendCountMatrix + userRank + userRankSize * i);
     159            0 :         info.sendDispls[i] = sdispl;
     160            0 :         info.recvDispls[i] = rdispl;
     161            0 :         sdispl += *(sendCountMatrix + userRank * userRankSize + i);
     162            0 :         rdispl += *(sendCountMatrix + userRank + userRankSize * i);
     163              :     }
     164            0 :     if (UNLIKELY(HcclCheckLogLevel(DLOG_INFO))) {
     165            0 :         for (u32 i = 0; i < userRankSize; i++) {
     166            0 :             HCCL_DEBUG(
     167              :                 "CalcA2AvcSendRecvInfo sendCounts[%d]=%ld, recvCounts[%d]=%ld, sdispls[%d]=%ld, rdispls[%d]=%ld", i,
     168              :                 info.sendCounts[i], i, info.recvCounts[i], i, info.sendDispls[i], i, info.recvDispls[i]);
     169              :         }
     170              :     }
     171            0 :     return HCCL_SUCCESS;
     172              : }
     173              : 
     174            0 : HcclResult CollAlltoAllVPipelineFor91093::Orchestrate(OpParam& param, AlgResourceResponse& algRes)
     175              : {
     176            0 :     HcclUs startut = TIME_NOW();
     177            0 :     HcclResult ret = HCCL_SUCCESS;
     178            0 :     tag_ = param.tag;
     179            0 :     algResResp_ = &algRes;
     180            0 :     AlltoAllVParam_ = param;
     181            0 :     ExecMem execMem;
     182            0 :     execMem.count = 0;
     183            0 :     execMem.inputPtr = param.inputPtr;
     184            0 :     execMem.outputPtr = param.outputPtr;
     185            0 :     execMem.inputMem = algRes.cclInputMem;
     186            0 :     execMem.outputMem = algRes.cclOutputMem;
     187            0 :     ret = KernelRun(param, execMem);
     188              : 
     189            0 :     CHK_PRT_RET(
     190              :         ret != HCCL_SUCCESS,
     191              :         HCCL_ERROR(
     192              :             "[CollAlltoAllVPipelineFor91093][Orchestrate]errNo[0x%016llx]executor run failed", HCCL_ERROR_CODE(ret)),
     193              :         ret);
     194              : 
     195            0 :     HCCL_INFO(
     196              :         "tag[%s], CollAlltoAllVPipelineFor91093 tempAlg orchestrate success, take time [%lld]us.", param.tag.c_str(),
     197              :         DURATION_US(TIME_NOW() - startut));
     198            0 :     return HCCL_SUCCESS;
     199            0 : }
     200              : 
     201            0 : HcclResult CollAlltoAllVPipelineFor91093::KernelRun(const OpParam& param, ExecMem& execMem)
     202              : {
     203            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollAlltoAllVPipelineFor91093][KernelRun] AllToAllV npu direct start.");
     204              :     // 获取通信域
     205            0 :     SubCommInfo level1CommInfo;
     206            0 :     SubCommInfo level2CommInfo;
     207            0 :     CHK_RET(CheckCommSize(COMM_COMBINE_L1, COMM_INDEX_0 + 1));
     208            0 :     CHK_RET(CheckCommSize(COMM_LEVEL2, COMM_INDEX_0 + 1));
     209            0 :     level1CommInfo = GetSubCommInfo(COMM_COMBINE_L1, COMM_INDEX_0);
     210            0 :     level2CommInfo = GetSubCommInfo(COMM_LEVEL2, COMM_INDEX_0);
     211              : 
     212              :     // 执行
     213            0 :     std::unique_ptr<AlgTemplateBase> tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
     214            0 :         TemplateType::TEMPLATE_ALL_2_ALL_V_CONTINUOUS_PIPELINE, dispatcher_);
     215            0 :     CHK_SMART_PTR_NULL(tempAlg);
     216              : 
     217            0 :     SendRecvInfo sendRecvInfo;
     218            0 :     CHK_RET(CalLocalSendRecvInfo(param, sendRecvInfo));
     219              : 
     220            0 :     A2aPipelineMemory a2aPipelineMemory;
     221            0 :     a2aPipelineMemory.userInput = algResResp_->paramInputMem;
     222            0 :     a2aPipelineMemory.userOutput = algResResp_->paramOutputMem;
     223            0 :     a2aPipelineMemory.cclInBuffer = execMem.inputMem;
     224            0 :     a2aPipelineMemory.cclOutBuffer = execMem.outputMem;
     225              : 
     226            0 :     HCCL_INFO(
     227              :         "[CollAlltoAllVPipelineFor91093] Memory info[addr, size]: userInput[%p, %llu], userOutput[%p, %llu], "
     228              :         "cclInBuffer[%p, %llu] ,cclOutBuffer[%p, %llu].",
     229              :         a2aPipelineMemory.userInput.ptr(), a2aPipelineMemory.userInput.size(), a2aPipelineMemory.userOutput.ptr(),
     230              :         a2aPipelineMemory.userOutput.size(), a2aPipelineMemory.cclInBuffer.ptr(), a2aPipelineMemory.cclInBuffer.size(),
     231              :         a2aPipelineMemory.cclOutBuffer.ptr(), a2aPipelineMemory.cclOutBuffer.size());
     232              : 
     233              : #ifndef OPEN_HCCL_TEST
     234            0 :     std::vector<SendRecvInfo> sendRecvInfoList{sendRecvInfo};
     235              : #else
     236              :     // 适配算法检查器,传入全局的info
     237              :     std::vector<SendRecvInfo> sendRecvInfoList = allMeshAggregationSendRecvInfo_;
     238              : #endif
     239              : 
     240            0 :     CHK_RET(tempAlg->Prepare(
     241              :         topoAttr_.userRank, a2aPipelineMemory, level1CommInfo, level2CommInfo, param.stream, algResResp_->slaveStreams,
     242              :         algResResp_->notifiesMain, algResResp_->notifiesAux, sendRecvInfoList, param.All2AllDataDes.sendType,
     243              :         workflowMode_));
     244              : 
     245            0 :     CHK_RET(tempAlg->RunAsync());
     246              : 
     247            0 :     HCCL_INFO("[CollAlltoAllVPipelineFor91093] executor run success.");
     248            0 :     return HCCL_SUCCESS;
     249            0 : }
     250              : 
     251              : REGISTER_EXEC("RunAlltoAllVPipelineFor91093", AlltoAllVPipelineFor91093, CollAlltoAllVPipelineFor91093);
     252              : } // namespace hccl
        

Generated by: LCOV version 2.0-1