LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/communicator/impl - hccl_dpu_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-07-28 12:11:00 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              : #ifndef HCCL_DPU_MANAGER_H
      11              : #define HCCL_DPU_MANAGER_H
      12              : 
      13              : #include "acl/acl_rt.h"
      14              : #include "hccl/hccl_types.h"
      15              : #include <memory>
      16              : #include <string>
      17              : #include <unordered_map>
      18              : #include "config_log.h"
      19              : #include "../../../unified_platform/resource/buffer/dev_buffer.h"
      20              : 
      21              : namespace hccl {
      22              : 
      23              : constexpr u32 SHARE_HBM_MEMORY_SIZE = 100 * 1024 * 1024; // 100MB
      24              : constexpr char DPUTAG[] = "DPUTAG";
      25              : 
      26              : class DpuManager {
      27              : public:
      28              :     DpuManager();
      29              :     ~DpuManager();
      30              : 
      31              :     HcclResult Init(const std::string &commId, u32 deviceLogicId);
      32              :     HcclResult InitDpuKernel();
      33              :     HcclResult DeInitDpuKernel();
      34              : 
      35            1 :     bool IsDpuKernelLaunched() const
      36              :     {
      37            1 :         return isDpuKernelLaunched_;
      38              :     }
      39              : 
      40              :     HcclResult CreateWorkspaceBuf(const char *memTag, uint64_t *size, bool *newCreated);
      41              :     std::shared_ptr<Hccl::DevBuffer> GetKFCWorkSpace(const char *memTag);
      42              :     HcclResult GetDevMemWorkSpace(const std::string &memTag, uint64_t *size, void **addr, bool *newCreated);
      43              :     HcclResult GetKFCWorkSpaceVA(const std::string &memTag, uint64_t *size, void **addr, bool *newCreated);
      44              :     HcclResult AllocAndRegKFCWorkSpace(uint64_t size);
      45              :     HcclResult DestroyKFCWorkSpaceVA();
      46              :     HcclResult DestroyDpuKernelResource();
      47              : 
      48              : private:
      49              :     HcclResult InitAndLaunchDpuKernel();
      50              :     HcclResult PrepareDpuKernelResource(aclrtFuncHandle &funcHandle);
      51              :     HcclResult LaunchDpuKernel(aclrtFuncHandle &funcHandle);
      52              :     HcclResult WaitDpuKernelThreadTerminate();
      53              : 
      54              :     std::string commId_;
      55              :     u32 devLogicId_{0};
      56              :     void *hostShareBuf_{nullptr};
      57              :     void* va_{nullptr};
      58              :     void* accessVA_{nullptr};
      59              :     std::unordered_map<std::string, std::shared_ptr<Hccl::DevBuffer>> tagWorkspaceVAMap_;
      60              :     aclrtStream dpuStream_{nullptr};
      61              :     aclrtContext dpuContext_{nullptr};
      62              :     aclrtContext npuContext_{nullptr};
      63              :     bool isDpuKernelLaunched_{false};
      64              :     u32 waitTransportReadyTimeoutMs_{200 * 1000}; // 默认200秒
      65              : 
      66              :     std::unordered_map<std::string, std::shared_ptr<Hccl::DevBuffer>> tagWorkspaceMap_;
      67              : };
      68              : } // namespace hccl
      69              : 
      70              : #endif // HCCL_DPU_MANAGER_H
        

Generated by: LCOV version 2.0-1