LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/notify - ipc_local_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 61.9 % 21 13
Test Date: 2026-08-18 17:47:01 Functions: 83.3 % 6 5

            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 "ipc_local_notify.h"
      12              : #include "runtime_api_exception.h"
      13              : #include "exchange_ipc_notify_dto.h"
      14              : 
      15              : namespace Hccl {
      16              : 
      17           15 : IpcLocalNotify::IpcLocalNotify(bool devUsed) : BaseLocalNotify(RmaType::IPC, devUsed)
      18              : {
      19              :     // SetIpc
      20           15 :     auto name = GetNotify()->SetIpcName();
      21           15 :     s32 sRet = memcpy_s(ipcName, RTS_IPC_MEM_NAME_LEN, name.c_str(), name.size());
      22           15 :     if (sRet != EOK) {
      23            0 :         THROW<RuntimeApiException>(StringFormat("[IpcLocalNotify]memcpy_s ipcname failed, cname[%s]", name.c_str()));
      24              :     }
      25           15 : }
      26              : 
      27            1 : void IpcLocalNotify::Wait(const Stream& stream, u32 timeout) const { GetNotify()->Wait(stream, timeout); }
      28              : 
      29            1 : void IpcLocalNotify::Post(const Stream& stream) const { GetNotify()->Post(stream); }
      30              : 
      31            0 : std::unique_ptr<Serializable> IpcLocalNotify::GetExchangeDto()
      32              : {
      33              :     std::unique_ptr<ExchangeIpcNotifyDto> dto = make_unique<ExchangeIpcNotifyDto>(
      34            0 :         GetNotify()->GetHandleAddr(), GetNotify()->GetId(), HrtDeviceGetBareTgid(), GetNotify()->GetDevPhyId(),
      35            0 :         GetNotify()->IsDevUsed());
      36            0 :     (void)memcpy_s(dto->name, RTS_IPC_MEM_NAME_LEN, ipcName, RTS_IPC_MEM_NAME_LEN);
      37            0 :     return std::unique_ptr<Serializable>(dto.release());
      38            0 : }
      39              : 
      40            3 : string IpcLocalNotify::Describe() const
      41              : {
      42            3 :     return StringFormat("IpcLocalNotify[notify=%s]", GetNotify()->Describe().c_str());
      43              : }
      44              : 
      45            1 : void IpcLocalNotify::Grant(u32 pid) const
      46              : {
      47            1 :     u32 myPid = HrtDeviceGetBareTgid();
      48            1 :     if (pid != myPid) {
      49            0 :         GetNotify()->SetIpcPid(static_cast<s32>(pid));
      50              :     }
      51            1 : }
      52              : 
      53              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1