LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/dfx/aicpu/profiling - profiling_handler_lite.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 72.9 % 262 191
Test Date: 2026-08-29 17:38:31 Functions: 76.0 % 25 19

            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 "profiling_handler_lite.h"
      12              : #include "exception_util.h"
      13              : #include "internal_exception.h"
      14              : #include "sal.h"
      15              : #include "task_info.h"
      16              : #include "task_param.h"
      17              : #include "communicator_impl_lite.h"
      18              : #include "dlprof_function_v2.h"
      19              : #include <mutex>
      20              : namespace Hccl {
      21              : 
      22              : static constexpr u32 aging = 1;
      23              : constexpr std::uint32_t HCCLINFO_REPORT_BATCH_NUM = 2;
      24              : ProfilingHandlerLite ProfilingHandlerLite::instance_;
      25              : 
      26            1 : ProfilingHandlerLite::ProfilingHandlerLite() {}
      27              : 
      28            1 : ProfilingHandlerLite::~ProfilingHandlerLite() {}
      29              : 
      30          122 : ProfilingHandlerLite& ProfilingHandlerLite::GetInstance() { return instance_; }
      31              : 
      32            0 : void ProfilingHandlerLite::SetCachedCclTag()
      33              : {
      34            0 :     for (const auto& item : CMD_OP_TYPE_INFO_MAP) {
      35            0 :         const string& tag = item.second.second;
      36            0 :         if (cachedCclTag_.find(tag) == cachedCclTag_.end()) {
      37            0 :             const std::string& cclTag = item.second.second;
      38            0 :             cachedCclTag_[tag] = GetProfHashId(cclTag.c_str(), cclTag.length());
      39              :         }
      40              :     }
      41            0 : }
      42              : 
      43            0 : void ProfilingHandlerLite::SetCachedGroupName(const std::string& groupName, u32 rankSize)
      44              : {
      45            0 :     cachedGroupName_ = GetProfHashId(groupName.c_str(), groupName.length());
      46            0 :     cachedRankSize_ = rankSize;
      47            0 : }
      48              : 
      49            5 : HcclResult ProfilingHandlerLite::Init()
      50              : {
      51              :     static std::mutex initMutex;
      52            5 :     std::lock_guard<std::mutex> lock(initMutex); // 互斥锁,避免多线程并发调用
      53            5 :     if (initializedFlag_) {
      54            0 :         return HCCL_SUCCESS;
      55              :     }
      56            5 :     cachedTid_ = SalGetTid();
      57            5 :     if (MsprofReportBatchAdditionalInfo == nullptr) {
      58            5 :         if (AdprofReportAdditionalInfo != nullptr) {
      59            5 :             reportAdditionalInfo_ = AdprofReportAdditionalInfo;
      60              :         }
      61            5 :         if (AdprofGetHashId != nullptr) {
      62            0 :             getProfHashId_ = AdprofGetHashId;
      63              :         }
      64            5 :         if (AdprofReportBatchAdditionalInfo != nullptr) {
      65            0 :             reportBatchAdditionalInfo_ = AdprofReportBatchAdditionalInfo;
      66              :         }
      67              :     } else {
      68            0 :         if (MsprofReportAdditionalInfo != nullptr) {
      69            0 :             reportAdditionalInfo_ = [](uint32_t flag, const void* data, uint32_t len) -> int32_t {
      70            0 :                 return MsprofReportAdditionalInfo(flag, const_cast<void*>(data), len);
      71              :             };
      72              :         }
      73            0 :         if (MsprofStr2Id != nullptr) {
      74            0 :             getProfHashId_ = MsprofStr2Id;
      75              :         }
      76            0 :         reportBatchAdditionalInfo_ = [](uint32_t flag, const void* data, uint32_t len) -> int32_t {
      77            0 :             return MsprofReportBatchAdditionalInfo(flag, const_cast<void*>(data), len);
      78              :         };
      79              :     }
      80            5 :     if (reportAdditionalInfo_ == nullptr) {
      81            0 :         HCCL_ERROR("[ProfilingHandlerLite][Init] reportAdditionalInfo_ is nullptr, profiling report will be skipped");
      82            0 :         return HCCL_E_PROFILING;
      83              :     }
      84            5 :     if (getProfHashId_ == nullptr) {
      85           15 :         HCCL_ERROR("[ProfilingHandlerLite][Init] getProfHashId_ is nullptr, profiling hash will be invalid");
      86            5 :         return HCCL_E_PROFILING;
      87              :     }
      88            0 :     for (auto i = 0; i < static_cast<int>(TaskParamType::__COUNT__); i++) {
      89            0 :         TaskParamType type(static_cast<TaskParamType::Value>(i));
      90            0 :         std::string nameInfo = GetProfTaskOpNameV2(type);
      91            0 :         taskTypeHashCache_[static_cast<uint32_t>(i)] = GetProfHashId(nameInfo.c_str(), nameInfo.length());
      92            0 :     }
      93            0 :     cachedAlgTypeHashId_ = GetProfHashId("AlgType::NHR", strlen("AlgType::NHR"));
      94            0 :     SetCachedCclTag();
      95            0 :     initializedFlag_ = true;
      96            0 :     return HCCL_SUCCESS;
      97            5 : }
      98              : 
      99            9 : void ProfilingHandlerLite::ReportHcclOpInfo(const DfxOpInfo& opInfo) const
     100              : {
     101            9 :     if (!GetProfL0State()) {
     102           15 :         HCCL_INFO("[ProfilingHandlerLite][ReportHcclOpInfo] l0 is false.");
     103            5 :         return;
     104              :     }
     105            4 :     if (aicpu::GetTaskAndStreamId == nullptr) {
     106            0 :         HCCL_WARNING("[ProfilingHandlerLite][ReportHcclOpInfo] GetTaskAndStreamId is nullptr.");
     107            0 :         return;
     108              :     }
     109            4 :     uint64_t taskId = 0U;
     110            4 :     uint32_t streamId = 0;
     111            4 :     if (aicpu::GetTaskAndStreamId(taskId, streamId) != aicpu::status_t::AICPU_ERROR_NONE) {
     112            0 :         THROW<InternalException>("[ProfilingHandler] Failed to get task id and stream id.");
     113              :     }
     114            4 :     if (taskId > static_cast<uint64_t>(std::numeric_limits<uint32_t>::max())) {
     115            0 :         THROW<InvalidParamsException>("[ProfilingHandler] taskId is larger than u32.");
     116              :     }
     117            4 :     MsprofAdditionalInfo reporterData{};
     118            4 :     reporterData.level = MSPROF_REPORT_AICPU_LEVEL;
     119            4 :     reporterData.type = MSPROF_REPORT_AICPU_HCCL_OP_INFO;
     120            4 :     reporterData.threadId = cachedTid_;
     121            4 :     reporterData.dataLen = sizeof(MsprofAicpuHCCLOPInfo);
     122            4 :     reporterData.timeStamp = ProfGetCurCpuTimestamp();
     123            4 :     auto* hcclOpInfo = reinterpret_cast<MsprofAicpuHCCLOPInfo*>(reporterData.data);
     124            4 :     hcclOpInfo->algType = cachedAlgTypeHashId_;
     125              : 
     126            4 :     hcclOpInfo->taskId = static_cast<uint32_t>(taskId);
     127            4 :     hcclOpInfo->streamId = streamId;
     128            4 :     hcclOpInfo->count = opInfo.op_.dataCount;
     129            4 :     hcclOpInfo->dataType = opInfo.op_.dataType;
     130            4 :     hcclOpInfo->groupName = cachedGroupName_;
     131            4 :     hcclOpInfo->ranksize = cachedRankSize_;
     132           12 :     HCCL_INFO(
     133              :         "[ProfilingHandlerLite][ReportHcclOpInfo] relay:%d, retry:%d, dataType:%s, algType:%llu, count:%llu, "
     134              :         "groupName:%llu, ranksize:%u, taskId:%u, streamId:%u",
     135              :         hcclOpInfo->relay, hcclOpInfo->retry, DataTypeToSerialString(hcclOpInfo->dataType).c_str(),
     136              :         static_cast<unsigned long long>(hcclOpInfo->algType), static_cast<unsigned long long>(hcclOpInfo->count),
     137              :         static_cast<unsigned long long>(hcclOpInfo->groupName), hcclOpInfo->ranksize, hcclOpInfo->taskId,
     138              :         static_cast<unsigned int>(hcclOpInfo->streamId));
     139            4 :     ReportAdditionInfo(reporterData);
     140              : }
     141              : 
     142            5 : void ProfilingHandlerLite::ReportHcclTaskDetailsLog(const std::vector<TaskInfo*>& taskInfo) const
     143              : {
     144            5 :     if (LIKELY(HcclCheckLogLevel(HCCL_LOG_INFO) == 0)) {
     145            0 :         return;
     146              :     }
     147           13 :     for (std::vector<Hccl::TaskInfo*>::size_type i = 0; i < taskInfo.size(); i++) {
     148            8 :         DumpTaskDetails(MsprofAicpuHcclTaskInfo{}, taskInfo[i]);
     149              :     }
     150              : }
     151              : 
     152            6 : bool ProfilingHandlerLite::FillBatchReporterData(
     153              :     uint32_t batchId, const MsprofAicpuHcclTaskInfo* taskInfos, MsprofAdditionalInfo& addInfo) const
     154              : {
     155            6 :     addInfo.level = MSPROF_REPORT_AICPU_LEVEL;
     156            6 :     addInfo.type = MSPROF_REPORT_AICPU_MC2_BATCH_HCCL_INFO;
     157            6 :     addInfo.threadId = cachedTid_;
     158            6 :     addInfo.timeStamp = 0;
     159            6 :     addInfo.dataLen = sizeof(MsprofAicpuHcclTaskInfo) * batchId;
     160            6 :     s32 sret = memcpy_s(addInfo.data, sizeof(addInfo.data), taskInfos, addInfo.dataLen);
     161            6 :     if (sret != 0) {
     162            0 :         HCCL_WARNING("[ProfilingHandlerLite][FillBatchReporterData] memcpy failed, sret[%d]", sret);
     163            0 :         return false;
     164              :     }
     165            6 :     return true;
     166              : }
     167              : 
     168            0 : bool ProfilingHandlerLite::ReportBatchAddInfo(
     169              :     uint32_t batchId, const MsprofAicpuHcclTaskInfo* taskInfos, MsprofAdditionalInfo* addInfoVec, uint32_t& addInfoIndx,
     170              :     uint32_t maxBatchNum, bool isLastBatch) const
     171              : {
     172            0 :     if (!FillBatchReporterData(batchId, taskInfos, addInfoVec[addInfoIndx])) {
     173            0 :         return false;
     174              :     }
     175            0 :     addInfoIndx++;
     176            0 :     if (addInfoIndx == maxBatchNum || isLastBatch) {
     177            0 :         if (reportBatchAdditionalInfo_(aging, addInfoVec, addInfoIndx * sizeof(MsprofAdditionalInfo)) != 0) {
     178            0 :             HCCL_WARNING("[ProfilingHandlerLite][ReportHcclTaskDetails] reportBatchAdditionalInfo failed");
     179            0 :             return false;
     180              :         }
     181            0 :         addInfoIndx = 0;
     182              :     }
     183            0 :     return true;
     184              : }
     185              : 
     186            5 : void ProfilingHandlerLite::ReportHcclTaskDetails(const std::vector<TaskInfo*>& taskInfo) const
     187              : {
     188            5 :     ReportHcclTaskDetailsLog(taskInfo);
     189            5 :     MsprofAicpuHcclTaskInfo taskInfos[HCCLINFO_REPORT_BATCH_NUM] = {};
     190            5 :     bool isSupportBatchReport = (reportBatchAdditionalInfo_ != nullptr);
     191           15 :     HCCL_INFO(
     192              :         "[ProfilingHandlerLite][ReportHcclTaskDetails] isSupportBatchReport: %s, taskInfo.size: %zu",
     193              :         isSupportBatchReport ? "true" : "false", taskInfo.size());
     194            5 :     constexpr int32_t MAX_BATCH_REPORT_NUM = 512;
     195         2560 :     MsprofAdditionalInfo addInfoVec[MAX_BATCH_REPORT_NUM] = {};
     196            5 :     uint32_t addInfoIndx = 0;
     197            5 :     uint32_t batchId = 0;
     198           13 :     for (std::vector<Hccl::TaskInfo*>::size_type i = 0; i < taskInfo.size(); i++) {
     199            8 :         GetTaskDetailInfos(taskInfo[i], taskInfos[batchId++]);
     200            8 :         if (batchId == HCCLINFO_REPORT_BATCH_NUM || i == taskInfo.size() - 1) {
     201            6 :             if (!isSupportBatchReport) {
     202            6 :                 MsprofAdditionalInfo reporterData{};
     203            6 :                 if (!FillBatchReporterData(batchId, taskInfos, reporterData)) {
     204            0 :                     return;
     205              :                 }
     206            6 :                 ReportAdditionInfo(reporterData);
     207              :             } else {
     208            0 :                 if (!ReportBatchAddInfo(
     209            0 :                         batchId, taskInfos, addInfoVec, addInfoIndx, MAX_BATCH_REPORT_NUM, i == taskInfo.size() - 1)) {
     210            0 :                     return;
     211              :                 }
     212              :             }
     213            6 :             batchId = 0;
     214            6 :             errno_t ret = memset_s(taskInfos, sizeof(taskInfos), 0, sizeof(taskInfos));
     215            6 :             if (ret != EOK) {
     216            0 :                 THROW<InternalException>(
     217              :                     "[ProfilingHandler] Failed to memset_s taskInfos, dest[%p], destMax[%zu], "
     218              :                     "c[%d], count[%zu], ret[%d].",
     219              :                     static_cast<void*>(taskInfos), sizeof(taskInfos), 0, sizeof(taskInfos), ret);
     220              :             }
     221              :         }
     222              :     }
     223              : }
     224              : 
     225            8 : void ProfilingHandlerLite::FillTaskParamDetails(const TaskInfo* it, MsprofAicpuHcclTaskInfo& taskDetailsInfos) const
     226              : {
     227            8 :     const auto& taskPara = it->taskParam_.taskPara;
     228            8 :     switch (it->taskParam_.taskType) {
     229            1 :         case TaskParamType::TASK_SDMA:
     230              :         case TaskParamType::TASK_RDMA:
     231              :         case TaskParamType::TASK_UB_INLINE_WRITE:
     232              :         case TaskParamType::TASK_WRITE_WITH_NOTIFY:
     233              :         case TaskParamType::TASK_UB:
     234            1 :             taskDetailsInfos.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.DMA.src));
     235            1 :             taskDetailsInfos.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.DMA.dst));
     236            1 :             taskDetailsInfos.dataSize = static_cast<u32>(taskPara.DMA.size);
     237            1 :             taskDetailsInfos.notifyID = taskPara.DMA.notifyID;
     238            1 :             taskDetailsInfos.linkType = static_cast<uint16_t>(taskPara.DMA.linkType);
     239            1 :             break;
     240            1 :         case TaskParamType::TASK_REDUCE_INLINE:
     241              :         case TaskParamType::TASK_REDUCE_TBE:
     242              :         case TaskParamType::TASK_UB_REDUCE_INLINE:
     243              :         case TaskParamType::TASK_WRITE_REDUCE_WITH_NOTIFY:
     244            1 :             taskDetailsInfos.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.Reduce.src));
     245            1 :             taskDetailsInfos.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.Reduce.dst));
     246            1 :             taskDetailsInfos.dataSize = static_cast<u32>(taskPara.Reduce.size);
     247            1 :             taskDetailsInfos.notifyID = taskPara.Reduce.notifyID;
     248            1 :             taskDetailsInfos.dataType = static_cast<uint16_t>(taskPara.Reduce.dataType);
     249            1 :             taskDetailsInfos.linkType = static_cast<uint16_t>(taskPara.Reduce.linkType);
     250            1 :             taskDetailsInfos.opType = taskPara.Reduce.reduceOp;
     251            1 :             break;
     252            5 :         case TaskParamType::TASK_NOTIFY_RECORD:
     253              :         case TaskParamType::TASK_NOTIFY_WAIT:
     254            5 :             taskDetailsInfos.notifyID = taskPara.Notify.notifyID;
     255            5 :             break;
     256            1 :         default:
     257            1 :             break;
     258              :     }
     259            8 : }
     260              : 
     261            8 : void ProfilingHandlerLite::GetTaskDetailInfos(const TaskInfo* it, MsprofAicpuHcclTaskInfo& taskDetailsInfos) const
     262              : {
     263            8 :     constexpr u32 INVALID_LOCAL_RANK = UINT32_MAX;
     264            8 :     constexpr u32 INVALID_REMOTE_RANK = UINT32_MAX;
     265            8 :     taskDetailsInfos.localRank = INVALID_LOCAL_RANK;
     266            8 :     taskDetailsInfos.remoteRank = INVALID_REMOTE_RANK;
     267            8 :     if (it->dfxOpInfo_ != nullptr) {
     268            7 :         auto cacheIt = taskTypeHashCache_.find(static_cast<uint32_t>(it->taskParam_.taskType));
     269            7 :         taskDetailsInfos.itemId = (cacheIt != taskTypeHashCache_.end()) ? cacheIt->second : INVALID_U64;
     270            7 :         auto cclTagIt = cachedCclTag_.find(it->dfxOpInfo_->tag_);
     271            7 :         taskDetailsInfos.cclTag = (cclTagIt != cachedCclTag_.end()) ? cclTagIt->second : INVALID_U64;
     272            7 :         taskDetailsInfos.remoteRank = it->GetRemoteRankId();
     273            7 :         taskDetailsInfos.groupName = cachedGroupName_;
     274            7 :         taskDetailsInfos.rankSize = cachedRankSize_;
     275            7 :         taskDetailsInfos.localRank = it->dfxOpInfo_->op_.myRank;
     276            7 :         taskDetailsInfos.stage = 0;
     277              :     } else {
     278            3 :         HCCL_WARNING("[ProfilingHandlerLite::GetTaskDetailInfos] dfxOpInfo_ is nullptr!");
     279            1 :         taskDetailsInfos.remoteRank = taskDetailsInfos.localRank;
     280              :     }
     281            8 :     taskDetailsInfos.stage = 0;
     282            8 :     FillTaskParamDetails(it, taskDetailsInfos);
     283            8 :     taskDetailsInfos.timeStamp = ProfGetCurCpuTimestamp();
     284            8 :     taskDetailsInfos.durationEstimated = 0;
     285            8 :     taskDetailsInfos.taskId = it->taskId_;
     286            8 :     taskDetailsInfos.streamId = it->streamId_;
     287            8 :     taskDetailsInfos.planeID = 0;
     288            8 :     taskDetailsInfos.transportType = static_cast<int32_t>(SimpleTaskType::UB);
     289            8 :     if (taskDetailsInfos.remoteRank == INVALID_VALUE_RANKID) {
     290            1 :         taskDetailsInfos.transportType = static_cast<int32_t>(SimpleTaskType::LOCAL);
     291            1 :         taskDetailsInfos.remoteRank = taskDetailsInfos.localRank;
     292              :     }
     293            8 :     taskDetailsInfos.role = static_cast<uint32_t>(TaskRole::DST);
     294            8 :     taskDetailsInfos.workFlowMode = static_cast<uint32_t>(HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
     295            8 : }
     296              : 
     297            8 : void ProfilingHandlerLite::DumpTaskDetails(
     298              :     [[maybe_unused]] const MsprofAicpuHcclTaskInfo& taskDetailsInfos, const TaskInfo* taskInfo) const
     299              : {
     300           24 :     HCCL_INFO("[ProfilingHandlerLite] DumpTaskDetails %s", taskInfo->Describe().c_str());
     301            8 : }
     302              : 
     303            9 : void ProfilingHandlerLite::ReportMainStreamTask(const FlagTaskInfo& flagTaskInfo) const
     304              : {
     305            9 :     if (!GetProfL0State()) {
     306           24 :         HCCL_INFO("[ProfilingHandlerLite][ReportMainStreamTask] l0 is false.");
     307            8 :         return;
     308              :     }
     309            1 :     if (aicpu::GetTaskAndStreamId == nullptr) {
     310            0 :         HCCL_WARNING("[ProfilingHandlerLite][ReportMainStreamTask] aicpu::GetTaskAndStreamId is nullptr.");
     311            0 :         return;
     312              :     }
     313            1 :     uint64_t aicpuKernelTaskId = 0U;
     314            1 :     uint32_t aicpuKernelStreamId = 0;
     315            1 :     if (aicpu::GetTaskAndStreamId(aicpuKernelTaskId, aicpuKernelStreamId) != aicpu::status_t::AICPU_ERROR_NONE) {
     316            0 :         THROW<InternalException>("[ProfilingHandler] Failed to get task id and stream id.");
     317              :     }
     318            1 :     if (aicpuKernelTaskId > static_cast<uint64_t>(std::numeric_limits<uint32_t>::max())) {
     319            0 :         THROW<InvalidParamsException>("[ProfilingHandler] aicpuKernelTaskId is larger than u32.");
     320              :     }
     321            1 :     MsprofAdditionalInfo reporterData{};
     322            1 :     reporterData.level = MSPROF_REPORT_AICPU_LEVEL;
     323            1 :     reporterData.type = MSPROF_REPORT_AICPU_HCCL_FLAG_TASK;
     324            1 :     reporterData.threadId = cachedTid_;
     325            1 :     reporterData.dataLen = sizeof(MsprofAicpuHcclMainStreamTask);
     326            1 :     reporterData.timeStamp = ProfGetCurCpuTimestamp();
     327            1 :     constexpr uint32_t UINT16_BIT_WIDTH = std::numeric_limits<uint16_t>::digits;
     328            1 :     auto* flagtask = reinterpret_cast<MsprofAicpuHcclMainStreamTask*>(reporterData.data);
     329            1 :     flagtask->taskId = static_cast<uint16_t>(flagTaskInfo.taskId >> UINT16_BIT_WIDTH);
     330            1 :     flagtask->streamId = static_cast<uint16_t>(flagTaskInfo.taskId);
     331            1 :     flagtask->type = flagTaskInfo.type;
     332            1 :     uint32_t aicpuKernelTaskIdLow32 = static_cast<uint32_t>(aicpuKernelTaskId);
     333            1 :     flagtask->aicpuTaskId = static_cast<uint16_t>(aicpuKernelTaskIdLow32 >> UINT16_BIT_WIDTH);
     334            1 :     flagtask->aicpuStreamId = static_cast<uint16_t>(aicpuKernelTaskIdLow32);
     335            3 :     HCCL_INFO(
     336              :         "[ProfilingHandlerLite][ReportMainStreamTask] streamId:%u, taskId:%u, type:%u,"
     337              :         "aicpuStreamId:%u, aicpuTaskId:%u",
     338              :         flagtask->streamId, flagtask->taskId, flagtask->type, flagtask->aicpuStreamId, flagtask->aicpuTaskId);
     339            1 :     ReportAdditionInfo(reporterData);
     340              : }
     341              : 
     342           11 : void ProfilingHandlerLite::ReportAdditionInfo(const MsprofAdditionalInfo& reporterData) const
     343              : {
     344           11 :     if (reportAdditionalInfo_(aging, &reporterData, sizeof(MsprofAdditionalInfo)) != 0) {
     345            1 :         THROW<InternalException>("[ProfilingHandler] ReportAdditionalInfo failed.");
     346              :     }
     347           10 : }
     348              : 
     349            5 : void ProfilingHandlerLite::UpdateProfSwitch()
     350              : {
     351            5 :     IsL1fromOffToOn();
     352            5 :     IsProfSwitchOn(ProfilingLevel::L0);
     353            5 :     IsProfSwitchOn(ProfilingLevel::L1);
     354            5 : }
     355              : 
     356           18 : bool ProfilingHandlerLite::IsProfOn(uint64_t feature) const
     357              : {
     358           18 :     if (MsprofReportBatchAdditionalInfo == nullptr) {
     359           18 :         if (AdprofCheckFeatureIsOn == nullptr) {
     360           18 :             return false;
     361              :         }
     362            0 :         return AdprofCheckFeatureIsOn(feature) > 0;
     363              :     } else {
     364            0 :         if (feature == ADPROF_TASK_TIME_L1) {
     365            0 :             return enableHcclL1_;
     366            0 :         } else if (feature == ADPROF_TASK_TIME_L0) {
     367            0 :             return enableHcclL0_;
     368              :         }
     369              :     }
     370              : 
     371            0 :     return false;
     372              : }
     373              : 
     374           17 : bool ProfilingHandlerLite::IsProfSwitchOn(ProfilingLevel level)
     375              : {
     376           17 :     bool res = false;
     377           17 :     if (level == ProfilingLevel::L0) {
     378            6 :         res = IsProfOn(ADPROF_TASK_TIME_L0);
     379            6 :         enableHcclL0_ = res;
     380           11 :     } else if (level == ProfilingLevel::L1) {
     381           11 :         res = IsProfOn(ADPROF_TASK_TIME_L1);
     382           11 :         enableHcclL1_ = res;
     383              :     }
     384           17 :     return res;
     385              : }
     386              : 
     387            6 : bool ProfilingHandlerLite::IsL1fromOffToOn()
     388              : {
     389            6 :     if (((!GetProfL1State()) && IsProfSwitchOn(ProfilingLevel::L1))) {
     390            0 :         HCCL_INFO("Profiling L1 switch from off to on.");
     391            0 :         return true;
     392              :     }
     393            6 :     return false;
     394              : }
     395              : 
     396            1 : void ProfilingHandlerLite::SetProL1On(bool val)
     397              : {
     398            3 :     HCCL_INFO("[%s] val = [%d]", __func__, val);
     399            1 :     enableHcclL1_ = val;
     400            1 : }
     401              : 
     402            1 : void ProfilingHandlerLite::SetProL0On(bool val)
     403              : {
     404            3 :     HCCL_INFO("[%s] val = [%d]", __func__, val);
     405            1 :     enableHcclL0_ = val;
     406            1 : }
     407              : 
     408            0 : uint64_t ProfilingHandlerLite::GetProfHashId(const char* name, uint32_t len) const
     409              : {
     410            0 :     if (name == nullptr || len == 0) {
     411            0 :         HCCL_WARNING("HashData is empty. name:%s, len:%u", name, len);
     412            0 :         return INVALID_U64;
     413              :     }
     414            0 :     return getProfHashId_(name, len);
     415              : }
     416              : 
     417              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1