LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/ccu/ccu_mc2 - mc2_compont.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 1 1

            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 MC2_COMPONT_H
      12              : #define MC2_COMPONT_H
      13              : 
      14              : #include <memory>
      15              : #include "communicator_impl.h"
      16              : #include "ins_exe_que.h"
      17              : #include "mc2_type.h"
      18              : #include "task_param.h"
      19              : 
      20              : namespace Hccl {
      21              : 
      22              : struct HcclAlgoInfo {
      23              :     uint32_t opType;
      24              :     uint8_t  algorithmType;
      25              : };
      26              : 
      27              : class Mc2Compont {
      28              : public:
      29          256 :     explicit Mc2Compont(CommunicatorImpl *comm) : comm(comm)
      30              :     {
      31          256 :     }
      32              :     ~Mc2Compont();
      33              :     Mc2Compont(const Mc2Compont &that) = delete;
      34              :     Mc2Compont &operator=(const Mc2Compont &that) = delete;
      35              :     Mc2Compont(Mc2Compont &&that) = delete;
      36              :     Mc2Compont &operator=(Mc2Compont &&that) = delete;
      37              : 
      38              :     void AllocCommResource(void *mc2Tiling, void **commContext);
      39              :     std::vector<CcuTaskParam> GetCcuTaskInfo(void *tilingData);
      40              :     std::vector<CcuTaskParam> GetAlgoCcuTaskInfo(InsExeQue::ExtInsExeEntityId execId) const;
      41              :     u32 GetCcuMc2ServerNum();
      42              : 
      43              : private:
      44              :     void     Alloc();
      45              :     void     AllocV2();
      46              :     void     GenerateCcuServer(const std::unordered_set<uint64_t> &algoTemplateRequire);
      47              :     bool     FindCcuServer(const std::unordered_set<uint64_t> &algoTemplateRequire,
      48              :                            InsExeQue::ExtInsExeEntityId       &execId) const;
      49              :     void     GenerateAlgoTemplates(Mc2Tiling *mc2TilingPtr, std::unordered_set<uint64_t> &algoTemplateRequire);
      50              :     void     GenerateAlgoTemplatesV2(const Mc2InitTilingInner *mc2TilingPtr, std::unordered_set<uint64_t> &algoTemplateRequire);
      51              :     void     FillCollOperator(const Mc2CommConfig &config);
      52              :     void     FillCollOperatorV2(const Mc2CcTilingInner &config);
      53              :     uint64_t GetTemplateSignature(const Mc2CommConfig &config) const;
      54              :     uint64_t GetTemplateSignatureV2(const Mc2CcTilingInner &config) const;
      55              :     void     SaveMc2DfxTaskInfo(const CcuTaskParam& ccuTaskParam, uint64_t execId) const;
      56              :     bool     CompareMissionMap(const std::map<uint8_t, std::map<uint32_t, uint32_t>> &mapA,
      57              :                                const std::map<uint8_t, std::map<uint32_t, uint32_t>> &mapB) const;
      58              :     void     MC2Orchestrate(const CollAlgParams& params, std::shared_ptr<InsQueue>& insQueue, uint8_t commEngine) const;
      59              :     void     MC2AllocCommRes(const CollAlgParams& params, std::shared_ptr<InsQueue>& insQueue, uint8_t commEngine) const;
      60              :     void     SaveAlgoInfo(uint32_t index, uint64_t templateSign, uint32_t opType, uint8_t algorithmType);
      61              : private:
      62              :     const uint32_t dataCount = 1024;
      63              :     CommunicatorImpl *comm;
      64              :     // algoTemplateMap已经生成的算子集合; key:签名, value: taskParam
      65              :     std::unordered_map<uint64_t, std::vector<std::vector<CcuTaskParam>>> algoTemplateMap;
      66              :     std::unordered_map<uint64_t, HcclAlgoInfo> algoInfoMap_;
      67              :     // ccuServer已经生成的server集合; key:execId, value:该server支持的算子签名
      68              :     std::unordered_map<InsExeQue::ExtInsExeEntityId, std::unordered_set<uint64_t>> ccuServerMap;
      69              : 
      70              :     std::shared_ptr<DevBuffer>   workspaceBuffer{nullptr};
      71              :     std::shared_ptr<DevBuffer>   combinOpParamBuffer{nullptr};
      72              :     std::shared_ptr<DevBuffer>   comParamBuffer{nullptr};
      73              :     std::shared_ptr<DevBuffer>   comSyncBuffer{nullptr};
      74              :     CcuResPack                   ccuResPack;
      75              :     InsExeQue::ExtInsExeEntityId curExecId{0};
      76              :     uint64_t                     tokenInfo{0};
      77              :     std::shared_ptr<DevBuffer>   inputMem{nullptr};
      78              : 
      79              :     std::vector<u64> dataCounts;
      80              :     std::vector<u64> displs;
      81              : 
      82              :     HcclCombinOpParam combinOpParam{0};
      83              :     bool              ccuResourceAlloced{false}; // 标记通信域粒度资源已经申请过了
      84              : };
      85              : } // namespace Hccl
      86              : #endif // MC2_COMPONT_H
        

Generated by: LCOV version 2.0-1