LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/interface/host - coll_alg_component.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 1 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 1 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_COLL_ALG_COMPONENT
      12              : #define HCCLV2_COLL_ALG_COMPONENT
      13              : 
      14              : #include "coll_alg_params.h"
      15              : #include "coll_operator.h"
      16              : #include "prim_queue.h"
      17              : #include "ins_queue.h"
      18              : #include "virtual_topo.h"
      19              : #include "execute_selector.h"
      20              : #include "mc2_selector.h"
      21              : #include "coll_alg_registry.h"
      22              : #include "ins_coll_alg_registry.h"
      23              : #include "env_func.h"
      24              : #include "env_config.h"
      25              : 
      26              : namespace Hccl {
      27              : 
      28              : using PrimQuePtr = std::shared_ptr<PrimQueue>;
      29              : using InsQuePtr  = std::shared_ptr<InsQueue>;
      30              : 
      31            0 : MAKE_ENUM(OrchestMode, PRIMITIVE, INSTRUCTION)
      32              : 
      33              : class CollAlgComponent {
      34              : public:
      35              :     CollAlgComponent(RankGraph *rankGraph, DevType devType, u32 myRank, u32 rankSize);
      36              : 
      37              :     void EnableDetour(bool enableDetour);
      38              :     void EnableDataAllign(bool enableAllign);
      39              :     void SetAllignSize(u64 allignSize);
      40              :     void SetMaxQueue(u32 maxQueue);
      41              :     void SetMaxLink(u32 maxLink);
      42              :     void SetMaxDepQueuePairs(u32 maxDepQueuePairs);
      43              :     void SetDmaMode(const DmaMode dmaMode);
      44              :     std::vector<char> GetPackedData() const;
      45              :     HcclResult ExecAlgSelect(const CollAlgOperator &op, const CollAlgParams &params, std::string &algName, OpExecuteConfig &opExecuteConfig);
      46              :     AlgorithmType GetAlgorithmTypeForMC2CCU(const std::string& name);
      47              :     // Host
      48              :     virtual HcclResult Orchestrate(const CollAlgOperator &op, const CollAlgParams &params,
      49              :                                    const string &algName, PrimQuePtr queue); // Primitive based
      50              :     virtual HcclResult Orchestrate(const CollAlgOperator &op, const CollAlgParams &params,
      51              :                                    const string &algName, InsQuePtr queue); // Instruction based
      52              :     virtual HcclResult CalcResOffload(const OpType &opType, const u64 &dataSize, const HcclDataType &dataType, const OpExecuteConfig &opExecuteConfig,
      53              :                                       CollOffloadOpResReq &resReq);
      54              :     HcclResult CalcTaskNum(OpType opType, DataType dataType, u32 count, u32 &taskNum);
      55              : 
      56              :     HcclResult CalNumBlocks(u32& numBlocks, u64 dataSize, OpType opType, string &algName, u32 numBlocksLimit) const;
      57              :     
      58              :     // for AICPU
      59              :     virtual std::vector<std::string> GetOpAlgNames(const OpType      &opType,
      60              :                                                    const OrchestMode &orchestMode = OrchestMode::PRIMITIVE);
      61              :     virtual CollAlgResReq            GetCollAlgResReqByName(const OpType &opType, const std::string &algName,
      62              :                                                             const OrchestMode &orchestMode = OrchestMode::PRIMITIVE);
      63              :     virtual CollAlgOpReq             GetCollAlgOpReq(const CollAlgOperator &op,
      64              :                                                      const std::string  &collAlgName);
      65              : 
      66              : protected:
      67              :     HcclResult SetCollAlgExecutor(std::shared_ptr<CollAlgBase> collAlgExecutor) const;
      68              :     HcclResult SetInsCollAlgExecutor(std::shared_ptr<InsCollAlgBase> insCollAlgExecutor) const;
      69              : 
      70              :     RankGraph *rankGraph_ = nullptr;
      71              :     DevType      devType_     = DevType::DEV_TYPE_NOSOC;
      72              :     u32          myRank_      = INVALID_RANKID;
      73              :     u32          rankSize_    = 0;
      74              : 
      75              :     bool enableDetour_ = false;
      76              :     bool enableAllign_ = false;
      77              :     u64  allignSize_   = 0;
      78              : 
      79              :     u32     maxQueue_         = 0;
      80              :     u32     maxLink_          = 0;
      81              :     u32     maxDepQueuePairs_ = 0;
      82              :     DmaMode dmaMode_          = DmaMode::DEFAULT;
      83              :     std::map<std::string, CollAlgResReq> algName2Res;
      84              :     std::shared_ptr<ExecuteSelector> collAlgSelector_;
      85              : 
      86              : private:
      87              :     void GetNHRStepNum(u32 &nSteps) const;
      88              :     HcclResult CalcTaskNumMesh(OpType opType, u64 dataSize, u64 scratchBufSize, u32 &taskNum);
      89              :     HcclResult CalcTaskNumNHR(OpType opType, u32 &taskNum) const;
      90              :     void GetRoundByBufferSize(OpType opType, u64 dataSize, u64 scratchBufSize, u32 &roundNum, u32 &extraNum) const;
      91              : };
      92              : 
      93              : using CollAlgComponentPtr = std::shared_ptr<CollAlgComponent>;
      94              : } // namespace Hccl
      95              : #endif
        

Generated by: LCOV version 2.0-1