LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/translator - ccu_rep_translator_v1.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
       3              :  * Description: ccu rep translator header file
       4              :  * Create: 2025-02-20
       5              :  */
       6              : 
       7              : #ifndef HCOMM_CCU_REP_TRANSLATOR_H
       8              : #define HCOMM_CCU_REP_TRANSLATOR_H
       9              : 
      10              : #include <memory>
      11              : #include <vector>
      12              : #include <functional>
      13              : 
      14              : #include "ccu_instr_info_v1.h"
      15              : #include "ccu_rep_block_v1.h"
      16              : #include "ccu_rep_reference_manager_v1.h"
      17              : #include "ccu_kernel_resource.h"
      18              : #include "ccu_rep_base_v1.h"
      19              : #include "ccu_kernel.h"
      20              : #include "ccu_dev_mgr_imp.h"
      21              : 
      22              : namespace hcomm {
      23              : namespace CcuRep {
      24              : 
      25              : class CcuRepTranslator {
      26              : public:
      27              :     CcuRepTranslator(int32_t deviceLogicId, uint8_t dieId,
      28              :         std::shared_ptr<CcuRepReferenceManager> refManager,
      29              :         std::array<uint16_t, CCU_MAX_IODIE_NUM> &reserverChannalId,
      30              :         std::pair<uint64_t, uint64_t> &ccuTokenInfo, uint64_t hbmTokenInfo);
      31              : 
      32              :     CcuRepTranslator(std::shared_ptr<CcuRepReferenceManager> refManager, const TransDep &transDep);
      33              :     static uint32_t             GetInstrNum(const int32_t devLogicId);
      34              :     static CcuResReq            GetResReq(const int32_t devLogicId, uint8_t dieId);
      35              :     void                        GetRes(CcuRepResource &res);
      36              :     CcuInstrInfo Translate(CcuKernel* ccuKernel, const std::vector<std::shared_ptr<CcuRepBase>> &repVec,
      37              :                             uint16_t startInstrId, bool isFuncBlock=false);
      38              :     void         Translate(CcuKernel* ccuKernel, const std::vector<std::shared_ptr<CcuRepBase>> &repVec,
      39              :                             CcuInstr *&instr, uint16_t &instrId, std::function<bool(std::shared_ptr<CcuRepBase>)> filter);
      40              :     void         DumpInstruction(const CcuInstrInfo &instrInfo) const;
      41              :     void         SetTransDep(TransDep transDepIn) {transDep = transDepIn;}
      42           43 :     TransDep&    GetTransDep() {return transDep;}
      43              : 
      44              : private:
      45              :     template <typename T1, typename T2> void BuildReference(const std::shared_ptr<CcuRepBase> &rep);
      46              :     void                                     PreProcess(std::shared_ptr<CcuRepBase> rep);
      47              :     void                                     CommonProcess(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId);
      48              :     void                                     FinishMainBlock(CcuInstr *&instr, uint16_t &instrId);
      49              :     void DumpRep(const std::vector<std::shared_ptr<CcuRepBase>> &repVec, const CcuInstrInfo &instrInfo) const;
      50              :     void BindResource(bool isFuncBlock);
      51              : 
      52              : private:
      53              :     static const int XN_NUM = 4; // 4: Xn资源个数
      54              :     static const int GSA_NUM = 3; // 3: GSA资源个数
      55              :     static const int CKE_NUM = 2; // 2: CKE资源个数
      56              :     static const int V2_RELJMP_INSTR_NUM = 9; // V2: RelJmp生成的指令数
      57              :     static const int V2_FINISH_BLOCK_INSTR_NUM = 10; // V2: FinishMainBlock占用的指令数(RelJmp+Jump或10xNop)
      58              :     std::shared_ptr<CcuRepReferenceManager> refManager{nullptr};
      59              :     Variable                             var[XN_NUM];
      60              :     Address                              addr[GSA_NUM];
      61              :     CompletedEvent                       signal[CKE_NUM]; // 声明为CompletedEvent,使用离散cke
      62              :     TransDep                             transDep{0};
      63              :     CcuVersion                           ccuVersion{CcuVersion::CCU_INVALID};
      64              : };
      65              : }; // namespace CcuRep
      66              : }; // namespace hcomm
      67              : 
      68              : #endif // HCCL_CCU_REP_TRANSLATOR_H
        

Generated by: LCOV version 2.0-1