LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/all_to_all - ccu_instruction_all_to_all_mesh2d.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 78.7 % 61 48
Test Date: 2026-08-18 17:47:01 Functions: 54.5 % 11 6

            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_TO_ALL_MESH_2D_H
      12              : #define HCCLV2_CCU_INSTRUCTION_ALL_TO_ALL_MESH_2D_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 CcuCtxArgAlltoAllMesh2D : public CcuCtxArg {
      26              : public:
      27            3 :     CcuCtxArgAlltoAllMesh2D(
      28              :         const std::vector<uint32_t>& dSize, uint32_t rId, uint32_t aId, const CollAlgOperator& op,
      29              :         const std::vector<std::vector<RankId>>& tempVTopo)
      30            3 :         : CcuCtxArg(),
      31            3 :           dimSize(dSize),
      32            3 :           rankId(rId),
      33            3 :           axisId(aId),
      34            3 :           op(op),
      35            3 :           tempVTopo(tempVTopo)
      36            3 :     {}
      37              : 
      38            3 :     ~CcuCtxArgAlltoAllMesh2D() override {}
      39              : 
      40            7 :     CcuCtxSignature GetCtxSignature() const override
      41              :     {
      42            7 :         CcuCtxSignature signature;
      43            7 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_ALLTOALL_MESH_2D_DIRECT, op, tempVTopo);
      44           21 :         HCCL_INFO("[CcuCtxArgAlltoAllMesh2D][GetCtxSignature] signature[%s]", signature.GetData().c_str());
      45            7 :         return signature;
      46            0 :     }
      47              : 
      48              :     // 需要存储,传递给算法
      49              :     std::vector<uint32_t> dimSize;
      50              :     uint32_t rankId;
      51              :     uint32_t axisId;
      52              : 
      53              :     const CollAlgOperator& op;
      54              :     const std::vector<std::vector<RankId>>& tempVTopo;
      55              : };
      56              : 
      57              : class CcuTaskArgAlltoAllMesh2D : public CcuTaskArg {
      58              : public:
      59           24 :     explicit CcuTaskArgAlltoAllMesh2D(
      60              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t scratchAddr, uint64_t sendStride, uint64_t recvStride,
      61              :         uint64_t sendLength, uint64_t aSize, uint64_t bSize, uint64_t baseOffset, uint64_t token)
      62           24 :         : CcuTaskArg(),
      63           24 :           inputAddr(inputAddr),
      64           24 :           outputAddr(outputAddr),
      65           24 :           scratchAddr(scratchAddr),
      66           24 :           sendStride(sendStride),
      67           24 :           recvStride(recvStride),
      68           24 :           sendLength(sendLength),
      69           24 :           aSize(aSize),
      70           24 :           bSize(bSize),
      71           24 :           baseOffset(baseOffset),
      72           24 :           token(token)
      73           24 :     {}
      74              : 
      75              :     uint64_t inputAddr;
      76              :     uint64_t outputAddr;
      77              :     uint64_t scratchAddr;
      78              :     uint64_t sendStride;
      79              :     uint64_t recvStride;
      80              :     uint64_t sendLength;
      81              :     uint64_t aSize; // X方向第一轮传输的数据量
      82              :     uint64_t bSize;
      83              :     uint64_t baseOffset; // 多轮执行时的基础偏移,等于step*(aSize+bSize)
      84              :     uint64_t token;
      85              : };
      86              : 
      87              : class CcuInstructionAlltoAllMesh2D : public CcuInstruction {
      88              : public:
      89            4 :     CcuInstructionAlltoAllMesh2D(
      90              :         const CollAlgOperator& op, const std::vector<uint32_t>& dimSize,
      91              :         const std::vector<std::vector<RankId>>& tempVTopo)
      92            4 :         : CcuInstruction(),
      93            4 :           op_(op),
      94            4 :           dimSize_(dimSize),
      95            8 :           tempVTopo_(tempVTopo)
      96            4 :     {}
      97              : 
      98            4 :     void Init(
      99              :         uint32_t rankId, uint64_t inputAddr, uint64_t outputAddr, uint64_t scratchAddr, uint64_t axisId,
     100              :         uint64_t sendStride, uint64_t recvStride, uint64_t sendLength, uint64_t aSize, uint64_t bSize,
     101              :         uint64_t baseOffset, uint64_t token)
     102              :     {
     103            4 :         rankId_ = rankId;
     104            4 :         inputAddr_ = inputAddr;
     105            4 :         outputAddr_ = outputAddr;
     106            4 :         scratchAddr_ = scratchAddr;
     107            4 :         axisId_ = axisId;
     108            4 :         sendStride_ = sendStride;
     109            4 :         recvStride_ = recvStride;
     110            4 :         sendLength_ = sendLength;
     111            4 :         aSize_ = aSize;
     112            4 :         bSize_ = bSize;
     113            4 :         baseOffset_ = baseOffset;
     114            4 :         token_ = token;
     115           12 :         HCCL_INFO(
     116              :             "[CcuInstructionAlltoAllMesh2D][Init] rankId[%u] inputAddr[%llu] outputAddr[%llu] scratchAddr[%llu],\
     117              : axisId[%u], sendStride[%llu], recvStride[%llu], sendLength[%llu], aSize[%llu], bSize[%llu], baseOffset[%llu], \
     118              : dimSize.size[%u], tempVTopo.size[%u]",
     119              :             rankId_, inputAddr_, outputAddr_, scratchAddr_, axisId_, sendStride_, recvStride_, sendLength_, aSize_,
     120              :             bSize_, baseOffset_, dimSize_.size(), tempVTopo_.size());
     121            4 :         return;
     122              :     }
     123              : 
     124            0 :     CcuInstType GetInstType() const override
     125              :     {
     126            0 :         HCCL_INFO("CcuInstructionAllGatherMesh1D instype is CCU_ALLTOALL_MESH_2D_DIRECT.");
     127            0 :         return instType_;
     128              :     }
     129              : 
     130            0 :     std::string Describe() const override
     131              :     {
     132            0 :         return StringFormat("[CcuInstructionAllGatherMesh1D]RankId[%u] Ins[%s]", rankId_, instType_.Describe().c_str());
     133              :     }
     134              : 
     135            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     136              :     {
     137            0 :         HCCL_INFO(
     138              :             "[CcuInstructionAlltoAllMesh2D][GetCtxArg] dimSize.size[%u], rankId[%u], axisId[%u], tempVTopo.size[%u]",
     139              :             dimSize_.size(), rankId_, axisId_, tempVTopo_.size());
     140            0 :         return std::make_unique<CcuCtxArgAlltoAllMesh2D>(dimSize_, rankId_, axisId_, op_, tempVTopo_);
     141              :     }
     142              : 
     143              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     144              : 
     145            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     146              :     {
     147            0 :         return std::make_unique<CcuTaskArgAlltoAllMesh2D>(
     148            0 :             inputAddr_, outputAddr_, scratchAddr_, sendStride_, recvStride_, sendLength_, aSize_, bSize_, baseOffset_,
     149            0 :             token_);
     150              :     }
     151              : 
     152              : private:
     153              :     CollAlgOperator op_;
     154              :     std::vector<uint32_t> dimSize_;
     155              :     std::vector<std::vector<RankId>> tempVTopo_;
     156              : 
     157              :     CcuInstType instType_ = CcuInstType::CCU_ALLTOALL_MESH_2D_DIRECT;
     158              : 
     159              :     uint32_t rankId_{0};
     160              :     uint64_t inputAddr_{0};
     161              :     uint64_t outputAddr_{0};
     162              :     uint64_t scratchAddr_{0};
     163              :     uint64_t sendStride_{0};
     164              :     uint64_t recvStride_{0};
     165              :     uint64_t axisId_{0};
     166              :     uint64_t sendLength_{0}; // 多轮时的单个数据块总大小
     167              :     uint64_t aSize_{0};
     168              :     uint64_t bSize_{0};
     169              :     uint64_t baseOffset_{0};
     170              :     uint64_t token_{0};
     171              : };
     172              : 
     173              : } // namespace Hccl
     174              : #endif // HCCLV2_CCU_INSTRUCTION_ALL_TO_ALL_MESH_2D_H
        

Generated by: LCOV version 2.0-1