LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/stream/aicpu - stream_lite.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 81.4 % 43 35
Test Date: 2026-08-18 17:47:01 Functions: 91.7 % 12 11

            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 "stream_lite.h"
      12              : #include "binary_stream.h"
      13              : #include "string_util.h"
      14              : #include "rtsq_a5.h"
      15              : namespace Hccl {
      16              : 
      17              : // 这里不进行构造时的特殊处理,因为RtsqA5的构造不会抛出异常,唯一的可能是申请内存失败,此时抛出标准异常
      18          125 : StreamLite::StreamLite(std::vector<char>& uniqueId)
      19              : {
      20          125 :     BinaryStream binaryStream(uniqueId);
      21          125 :     binaryStream >> id;
      22          125 :     binaryStream >> sqId;
      23          125 :     binaryStream >> devPhyId;
      24          125 :     binaryStream >> cqId;
      25          375 :     HCCL_INFO(
      26              :         "StreamLite::StreamLite:Start: %s, data=%s", Describe().c_str(),
      27              :         Bytes2hex(uniqueId.data(), uniqueId.size()).c_str());
      28          125 :     rtsq = std::make_unique<RtsqA5>(devPhyId, id, sqId);
      29          375 :     HCCL_INFO("StreamLite::StreamLite:End: %s", Describe().c_str());
      30          125 : }
      31              : 
      32            8 : StreamLite::StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds) : id(id), sqId(sqIds), devPhyId(phyId), cqId(cqIds)
      33              : {
      34            8 :     rtsq = std::make_unique<RtsqA5>(phyId, id, sqIds);
      35            8 : }
      36              : 
      37            0 : StreamLite::StreamLite(u32 id, u32 sqIds, u32 phyId, u32 cqIds, bool launchFlag)
      38            0 :     : id(id),
      39            0 :       sqId(sqIds),
      40            0 :       devPhyId(phyId),
      41            0 :       cqId(cqIds)
      42              : {
      43            0 :     rtsq = std::make_unique<RtsqA5>(phyId, id, sqIds, launchFlag);
      44            0 : }
      45              : 
      46          324 : RtsqBase* StreamLite::GetRtsq() const { return rtsq.get(); }
      47              : 
      48          252 : std::string StreamLite::Describe() const
      49              : {
      50          252 :     return StringFormat("StreamLite[id=%u, sqid=%u, devPhyId=%u]", id, sqId, devPhyId);
      51              : }
      52              : 
      53            7 : TaskInfoCircularQueue* StreamLite::GetTaskInfos() const { return &taskInfos_; }
      54              : 
      55           21 : DfxTaskInfo* StreamLite::NextTaskSlot() const
      56              : {
      57           21 :     if (taskInfos_.IsFull()) {
      58            0 :         ReportStreamTask();
      59              :     }
      60           21 :     return static_cast<DfxTaskInfo*>(taskInfos_.NextSlot());
      61              : }
      62              : 
      63            3 : void StreamLite::SetReportStreamTaskCallback(std::function<void(TaskInfoCircularQueue*)> callback)
      64              : {
      65            3 :     reportStreamTaskCallback_ = std::move(callback);
      66            3 : }
      67              : 
      68            3 : bool StreamLite::HasReportStreamTaskCallback() const { return reportStreamTaskCallback_ != nullptr; }
      69              : 
      70            2 : void StreamLite::ReportStreamTask() const
      71              : {
      72            2 :     if (reportStreamTaskCallback_ != nullptr) {
      73            1 :         reportStreamTaskCallback_(&taskInfos_);
      74              :     }
      75            2 : }
      76              : 
      77            1 : void StreamLite::SetGetLatestDfxOpInfoCallback(std::function<const void*()> callback)
      78              : {
      79            1 :     getLatestDfxOpInfoCallback_ = std::move(callback);
      80            1 : }
      81              : 
      82           23 : const void* StreamLite::GetLatestDfxOpInfo() const
      83              : {
      84           23 :     if (getLatestDfxOpInfoCallback_ != nullptr) {
      85            1 :         return getLatestDfxOpInfoCallback_();
      86              :     }
      87           22 :     return nullptr;
      88              : }
      89              : 
      90              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1