LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/ccu/ccu_mc2 - mc2_context.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 6 6
Test Date: 2026-08-18 17:47:01 Functions: 88.9 % 9 8

            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 HCCL_MC2_CONTEXT_H
      12              : #define HCCL_MC2_CONTEXT_H
      13              : 
      14              : #include <vector>
      15              : #include <array>
      16              : #include <unordered_map>
      17              : #include "ccu_ctx.h"
      18              : #include "mc2_type.h"
      19              : 
      20              : namespace Hccl {
      21              : 
      22              : class Mc2ContextBase : public CcuContext {
      23              : public:
      24           10 :     Mc2ContextBase() = default;
      25           10 :     ~Mc2ContextBase() override {}
      26              : 
      27              :     void Algorithm() override;
      28              : 
      29              :     void SetAlgoTemplateInfo(const std::map<uint64_t, uint32_t>& algoTemplateInfo);
      30              :     void SetMissionNumAndId(uint32_t miNum, uint32_t miIndex);
      31              :     void MissionPreSync(CcuRep::Variable& func);
      32              :     void MissionPostSync();
      33              : 
      34              : protected:
      35              :     void GenOpSelector();
      36              :     virtual void GenCircularQueue() = 0;
      37              : 
      38              : protected:
      39              :     // 同一个Die上的Mission数量
      40              :     uint32_t missionNum{1};
      41              :     // 同一个Die上的Mission的编号
      42              :     uint32_t missionIndex{0};
      43              :     // 用于Mission间同步信号
      44              :     std::vector<CcuRep::MaskSignal> exportMissoinSig;
      45              :     std::vector<CcuRep::MaskSignal> importMissionSig;
      46              :     // 用于Mission间同步变量
      47              :     std::vector<CcuRep::Variable> exportMissionVar;
      48              :     std::vector<CcuRep::Variable> importMissionVar;
      49              :     // 算子签名与起始地址Map <指令模板签名, 指令起始地址>,用于算子选择
      50              :     std::map<uint64_t, uint32_t> algoTemplateInfo_;
      51              : };
      52              : 
      53              : class Mc2Context : public Mc2ContextBase {
      54              : public:
      55            8 :     Mc2Context() = default;
      56           11 :     ~Mc2Context() override {}
      57              : 
      58              :     void SetCommAddr(uint64_t syncAddr, uint64_t paramAddr);
      59              :     void SetDieNum(uint32_t dieNum);
      60              : 
      61              :     std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
      62              : 
      63              : protected:
      64              :     void GenCircularQueue() override;
      65              : 
      66              : private:
      67              :     void WaitTurnStartSig(const CcuRep::Variable& hbmSigAddr, CcuRep::Variable& turnStartSig);
      68              :     void SetTurnEndSig(const CcuRep::Variable& hbmSigAddr, const CcuRep::Variable& turnEndSig);
      69              :     void
      70              :     LoadFuncParamFromMemory(CcuRep::Variable& paramAddr, std::array<CcuRep::Variable, CCU_PARAM_NUM_PER_DIE>& param);
      71              : 
      72              : private:
      73              :     // HBM上的每轮开始信号的首地址
      74              :     uint64_t waitAddr_{0};
      75              :     // HBM上的每轮完成信号的首地址
      76              :     uint64_t recordAddr_{0};
      77              :     // HBM上的算子执行参数首地址
      78              :     uint64_t paramAddr_{0};
      79              : 
      80              :     // Die数量,用于判断单双Die,默认为1即单Die
      81              :     uint32_t dieNum_{1};
      82              :     // 用于Die间同步信号
      83              :     CcuRep::MaskSignal exportDieSig;
      84              :     CcuRep::MaskSignal importDieSig;
      85              : };
      86              : 
      87              : class Mc2SlaveContext : public Mc2ContextBase {
      88              : public:
      89            2 :     Mc2SlaveContext() = default;
      90            4 :     ~Mc2SlaveContext() override {}
      91              : 
      92              :     std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
      93              : 
      94              : protected:
      95              :     void GenCircularQueue() override;
      96              : };
      97              : } // namespace Hccl
      98              : 
      99              : #endif // HCCL_MC2_CONTEXT_H
        

Generated by: LCOV version 2.0-1