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: 93.5 % 46 43
Test Date: 2026-08-04 10:52:23 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.h"
      11              : #include "log.h"
      12              : #include "dev_capability.h"
      13              : #include "binary_stream.h"
      14              : namespace Hccl {
      15              : 
      16          973 : RtsNotify::RtsNotify(bool devUsed) : devPhyId(HrtGetDevicePhyIdByIndex(HrtGetDevice())), devUsed(devUsed)
      17              : {
      18          973 :     s32 deviceID = HrtGetDevice();
      19              : 
      20          973 :     if (devUsed) {
      21          121 :         handle = HrtNotifyCreateWithFlag(deviceID, ACL_NOTIFY_DEVICE_USE_ONLY);
      22              :     } else {
      23          852 :         handle = HrtNotifyCreate(deviceID);
      24              :     }
      25              : 
      26          973 :     id = HrtGetNotifyID(handle);
      27          973 : }
      28              : 
      29          973 : RtsNotify::~RtsNotify()
      30              : {
      31          973 :     DECTOR_TRY_CATCH("RtsNotify", HrtNotifyDestroy(handle));
      32          973 : }
      33              : 
      34           17 : std::string RtsNotify::SetIpcName() const
      35              : {
      36           17 :     char ipcName[RTS_IPC_MEM_NAME_LEN] = {0};
      37           17 :     HrtIpcSetNotifyName(handle, ipcName, RTS_IPC_MEM_NAME_LEN);
      38           34 :     return ipcName;
      39              : }
      40              : 
      41              : 
      42            0 : void RtsNotify::SetIpcPid(s32 pid) const
      43              : {
      44            0 :     HrtSetIpcNotifyPid(handle, pid);
      45            0 : }
      46              : 
      47          133 : u32 RtsNotify::GetId() const
      48              : {
      49          133 :     return id;
      50              : }
      51              : 
      52            2 : u64 RtsNotify::GetOffset() const
      53              : {
      54            2 :     return HrtNotifyGetOffset(handle);
      55              : }
      56              : 
      57           20 : u64 RtsNotify::GetHandleAddr() const
      58              : {
      59           20 :     return reinterpret_cast<u64>(handle);
      60              : }
      61              : 
      62            2 : u32 RtsNotify::GetSize() const
      63              : {
      64            2 :     return DevCapability::GetInstance().GetNotifySize();
      65              : }
      66              : 
      67            2 : bool RtsNotify::IsDevUsed() const
      68              : {
      69            2 :     return devUsed;
      70              : }
      71              : 
      72           14 : u32 RtsNotify::GetDevPhyId() const
      73              : {
      74           14 :     return devPhyId;
      75              : }
      76              : 
      77           58 : std::vector<char> RtsNotify::GetUniqueId() const
      78              : {
      79           58 :     BinaryStream binaryStream;
      80           58 :     binaryStream << id;
      81           58 :     binaryStream << devPhyId;
      82          152 :     HCCL_INFO("[RtsNotify][GetUniqueId]id[%u] devPhyId[%u]", id, devPhyId);
      83           58 :     std::vector<char> result;
      84           58 :     binaryStream.Dump(result);
      85           58 :     return result;
      86           58 : }
      87              : 
      88           13 : void RtsNotify::Wait(const Stream &stream, u32 timeout) const
      89              : {
      90           13 :     HrtNotifyWaitWithTimeOut(handle, stream.GetPtr(), timeout);
      91           13 : }
      92              : 
      93           10 : void RtsNotify::Post(const Stream &stream) const
      94              : {
      95           10 :     HrtNotifyRecord(handle, stream.GetPtr());
      96           10 : }
      97              : 
      98           97 : string RtsNotify::Describe() const
      99              : {
     100           97 :     return StringFormat("RtsNotify[devUsed=%d, id=%u, handle=%p]", devUsed, id, handle);
     101              : }
     102              : 
     103              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1