LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/notify - rts_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 97.1 % 34 33
Test Date: 2026-08-17 10:19:35 Functions: 92.9 % 14 13

            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 "rts_notify_v2.h"
      11              : #include "log.h"
      12              : #include "dev_capability.h"
      13              : #include "binary_stream.h"
      14              : namespace Hccl {
      15              : 
      16          980 : RtsNotify::RtsNotify(bool devUsed) : devPhyId(HrtGetDevicePhyIdByIndex(HrtGetDevice())), devUsed(devUsed)
      17              : {
      18          980 :     s32 deviceID = HrtGetDevice();
      19              : 
      20          980 :     if (devUsed) {
      21          121 :         handle = HrtNotifyCreateWithFlag(deviceID, ACL_NOTIFY_DEVICE_USE_ONLY);
      22              :     } else {
      23          859 :         handle = HrtNotifyCreate(deviceID);
      24              :     }
      25              : 
      26          980 :     id = HrtGetNotifyID(handle);
      27          980 : }
      28              : 
      29          980 : RtsNotify::~RtsNotify() { DECTOR_TRY_CATCH("RtsNotify", HrtNotifyDestroy(handle)); }
      30              : 
      31           17 : std::string RtsNotify::SetIpcName() const
      32              : {
      33           17 :     char ipcName[RTS_IPC_MEM_NAME_LEN] = {0};
      34           17 :     HrtIpcSetNotifyName(handle, ipcName, RTS_IPC_MEM_NAME_LEN);
      35           34 :     return ipcName;
      36              : }
      37              : 
      38            0 : void RtsNotify::SetIpcPid(s32 pid) const { HrtSetIpcNotifyPid(handle, pid); }
      39              : 
      40          149 : u32 RtsNotify::GetId() const { return id; }
      41              : 
      42            2 : u64 RtsNotify::GetOffset() const { return HrtNotifyGetOffset(handle); }
      43              : 
      44           20 : u64 RtsNotify::GetHandleAddr() const { return reinterpret_cast<u64>(handle); }
      45              : 
      46            2 : u32 RtsNotify::GetSize() const { return DevCapability::GetInstance().GetNotifySize(); }
      47              : 
      48            2 : bool RtsNotify::IsDevUsed() const { return devUsed; }
      49              : 
      50           14 : u32 RtsNotify::GetDevPhyId() const { return devPhyId; }
      51              : 
      52           62 : std::vector<char> RtsNotify::GetUniqueId() const
      53              : {
      54           62 :     BinaryStream binaryStream;
      55           62 :     binaryStream << id;
      56           62 :     binaryStream << devPhyId;
      57          164 :     HCCL_INFO("[RtsNotify][GetUniqueId]id[%u] devPhyId[%u]", id, devPhyId);
      58           62 :     std::vector<char> result;
      59           62 :     binaryStream.Dump(result);
      60           62 :     return result;
      61           62 : }
      62              : 
      63           13 : void RtsNotify::Wait(const Stream& stream, u32 timeout) const
      64              : {
      65           13 :     HrtNotifyWaitWithTimeOut(handle, stream.GetPtr(), timeout);
      66           13 : }
      67              : 
      68           10 : void RtsNotify::Post(const Stream& stream) const { HrtNotifyRecord(handle, stream.GetPtr()); }
      69              : 
      70          105 : string RtsNotify::Describe() const
      71              : {
      72          105 :     return StringFormat("RtsNotify[devUsed=%d, id=%u, handle=%p]", devUsed, id, handle);
      73              : }
      74              : 
      75              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1