LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/scatter - ccu_instruction_scatter_nhr1d_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 76 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_SCATTER_NHR_1D_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_SCATTER_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              : using NHRStepInfo = struct NHRStepInfoDef {
      24              :     u32 step = 0;
      25              :     u32 myRank = 0;
      26              :     u32 nSlices;
      27              :     u32 toRank = 0;
      28              :     u32 fromRank = 0;
      29              :     std::vector<u32> txSliceIdxs;
      30              :     std::vector<u32> rxSliceIdxs;
      31            0 :     NHRStepInfoDef() : nSlices(0) {}
      32              : };
      33              : 
      34              : // 为ScatterNHR1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      35              : class CcuCtxArgScatterNHR1D : public CcuCtxArg {
      36              : public:
      37            0 :     explicit CcuCtxArgScatterNHR1D(
      38              :         const std::vector<uint64_t>& dimSize, uint32_t rankId, uint32_t rootId, uint32_t axisId, uint32_t axisSize,
      39              :         const std::vector<NHRStepInfo> stepInfoVector, const std::map<u32, u32> indexMap, const CollAlgOperator& op,
      40              :         const std::vector<std::vector<RankId>>& tempVTopo)
      41            0 :         : dimSize_(dimSize),
      42            0 :           rankId_(rankId),
      43            0 :           rootId_(rootId),
      44            0 :           axisId_(axisId),
      45            0 :           axisSize_(axisSize),
      46            0 :           stepInfoVector_(stepInfoVector),
      47            0 :           indexMap_(indexMap),
      48            0 :           op_(op),
      49            0 :           tempVTopo_(tempVTopo)
      50            0 :     {}
      51            0 :     CcuCtxSignature GetCtxSignature() const override
      52              :     {
      53            0 :         CcuCtxSignature signature;
      54            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_SCATTER_NHR_1D_MEM2MEM, op_, tempVTopo_);
      55            0 :         return signature;
      56            0 :     }
      57              :     std::vector<uint64_t> dimSize_;
      58              :     uint64_t rankId_;
      59              :     uint64_t rootId_;
      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 CcuTaskArgScatterNHR1D : public CcuTaskArg {
      69              : public:
      70            0 :     explicit CcuTaskArgScatterNHR1D(
      71              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t scratchAddr, uint64_t token, uint64_t sliceSize,
      72              :         uint64_t die0Size, uint64_t die1Size, uint64_t inputSliceStride, uint64_t outputSliceStride,
      73              :         uint64_t inputRepeatStride, uint64_t outputRepeatStride, uint64_t repeatNum, uint64_t repeatNumVar,
      74              :         uint64_t isOutputScratch)
      75            0 :         : inputAddr_(inputAddr),
      76            0 :           outputAddr_(outputAddr),
      77            0 :           scratchAddr_(scratchAddr),
      78            0 :           token_(token),
      79            0 :           sliceSize_(sliceSize),
      80            0 :           die0Size_(die0Size),
      81            0 :           die1Size_(die1Size),
      82            0 :           inputSliceStride_(inputSliceStride),
      83            0 :           outputSliceStride_(outputSliceStride),
      84            0 :           inputRepeatStride_(inputRepeatStride),
      85            0 :           outputRepeatStride_(outputRepeatStride),
      86            0 :           repeatNum_(repeatNum),
      87            0 :           repeatNumVar_(repeatNumVar),
      88            0 :           isOutputScratch_(isOutputScratch)
      89            0 :     {}
      90              : 
      91              :     uint64_t inputAddr_;
      92              :     uint64_t outputAddr_;
      93              :     uint64_t scratchAddr_;
      94              :     uint64_t token_;
      95              :     uint64_t sliceSize_;
      96              :     uint64_t die0Size_;
      97              :     uint64_t die1Size_;
      98              :     uint64_t inputSliceStride_;
      99              :     uint64_t outputSliceStride_;
     100              :     uint64_t inputRepeatStride_;
     101              :     uint64_t outputRepeatStride_;
     102              :     uint64_t repeatNum_;
     103              :     uint64_t repeatNumVar_;
     104              :     uint64_t isOutputScratch_;
     105              : };
     106              : 
     107              : class CcuInstructionScatterNHR1D : public CcuInstruction {
     108              : public:
     109            0 :     CcuInstructionScatterNHR1D() : CcuInstruction() {}
     110              : 
     111            0 :     void Init(
     112              :         uint32_t rankId, uint32_t rootId, uint64_t inputAddr, uint64_t outputAddr, uint64_t scratchAddr,
     113              :         uint64_t axisId, uint64_t axisSize, uint64_t sliceSize, uint64_t die0Size, uint64_t die1Size,
     114              :         uint64_t inputSliceStride, uint64_t outputSliceStride, uint64_t inputRepeatStride, uint64_t outputRepeatStride,
     115              :         uint32_t repeatNum, uint64_t repeatNumVar, std::vector<NHRStepInfo> stepInfoVector, std::map<u32, u32> indexMap,
     116              :         uint64_t token, CollAlgOperator& op, std::vector<std::vector<RankId>>& tempVTopo, uint64_t isOutputScratch)
     117              :     {
     118            0 :         u32 maxDimNum = 1;
     119            0 :         if (tempVTopo.size() != maxDimNum) {
     120            0 :             THROW<InvalidParamsException>(
     121            0 :                 StringFormat("[CcuInstructionScatterNHR1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
     122              :         }
     123            0 :         dimSize_.push_back(tempVTopo[0].size());
     124            0 :         rankId_ = rankId;
     125            0 :         rootId_ = rootId;
     126            0 :         token_ = token;
     127            0 :         inputAddr_ = inputAddr;
     128            0 :         outputAddr_ = outputAddr;
     129            0 :         scratchAddr_ = scratchAddr;
     130            0 :         axisId_ = axisId;
     131            0 :         axisSize_ = axisSize;
     132            0 :         sliceSize_ = sliceSize;
     133            0 :         die0Size_ = die0Size;
     134            0 :         die1Size_ = die1Size;
     135            0 :         inputSliceStride_ = inputSliceStride;
     136            0 :         outputSliceStride_ = outputSliceStride;
     137            0 :         inputRepeatStride_ = inputRepeatStride;
     138            0 :         outputRepeatStride_ = outputRepeatStride;
     139            0 :         stepInfoVector_ = stepInfoVector;
     140            0 :         indexMap_ = indexMap;
     141            0 :         token_ = token;
     142            0 :         op_ = op;
     143            0 :         tempVTopo_ = tempVTopo;
     144            0 :         repeatNum_ = repeatNum;
     145            0 :         repeatNumVar_ = repeatNumVar;
     146            0 :         isOutputScratch_ = isOutputScratch;
     147            0 :         return;
     148              :     }
     149              : 
     150            0 :     CcuInstType GetInstType() const override
     151              :     {
     152            0 :         HCCL_INFO("CcuInstructionScatterNHR1D instype is CCU_SCATTER_NHR_1D_MEM2MEM.");
     153            0 :         return instType_;
     154              :     }
     155              : 
     156            0 :     std::string Describe() const override
     157              :     {
     158              :         return StringFormat(
     159            0 :             "CcuInstructionScatterNHR1D rankId [%u], instType[%s]", rankId_, instType_.Describe().c_str());
     160              :     }
     161              : 
     162              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     163              : 
     164            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     165              :     {
     166            0 :         return std::make_unique<CcuCtxArgScatterNHR1D>(
     167            0 :             dimSize_, rankId_, rootId_, axisId_, axisSize_, stepInfoVector_, indexMap_, op_, tempVTopo_);
     168              :     }
     169              : 
     170            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     171              :     {
     172            0 :         return std::make_unique<CcuTaskArgScatterNHR1D>(
     173            0 :             inputAddr_, outputAddr_, scratchAddr_, token_, sliceSize_, die0Size_, die1Size_, inputSliceStride_,
     174            0 :             outputSliceStride_, inputRepeatStride_, outputRepeatStride_, repeatNum_, repeatNumVar_, isOutputScratch_);
     175              :     }
     176              : 
     177              : private:
     178              :     CcuInstType instType_ = CcuInstType::CCU_SCATTER_NHR_1D_MEM2MEM;
     179              :     std::vector<uint64_t> dimSize_;
     180              :     CollAlgOperator op_;
     181              :     uint32_t rankId_{0};
     182              :     uint32_t rootId_{0};
     183              :     uint32_t axisId_{0};
     184              :     uint32_t axisSize_{0};
     185              :     uint32_t sliceSize_{0};
     186              :     uint64_t inputAddr_{0};
     187              :     uint64_t outputAddr_{0};
     188              :     uint64_t scratchAddr_{0};
     189              :     uint64_t die0Size_{0};
     190              :     uint64_t die1Size_{0};
     191              :     uint64_t inputSliceStride_{0};
     192              :     uint64_t outputSliceStride_{0};
     193              :     uint64_t inputRepeatStride_{0};
     194              :     uint64_t outputRepeatStride_{0};
     195              :     uint32_t repeatNum_{0};
     196              :     uint64_t repeatNumVar_{0};
     197              :     uint64_t isOutputScratch_{0};
     198              :     std::vector<NHRStepInfo> stepInfoVector_;
     199              :     std::map<u32, u32> indexMap_;
     200              :     uint64_t token_{0};
     201              :     std::vector<std::vector<RankId>> tempVTopo_;
     202              : };
     203              : } // namespace Hccl
     204              : 
     205              : #endif // HCCLV2_CCU_INSTRUCTION_SCATTER_NHR_1D_H_
        

Generated by: LCOV version 2.0-1