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

Generated by: LCOV version 2.0-1