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

Generated by: LCOV version 2.0-1