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

Generated by: LCOV version 2.0-1