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

Generated by: LCOV version 2.0-1