LCOV - code coverage report
Current view: top level - coll_communicator_mgr/dfx/profiling/aicpu - dfx_profiling_reporter_lite.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 6.1 % 49 3
Test Date: 2026-08-17 10:19:35 Functions: 12.5 % 8 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              : #include "dfx_profiling_reporter_lite.h"
      11              : #include "aicpu_ts_thread.h"
      12              : 
      13              : namespace Hccl {
      14            0 : DfxProfilingReporterLite::DfxProfilingReporterLite(DfxProfilingHandlerLite* profilingHandlerLite)
      15            0 :     : profilingHandlerLite_(profilingHandlerLite)
      16            0 : {}
      17              : 
      18            0 : DfxProfilingReporterLite::~DfxProfilingReporterLite() {}
      19              : 
      20            0 : HcclResult DfxProfilingReporterLite::Init()
      21              : {
      22            0 :     if (initializedFlag_) {
      23            0 :         return HCCL_SUCCESS;
      24              :     }
      25            0 :     if (UNLIKELY(profilingHandlerLite_ == nullptr)) {
      26            0 :         HCCL_ERROR("[DfxProfilingReporterLite][Init] profilingHandlerLite is nullptr.");
      27            0 :         return HCCL_E_PTR;
      28              :     }
      29            0 :     initializedFlag_ = true;
      30            0 :     return HCCL_SUCCESS;
      31              : }
      32              : 
      33            0 : void DfxProfilingReporterLite::ReportStreamTask(TaskInfoCircularQueue* taskQueue)
      34              : {
      35            0 :     if (taskQueue == nullptr) {
      36            0 :         return;
      37              :     }
      38            0 :     if (!profilingHandlerLite_->GetProfL1State()) {
      39            0 :         taskQueue->MarkAllRead(); // L1关闭时跳过上报,但仍需标记已读,防止L1重新开启后重复上报
      40            0 :         return;
      41              :     }
      42            0 :     profilingHandlerLite_->ReportStreamTaskDetails(*taskQueue);
      43            0 :     taskQueue->MarkAllRead(); // 将队列begin推到end,标记已上报的task为已读,下次只遍历新增task
      44              : }
      45              : 
      46            1 : void DfxProfilingReporterLite::ReportAllTasksLog(const std::vector<hccl::Thread*>& threads) const
      47              : {
      48            1 :     if (LIKELY(HcclCheckLogLevel(HCCL_LOG_INFO) == 0)) {
      49            0 :         return;
      50              :     }
      51            1 :     for (auto* thread : threads) {
      52            0 :         auto* aicpuThread = static_cast<hccl::AicpuTsThread*>(thread);
      53            0 :         if (aicpuThread == nullptr) {
      54            0 :             continue;
      55              :         }
      56            0 :         auto* taskQueue = aicpuThread->GetTaskInfos();
      57            0 :         if (taskQueue == nullptr || taskQueue->IsEmpty()) {
      58            0 :             continue;
      59              :         }
      60            0 :         profilingHandlerLite_->ReportStreamTaskDetailsLog(*taskQueue);
      61              :     }
      62              : }
      63              : 
      64            0 : void DfxProfilingReporterLite::ReportAllTasks(const std::vector<hccl::Thread*>& threads)
      65              : {
      66            0 :     ReportAllTasksLog(threads);
      67            0 :     if (!profilingHandlerLite_->GetProfL1State()) {
      68            0 :         HCCL_DEBUG("[DfxProfilingReporterLite][ReportAllTasks] L1 is off, MarkAllRead and skip report.");
      69            0 :         for (auto* thread : threads) {
      70            0 :             auto* aicpuThread = static_cast<hccl::AicpuTsThread*>(thread);
      71            0 :             if (aicpuThread == nullptr) {
      72            0 :                 continue;
      73              :             }
      74            0 :             auto* taskQueue = aicpuThread->GetTaskInfos();
      75            0 :             if (taskQueue != nullptr) {
      76            0 :                 taskQueue->MarkAllRead(); // L1关闭时跳过上报,但仍需标记已读,防止L1重新开启后重复上报关闭期间的task
      77              :             }
      78              :         }
      79            0 :         return;
      80              :     }
      81              : 
      82            0 :     for (auto* thread : threads) {
      83            0 :         auto* aicpuThread = static_cast<hccl::AicpuTsThread*>(thread);
      84            0 :         if (aicpuThread == nullptr) {
      85            0 :             continue;
      86              :         }
      87            0 :         ReportStreamTask(aicpuThread->GetTaskInfos());
      88              :     }
      89              : }
      90              : 
      91            0 : void DfxProfilingReporterLite::UpdateProfStat() { profilingHandlerLite_->UpdateProfSwitch(); }
      92              : 
      93              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1