LCOV - code coverage report
Current view: top level - coll_communicator_mgr/dfx/profiling/host - hcclCommProfiling.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 78.1 % 32 25
Test Date: 2026-08-17 10:19:35 Functions: 88.9 % 9 8

            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 "hcclCommProfiling.h"
      11              : #include "profiling_reporter.h"
      12              : #include "profiling_handler.h"
      13              : #include "../../../../legacy/ascend950/framework/dfx/profiling/dlprof_function_v2.h"
      14              : namespace hccl {
      15              : 
      16            0 : HcclResult HcclCommProfiling::ReportKernel(
      17              :     uint64_t beginTime, const std::string& commTag, const std::string& kernelName, uint32_t threadId,
      18              :     bool cachedReq) const
      19              : {
      20            0 :     u64 endTime = Hccl::DlProfFunction::GetInstance().dlMsprofSysCycleTime();
      21            0 :     uint64_t cmdItemId = Hccl::DlProfFunction::GetInstance().dlMsprofStr2Id(kernelName.c_str(), kernelName.length());
      22            0 :     EXCEPTION_CATCH(
      23              :         Hccl::ProfilingHandler::GetInstance().ReportNodeApi(beginTime, endTime, cmdItemId, threadId, cachedReq),
      24              :         return HCCL_E_PTR);
      25            0 :     EXCEPTION_CATCH(
      26              :         Hccl::ProfilingHandler::GetInstance().ReportNodeBasicInfo(endTime, cmdItemId, threadId, cachedReq),
      27              :         return HCCL_E_PTR);
      28            0 :     HCCL_INFO(
      29              :         "[HcclCommProfiling][ReportKernel] beginTime [%llu] endTime[%llu] kernelName[%s] commTag[%s] threadId[%u]",
      30              :         beginTime, endTime, kernelName.c_str(), commTag.c_str(), threadId);
      31            0 :     return HCCL_SUCCESS;
      32              : }
      33              : 
      34          182 : HcclCommProfiling::HcclCommProfiling(u32 deviceId, Hccl::MirrorTaskManager* mirrorTaskManager)
      35          182 :     : mirrorTaskManager_(mirrorTaskManager)
      36              : {
      37              :     (void)deviceId;
      38          182 : }
      39              : 
      40          171 : HcclResult HcclCommProfiling::Init()
      41              : {
      42          171 :     if (initializedFlag_) {
      43            1 :         return HCCL_SUCCESS;
      44              :     }
      45          170 :     CHK_RET(Hccl::ProfilingHandler::GetInstance().Init());
      46              :     profilingReporter_
      47          170 :         = std::make_unique<Hccl::ProfilingReporter>(mirrorTaskManager_, &Hccl::ProfilingHandler::GetInstance());
      48          170 :     CHK_RET(profilingReporter_->Init());
      49          170 :     initializedFlag_ = true;
      50          170 :     return HCCL_SUCCESS;
      51              : }
      52              : 
      53              : // HcclCommProfiling任务上报
      54          147 : void HcclCommProfiling::ReportAllTasks(bool cachedReq) const { profilingReporter_->ReportAllTasks(cachedReq); }
      55              : 
      56              : // HcclCommProfiling::ReportOp实现
      57            1 : void HcclCommProfiling::ReportOp(uint64_t beginTime, bool cachedReq, bool isOpBase)
      58              : {
      59            1 :     profilingReporter_->ReportOp(beginTime, cachedReq, isOpBase);
      60            1 : }
      61              : 
      62            7 : void HcclCommProfiling::ReportMc2CommInfo(const Mc2CommInfo& mc2CommInfo)
      63              : {
      64            7 :     profilingReporter_->CallReportMc2CommInfo(
      65            7 :         mc2CommInfo.FreeStreamId, mc2CommInfo.streamsId, mc2CommInfo.groupname, mc2CommInfo.myRankId,
      66            7 :         mc2CommInfo.rankSize, mc2CommInfo.parentRankId);
      67            7 : }
      68              : 
      69            1 : void HcclCommProfiling::SetCurrDfxOpInfo(std::shared_ptr<Hccl::DfxOpInfo> dfxOpInfo)
      70              : {
      71            1 :     profilingReporter_->SetCurrDfxOpInfo(dfxOpInfo);
      72            1 : }
      73              : 
      74              : // HcclCommProfiling::UpdateProfStat实现
      75            1 : void HcclCommProfiling::UpdateProfStat() { profilingReporter_->UpdateProfStat(); }
      76            2 : Hccl::MirrorTaskManager* HcclCommProfiling::GetMirrorTaskManager() const { return mirrorTaskManager_; }
      77              : } // namespace hccl
        

Generated by: LCOV version 2.0-1