LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/all_reduce - ccu_context_all_reduce_nhr1d_mem2mem.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 264 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 17 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 "ccu_context_all_reduce_nhr1d_mem2mem.h"
      12              : 
      13              : namespace Hccl {
      14              : 
      15              : constexpr uint16_t RANK_NUM_PER_CKE = 16; // 本rank给远端置位时应当写的CKE,16个对端一个CKE
      16              : constexpr uint16_t OUTPUT_XN_ID = 1;
      17              : constexpr uint16_t TOKEN_XN_ID = 2;
      18              : constexpr uint16_t CKE_IDX_0 = 0; // 后同步
      19              : constexpr uint16_t CKE_IDX_1 = 1; // 前同步addr
      20              : constexpr uint16_t CKE_IDX_2 = 2; // 前同步token
      21              : constexpr uint16_t CKE_IDX_3 = 3; // NHR step同步信号0,用于RS前同步,AG后同步
      22              : constexpr uint16_t CKE_IDX_4 = 4; // NHR step同步信号1,用于RS后同步
      23              : constexpr uint16_t FST_AXIS_ID = 0;
      24              : constexpr uint16_t SEC_AXIS_ID = 1;
      25              : 
      26            0 : CcuContextAllReduceNHR1D::CcuContextAllReduceNHR1D(
      27            0 :     const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group)
      28            0 :     : CcuContextAlgBase(arg, transports, group)
      29              : {
      30            0 :     const CcuCtxArgAllReduceNHR1D* ctxArg = dynamic_cast<const CcuCtxArgAllReduceNHR1D*>(&arg);
      31            0 :     rankId_ = ctxArg->rankId_;
      32            0 :     axisId_ = ctxArg->axisId_;
      33            0 :     axisSize_ = ctxArg->axisSize_;
      34            0 :     dimSize_ = ctxArg->dimSize_[0];
      35            0 :     stepInfoVector_ = ctxArg->stepInfoVector_;
      36            0 :     indexMap_ = ctxArg->indexMap_;
      37            0 :     localSize_ = indexMap_.size();
      38            0 :     myRankIdx_ = indexMap_.size();
      39            0 :     dataType_ = ctxArg->op_.dataType;
      40            0 :     reduceOp_ = ctxArg->op_.reduceOp;
      41            0 :     signalNum_ = (dimSize_ + RANK_NUM_PER_CKE - 1) / RANK_NUM_PER_CKE; // 每个CKE有16个bit
      42            0 :     HCCL_INFO(
      43              :         "[CcuContextAllReduceNHR1D] CtxArg: rankId_[%u], axisId_[%u], axisSize_[%u], dimSize_[%u], localSize_[%u], "
      44              :         "signalNum_[%u], dataType[%s], reduceOp[%s]",
      45              :         rankId_, axisId_, axisSize_, dimSize_, localSize_, signalNum_, dataType_.Describe().c_str(),
      46              :         reduceOp_.Describe().c_str());
      47            0 : }
      48              : 
      49            0 : void CcuContextAllReduceNHR1D::LoadArgs()
      50              : {
      51            0 :     Load(input_);
      52            0 :     Load(output_[myRankIdx_]);
      53            0 :     Load(token_[myRankIdx_]);
      54            0 :     Load(isInputOutputEqual_);
      55            0 :     Load(die0Size_);
      56            0 :     Load(die1Size_);
      57            0 :     Load(die0SliceSize_);
      58            0 :     Load(die1SliceSize_);
      59            0 :     Load(die0LastSliceSize_);
      60            0 :     Load(die1LastSliceSize_);
      61            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] LoadArgs run finished");
      62            0 : }
      63              : 
      64            0 : void CcuContextAllReduceNHR1D::InitResources()
      65              : {
      66            0 :     isInputOutputEqual_ = CreateVariable();
      67            0 :     die0SliceSize_ = CreateVariable();
      68            0 :     die1SliceSize_ = CreateVariable();
      69            0 :     die0LastSliceSize_ = CreateVariable();
      70            0 :     die1LastSliceSize_ = CreateVariable();
      71            0 :     die0Size_ = CreateVariable();
      72            0 :     die1Size_ = CreateVariable();
      73            0 :     localSignal_ = CreateMaskSignal();
      74              : 
      75            0 :     input_ = CreateVariable();
      76            0 :     for (uint32_t transportIdx = 0; transportIdx < localSize_; transportIdx++) {
      77            0 :         HCCL_DEBUG("[CcuContextAllReduceNHR1D] MyRank[%u], TransportId[%u]", rankId_, transportIdx);
      78            0 :         CHK_PRT_RET(
      79              :             transports[transportIdx] == nullptr,
      80              :             HCCL_ERROR("[CcuContextAllReduceNHR1D] Algorithm transport ptr is null"), );
      81            0 :         output_.push_back(
      82            0 :             CreateVariable((*transports[transportIdx]), OUTPUT_XN_ID)); // 获取transport中id=1的Var来传递output
      83            0 :         token_.push_back(CreateVariable((*transports[transportIdx]), TOKEN_XN_ID));
      84              :     }
      85            0 :     output_.push_back(CreateVariable());
      86            0 :     token_.push_back(CreateVariable());
      87              : 
      88            0 :     srcMem_ = CreateMemory();
      89            0 :     dstMem_ = CreateMemory();
      90            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] InitResources finished");
      91              : }
      92              : 
      93            0 : void CcuContextAllReduceNHR1D::PreSync()
      94              : {
      95            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] PreSync start");
      96            0 :     uint16_t selfBit = 1 << (rankId_ % RANK_NUM_PER_CKE);
      97            0 :     uint16_t selfSignalId = rankId_ / RANK_NUM_PER_CKE;
      98            0 :     std::vector<uint16_t> waitBitVector(signalNum_, 0);
      99            0 :     for (auto t : transports) {
     100            0 :         WriteVariableWithSignal(*t, output_[localSize_], OUTPUT_XN_ID, selfSignalId + signalNum_ * CKE_IDX_1, selfBit);
     101            0 :         WriteVariableWithSignal(*t, token_[localSize_], TOKEN_XN_ID, selfSignalId + signalNum_ * CKE_IDX_2, selfBit);
     102              :     }
     103            0 :     for (auto& pair : indexMap_) {
     104            0 :         uint16_t pairBit = 1 << (pair.first % RANK_NUM_PER_CKE);
     105            0 :         uint16_t pairSignalId = pair.first / RANK_NUM_PER_CKE;
     106            0 :         waitBitVector[pairSignalId] = waitBitVector[pairSignalId] | pairBit;
     107              :     }
     108            0 :     for (uint16_t sId = 0; sId < waitBitVector.size(); sId++) {
     109            0 :         GroupWait(*transportGroup, sId + signalNum_ * CKE_IDX_1, waitBitVector[sId]);
     110            0 :         GroupWait(*transportGroup, sId + signalNum_ * CKE_IDX_2, waitBitVector[sId]);
     111              :     }
     112            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] PreSync end");
     113            0 : }
     114              : 
     115            0 : void CcuContextAllReduceNHR1D::PostSync()
     116              : {
     117            0 :     uint16_t selfSignalId = rankId_ / RANK_NUM_PER_CKE;
     118            0 :     uint16_t selfBit = 1 << (rankId_ % RANK_NUM_PER_CKE);
     119            0 :     std::vector<uint16_t> waitBitVector(signalNum_, 0);
     120            0 :     for (auto& t : transports) {
     121            0 :         RemotePost(*t, selfSignalId + signalNum_ * CKE_IDX_0, selfBit);
     122              :     }
     123            0 :     for (auto& pair : indexMap_) {
     124            0 :         uint16_t pairSignalId = pair.first / RANK_NUM_PER_CKE;
     125            0 :         uint16_t pairBit = 1 << (pair.first % RANK_NUM_PER_CKE);
     126            0 :         waitBitVector[pairSignalId] = waitBitVector[pairSignalId] | pairBit;
     127              :     }
     128            0 :     for (uint32_t sId = 0; sId < signalNum_; sId++) {
     129            0 :         GroupWait(*transportGroup, sId + signalNum_ * CKE_IDX_0, waitBitVector[sId]);
     130              :     }
     131            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] PostSync run finished");
     132            0 : }
     133              : 
     134            0 : void CcuContextAllReduceNHR1D::AxisSync(uint32_t signalIndex)
     135              : {
     136            0 :     const uint32_t DIE_NUM = 2;
     137            0 :     if (signalIndex > 1) {
     138            0 :         THROW<InvalidParamsException>(
     139            0 :             StringFormat("[CcuContextAllReduceNHR1D] Unexpected SignalInex[%u]", signalIndex));
     140              :     }
     141            0 :     LocalCtxPost(anotherAxisSignal_, 1 << (axisId_ + signalIndex * DIE_NUM));
     142            0 :     LocalWait(localAxisSignal_, 1 << (1 - axisId_ + signalIndex * DIE_NUM));
     143            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] AxisSync run finished");
     144            0 :     return;
     145              : }
     146              : 
     147            0 : void CcuContextAllReduceNHR1D::DoReduceScatterNHR()
     148              : {
     149            0 :     const uint32_t NHR_NUM = 2;
     150            0 :     for (u64 i = 0; i < stepInfoVector_.size() / NHR_NUM; i++) {
     151            0 :         const NHRStepInfo& nhrStepInfo = stepInfoVector_[i];
     152            0 :         DoReduceScatterNHRSingleStep(nhrStepInfo);
     153              :     }
     154            0 : }
     155              : 
     156            0 : void CcuContextAllReduceNHR1D::DoReduceScatterNHRSingleStep(const NHRStepInfo& nhrStepInfo)
     157              : {
     158            0 :     u32 sendSliceIdx = 0;
     159            0 :     u32& fromRankIdx = indexMap_[nhrStepInfo.fromRank];
     160            0 :     u32& toRankIdx = indexMap_[nhrStepInfo.toRank];
     161            0 :     const std::vector<u32>& sendSliceIdxList = nhrStepInfo.txSliceIdxs;
     162            0 :     srcMem_.token = token_[myRankIdx_];
     163            0 :     dstMem_.token = token_[toRankIdx];
     164            0 :     CcuTransport* sendTransport = transports[toRankIdx];
     165            0 :     CcuTransport* recvTransport = transports[fromRankIdx];
     166              : 
     167            0 :     uint16_t selfSignalId = rankId_ / RANK_NUM_PER_CKE;
     168            0 :     uint16_t selfBit = 1 << (rankId_ % RANK_NUM_PER_CKE);
     169            0 :     uint16_t sendSignalId = nhrStepInfo.toRank / RANK_NUM_PER_CKE;
     170            0 :     uint16_t sendBit = 1 << (nhrStepInfo.toRank % RANK_NUM_PER_CKE);
     171            0 :     if (nhrStepInfo.step != 0) {
     172              :         // 通知fromRank,可以写入
     173            0 :         RemotePost(*recvTransport, selfSignalId + signalNum_ * CKE_IDX_3, selfBit, true);
     174              : 
     175              :         // 等待toRank通知其可以写入
     176            0 :         RemoteWait(*sendTransport, sendSignalId + signalNum_ * CKE_IDX_3, sendBit);
     177              :     }
     178              : 
     179            0 :     for (u32 i = 0; i < sendSliceIdxList.size(); i++) {
     180            0 :         sendSliceIdx = sendSliceIdxList[i];
     181            0 :         if (i != 0) {
     182            0 :             if (i % RANK_NUM_PER_CKE == 0) {
     183            0 :                 LocalWait(localSignal_, (1 << RANK_NUM_PER_CKE) - 1);
     184              :             }
     185              :         }
     186            0 :         if (nhrStepInfo.step == 0) {
     187              :             // 只有第0步的源数据从input中取
     188            0 :             HCCL_INFO("[CcuContextAllReduceNHR1D] nhrStepInfo 0.");
     189            0 :             srcMem_.addr = input_;
     190            0 :             srcMem_.addr += sliceOffset_[sendSliceIdx];
     191              :         } else {
     192            0 :             srcMem_.addr = output_[myRankIdx_];
     193            0 :             srcMem_.addr += sliceOffset_[sendSliceIdx];
     194              :         }
     195            0 :         dstMem_.addr = output_[toRankIdx];
     196            0 :         dstMem_.addr += sliceOffset_[sendSliceIdx];
     197            0 :         DoWriteReduceSlice(nhrStepInfo.toRank, srcMem_, dstMem_, sendSliceIdx, i % RANK_NUM_PER_CKE);
     198              :     }
     199            0 :     LocalWait(localSignal_, (1 << (sendSliceIdxList.size() % RANK_NUM_PER_CKE)) - 1);
     200              : 
     201              :     // 通知toRank数据写入完毕
     202            0 :     RemotePost(*sendTransport, selfSignalId + signalNum_ * CKE_IDX_4, selfBit, true);
     203              :     // 等待fromRank通知数据写入完毕
     204            0 :     uint16_t recvBit = 1 << (nhrStepInfo.fromRank % RANK_NUM_PER_CKE);
     205            0 :     uint16_t recvSignalId = nhrStepInfo.fromRank / RANK_NUM_PER_CKE;
     206            0 :     RemoteWait(*recvTransport, recvSignalId + signalNum_ * CKE_IDX_4, recvBit);
     207            0 :     HCCL_DEBUG(
     208              :         "[DoReduceScatterNHRSingleStep] rank %u step %u, toRank=%u, fromRank=%u, nSlice=%lu", rankId_, nhrStepInfo.step,
     209              :         nhrStepInfo.toRank, nhrStepInfo.fromRank, sendSliceIdxList.size());
     210            0 : }
     211              : 
     212            0 : void CcuContextAllReduceNHR1D::DoWriteReduceSlice(
     213              :     const u32& toRank, CcuRep::Memory& src, CcuRep::Memory& dst, const u32& sendSliceIdx, u32 signalIndex)
     214              : {
     215              :     bool islastSlice;
     216              :     // 添加 die1 偏移
     217            0 :     if (axisId_ == 1) {
     218            0 :         dst.addr += die0Size_;
     219            0 :         src.addr += die0Size_;
     220              :     }
     221            0 :     CcuTransport* sendTransport = transports[indexMap_[toRank]];
     222            0 :     islastSlice = (sendSliceIdx + 1 == dimSize_);
     223              : 
     224              :     // allreduce切片的最后一块slice,大小可能不一致
     225            0 :     const CcuRep::Variable& sliceSize = axisId_ == 0 ? (islastSlice ? die0LastSliceSize_ : die0SliceSize_) :
     226              :                                                        (islastSlice ? die1LastSliceSize_ : die1SliceSize_);
     227            0 :     CCU_IF(sliceSize != 0)
     228              :     {
     229            0 :         WriteReduce(*sendTransport, dst, src, sliceSize, dataType_, reduceOp_, localSignal_, 1 << signalIndex);
     230            0 :     }
     231            0 :     CCU_IF(sliceSize == 0) { LocalPost(localSignal_, 1 << signalIndex); }
     232            0 : }
     233              : 
     234            0 : void CcuContextAllReduceNHR1D::DoAllGatherNHR()
     235              : {
     236            0 :     const uint32_t NHR_NUM = 2;
     237            0 :     for (u64 i = stepInfoVector_.size() / NHR_NUM; i < stepInfoVector_.size(); i++) {
     238            0 :         const NHRStepInfo& nhrStepInfo = stepInfoVector_[i];
     239            0 :         DoAllGatherNHRSingleStep(nhrStepInfo);
     240              :     }
     241            0 : }
     242              : 
     243            0 : void CcuContextAllReduceNHR1D::DoAllGatherNHRSingleStep(const NHRStepInfo& nhrStepInfo)
     244              : {
     245            0 :     u32 sendSliceIdx = 0;
     246            0 :     u32& toRankIdx = indexMap_[nhrStepInfo.toRank];
     247            0 :     u32& fromRankIdx = indexMap_[nhrStepInfo.fromRank];
     248            0 :     CcuTransport* sendTransport = transports[toRankIdx];
     249            0 :     CcuTransport* recvTransport = transports[fromRankIdx];
     250            0 :     const std::vector<u32>& sendSliceIdxList = nhrStepInfo.txSliceIdxs;
     251            0 :     srcMem_.token = token_[myRankIdx_];
     252            0 :     dstMem_.token = token_[toRankIdx];
     253              : 
     254            0 :     uint16_t selfSignalId = rankId_ / RANK_NUM_PER_CKE;
     255            0 :     uint16_t selfBit = 1 << (rankId_ % RANK_NUM_PER_CKE);
     256              : 
     257            0 :     for (u32 i = 0; i < sendSliceIdxList.size(); i++) {
     258            0 :         sendSliceIdx = sendSliceIdxList[i];
     259              : 
     260            0 :         if (i != 0) {
     261            0 :             if (i % RANK_NUM_PER_CKE == 0) {
     262            0 :                 LocalWait(localSignal_, (1 << RANK_NUM_PER_CKE) - 1);
     263              :             }
     264              :         }
     265              : 
     266            0 :         srcMem_.addr = output_[myRankIdx_];
     267            0 :         dstMem_.addr = output_[toRankIdx];
     268            0 :         dstMem_.addr += sliceOffset_[sendSliceIdx];
     269            0 :         srcMem_.addr += sliceOffset_[sendSliceIdx];
     270            0 :         DoSendRecvSlice(nhrStepInfo.toRank, srcMem_, dstMem_, sendSliceIdx, i % RANK_NUM_PER_CKE);
     271              :     }
     272            0 :     LocalWait(localSignal_, (1 << (sendSliceIdxList.size() % RANK_NUM_PER_CKE)) - 1);
     273              : 
     274            0 :     if (nhrStepInfo.step + 1 != stepInfoVector_.size()) { // 最后一步不需要同步
     275              :         // 通知toRank,写入完毕
     276            0 :         RemotePost(*sendTransport, selfSignalId + signalNum_ * CKE_IDX_3, selfBit, true);
     277              :         // 等待fromRank通知写入完毕
     278            0 :         uint16_t recvBit = 1 << (nhrStepInfo.fromRank % RANK_NUM_PER_CKE);
     279            0 :         uint16_t recvSignalId = nhrStepInfo.fromRank / RANK_NUM_PER_CKE;
     280            0 :         RemoteWait(*recvTransport, recvSignalId + signalNum_ * CKE_IDX_3, recvBit);
     281              :     }
     282              : 
     283            0 :     HCCL_DEBUG(
     284              :         "[DoAllGatherNHRSingleStep] rank %u step %u, toRank=%u, fromRank=%u, nSlice=%lu", rankId_, nhrStepInfo.step,
     285              :         nhrStepInfo.toRank, nhrStepInfo.fromRank, sendSliceIdxList.size());
     286            0 : }
     287              : 
     288            0 : void CcuContextAllReduceNHR1D::DoSendRecvSlice(
     289              :     const u32& toRank, CcuRep::Memory& src, CcuRep::Memory& dst, const u32& sendSliceIdx, u32 signalIndex)
     290              : {
     291              :     bool islastSlice;
     292            0 :     CcuTransport* sendTransport = transports[indexMap_[toRank]];
     293            0 :     islastSlice = (sendSliceIdx + 1 == dimSize_);
     294              :     // 添加 die1 偏移
     295            0 :     if (axisId_ == 1) {
     296            0 :         dst.addr += die0Size_;
     297            0 :         src.addr += die0Size_;
     298              :     }
     299            0 :     const CcuRep::Variable& sliceSize = axisId_ == 0 ? (islastSlice ? die0LastSliceSize_ : die0SliceSize_) :
     300              :                                                        (islastSlice ? die1LastSliceSize_ : die1SliceSize_);
     301            0 :     CCU_IF(sliceSize != 0) { Write(*sendTransport, dst, src, sliceSize, localSignal_, 1 << signalIndex); }
     302            0 :     CCU_IF(sliceSize == 0) { LocalPost(localSignal_, 1 << signalIndex); }
     303            0 : }
     304              : 
     305            0 : void CcuContextAllReduceNHR1D::LocalCopySlices()
     306              : {
     307            0 :     u32 nonTxSliceIdx = 0;
     308            0 :     CcuRep::Variable tmpSliceOffset = CreateVariable();
     309            0 :     tmpSliceOffset = 0;
     310              : 
     311            0 :     for (u64 i = 0; i < dimSize_; i++) {
     312            0 :         sliceOffset_.push_back(CreateVariable());
     313            0 :         sliceOffset_[i] = tmpSliceOffset;
     314            0 :         tmpSliceOffset += axisId_ == 0 ? die0SliceSize_ : die1SliceSize_;
     315              :     }
     316              : 
     317              :     // 当input == output时,不需要拷贝
     318            0 :     CCU_IF(isInputOutputEqual_ == 0)
     319              :     {
     320              :         // 将step0中不需要写的slice,拷贝到本rank的output中
     321            0 :         const NHRStepInfo& nhrStepInfo = stepInfoVector_[0];
     322            0 :         const std::vector<u32>& nonTxSliceIdxList = GetNonTxSliceIdxs(nhrStepInfo.txSliceIdxs);
     323            0 :         for (u32 i = 0; i < nonTxSliceIdxList.size(); i++) {
     324            0 :             nonTxSliceIdx = nonTxSliceIdxList[i];
     325              : 
     326            0 :             if (i != 0) {
     327            0 :                 if (i % RANK_NUM_PER_CKE == 0) {
     328            0 :                     LocalWait(localSignal_, (1 << RANK_NUM_PER_CKE) - 1);
     329              :                 }
     330              :             }
     331              : 
     332            0 :             srcMem_.addr = input_;
     333            0 :             dstMem_.addr = output_[myRankIdx_];
     334            0 :             srcMem_.addr += sliceOffset_[nonTxSliceIdx];
     335            0 :             dstMem_.addr += sliceOffset_[nonTxSliceIdx];
     336            0 :             srcMem_.token = token_[myRankIdx_];
     337            0 :             dstMem_.token = token_[myRankIdx_];
     338            0 :             DoLocalCopySlice(srcMem_, dstMem_, nonTxSliceIdx, i);
     339              :         }
     340            0 :         LocalWait(localSignal_, (1 << (nonTxSliceIdxList.size() % RANK_NUM_PER_CKE)) - 1);
     341            0 :     }
     342            0 : }
     343              : 
     344            0 : std::vector<u32> CcuContextAllReduceNHR1D::GetNonTxSliceIdxs(const std::vector<u32>& txSliceIdxs) const
     345              : {
     346            0 :     std::vector<bool> isTx(dimSize_, false);
     347            0 :     for (u32 idx : txSliceIdxs) {
     348            0 :         if (idx < dimSize_) {
     349            0 :             isTx[idx] = true;
     350              :         }
     351              :     }
     352              : 
     353            0 :     std::vector<u32> nonTxSliceIdxs;
     354            0 :     for (u32 idx = 0; idx < dimSize_; ++idx) {
     355            0 :         if (!isTx[idx]) {
     356            0 :             nonTxSliceIdxs.push_back(idx);
     357              :         }
     358              :     }
     359              : 
     360            0 :     return nonTxSliceIdxs;
     361            0 : }
     362              : 
     363            0 : void CcuContextAllReduceNHR1D::DoLocalCopySlice(
     364              :     CcuRep::Memory& src, CcuRep::Memory& dst, const u32& copySliceIdx, u32 signalIndex)
     365              : {
     366              :     bool islastSlice;
     367              :     // 添加 die1 偏移
     368            0 :     if (axisId_ == 1) {
     369            0 :         src.addr += die0Size_;
     370            0 :         dst.addr += die0Size_;
     371              :     }
     372              : 
     373            0 :     islastSlice = (copySliceIdx + 1 == dimSize_);
     374            0 :     const CcuRep::Variable& sliceSize = axisId_ == 0 ? (islastSlice ? die0LastSliceSize_ : die0SliceSize_) :
     375              :                                                        (islastSlice ? die1LastSliceSize_ : die1SliceSize_);
     376            0 :     CCU_IF(sliceSize == 0) { LocalPost(localSignal_, 1 << signalIndex); }
     377              : 
     378            0 :     CCU_IF(sliceSize != 0) { LocalCopy(dst, src, sliceSize, localSignal_, 1 << signalIndex); }
     379            0 : }
     380              : 
     381            0 : void CcuContextAllReduceNHR1D::Algorithm()
     382              : {
     383            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] AllReduceNHR1D run");
     384              : 
     385            0 :     InitResources();
     386            0 :     LoadArgs();
     387            0 :     LocalCopySlices();
     388            0 :     PreSync();
     389            0 :     DoReduceScatterNHR();
     390            0 :     DoAllGatherNHR();
     391            0 :     PostSync();
     392              : 
     393            0 :     HCCL_DEBUG("[CcuContextAllReduceNHR1D] AllReduceNHR1D end");
     394            0 :     return;
     395              : }
     396              : 
     397            0 : std::vector<uint64_t> CcuContextAllReduceNHR1D::GeneArgs(const CcuTaskArg& arg)
     398              : {
     399            0 :     const CcuTaskArgAllReduceNHR1D* taskArg = dynamic_cast<const CcuTaskArgAllReduceNHR1D*>(&arg);
     400            0 :     if (taskArg == nullptr) {
     401            0 :         THROW<NullPtrException>(StringFormat("CcuContextAllReduceNHR1D::taskArg ptr is null"));
     402              :     }
     403              :     // input&output&buffer地址
     404            0 :     uint64_t inputAddr = taskArg->inputAddr_;
     405            0 :     uint64_t outputAddr = taskArg->outputAddr_;
     406            0 :     uint64_t token = taskArg->token_;
     407            0 :     uint64_t isInputOutputEqual = taskArg->isInputOutputEqual_;
     408            0 :     uint64_t die0Size = taskArg->die0Size_;
     409            0 :     uint64_t die1Size = taskArg->die1Size_;
     410            0 :     uint64_t die0SliceSize = taskArg->die0SliceSize_;
     411            0 :     uint64_t die1SliceSize = taskArg->die1SliceSize_;
     412            0 :     uint64_t die0LastSliceSize = taskArg->die0LastSliceSize_;
     413            0 :     uint64_t die1LastSliceSize = taskArg->die1LastSliceSize_;
     414              : 
     415            0 :     HCCL_INFO(
     416              :         "[CcuContextAllReduceNHR1D] TaskArgs: inputAddr[%llu], outputAddr[%llu], "
     417              :         "die0Size[%llu], die1Size[%llu], die0SliceSize[%llu], die1SliceSize[%llu],"
     418              :         "die0LastSliceSize[%llu], die1LastSliceSize[%llu]",
     419              :         inputAddr, outputAddr, die0Size, die1Size, die0SliceSize, die1SliceSize, die0LastSliceSize, die1LastSliceSize);
     420              : 
     421              :     return {inputAddr, outputAddr,    token,         isInputOutputEqual, die0Size,
     422            0 :             die1Size,  die0SliceSize, die1SliceSize, die0LastSliceSize,  die1LastSliceSize};
     423              : }
     424              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1