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-18 17:47:01 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_v2.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(
      46              :         const CollAlgOperator& op, const CollAlgParams& params, std::string& algName, OpExecuteConfig& opExecuteConfig);
      47              :     AlgorithmType GetAlgorithmTypeForMC2CCU(const std::string& name);
      48              :     // Host
      49              :     virtual HcclResult Orchestrate(
      50              :         const CollAlgOperator& op, const CollAlgParams& params, const string& algName,
      51              :         PrimQuePtr queue); // Primitive based
      52              :     virtual HcclResult Orchestrate(
      53              :         const CollAlgOperator& op, const CollAlgParams& params, const string& algName,
      54              :         InsQuePtr queue); // Instruction based
      55              :     virtual HcclResult CalcResOffload(
      56              :         const OpType& opType, const u64& dataSize, const HcclDataType& dataType, const OpExecuteConfig& opExecuteConfig,
      57              :         CollOffloadOpResReq& resReq);
      58              :     HcclResult CalcTaskNum(OpType opType, DataType dataType, u32 count, u32& taskNum);
      59              : 
      60              :     HcclResult CalNumBlocks(u32& numBlocks, u64 dataSize, OpType opType, string& algName, u32 numBlocksLimit) const;
      61              : 
      62              :     // for AICPU
      63              :     virtual std::vector<std::string>
      64              :     GetOpAlgNames(const OpType& opType, const OrchestMode& orchestMode = OrchestMode::PRIMITIVE);
      65              :     virtual CollAlgResReq GetCollAlgResReqByName(
      66              :         const OpType& opType, const std::string& algName, const OrchestMode& orchestMode = OrchestMode::PRIMITIVE);
      67              :     virtual CollAlgOpReq GetCollAlgOpReq(const CollAlgOperator& op, const std::string& collAlgName);
      68              : 
      69              : protected:
      70              :     HcclResult SetCollAlgExecutor(std::shared_ptr<CollAlgBase> collAlgExecutor) const;
      71              :     HcclResult SetInsCollAlgExecutor(std::shared_ptr<InsCollAlgBase> insCollAlgExecutor) const;
      72              : 
      73              :     RankGraph* rankGraph_ = nullptr;
      74              :     DevType devType_ = DevType::DEV_TYPE_NOSOC;
      75              :     u32 myRank_ = INVALID_RANKID;
      76              :     u32 rankSize_ = 0;
      77              : 
      78              :     bool enableDetour_ = false;
      79              :     bool enableAllign_ = false;
      80              :     u64 allignSize_ = 0;
      81              : 
      82              :     u32 maxQueue_ = 0;
      83              :     u32 maxLink_ = 0;
      84              :     u32 maxDepQueuePairs_ = 0;
      85              :     DmaMode dmaMode_ = DmaMode::DEFAULT;
      86              :     std::map<std::string, CollAlgResReq> algName2Res;
      87              :     std::shared_ptr<ExecuteSelector> collAlgSelector_;
      88              : 
      89              : private:
      90              :     void GetNHRStepNum(u32& nSteps) const;
      91              :     HcclResult CalcTaskNumMesh(OpType opType, u64 dataSize, u64 scratchBufSize, u32& taskNum);
      92              :     HcclResult CalcTaskNumNHR(OpType opType, u32& taskNum) const;
      93              :     void GetRoundByBufferSize(OpType opType, u64 dataSize, u64 scratchBufSize, u32& roundNum, u32& extraNum) const;
      94              : };
      95              : 
      96              : using CollAlgComponentPtr = std::shared_ptr<CollAlgComponent>;
      97              : } // namespace Hccl
      98              : #endif
        

Generated by: LCOV version 2.0-1