LCOV - code coverage report
Current view: top level - legacy/ascend910/common/debug/profiling - task_profiling.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 61.2 % 258 158
Test Date: 2026-08-17 10:19:35 Functions: 56.7 % 30 17

            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              : 
      11              : #include <securec.h>
      12              : #include "profiling_manager.h"
      13              : #include "adapter_prof.h"
      14              : #include "task_profiling.h"
      15              : 
      16              : namespace hccl {
      17              : std::mutex TaskProfiling::mutex_;
      18              : 
      19          315 : TaskProfiling::TaskProfiling(u32 deviceLogicId_, u32 localRank_, u32 rankSize_, bool profilingOn)
      20              :     : ProfilerBase(deviceLogicId_),
      21          315 :       localRank_(localRank_),
      22          315 :       rankSize_(rankSize_),
      23          315 :       profilingOn_(profilingOn)
      24          315 : {}
      25              : 
      26          627 : TaskProfiling::~TaskProfiling() {}
      27              : 
      28            0 : u64 TaskProfiling::TimestampNanosecond() const
      29              : {
      30              :     // 此时间戳获取方式需要与runtime保持一致
      31              :     struct timespec ts;
      32            0 :     clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
      33            0 :     return static_cast<u64>(ts.tv_sec * MULTIPLIER_S2NS + ts.tv_nsec);
      34              : }
      35              : 
      36           24 : double TaskProfiling::GetTaskTime(TaskType taskType, const TaskData& taskData) const
      37              : {
      38           24 :     double estimatedUs = DURATION_INIT_VALUE;
      39           24 :     double fixedUs = DURATION_INIT_VALUE;
      40              : 
      41           24 :     switch (taskType) {
      42           15 :         case TaskType::TASK_SDMA:
      43              :             /* * 统一按照PCIe的带宽来计算, SDMA的固定开销按照0.6us(<512KB), 1.5us(>512KB)计算
      44              :                 PCIe DMA实测带宽为19.3GB */
      45           15 :             fixedUs = (taskData.DMA.size > DURATION_SDMA_FIXED_THRESHOLD) ? DURATION_SDMA_FIXED_THRESHOLD_ABOVE :
      46              :                                                                             DURATION_SDMA_FIXED_THRESHOLD_BELOW;
      47           15 :             estimatedUs = (taskData.DMA.size / DURATION_SDMA_BANDWIDTH_MB) + fixedUs;
      48           15 :             break;
      49              : 
      50            9 :         case TaskType::TASK_REDUCE_INLINE:
      51              :             /* * 统一按照PCIe的带宽来计算, SDMA的固定开销按照0.6us(<512KB), 1.5us(>512KB)计算
      52              :                 PCIe DMA实测带宽为19.3GB */
      53            9 :             fixedUs = (taskData.DMA.size > DURATION_SDMA_FIXED_THRESHOLD) ? DURATION_SDMA_FIXED_THRESHOLD_ABOVE :
      54              :                                                                             DURATION_SDMA_FIXED_THRESHOLD_BELOW;
      55            9 :             estimatedUs = (taskData.Reduce.size / DURATION_SDMA_BANDWIDTH_MB) + fixedUs;
      56            9 :             break;
      57              : 
      58            0 :         case TaskType::TASK_RDMA:
      59              :             /* * RDMA的固定开销按照7us计算(实测7us)
      60              :                 RDMA实测大包单流带宽为 12.5 GB(刨去协议头, 取12GB) */
      61            0 :             estimatedUs = (taskData.DMA.size / DURATION_RDMA_BANDWIDTH_MB) + DURATION_RDMA_FIXED;
      62            0 :             break;
      63              : 
      64            0 :         case TaskType::TASK_REDUCE_TBE:
      65              :             // 统一按照10GB计算, CCE reduce的固定开销按照0.6us计算(理论值0.5 + dim * 8)
      66            0 :             estimatedUs = (taskData.Reduce.size / DURATION_CCE_BANDWIDTH_MB) + DURATION_CCE_FIXED;
      67            0 :             break;
      68              : 
      69            0 :         case TaskType::TASK_NOTIFY_RECORD:
      70              :             // 统一按1us算(片间1us, 片内0.5us)
      71            0 :             estimatedUs = DURATION_NOTIFY_RECORD;
      72            0 :             break;
      73              : 
      74            0 :         case TaskType::TASK_NOTIFY_WAIT:
      75              :             // Notify Wait按0.02us估计
      76            0 :             estimatedUs = DURATION_NOTIFY_WAIT;
      77            0 :             break;
      78              : 
      79            0 :         default:
      80            0 :             break;
      81              :     }
      82              : 
      83           24 :     return estimatedUs;
      84              : }
      85              : 
      86           24 : ProfTaskType TaskProfiling::GetProfTaskType(TaskType taskType) const
      87              : {
      88           24 :     ProfTaskType type = ProfTaskType::TASK_INVALID;
      89           24 :     switch (taskType) {
      90           15 :         case TaskType::TASK_SDMA:
      91              :         case TaskType::TASK_RDMA:
      92           15 :             type = (taskType == TaskType::TASK_SDMA) ? (ProfTaskType::TASK_SDMA) : (ProfTaskType::TASK_RDMA);
      93           15 :             break;
      94            9 :         case TaskType::TASK_REDUCE_INLINE:
      95              :         case TaskType::TASK_REDUCE_TBE:
      96            9 :             type = (taskType == TaskType::TASK_REDUCE_INLINE) ? (ProfTaskType::TASK_REDUCE_INLINE) :
      97              :                                                                 (ProfTaskType::TASK_REDUCE_TBE);
      98            9 :             break;
      99            0 :         case TaskType::TASK_NOTIFY_RECORD:
     100              :         case TaskType::TASK_NOTIFY_WAIT:
     101            0 :             type = (taskType == TaskType::TASK_NOTIFY_RECORD) ? (ProfTaskType::TASK_NOTIFY_RECORD) :
     102              :                                                                 (ProfTaskType::TASK_NOTIFY_WAIT);
     103            0 :             break;
     104            0 :         default:
     105            0 :             break;
     106              :     }
     107              : 
     108           24 :     return type;
     109              : }
     110              : 
     111           24 : uint32_t TaskProfiling::GetTransportType(TaskType taskType) const
     112              : {
     113           24 :     if (taskType == TaskType::TASK_SDMA || taskType == TaskType::TASK_REDUCE_INLINE
     114            0 :         || taskType == TaskType::TASK_NOTIFY_RECORD) {
     115           24 :         return static_cast<int32_t>(SimpleTaskType::SDMA);
     116            0 :     } else if (taskType == TaskType::TASK_RDMA) {
     117            0 :         return static_cast<int32_t>(SimpleTaskType::RDMA);
     118              :     } else {
     119            0 :         return static_cast<int32_t>(SimpleTaskType::LOCAL);
     120              :     }
     121              : }
     122              : 
     123           24 : uint32_t TaskProfiling::GetTaskRole(TaskType taskType) const
     124              : {
     125           24 :     if (taskType == TaskType::TASK_SDMA || taskType == TaskType::TASK_REDUCE_INLINE
     126            0 :         || taskType == TaskType::TASK_REDUCE_TBE || taskType == TaskType::TASK_NOTIFY_WAIT) {
     127           24 :         return static_cast<uint32_t>(TaskRole::DST);
     128              :     } else {
     129            0 :         return static_cast<uint32_t>(TaskRole::SRC);
     130              :     }
     131              : }
     132              : 
     133           24 : void TaskProfiling::GetTaskData(TaskType taskType, const TaskData& taskData, struct MsprofHcclInfo& taskInfo)
     134              : {
     135           24 :     switch (taskType) {
     136           15 :         case TaskType::TASK_SDMA:
     137           15 :             GetSdmaTaskData(taskType, taskData, taskInfo);
     138           15 :             break;
     139            0 :         case TaskType::TASK_RDMA:
     140            0 :             GetRdmaTaskData(taskType, taskData, taskInfo);
     141            0 :             break;
     142            9 :         case TaskType::TASK_REDUCE_INLINE:
     143              :         case TaskType::TASK_REDUCE_TBE:
     144            9 :             GetReduceTaskData(taskType, taskData, taskInfo);
     145            9 :             break;
     146            0 :         case TaskType::TASK_NOTIFY_RECORD:
     147              :         case TaskType::TASK_NOTIFY_WAIT:
     148            0 :             GetNotifyTaskData(taskType, taskData, taskInfo);
     149            0 :             break;
     150            0 :         default:
     151            0 :             break;
     152              :     }
     153           24 : }
     154              : 
     155           15 : void TaskProfiling::GetSdmaTaskData(TaskType taskType, const TaskData& taskData, struct MsprofHcclInfo& taskInfo) const
     156              : {
     157           15 :     taskInfo.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.src));
     158           15 :     taskInfo.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.dst));
     159           15 :     taskInfo.dataSize = static_cast<u64>(taskData.DMA.size);
     160           15 :     taskInfo.notifyID = taskData.DMA.notifyID;
     161           15 :     taskInfo.linkType = static_cast<u32>(taskData.DMA.linkType);
     162              :     taskInfo.remoteRank
     163           15 :         = (taskData.DMA.remoteUserRank == INVALID_VALUE_RANKID) ? localRank_ : taskData.DMA.remoteUserRank;
     164           15 :     taskInfo.transportType = GetTransportType(taskType);
     165           15 :     taskInfo.role = GetTaskRole(taskType);
     166           15 :     taskInfo.durationEstimated = GetTaskTime(taskData.taskType, taskData);
     167           15 :     taskInfo.ctxId = taskData.DMA.ctxId;
     168           15 : }
     169              : 
     170            0 : void TaskProfiling::GetRdmaTaskData(TaskType taskType, const TaskData& taskData, struct MsprofHcclInfo& taskInfo) const
     171              : {
     172            0 :     taskInfo.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.src));
     173            0 :     taskInfo.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.dst));
     174            0 :     taskInfo.dataSize = static_cast<u64>(taskData.DMA.size);
     175            0 :     taskInfo.notifyID = taskData.DMA.notifyID;
     176            0 :     taskInfo.linkType = static_cast<u32>(taskData.DMA.linkType);
     177              :     taskInfo.remoteRank
     178            0 :         = (taskData.DMA.remoteUserRank == INVALID_VALUE_RANKID) ? localRank_ : taskData.DMA.remoteUserRank;
     179            0 :     taskInfo.transportType = GetTransportType(taskType);
     180            0 :     taskInfo.role = GetTaskRole(taskType);
     181            0 :     taskInfo.rdmaType = static_cast<u32>(taskData.DMA.rdmaType);
     182            0 :     taskInfo.durationEstimated = GetTaskTime(taskData.taskType, taskData);
     183            0 :     taskInfo.ctxId = taskData.DMA.ctxId;
     184            0 : }
     185              : 
     186            9 : void TaskProfiling::GetReduceTaskData(
     187              :     TaskType taskType, const TaskData& taskData, struct MsprofHcclInfo& taskInfo) const
     188              : {
     189            9 :     taskInfo.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.src));
     190            9 :     taskInfo.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskData.DMA.dst));
     191            9 :     taskInfo.dataSize = static_cast<u64>(taskData.Reduce.size);
     192            9 :     taskInfo.opType = opString[taskData.Reduce.op];
     193            9 :     taskInfo.dataType = dataTypeString[taskData.Reduce.dataType];
     194            9 :     taskInfo.linkType = static_cast<u32>(taskData.Reduce.linkType);
     195            9 :     taskInfo.remoteRank = taskData.Reduce.remoteUserRank;
     196            9 :     taskInfo.transportType = GetTransportType(taskType);
     197            9 :     taskInfo.role = GetTaskRole(taskType);
     198            9 :     taskInfo.durationEstimated = GetTaskTime(taskData.taskType, taskData);
     199            9 :     taskInfo.ctxId = taskData.Reduce.ctxId;
     200            9 : }
     201              : 
     202            0 : void TaskProfiling::GetNotifyTaskData(
     203              :     TaskType taskType, const TaskData& taskData, struct MsprofHcclInfo& taskInfo) const
     204              : {
     205            0 :     taskInfo.notifyID = taskData.Notify.notifyID;
     206            0 :     taskInfo.stage = taskData.Notify.stage;
     207            0 :     taskInfo.remoteRank = taskData.Notify.remoteUserRank;
     208            0 :     taskInfo.transportType = GetTransportType(taskType);
     209            0 :     taskInfo.role = GetTaskRole(taskType);
     210            0 :     taskInfo.durationEstimated = GetTaskTime(taskData.taskType, taskData);
     211            0 :     taskInfo.ctxId = taskData.Notify.ctxId;
     212            0 : }
     213              : 
     214            0 : HcclResult TaskProfiling::Run(const StepData& stepData) { return HCCL_SUCCESS; }
     215              : 
     216           41 : HcclResult TaskProfiling::Run(const TaskData& taskData, bool isCapture)
     217              : {
     218           41 :     HCCLReportData hcclReportData{};
     219           41 :     auto& profilingManager = hccl::ProfilingManager::Instance();
     220           41 :     bool isSubscribed = profilingManager.GetAdditionInfoState();
     221           41 :     if (!isSubscribed && GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE && !isCapture) {
     222           17 :         return HCCL_SUCCESS;
     223              :     }
     224           24 :     std::unique_lock<std::mutex> lock(mutex_);
     225              : 
     226           24 :     std::unique_lock<std::mutex> streamLock(streamMutex_[deviceLogicId_]);
     227           24 :     if (streamRecordInfoMap_[deviceLogicId_].find(taskData.streamID) == streamRecordInfoMap_[deviceLogicId_].end()) {
     228              :         // 找不到对应的tag则认为该stream不参与profiling, 返回SUCCESS
     229           12 :         HCCL_DEBUG("streamID[%u] not found in profiler", taskData.streamID);
     230           12 :         hcclReportData.tag = "unknown";
     231           12 :         hcclReportData.profInfo.planeID = 0;
     232           12 :         hcclReportData.groupName = "unknown";
     233           12 :         hcclReportData.profInfo.workFlowMode = 0;
     234              :     } else {
     235           12 :         StreamRecordInfo& streamInfo = streamRecordInfoMap_[deviceLogicId_][taskData.streamID];
     236           12 :         hcclReportData.tag = streamInfo.tag;
     237           12 :         hcclReportData.profInfo.planeID = streamInfo.planeId;
     238           12 :         hcclReportData.groupName = tagGroupMap_[deviceLogicId_][hcclReportData.tag];
     239           12 :         hcclReportData.profInfo.workFlowMode = static_cast<uint32_t>(tagModeMap_[deviceLogicId_][hcclReportData.tag]);
     240              :     }
     241           24 :     streamLock.unlock();
     242              : 
     243           24 :     hcclReportData.ts = hrtMsprofSysCycleTime();
     244           24 :     ProfTaskType type = GetProfTaskType(taskData.taskType);
     245           24 :     hcclReportData.type = static_cast<int32_t>(type);
     246           24 :     std::string nameInfo = GetProfTaskOpName(type);
     247           24 :     hcclReportData.profInfo.itemId = hrtMsprofGetHashId(nameInfo.c_str(), nameInfo.length());
     248           24 :     hcclReportData.profInfo.localRank = localRank_;
     249           24 :     hcclReportData.profInfo.rankSize = rankSize_;
     250           24 :     GetTaskData(taskData.taskType, taskData, hcclReportData.profInfo);
     251              : 
     252           24 :     hcclReportData.profInfo.cclTag = hrtMsprofGetHashId(hcclReportData.tag.c_str(), hcclReportData.tag.length());
     253              :     hcclReportData.profInfo.groupName
     254           24 :         = hrtMsprofGetHashId(hcclReportData.groupName.c_str(), hcclReportData.groupName.length());
     255              : 
     256           24 :     HCCL_DEBUG(
     257              :         "ReportMsprofData:streamID[%u] tag[%s][%llu] group[%s][%llu]", taskData.streamID, hcclReportData.tag.c_str(),
     258              :         hcclReportData.profInfo.cclTag, hcclReportData.groupName.c_str(), hcclReportData.profInfo.groupName);
     259              : 
     260           24 :     DumpReportDataInfo(hcclReportData.type, hcclReportData.profInfo);
     261           24 :     CHK_RET(ReportMsprofData(hcclReportData));
     262           24 :     return HCCL_SUCCESS;
     263           41 : }
     264              : 
     265            0 : HcclResult TaskProfiling::Run(const std::string& opName, const std::string& tag) const { return HCCL_SUCCESS; }
     266              : 
     267              : HcclResult
     268            0 : TaskProfiling::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaReduce& paraReduce)
     269              : {
     270            0 :     TaskData taskData(captureStreamID, taskID, taskType, paraReduce);
     271            0 :     Run(taskData, true);
     272            0 :     return HCCL_SUCCESS;
     273              : }
     274              : 
     275            9 : HcclResult TaskProfiling::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaReduce& paraReduce)
     276              : {
     277            9 :     TaskData taskData(streamID, taskID, taskType, paraReduce);
     278            9 :     Run(taskData);
     279            9 :     return HCCL_SUCCESS;
     280              : }
     281              : 
     282              : HcclResult
     283            0 : TaskProfiling::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaDMA& paraDMA)
     284              : {
     285            0 :     TaskData taskData(captureStreamID, taskID, taskType, paraDMA);
     286            0 :     Run(taskData, true);
     287            0 :     return HCCL_SUCCESS;
     288              : }
     289              : 
     290           32 : HcclResult TaskProfiling::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaDMA& paraDMA)
     291              : {
     292           32 :     TaskData taskData(streamID, taskID, taskType, paraDMA);
     293           32 :     Run(taskData);
     294           32 :     return HCCL_SUCCESS;
     295              : }
     296              : 
     297              : HcclResult
     298            0 : TaskProfiling::Save(u32 captureStreamID, u32 streamID, u32 taskID, TaskType& taskType, const TaskParaNotify& paraNotify)
     299              : {
     300            0 :     TaskData taskData(captureStreamID, taskID, taskType, paraNotify);
     301            0 :     Run(taskData, true);
     302            0 :     return HCCL_SUCCESS;
     303              : }
     304              : 
     305            0 : HcclResult TaskProfiling::Save(u32& streamID, u32& taskID, TaskType& taskType, const TaskParaNotify& paraNotify)
     306              : {
     307            0 :     TaskData taskData(streamID, taskID, taskType, paraNotify);
     308            0 :     Run(taskData);
     309            0 :     return HCCL_SUCCESS;
     310              : }
     311              : 
     312            0 : HcclResult TaskProfiling::Save(u32 captureStreamID, u32 streamID, u32 taskID, const void* descBuf, size_t descBufLen)
     313              : {
     314            0 :     return HCCL_SUCCESS;
     315              : }
     316              : 
     317            8 : HcclResult TaskProfiling::Save(u32 captureStreamID, u32 streamID, u32 taskID, const TaskParaAiv& paraAiv)
     318              : {
     319            8 :     HCCLReportData hcclReportData{};
     320            8 :     auto& profilingManager = hccl::ProfilingManager::Instance();
     321            8 :     bool isSubscribed = profilingManager.GetAdditionInfoState();
     322            8 :     bool isCapture = (captureStreamID != streamID);
     323            8 :     if (!isSubscribed && GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE && !isCapture) {
     324            5 :         return HCCL_SUCCESS;
     325              :     }
     326            3 :     std::unique_lock<std::mutex> lock(mutex_);
     327              : 
     328            3 :     std::unique_lock<std::mutex> streamLock(streamMutex_[deviceLogicId_]);
     329              : 
     330            3 :     if (streamRecordInfoMap_[deviceLogicId_].find(captureStreamID) == streamRecordInfoMap_[deviceLogicId_].end()) {
     331              :         // 找不到对应的tag则认为该stream不参与profiling, 返回SUCCESS
     332            1 :         HCCL_DEBUG("streamID[%u] not found in profiler", captureStreamID);
     333            1 :         hcclReportData.tag = "unknown";
     334            1 :         hcclReportData.profInfo.planeID = 0;
     335            1 :         hcclReportData.groupName = "unknown";
     336            1 :         hcclReportData.profInfo.workFlowMode = 0;
     337              :     } else {
     338            2 :         StreamRecordInfo& streamInfo = streamRecordInfoMap_[deviceLogicId_][captureStreamID];
     339            2 :         hcclReportData.tag = streamInfo.tag;
     340            2 :         hcclReportData.profInfo.planeID = streamInfo.planeId;
     341            2 :         hcclReportData.groupName = tagGroupMap_[deviceLogicId_][hcclReportData.tag];
     342            2 :         hcclReportData.profInfo.workFlowMode = static_cast<uint32_t>(tagModeMap_[deviceLogicId_][hcclReportData.tag]);
     343              :     }
     344            3 :     streamLock.unlock();
     345              : 
     346            3 :     hcclReportData.ts = hrtMsprofSysCycleTime();
     347              : 
     348            3 :     hcclReportData.type = static_cast<int32_t>(ProfTaskType::TASK_AIV);
     349            3 :     std::string nameInfo = GetCMDTypeEnumStr(paraAiv.cmdType) + "AivKernel";
     350            3 :     hcclReportData.profInfo.itemId = hrtMsprofGetHashId(nameInfo.c_str(), nameInfo.length());
     351            3 :     hcclReportData.profInfo.localRank = localRank_;
     352            3 :     hcclReportData.profInfo.rankSize = rankSize_;
     353              : 
     354            3 :     hcclReportData.profInfo.dataSize = paraAiv.size;
     355            3 :     hcclReportData.profInfo.cclTag = hrtMsprofGetHashId(hcclReportData.tag.c_str(), hcclReportData.tag.length());
     356              :     hcclReportData.profInfo.groupName
     357            3 :         = hrtMsprofGetHashId(hcclReportData.groupName.c_str(), hcclReportData.groupName.length());
     358              : 
     359            3 :     HCCL_DEBUG(
     360              :         "ReportMsprofData:streamID[%u] tag[%s][%llu] group[%s][%llu]", captureStreamID, hcclReportData.tag.c_str(),
     361              :         hcclReportData.profInfo.cclTag, hcclReportData.groupName.c_str(), hcclReportData.profInfo.groupName);
     362              : 
     363            3 :     DumpReportDataInfo(hcclReportData.type, hcclReportData.profInfo);
     364            3 :     CHK_RET(ReportMsprofData(hcclReportData));
     365            3 :     return HCCL_SUCCESS;
     366            8 : }
     367              : 
     368            2 : HcclResult TaskProfiling::Save(u32 streamID, u32 taskID, const TaskParaAiv& paraAiv)
     369              : {
     370            2 :     return Save(streamID, streamID, taskID, paraAiv);
     371              : }
     372              : 
     373            0 : HcclResult TaskProfiling::Save(u32& streamID, u32& taskID, const void* descBuf, size_t descBufLen)
     374              : {
     375            0 :     return HCCL_SUCCESS;
     376              : }
     377              : 
     378            0 : HcclResult TaskProfiling::SaveToLog(const TaskParaHost& paraHost)
     379              : {
     380            0 :     auto& profilingManager = hccl::ProfilingManager::Instance();
     381            0 :     bool isSubscribed = profilingManager.GetAdditionInfoState();
     382            0 :     if (!isSubscribed) {
     383            0 :         return HCCL_SUCCESS;
     384              :     }
     385              : 
     386            0 :     u32 streamID = paraHost.streamID;
     387            0 :     u32 taskID = paraHost.taskID;
     388            0 :     u64 len = paraHost.len;
     389            0 :     std::string tag = paraHost.tag;
     390            0 :     std::chrono::microseconds duration = paraHost.duration;
     391              : 
     392            0 :     double bandWidth = 0;
     393            0 :     if (duration.count() > 0) {
     394            0 :         double ratio = 1.0 * std::chrono::microseconds::period::num / std::chrono::microseconds::period::den;
     395            0 :         bandWidth = len / (duration.count() * ratio);
     396            0 :         double BytetoGB = 1 << 30;
     397            0 :         bandWidth /= BytetoGB;
     398              :     }
     399              : 
     400            0 :     HCCL_INFO(
     401              :         "[profiling][host TCP/RDMA] tag[%s], streamId[%u], taskId[%u], bandWidth[%f GB / s]", tag.c_str(), streamID,
     402              :         taskID, bandWidth);
     403              : 
     404            0 :     return HCCL_SUCCESS;
     405            0 : }
     406              : 
     407           27 : void TaskProfiling::DumpReportDataInfo(uint32_t type, const MsprofHcclInfo& profInfo)
     408              : {
     409           27 :     HCCL_DEBUG(
     410              :         "[DumpReportDataInfo] type[%u], itemId[%llu], cclTag[%llu], groupName[%llu], localRank[%u], remoteRank[%u], "
     411              :         "rankSize[%u], workFlowMode[%u], planeID[%u], ctxId[%u], notifyID[%llu], stage[%u], role[%u], "
     412              :         "durationEstimated[%f], srcAddr[%llu], dstAddr[%llu], dataSize[%llu Byte], opType[%u], dataType[%u], "
     413              :         "linkType[%u], "
     414              :         "transportType[%u], rdmaType[%u]",
     415              :         type, profInfo.itemId, profInfo.cclTag, profInfo.groupName, profInfo.localRank, profInfo.remoteRank,
     416              :         profInfo.rankSize, profInfo.workFlowMode, profInfo.planeID, profInfo.ctxId, profInfo.notifyID, profInfo.stage,
     417              :         profInfo.role, profInfo.durationEstimated, profInfo.srcAddr, profInfo.dstAddr, profInfo.dataSize,
     418              :         profInfo.opType, profInfo.dataType, profInfo.linkType, profInfo.transportType, profInfo.rdmaType);
     419              : 
     420           27 :     return;
     421              : }
     422              : 
     423           24 : HcclResult TaskProfiling::ReportMsprofData(HCCLReportData& hcclReportData)
     424              : {
     425              :     int32_t cb_ret;
     426           24 :     auto& profilingManager = hccl::ProfilingManager::Instance();
     427           48 :     cb_ret = profilingManager.CallMsprofReportAdditionInfo(
     428           24 :         static_cast<uint32_t>(ProfTaskType::TASK_HCCL_INFO), hcclReportData.ts, &hcclReportData.profInfo,
     429              :         sizeof(hcclReportData.profInfo));
     430           24 :     CHK_PRT_RET((cb_ret != 0), HCCL_ERROR("[TaskProfiling] ReportData profiling failed."), HCCL_E_PARA);
     431              : 
     432           24 :     return HCCL_SUCCESS;
     433              : }
     434              : 
     435            0 : HcclResult TaskProfiling::Flush() { return HCCL_SUCCESS; }
     436              : } // namespace hccl
        

Generated by: LCOV version 2.0-1