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-18 17:47:01 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 :             memset_s(taskInfos, sizeof(taskInfos), 0, sizeof(taskInfos));
     215              :         }
     216              :     }
     217              : }
     218              : 
     219            8 : void ProfilingHandlerLite::FillTaskParamDetails(const TaskInfo* it, MsprofAicpuHcclTaskInfo& taskDetailsInfos) const
     220              : {
     221            8 :     const auto& taskPara = it->taskParam_.taskPara;
     222            8 :     switch (it->taskParam_.taskType) {
     223            1 :         case TaskParamType::TASK_SDMA:
     224              :         case TaskParamType::TASK_RDMA:
     225              :         case TaskParamType::TASK_UB_INLINE_WRITE:
     226              :         case TaskParamType::TASK_WRITE_WITH_NOTIFY:
     227              :         case TaskParamType::TASK_UB:
     228            1 :             taskDetailsInfos.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.DMA.src));
     229            1 :             taskDetailsInfos.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.DMA.dst));
     230            1 :             taskDetailsInfos.dataSize = static_cast<u32>(taskPara.DMA.size);
     231            1 :             taskDetailsInfos.notifyID = taskPara.DMA.notifyID;
     232            1 :             taskDetailsInfos.linkType = static_cast<uint16_t>(taskPara.DMA.linkType);
     233            1 :             break;
     234            1 :         case TaskParamType::TASK_REDUCE_INLINE:
     235              :         case TaskParamType::TASK_REDUCE_TBE:
     236              :         case TaskParamType::TASK_UB_REDUCE_INLINE:
     237              :         case TaskParamType::TASK_WRITE_REDUCE_WITH_NOTIFY:
     238            1 :             taskDetailsInfos.srcAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.Reduce.src));
     239            1 :             taskDetailsInfos.dstAddr = static_cast<u64>(reinterpret_cast<uintptr_t>(taskPara.Reduce.dst));
     240            1 :             taskDetailsInfos.dataSize = static_cast<u32>(taskPara.Reduce.size);
     241            1 :             taskDetailsInfos.notifyID = taskPara.Reduce.notifyID;
     242            1 :             taskDetailsInfos.dataType = static_cast<uint16_t>(taskPara.Reduce.dataType);
     243            1 :             taskDetailsInfos.linkType = static_cast<uint16_t>(taskPara.Reduce.linkType);
     244            1 :             taskDetailsInfos.opType = taskPara.Reduce.reduceOp;
     245            1 :             break;
     246            5 :         case TaskParamType::TASK_NOTIFY_RECORD:
     247              :         case TaskParamType::TASK_NOTIFY_WAIT:
     248            5 :             taskDetailsInfos.notifyID = taskPara.Notify.notifyID;
     249            5 :             break;
     250            1 :         default:
     251            1 :             break;
     252              :     }
     253            8 : }
     254              : 
     255            8 : void ProfilingHandlerLite::GetTaskDetailInfos(const TaskInfo* it, MsprofAicpuHcclTaskInfo& taskDetailsInfos) const
     256              : {
     257            8 :     constexpr u32 INVALID_LOCAL_RANK = UINT32_MAX;
     258            8 :     constexpr u32 INVALID_REMOTE_RANK = UINT32_MAX;
     259            8 :     taskDetailsInfos.localRank = INVALID_LOCAL_RANK;
     260            8 :     taskDetailsInfos.remoteRank = INVALID_REMOTE_RANK;
     261            8 :     if (it->dfxOpInfo_ != nullptr) {
     262            7 :         auto cacheIt = taskTypeHashCache_.find(static_cast<uint32_t>(it->taskParam_.taskType));
     263            7 :         taskDetailsInfos.itemId = (cacheIt != taskTypeHashCache_.end()) ? cacheIt->second : INVALID_U64;
     264            7 :         auto cclTagIt = cachedCclTag_.find(it->dfxOpInfo_->tag_);
     265            7 :         taskDetailsInfos.cclTag = (cclTagIt != cachedCclTag_.end()) ? cclTagIt->second : INVALID_U64;
     266            7 :         taskDetailsInfos.remoteRank = it->GetRemoteRankId();
     267            7 :         taskDetailsInfos.groupName = cachedGroupName_;
     268            7 :         taskDetailsInfos.rankSize = cachedRankSize_;
     269            7 :         taskDetailsInfos.localRank = it->dfxOpInfo_->op_.myRank;
     270            7 :         taskDetailsInfos.stage = 0;
     271              :     } else {
     272            3 :         HCCL_WARNING("[ProfilingHandlerLite::GetTaskDetailInfos] dfxOpInfo_ is nullptr!");
     273            1 :         taskDetailsInfos.remoteRank = taskDetailsInfos.localRank;
     274              :     }
     275            8 :     taskDetailsInfos.stage = 0;
     276            8 :     FillTaskParamDetails(it, taskDetailsInfos);
     277            8 :     taskDetailsInfos.timeStamp = ProfGetCurCpuTimestamp();
     278            8 :     taskDetailsInfos.durationEstimated = 0;
     279            8 :     taskDetailsInfos.taskId = it->taskId_;
     280            8 :     taskDetailsInfos.streamId = it->streamId_;
     281            8 :     taskDetailsInfos.planeID = 0;
     282            8 :     taskDetailsInfos.transportType = static_cast<int32_t>(SimpleTaskType::UB);
     283            8 :     if (taskDetailsInfos.remoteRank == INVALID_VALUE_RANKID) {
     284            1 :         taskDetailsInfos.transportType = static_cast<int32_t>(SimpleTaskType::LOCAL);
     285            1 :         taskDetailsInfos.remoteRank = taskDetailsInfos.localRank;
     286              :     }
     287            8 :     taskDetailsInfos.role = static_cast<uint32_t>(TaskRole::DST);
     288            8 :     taskDetailsInfos.workFlowMode = static_cast<uint32_t>(HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
     289            8 : }
     290              : 
     291            8 : void ProfilingHandlerLite::DumpTaskDetails(
     292              :     [[maybe_unused]] const MsprofAicpuHcclTaskInfo& taskDetailsInfos, const TaskInfo* taskInfo) const
     293              : {
     294           24 :     HCCL_INFO("[ProfilingHandlerLite] DumpTaskDetails %s", taskInfo->Describe().c_str());
     295            8 : }
     296              : 
     297            9 : void ProfilingHandlerLite::ReportMainStreamTask(const FlagTaskInfo& flagTaskInfo) const
     298              : {
     299            9 :     if (!GetProfL0State()) {
     300           24 :         HCCL_INFO("[ProfilingHandlerLite][ReportMainStreamTask] l0 is false.");
     301            8 :         return;
     302              :     }
     303            1 :     if (aicpu::GetTaskAndStreamId == nullptr) {
     304            0 :         HCCL_WARNING("[ProfilingHandlerLite][ReportMainStreamTask] aicpu::GetTaskAndStreamId is nullptr.");
     305            0 :         return;
     306              :     }
     307            1 :     uint64_t aicpuKernelTaskId = 0U;
     308            1 :     uint32_t aicpuKernelStreamId = 0;
     309            1 :     if (aicpu::GetTaskAndStreamId(aicpuKernelTaskId, aicpuKernelStreamId) != aicpu::status_t::AICPU_ERROR_NONE) {
     310            0 :         THROW<InternalException>("[ProfilingHandler] Failed to get task id and stream id.");
     311              :     }
     312            1 :     if (aicpuKernelTaskId > static_cast<uint64_t>(std::numeric_limits<uint32_t>::max())) {
     313            0 :         THROW<InvalidParamsException>("[ProfilingHandler] aicpuKernelTaskId is larger than u32.");
     314              :     }
     315            1 :     MsprofAdditionalInfo reporterData{};
     316            1 :     reporterData.level = MSPROF_REPORT_AICPU_LEVEL;
     317            1 :     reporterData.type = MSPROF_REPORT_AICPU_HCCL_FLAG_TASK;
     318            1 :     reporterData.threadId = cachedTid_;
     319            1 :     reporterData.dataLen = sizeof(MsprofAicpuHcclMainStreamTask);
     320            1 :     reporterData.timeStamp = ProfGetCurCpuTimestamp();
     321            1 :     constexpr uint32_t UINT16_BIT_WIDTH = std::numeric_limits<uint16_t>::digits;
     322            1 :     auto* flagtask = reinterpret_cast<MsprofAicpuHcclMainStreamTask*>(reporterData.data);
     323            1 :     flagtask->taskId = static_cast<uint16_t>(flagTaskInfo.taskId >> UINT16_BIT_WIDTH);
     324            1 :     flagtask->streamId = static_cast<uint16_t>(flagTaskInfo.taskId);
     325            1 :     flagtask->type = flagTaskInfo.type;
     326            1 :     uint32_t aicpuKernelTaskIdLow32 = static_cast<uint32_t>(aicpuKernelTaskId);
     327            1 :     flagtask->aicpuTaskId = static_cast<uint16_t>(aicpuKernelTaskIdLow32 >> UINT16_BIT_WIDTH);
     328            1 :     flagtask->aicpuStreamId = static_cast<uint16_t>(aicpuKernelTaskIdLow32);
     329            3 :     HCCL_INFO(
     330              :         "[ProfilingHandlerLite][ReportMainStreamTask] streamId:%u, taskId:%u, type:%u,"
     331              :         "aicpuStreamId:%u, aicpuTaskId:%u",
     332              :         flagtask->streamId, flagtask->taskId, flagtask->type, flagtask->aicpuStreamId, flagtask->aicpuTaskId);
     333            1 :     ReportAdditionInfo(reporterData);
     334              : }
     335              : 
     336           11 : void ProfilingHandlerLite::ReportAdditionInfo(const MsprofAdditionalInfo& reporterData) const
     337              : {
     338           11 :     if (reportAdditionalInfo_(aging, &reporterData, sizeof(MsprofAdditionalInfo)) != 0) {
     339            1 :         THROW<InternalException>("[ProfilingHandler] ReportAdditionalInfo failed.");
     340              :     }
     341           10 : }
     342              : 
     343            5 : void ProfilingHandlerLite::UpdateProfSwitch()
     344              : {
     345            5 :     IsL1fromOffToOn();
     346            5 :     IsProfSwitchOn(ProfilingLevel::L0);
     347            5 :     IsProfSwitchOn(ProfilingLevel::L1);
     348            5 : }
     349              : 
     350           18 : bool ProfilingHandlerLite::IsProfOn(uint64_t feature) const
     351              : {
     352           18 :     if (MsprofReportBatchAdditionalInfo == nullptr) {
     353           18 :         if (AdprofCheckFeatureIsOn == nullptr) {
     354           18 :             return false;
     355              :         }
     356            0 :         return AdprofCheckFeatureIsOn(feature) > 0;
     357              :     } else {
     358            0 :         if (feature == ADPROF_TASK_TIME_L1) {
     359            0 :             return enableHcclL1_;
     360            0 :         } else if (feature == ADPROF_TASK_TIME_L0) {
     361            0 :             return enableHcclL0_;
     362              :         }
     363              :     }
     364              : 
     365            0 :     return false;
     366              : }
     367              : 
     368           17 : bool ProfilingHandlerLite::IsProfSwitchOn(ProfilingLevel level)
     369              : {
     370           17 :     bool res = false;
     371           17 :     if (level == ProfilingLevel::L0) {
     372            6 :         res = IsProfOn(ADPROF_TASK_TIME_L0);
     373            6 :         enableHcclL0_ = res;
     374           11 :     } else if (level == ProfilingLevel::L1) {
     375           11 :         res = IsProfOn(ADPROF_TASK_TIME_L1);
     376           11 :         enableHcclL1_ = res;
     377              :     }
     378           17 :     return res;
     379              : }
     380              : 
     381            6 : bool ProfilingHandlerLite::IsL1fromOffToOn()
     382              : {
     383            6 :     if (((!GetProfL1State()) && IsProfSwitchOn(ProfilingLevel::L1))) {
     384            0 :         HCCL_INFO("Profiling L1 switch form off to on.");
     385            0 :         return true;
     386              :     }
     387            6 :     return false;
     388              : }
     389              : 
     390            1 : void ProfilingHandlerLite::SetProL1On(bool val)
     391              : {
     392            3 :     HCCL_INFO("[%s] val = [%d]", __func__, val);
     393            1 :     enableHcclL1_ = val;
     394            1 : }
     395              : 
     396            1 : void ProfilingHandlerLite::SetProL0On(bool val)
     397              : {
     398            3 :     HCCL_INFO("[%s] val = [%d]", __func__, val);
     399            1 :     enableHcclL0_ = val;
     400            1 : }
     401              : 
     402            0 : uint64_t ProfilingHandlerLite::GetProfHashId(const char* name, uint32_t len) const
     403              : {
     404            0 :     if (name == nullptr || len == 0) {
     405            0 :         HCCL_WARNING("HashData is empty. name:%s, len:%u", name, len);
     406            0 :         return INVALID_U64;
     407              :     }
     408            0 :     return getProfHashId_(name, len);
     409              : }
     410              : 
     411              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1