LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/notify - local_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 69.1 % 68 47
Test Date: 2026-08-04 10:52:23 Functions: 62.5 % 16 10

            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_notify.h"
      11              : #include "local_notify_impl.h"
      12              : 
      13              : namespace hccl {
      14              : 
      15         4518 : LocalNotify::LocalNotify()
      16              : {
      17         4517 : }
      18              : 
      19         4520 : LocalNotify::~LocalNotify()
      20              : {
      21         4520 :     Destroy();
      22         4520 : }
      23              : 
      24         1010 : HcclResult LocalNotify::Init(const NotifyLoadType type)
      25              : {
      26         1010 :     notifyOwner_ = true; // host侧需要申请新的notify资源
      27         1010 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      28         1012 :     CHK_SMART_PTR_NULL(pimpl_);
      29         1011 :     HcclResult ret = pimpl_->Init(type);
      30         1015 :     if (ret != HCCL_SUCCESS) {
      31            4 :         pimpl_ = nullptr;
      32            4 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%d]", ret);
      33            4 :         return ret;
      34              :     }
      35              : 
      36              :     HcclSignalInfo notifyInfo;
      37         1011 :     CHK_RET(pimpl_->GetNotifyData(notifyInfo));
      38         1011 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      39              : 
      40         1011 :     notifyPtr = pimpl_->ptr();
      41         1010 :     return HCCL_SUCCESS;
      42              : }
      43              : 
      44         3218 : HcclResult LocalNotify::Init(const HcclSignalInfo &signalInfo, const NotifyLoadType type)
      45              : {
      46         3218 :     notifyOwner_ = false; // aicpu侧不需要申请新的notify资源
      47         3218 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      48         3218 :     CHK_SMART_PTR_NULL(pimpl_);
      49         3218 :     HcclResult ret = pimpl_->Init(signalInfo, type);
      50         3218 :     if (ret != HCCL_SUCCESS) {
      51            0 :         pimpl_ = nullptr;
      52            0 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%d]", ret);
      53            0 :         return ret;
      54              :     }
      55              : 
      56              :     HcclSignalInfo notifyInfo;
      57         3218 :     CHK_RET(pimpl_->GetNotifyData(notifyInfo));
      58         3218 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      59              : 
      60         3218 :     notifyPtr = pimpl_->ptr();
      61         3218 :     return HCCL_SUCCESS;
      62              : }
      63              : 
      64          273 : HcclResult LocalNotify::InitNotifyLite(const HcclSignalInfo &notifyInfo)
      65              : {
      66          273 :     notifyOwner_ = false; // aicpu侧不需要申请新的notify资源
      67          273 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      68          273 :     HCCL_INFO("[LocalNotify]Init success. notify id [%u]", notifyId_);
      69          273 :     return HCCL_SUCCESS;
      70              : }
      71              : 
      72            0 : HcclResult LocalNotify::Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut)
      73              : {
      74            0 :     return pimpl_->Wait(stream, dispatcher, stage, timeOut);
      75              : }
      76              : 
      77            1 : HcclResult LocalNotify::Wait(Stream& stream, u32 timeOut)
      78              : {
      79            1 :     return pimpl_->Wait(stream, timeOut);
      80              : }
      81              : 
      82            0 : HcclResult LocalNotify::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage)
      83              : {
      84            0 :     return pimpl_->Post(stream, dispatcher, stage);
      85              : }
      86              : 
      87            1 : HcclResult LocalNotify::Post(Stream& stream)
      88              : {
      89            1 :     return pimpl_->Post(stream);
      90              : }
      91              : 
      92            0 : HcclResult LocalNotify::Wait(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify> &notify,
      93              :     s32 stage, u32 timeOut)
      94              : {
      95            0 :     CHK_PTR_NULL(dispatcherPtr);
      96            0 :     CHK_SMART_PTR_NULL(notify);
      97              :     
      98            0 :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)->SignalWait(
      99            0 :         notify->ptr(), stream, INVALID_VALUE_RANKID, INVALID_VALUE_RANKID, stage, true, notify->notifyId_, timeOut);
     100              : }
     101              : 
     102            0 : HcclResult LocalNotify::Post(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify> &notify,
     103              :     s32 stage)
     104              : {
     105            0 :     CHK_PTR_NULL(dispatcherPtr);
     106            0 :     CHK_SMART_PTR_NULL(notify);
     107              : 
     108            0 :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)->SignalRecord(
     109            0 :         notify->ptr(), stream, INVALID_VALUE_RANKID, INVALID_U64, stage, true, INVALID_U64, notify->notifyId_);
     110              : }
     111              : 
     112         5054 : HcclResult LocalNotify::Destroy()
     113              : {
     114         5054 :     if (notifyOwner_ == true && pimpl_ != nullptr) {
     115         1012 :         pimpl_->Destroy();
     116         1012 :         pimpl_ = nullptr;
     117         1012 :         notifyPtr = nullptr;
     118              :     }
     119         5054 :     return HCCL_SUCCESS;
     120              : }
     121              : 
     122           71 : HcclResult LocalNotify::SetIpc()
     123              : {
     124           71 :     return pimpl_->SetIpc();
     125              : }
     126              : 
     127              : 
     128         2777 : HcclResult LocalNotify::GetNotifyData(HcclSignalInfo &notifyInfo)
     129              : {
     130         2777 :     return pimpl_->GetNotifyData(notifyInfo);
     131              : }
     132              : 
     133            0 : HcclResult LocalNotify::SetNotifyData(HcclSignalInfo &notifyInfo)
     134              : {
     135            0 :     return pimpl_->SetNotifyData(notifyInfo);
     136              : }
     137              : 
     138            0 : HcclResult LocalNotify::GetNotifyOffset(u64 &notifyOffset)
     139              : {
     140            0 :     return pimpl_->GetNotifyOffset(notifyOffset);
     141              : }
     142              : }
        

Generated by: LCOV version 2.0-1