LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/communicator/hostdpu - flush_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.0 % 4 2
Test Date: 2026-08-04 10:52:23 Functions: 50.0 % 2 1

            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              : #ifndef HCCL_FLUSH_MANAGER_H
      11              : #define HCCL_FLUSH_MANAGER_H
      12              : 
      13              : #include <memory.h>
      14              : #include <unordered_map>
      15              : #include "flush_handle.h"
      16              : #include "infiniband/verbs.h"
      17              : 
      18              : namespace Hccl {
      19              : 
      20              : #define ROCE_WR_FLUSH (static_cast<ibv_wr_opcode>(0x40))
      21              : 
      22              : class FlushManager {
      23              : public:
      24              :     static FlushManager &GetInstance();
      25              :     FlushManager(const FlushManager&) = delete;
      26              :     FlushManager& operator = (const FlushManager&) = delete;
      27              :     
      28              :     HcclResult initFlushHandle(IpAddress ip, u32 devPhyId);
      29              :     HcclResult Flush();
      30              : 
      31              : private:
      32              :     FlushManager();
      33              :     ~FlushManager();
      34              :     std::unordered_map<IpAddress, std::shared_ptr<FlushHandle>> flushHandleMap_;
      35              : 
      36              :     // flush实现
      37              :     HcclResult FlushParamPrepare(std::shared_ptr<FlushHandle> flushHandlePtr, ibv_send_wr *swr) const;
      38              :     HcclResult ExecuteRdmaRead(ibv_qp *loopbackqp0, ibv_cq *cq, ibv_send_wr &swr, int timeoutSec) const;
      39              : 
      40              :     // flush销毁
      41              :     HcclResult DestroyAll();
      42              :     std::mutex mutex_;
      43            2 :     int FlushPostSend(struct ibv_qp *qp, struct ibv_send_wr *wr, struct ibv_send_wr **bad_wr) const
      44              :     {
      45            2 :         return ibv_post_send(qp, wr, bad_wr);
      46              :     }
      47            0 :     int FlushPollCq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc) const
      48              :     {
      49            0 :         return ibv_poll_cq(cq, num_entries, wc);
      50              :     }
      51              : };
      52              : 
      53              : }  // namespace Hccl
      54              : 
      55              : #endif
        

Generated by: LCOV version 2.0-1