LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/notify - local_ipc_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.8 % 59 30
Test Date: 2026-07-28 12:11:00 Functions: 41.7 % 12 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              : #include "local_ipc_notify.h"
      11              : #include "local_notify_impl.h"
      12              : 
      13              : namespace hccl {
      14           13 : LocalIpcNotify::LocalIpcNotify()
      15              : {
      16           13 : }
      17              : 
      18           13 : LocalIpcNotify::~LocalIpcNotify()
      19              : {
      20           13 :     Destroy();
      21           13 : }
      22              : 
      23            1 : HcclResult LocalIpcNotify::Init(const s32 localDeviceId, const s32 remoteDeviceId,
      24              :     const NotifyLoadType type)
      25              : {
      26            1 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      27            1 :     CHK_SMART_PTR_NULL(pimpl_);
      28            1 :     HcclResult ret = pimpl_->Init(localDeviceId, remoteDeviceId, type);
      29            1 :     if (ret != HCCL_SUCCESS) {
      30            0 :         pimpl_ = nullptr;
      31            0 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%p]", ret);
      32            0 :         return ret;
      33              :     }
      34              : 
      35            1 :     notifyPtr = pimpl_->ptr();
      36              : 
      37            1 :     if (localDeviceId == HOST_DEVICE_ID || remoteDeviceId == HOST_DEVICE_ID) {
      38            0 :         return HCCL_SUCCESS;
      39              :     }
      40              : 
      41            1 :     CHK_RET(pimpl_->GetNotifyOffset(offset));
      42              :     HcclSignalInfo notifyInfo;
      43            1 :     CHK_RET(pimpl_->GetNotifyData(notifyInfo));
      44            1 :     address = notifyInfo.addr;
      45            1 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      46              : 
      47            1 :     return HCCL_SUCCESS;
      48              : }
      49              : 
      50            6 : HcclResult LocalIpcNotify::Init(const HcclSignalInfo &notifyInfo, const NotifyLoadType type)
      51              : {
      52            6 :     notifyOwner_ = false; // aicpu侧不需要申请新的notify资源
      53            6 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      54            6 :     CHK_SMART_PTR_NULL(pimpl_);
      55            6 :     HcclResult ret = pimpl_->Init(notifyInfo, type);
      56            6 :     if (ret != HCCL_SUCCESS) {
      57            0 :         pimpl_ = nullptr;
      58            0 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%p]", ret);
      59            0 :         return ret;
      60              :     }
      61              :     
      62            6 :     CHK_RET(pimpl_->GetNotifyOffset(offset));
      63            6 :     address = notifyInfo.addr;
      64            6 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      65              : 
      66            6 :     notifyPtr = pimpl_->ptr();
      67            6 :     return HCCL_SUCCESS;
      68              : }
      69              : 
      70            1 : HcclResult LocalIpcNotify::Serialize(std::vector<u8> &byteVector)
      71              : {
      72            1 :     return pimpl_->Serialize(byteVector);
      73              : }
      74              : 
      75            0 : HcclResult LocalIpcNotify::Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage,
      76              :     u32 timeOut, u32 userRank, u32 remoteUserRank)
      77              : {
      78            0 :     return pimpl_->Wait(stream, dispatcher, stage, timeOut, userRank, remoteUserRank);
      79              : }
      80              : 
      81            0 : HcclResult LocalIpcNotify::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage,
      82              :     u32 remoteUserRank)
      83              : {
      84            0 :     return pimpl_->Post(stream, dispatcher, stage, remoteUserRank);
      85              : }
      86              : 
      87            0 : HcclResult LocalIpcNotify::Wait(Stream& stream, HcclDispatcher dispatcherPtr,
      88              :     const std::shared_ptr<LocalIpcNotify> &notify, s32 stage, u32 timeOut, u32 userRank, u32 remoteUserRank)
      89              : {
      90            0 :     CHK_PTR_NULL(dispatcherPtr);
      91            0 :     CHK_SMART_PTR_NULL(notify);
      92              : 
      93            0 :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)->SignalWait(notify->ptr(),
      94            0 :         stream, userRank, remoteUserRank, stage, false, INVALID_UINT, timeOut);
      95              : }
      96            0 : HcclResult LocalIpcNotify::Post(Stream& stream, HcclDispatcher dispatcherPtr,
      97              :     const std::shared_ptr<LocalIpcNotify> &notify, s32 stage, u32 remoteUserRank)
      98              : {
      99            0 :     CHK_PTR_NULL(dispatcherPtr);
     100            0 :     CHK_SMART_PTR_NULL(notify);
     101              : 
     102            0 :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)->SignalRecord(
     103            0 :         notify->ptr(), stream, remoteUserRank, notify->offset, stage, false, notify->address);
     104              : }
     105              : 
     106            0 : HcclResult LocalIpcNotify::Grant(s64 recvId)
     107              : {
     108            0 :     return pimpl_->Grant(recvId);
     109              : }
     110              : 
     111            0 : void LocalIpcNotify::Break()
     112              : {
     113            0 :     return pimpl_->Break();
     114              : }
     115              : 
     116            0 : void LocalIpcNotify::SetEventIdAndTid(const u32 eventId, const u32 tid)
     117              : {
     118            0 :     LocalNotifyImpl impl;
     119            0 :     return impl.SetEventIdAndTid(eventId, tid);
     120            0 : }
     121              : }
        

Generated by: LCOV version 2.0-1