LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_instance - ccu_instance.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 HCOMM_CCU_INSTANCE_H
      12              : #define HCOMM_CCU_INSTANCE_H
      13              : 
      14              : #include <array>
      15              : #include <memory>
      16              : #include <vector>
      17              : 
      18              : #include "ccu_types.h"
      19              : #include "ccu_res_pack.h"
      20              : #include "ccu_drv_handle.h"
      21              : #include "ccu_device_res.h"
      22              : #include "ccu_res_desc.h"
      23              : #include "ccu_res_desc_mgr.h"
      24              : 
      25              : namespace hcomm {
      26              : 
      27              : /**
      28              :  * @note 职责:管理通信域持有的CCU资源
      29              :  */
      30              : class CcuInstance {
      31              : public:
      32          152 :     explicit CcuInstance() {};
      33              :     ~CcuInstance();
      34              :     CcuResult InitByInsType(const CcuInstanceType insType);
      35              :     // 基于资源描述符数组初始化(新接口路径,资源数量由 resDesc 驱动)
      36              :     CcuResult InitByResDescs(const CcuResDesc* descs[], uint32_t descNum);
      37              :     // 使用当前 Device 上所有已使能 ioDie 的全部资源初始化
      38              :     CcuResult InitByAllRes();
      39              :     CcuResult Reset();
      40              :     CcuResPack* GetResPack();
      41              :     // 获取 ccuIns 在指定 die 上持有的资源描述符,用于查询接口
      42              :     const CcuResDesc& GetTotalResDescs(uint8_t dieId) const;
      43              :     CcuResult SaveKernel(const CcuKernelHandle kernelHandle);
      44              :     const std::vector<CcuKernelHandle>& GetUntranslatedKernels();
      45              :     void SetHandle(CcuInsHandle insHandle);
      46              : 
      47              :     CcuResult BeginRegister();
      48              :     CcuResult CheckRegistering() const;
      49              :     CcuResult EndRegister();
      50              :     void AbortRegister();
      51              : 
      52              : private:
      53              :     // 从 resPack_ 取 CcuResRepository,把各 die 各资源类型的占用数量写入 totalResDescs_
      54              :     CcuResult FillTotalResDescs();
      55              : 
      56              :     enum class RegisterState { IDLE, REGISTERING, REGISTER_ABORTED };
      57              :     RegisterState registerState_{RegisterState::IDLE};
      58              :     int32_t devLogicId_{INT32_MAX};
      59              :     CcuInsHandle insHandle_{0};
      60              :     std::shared_ptr<hcomm::CcuDrvHandle> ccuDrvHandle_{};
      61              :     std::unique_ptr<CcuResPack> resPack_{};
      62              :     std::vector<CcuKernelHandle> kernelHandles_{};
      63              :     std::vector<CcuKernelHandle> untranslatedKernelHandles_{};
      64              :     std::array<CcuResDesc, CCU_MAX_IODIE_NUM> totalResDescs_{}; // ccuIns持有的全部资源描述符
      65              : };
      66              : 
      67              : } // namespace hcomm
      68              : #endif // HCOMM_CCU_INSTANCE_H
        

Generated by: LCOV version 2.0-1