LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/broadcast - ccu_instruction_broadcast_mesh1d.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 42 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 9 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_BROADCAST_MESH_1D_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_BROADCAST_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              : // 为BroadcastMesh1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      25              : class CcuCtxArgBroadcastMesh1D : public CcuCtxArg {
      26              : public:
      27            0 :     explicit CcuCtxArgBroadcastMesh1D(const std::vector<uint64_t> &dSize, uint32_t missionId, uint32_t rId,
      28              :         uint32_t rootId, const CollAlgOperator &op, const std::vector<std::vector<RankId>> &tempVTopo,
      29            0 :         const CcuInstType insType) :
      30            0 :             dimSize_(dSize), missionId_(missionId), rankId_(rId), rootId_(rootId), op_(op), tempVTopo_(tempVTopo),
      31            0 :             ccuInsType_(insType) {}
      32            0 :     CcuCtxSignature GetCtxSignature() const override
      33              :     {
      34            0 :         CcuCtxSignature signature;
      35            0 :         GenerateCcuCtxSignature(signature, ccuInsType_, op_, tempVTopo_);
      36            0 :         return signature;
      37            0 :     }
      38              : 
      39              :     std::vector<uint64_t> dimSize_;
      40              :     uint32_t missionId_;
      41              :     uint32_t rankId_;
      42              :     uint32_t rootId_;
      43              :     CollAlgOperator op_;
      44              :     std::vector<std::vector<RankId>> tempVTopo_;
      45              :     CcuInstType ccuInsType_;
      46              : };
      47              : 
      48              : class CcuTaskArgBroadcastMesh1D : public CcuTaskArg {
      49              : public:
      50            0 :     explicit CcuTaskArgBroadcastMesh1D(uint64_t inputAddr, uint64_t outputAddr, uint64_t sliceSize, uint64_t offset,
      51            0 :         uint64_t token) :
      52            0 :         inputAddr_(inputAddr), outputAddr_(outputAddr), sliceSize_(sliceSize), offset_(offset), token_(token) {}
      53              : 
      54              :     uint64_t inputAddr_;
      55              :     uint64_t outputAddr_;
      56              :     uint64_t sliceSize_;
      57              :     uint64_t offset_;
      58              :     uint64_t token_;
      59              : };
      60              : 
      61              : class CcuInstructionBroadcastMesh1D : public CcuInstruction {
      62              : public:
      63            0 :     CcuInstructionBroadcastMesh1D() : CcuInstruction()
      64              :     {
      65            0 :     }
      66              : 
      67            0 :     void Init(uint32_t rankId, uint32_t rootId, uint64_t inputAddr, uint64_t outputAddr,
      68              :         uint64_t sliceSize, uint64_t offset, uint64_t token, CollAlgOperator &op,
      69              :         std::vector<std::vector<RankId>> &tempVTopo, uint32_t missionId = 0)
      70              :     {
      71            0 :         u32 maxDimNum = 1;
      72            0 :         if (tempVTopo.size() != maxDimNum) {
      73            0 :             THROW<InvalidParamsException>(StringFormat(
      74              :                 "[CcuInstructionBroadcastMesh1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
      75              :         }
      76            0 :         dimSize_.push_back(tempVTopo[0].size());
      77            0 :         missionId_  = missionId;
      78            0 :         rankId_     = rankId;
      79            0 :         rootId_     = rootId; // add
      80            0 :         inputAddr_  = inputAddr;
      81            0 :         outputAddr_ = outputAddr;
      82            0 :         sliceSize_  = sliceSize;
      83            0 :         token_      = token;
      84            0 :         offset_     = offset;
      85            0 :         op_         = op;
      86            0 :         tempVTopo_  = tempVTopo;
      87            0 :         return;
      88              :     }
      89              : 
      90            0 :     CcuInstType GetInstType() const override
      91              :     {
      92            0 :         HCCL_INFO("CcuInstructionBroadcastMesh1D instype is CCU_BROADCAST_MESH_1D_DIRECT.");
      93            0 :         return instType_;
      94              :     }
      95              : 
      96            0 :     std::string Describe() const override
      97              :     {
      98            0 :         return StringFormat("CcuInstructionBroadcastMesh1D rankId [%u], instType[%d]", rankId_, instType_);
      99              :     }
     100              : 
     101              :     void SetInstType(CcuInstType instType) 
     102              :     { 
     103              :         instType_ = instType; 
     104              :     }
     105              : 
     106            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     107              :     {
     108            0 :         HCCL_INFO("[BroadcastAlgo]GetCtxArg begin");
     109            0 :         return std::make_unique<CcuCtxArgBroadcastMesh1D>(dimSize_, missionId_, rankId_, rootId_, op_,
     110            0 :             tempVTopo_, instType_);
     111              :     }
     112              : 
     113            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     114              :     {
     115            0 :         HCCL_INFO("[BroadcastAlgo]GetTaskArg begin");
     116            0 :         return std::make_unique<CcuTaskArgBroadcastMesh1D>(inputAddr_, outputAddr_, sliceSize_, offset_, token_);
     117              :     }
     118              : 
     119              : private:
     120              :     CcuInstType instType_ = CcuInstType::CCU_BROADCAST_MESH_1D_DIRECT;
     121              :     std::vector<uint64_t> dimSize_;
     122              :     uint32_t missionId_{0};
     123              :     uint32_t rankId_{0};
     124              :     uint32_t rootId_{0}; // add
     125              :     uint64_t inputAddr_{0};
     126              :     uint64_t outputAddr_{0};
     127              :     uint64_t sliceSize_{0};
     128              :     uint64_t offset_{0};
     129              :     uint64_t token_{0};
     130              : 
     131              :     CollAlgOperator op_;
     132              :     std::vector<std::vector<RankId>> tempVTopo_;
     133              : };
     134              : 
     135              : }
     136              : #endif // HCCLV2_CCU_INSTRUCTION_BROADCAST_MESH_1D_H_
        

Generated by: LCOV version 2.0-1