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

Generated by: LCOV version 2.0-1