LCOV - code coverage report
Current view: top level - base_comm/resources/endpoints/dfx - endpoint_monitor.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-17 10:19:35 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 ENDPOINT_MONITOR_H
      11              : #define ENDPOINT_MONITOR_H
      12              : #include <thread>
      13              : #include <unordered_set>
      14              : #include <mutex>
      15              : #include <atomic>
      16              : #include "log.h"
      17              : #include "hccl/hccl_types.h"
      18              : #include "hcomm_res_defs.h"
      19              : #include "hccp_ctx.h"
      20              : 
      21              : namespace hcomm {
      22              : 
      23              : class EndpointMonitor {
      24              : public:
      25          264 :     EndpointMonitor() = default;
      26              :     EndpointMonitor(const EndpointMonitor&) = delete;
      27              :     EndpointMonitor& operator=(const EndpointMonitor&) = delete;
      28              :     EndpointMonitor(EndpointMonitor&&) = delete;
      29              :     EndpointMonitor& operator=(EndpointMonitor&&) = delete;
      30              :     ~EndpointMonitor();
      31              : 
      32              :     static EndpointMonitor& GetInstance(s32 deviceId);
      33              :     HcclResult RegisterToEndpointMonitor(s32 deviceLogicId, EndpointHandle epHandle);
      34              :     HcclResult UnRegisterToEndpointMonitor();
      35              :     void RemoveEpHandleFromEndpointMonitor(EndpointHandle epHandle);
      36              : 
      37              : private:
      38              :     HcclResult RunMonitorThread();
      39              :     void MonitorThread();
      40              :     HcclResult DeInit(s32 deviceLogicId);
      41              : 
      42              :     void ProcessUbAsyncEvents();
      43              :     void PrintUbAsyncEventsContext(void* epHandle, u32 seq, const struct AsyncEvent& event);
      44              : 
      45              :     static constexpr u32 MONITOR_INTERVAL = 1000;
      46              :     std::unique_ptr<std::thread> endpointMonitorThread_;
      47              : 
      48              :     std::atomic<bool> initialized_{false};
      49              :     std::atomic<bool> endpointMonitorThreadFlag_{false};
      50              :     std::mutex threadLock_;
      51              :     u32 devPhyId_{0};
      52              :     s32 deviceLogicId_{0};
      53              :     std::unordered_set<u64> epHandleSet_;
      54              : 
      55              :     struct AsyncEvent events_[ASYNC_EVENT_MAX_NUM];
      56              : };
      57              : } // namespace hcomm
      58              : #endif // ENDPOINT_MONITOR_H
        

Generated by: LCOV version 2.0-1