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

Generated by: LCOV version 2.0-1