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_mesh1d.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 64.3 % 42 27
Test Date: 2026-08-18 17:47:01 Functions: 88.9 % 9 8

            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_MESH_1D_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_ALL_GATHER_MESH_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              : // 为AllGatherMesh1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      25              : class CcuCtxArgAllGatherMesh1D : public CcuCtxArg {
      26              : public:
      27           10 :     explicit CcuCtxArgAllGatherMesh1D(
      28              :         const std::vector<uint64_t>& dSize, uint32_t rId, const CollAlgOperator& op,
      29              :         const std::vector<std::vector<RankId>>& tempVTopo)
      30           20 :         : dimSize_(dSize),
      31           10 :           rankId_(rId),
      32           10 :           op_(op),
      33           20 :           tempVTopo_(tempVTopo)
      34           10 :     {}
      35           12 :     CcuCtxSignature GetCtxSignature() const override
      36              :     {
      37           12 :         CcuCtxSignature signature;
      38           12 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_ALLGATHER_MESH_1D_DIRECT, op_, tempVTopo_);
      39           12 :         return signature;
      40            0 :     }
      41              :     std::vector<uint64_t> dimSize_;
      42              :     uint32_t rankId_;
      43              :     CollAlgOperator op_;
      44              :     std::vector<std::vector<RankId>> tempVTopo_;
      45              : };
      46              : 
      47              : class CcuTaskArgAllGatherMesh1D : public CcuTaskArg {
      48              : public:
      49           12 :     explicit CcuTaskArgAllGatherMesh1D(
      50              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t sliceSize, uint64_t offset, uint64_t token)
      51           24 :         : inputAddr_(inputAddr),
      52           12 :           outputAddr_(outputAddr),
      53           12 :           sliceSize_(sliceSize),
      54           12 :           offset_(offset),
      55           12 :           token_(token)
      56           12 :     {}
      57              : 
      58              :     uint64_t inputAddr_;
      59              :     uint64_t outputAddr_;
      60              :     uint64_t sliceSize_;
      61              :     uint64_t offset_;
      62              :     uint64_t token_;
      63              : };
      64              : 
      65              : class CcuInstructionAllGatherMesh1D : public CcuInstruction {
      66              : public:
      67           39 :     CcuInstructionAllGatherMesh1D() : CcuInstruction() {}
      68              : 
      69            0 :     void Init(
      70              :         uint32_t rankId, uint64_t inputAddr, uint64_t outputAddr, uint64_t sliceSize, uint64_t offset, uint64_t token,
      71              :         CollAlgOperator& op, std::vector<std::vector<RankId>>& tempVTopo)
      72              :     {
      73            0 :         u32 maxDimNum = 1;
      74            0 :         if (tempVTopo.size() != maxDimNum) {
      75            0 :             THROW<InvalidParamsException>(StringFormat(
      76              :                 "[CcuInstructionAllGatherMesh1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
      77              :         }
      78            0 :         dimSize_.push_back(tempVTopo[0].size());
      79            0 :         rankId_ = rankId;
      80            0 :         inputAddr_ = inputAddr;
      81            0 :         outputAddr_ = outputAddr;
      82            0 :         sliceSize_ = sliceSize;
      83            0 :         token_ = token;
      84            0 :         op_ = op;
      85            0 :         tempVTopo_ = tempVTopo;
      86            0 :         offset_ = offset;
      87            0 :         return;
      88              :     }
      89              : 
      90              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
      91              : 
      92           11 :     std::string Describe() const override
      93              :     {
      94              :         return StringFormat(
      95           11 :             "CcuInstructionAllGatherMesh1D rankId [%u], instType[%s]", rankId_, instType_.Describe().c_str());
      96              :     }
      97              : 
      98            6 :     CcuInstType GetInstType() const override
      99              :     {
     100           18 :         HCCL_INFO("CcuInstructionAllGatherMesh1D instype is CCU_ALLGATHER_MESH_1D_DIRECT.");
     101            6 :         return instType_;
     102              :     }
     103              : 
     104           10 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     105              :     {
     106           10 :         return std::make_unique<CcuCtxArgAllGatherMesh1D>(dimSize_, rankId_, op_, tempVTopo_);
     107              :     }
     108              : 
     109           12 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     110              :     {
     111           12 :         return std::make_unique<CcuTaskArgAllGatherMesh1D>(inputAddr_, outputAddr_, sliceSize_, offset_, token_);
     112              :     }
     113              : 
     114              : private:
     115              :     CcuInstType instType_ = CcuInstType::CCU_ALLGATHER_MESH_1D_DIRECT;
     116              :     std::vector<uint64_t> dimSize_;
     117              :     uint32_t rankId_{0};
     118              :     uint64_t inputAddr_{0};
     119              :     uint64_t outputAddr_{0};
     120              :     uint64_t sliceSize_{0};
     121              :     uint64_t offset_{0};
     122              :     uint64_t token_{0};
     123              :     CollAlgOperator op_;
     124              :     std::vector<std::vector<RankId>> tempVTopo_;
     125              : };
     126              : 
     127              : } // namespace Hccl
     128              : #endif // HCCLV2_CCU_INSTRUCTION_ALL_GATHER_MESH_1D_H_
        

Generated by: LCOV version 2.0-1