LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/all_gather - ccu_instruction_all_gather_nhr1d_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 10 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              : #ifndef HCCLV2_CCU_INSTRUCTION_ALL_GATHER_NHR_1D_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_ALL_GATHER_NHR_1D_H_
      13              : 
      14              : #include "template_utils.h"
      15              : #include "instruction.h"
      16              : #include "ins_queue.h"
      17              : #include "ccu_context_utils.h"
      18              : #include "ccu_ctx_signature.h"
      19              : #include "ccu_ins.h"
      20              : #include "ccu_rank_group.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : using NHRStepInfo = struct NHRStepInfoDef {
      25              :     u32 step = 0;
      26              :     u32 myRank = 0;
      27              :     u32 nSlices;
      28              :     u32 toRank = 0;
      29              :     u32 fromRank = 0;
      30              :     std::vector<u32> txSliceIdxs;
      31              :     std::vector<u32> rxSliceIdxs;
      32              : 
      33            0 :     NHRStepInfoDef() : nSlices(0) {}
      34              : };
      35              : 
      36              : // 为AllGatherNHR1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      37              : class CcuCtxArgAllGatherNHR1D : public CcuCtxArg {
      38              : public:
      39            0 :     explicit CcuCtxArgAllGatherNHR1D(
      40              :         const std::vector<uint64_t>& dimSize, uint32_t rankId, uint32_t axisId, uint32_t axisSize,
      41              :         const std::vector<NHRStepInfo> stepInfoVector, const std::map<u32, u32> indexMap, const CollAlgOperator& op,
      42              :         const std::vector<std::vector<RankId>>& tempVTopo)
      43            0 :         : dimSize_(dimSize),
      44            0 :           rankId_(rankId),
      45            0 :           axisId_(axisId),
      46            0 :           axisSize_(axisSize),
      47            0 :           stepInfoVector_(stepInfoVector),
      48            0 :           indexMap_(indexMap),
      49            0 :           op_(op),
      50            0 :           tempVTopo_(tempVTopo)
      51            0 :     {}
      52            0 :     CcuCtxSignature GetCtxSignature() const override
      53              :     {
      54            0 :         CcuCtxSignature signature;
      55            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_ALLGATHER_NHR_1D_MEM2MEM, op_, tempVTopo_);
      56            0 :         return signature;
      57            0 :     }
      58              :     std::vector<uint64_t> dimSize_;
      59              :     uint64_t rankId_;
      60              :     uint64_t axisId_;
      61              :     uint64_t axisSize_;
      62              :     std::vector<NHRStepInfo> stepInfoVector_;
      63              :     std::map<u32, u32> indexMap_;
      64              :     CollAlgOperator op_;
      65              :     std::vector<std::vector<RankId>> tempVTopo_;
      66              : };
      67              : 
      68              : class CcuTaskArgAllGatherNHR1D : public CcuTaskArg {
      69              : public:
      70            0 :     explicit CcuTaskArgAllGatherNHR1D(
      71              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t die0Size, uint64_t die1Size,
      72              :         uint64_t repeatNum, uint64_t inputSliceStride, uint64_t outputSliceStride, uint64_t inputRepeatStride,
      73              :         uint64_t outputRepeatStride, uint64_t isInputOutputEqual)
      74            0 :         : inputAddr_(inputAddr),
      75            0 :           outputAddr_(outputAddr),
      76            0 :           token_(token),
      77            0 :           die0Size_(die0Size),
      78            0 :           die1Size_(die1Size),
      79            0 :           repeatNum_(repeatNum),
      80            0 :           inputSliceStride_(inputSliceStride),
      81            0 :           outputSliceStride_(outputSliceStride),
      82            0 :           inputRepeatStride_(inputRepeatStride),
      83            0 :           outputRepeatStride_(outputRepeatStride),
      84            0 :           isInputOutputEqual_(isInputOutputEqual)
      85            0 :     {}
      86              : 
      87              :     uint64_t inputAddr_;
      88              :     uint64_t outputAddr_;
      89              :     uint64_t token_;
      90              :     uint64_t die0Size_;
      91              :     uint64_t die1Size_;
      92              :     uint64_t repeatNum_;
      93              :     uint64_t inputSliceStride_;
      94              :     uint64_t outputSliceStride_;
      95              :     uint64_t inputRepeatStride_;
      96              :     uint64_t outputRepeatStride_;
      97              :     uint64_t isInputOutputEqual_;
      98              : };
      99              : 
     100              : class CcuInstructionAllGatherNHR1D : public CcuInstruction {
     101              : public:
     102            0 :     CcuInstructionAllGatherNHR1D() : CcuInstruction() {}
     103              : 
     104            0 :     void Init(
     105              :         uint32_t rankId, uint64_t inputAddr, uint64_t outputAddr, uint64_t axisId, uint32_t axisSize, uint64_t die0Size,
     106              :         uint64_t die1Size, uint64_t repeatNum, uint64_t inputSliceStride, uint64_t outputSliceStride,
     107              :         uint64_t inputRepeatStride, uint64_t outputRepeatStride, std::vector<NHRStepInfo> stepInfoVector,
     108              :         std::map<u32, u32> indexMap, uint64_t token, uint64_t isInputOutputEqual, CollAlgOperator& op,
     109              :         std::vector<std::vector<RankId>>& tempVTopo)
     110              :     {
     111            0 :         u32 maxDimNum = 1;
     112            0 :         if (tempVTopo.size() != maxDimNum) {
     113            0 :             THROW<InvalidParamsException>(StringFormat(
     114              :                 "[CcuInstructionAllGatherNHR1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
     115              :         }
     116            0 :         dimSize_.push_back(tempVTopo[0].size());
     117            0 :         rankId_ = rankId;
     118            0 :         inputAddr_ = inputAddr;
     119            0 :         outputAddr_ = outputAddr;
     120            0 :         axisId_ = axisId;
     121            0 :         axisSize_ = axisSize;
     122            0 :         die0Size_ = die0Size;
     123            0 :         die1Size_ = die1Size;
     124            0 :         repeatNum_ = repeatNum;
     125            0 :         inputSliceStride_ = inputSliceStride;
     126            0 :         outputSliceStride_ = outputSliceStride;
     127            0 :         inputRepeatStride_ = inputRepeatStride;
     128            0 :         outputRepeatStride_ = outputRepeatStride;
     129            0 :         stepInfoVector_ = stepInfoVector;
     130            0 :         indexMap_ = indexMap;
     131            0 :         token_ = token;
     132            0 :         isInputOutputEqual_ = isInputOutputEqual;
     133            0 :         op_ = op;
     134            0 :         tempVTopo_ = tempVTopo;
     135            0 :         return;
     136              :     }
     137              : 
     138            0 :     CcuInstType GetInstType() const override
     139              :     {
     140            0 :         HCCL_INFO("CcuInstructionAllGatherNHR1D instype is CCU_ALLGATHER_NHR_1D_MEM2MEM.");
     141            0 :         return instType_;
     142              :     }
     143              : 
     144            0 :     std::string Describe() const override
     145              :     {
     146              :         return StringFormat(
     147            0 :             "CcuInstructionAllGatherNHR1D rankId [%u], instType[%s]", rankId_, instType_.Describe().c_str());
     148              :     }
     149              : 
     150            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     151              :     {
     152            0 :         return std::make_unique<CcuCtxArgAllGatherNHR1D>(
     153            0 :             dimSize_, rankId_, axisId_, axisSize_, stepInfoVector_, indexMap_, op_, tempVTopo_);
     154              :     }
     155              : 
     156              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     157              : 
     158            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     159              :     {
     160            0 :         return std::make_unique<CcuTaskArgAllGatherNHR1D>(
     161            0 :             inputAddr_, outputAddr_, token_, die0Size_, die1Size_, repeatNum_, inputSliceStride_, outputSliceStride_,
     162            0 :             inputRepeatStride_, outputRepeatStride_, isInputOutputEqual_);
     163              :     }
     164              : 
     165              : private:
     166              :     std::vector<std::vector<RankId>> tempVTopo_;
     167              :     CcuInstType instType_ = CcuInstType::CCU_ALLGATHER_NHR_1D_MEM2MEM;
     168              :     std::vector<uint64_t> dimSize_;
     169              :     uint32_t rankId_{0};
     170              :     uint32_t axisId_{0};
     171              :     uint32_t axisSize_{0};
     172              :     uint64_t inputAddr_{0};
     173              :     uint64_t outputAddr_{0};
     174              :     uint64_t die1Size_{0};
     175              :     uint64_t die0Size_{0};
     176              :     uint64_t repeatNum_{0};
     177              :     uint64_t inputSliceStride_{0};
     178              :     uint64_t outputSliceStride_{0};
     179              :     uint64_t inputRepeatStride_{0};
     180              :     uint64_t outputRepeatStride_{0};
     181              :     uint64_t isInputOutputEqual_{0};
     182              :     std::vector<NHRStepInfo> stepInfoVector_;
     183              :     std::map<u32, u32> indexMap_;
     184              :     uint64_t token_{0};
     185              :     CollAlgOperator op_;
     186              : };
     187              : } // namespace Hccl
     188              : 
     189              : #endif // HCCLV2_CCU_INSTRUCTION_ALL_GATHER_NHR_1D_H_
        

Generated by: LCOV version 2.0-1