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: 67.8 % 59 40
Test Date: 2026-08-17 10:19:35 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         4540 : LocalNotify::LocalNotify() {}
      16              : 
      17         4544 : LocalNotify::~LocalNotify() { Destroy(); }
      18              : 
      19         1024 : HcclResult LocalNotify::Init(const NotifyLoadType type)
      20              : {
      21         1024 :     notifyOwner_ = true; // host侧需要申请新的notify资源
      22         1024 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      23         1025 :     CHK_SMART_PTR_NULL(pimpl_);
      24         1022 :     HcclResult ret = pimpl_->Init(type);
      25         1032 :     if (ret != HCCL_SUCCESS) {
      26            4 :         pimpl_ = nullptr;
      27            4 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%d]", ret);
      28            4 :         return ret;
      29              :     }
      30              : 
      31              :     HcclSignalInfo notifyInfo;
      32         1028 :     CHK_RET(pimpl_->GetNotifyData(notifyInfo));
      33         1029 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      34              : 
      35         1029 :     notifyPtr = pimpl_->ptr();
      36         1028 :     return HCCL_SUCCESS;
      37              : }
      38              : 
      39         3218 : HcclResult LocalNotify::Init(const HcclSignalInfo& signalInfo, const NotifyLoadType type)
      40              : {
      41         3218 :     notifyOwner_ = false; // aicpu侧不需要申请新的notify资源
      42         3218 :     pimpl_.reset((new (std::nothrow) LocalNotifyImpl()));
      43         3218 :     CHK_SMART_PTR_NULL(pimpl_);
      44         3218 :     HcclResult ret = pimpl_->Init(signalInfo, type);
      45         3218 :     if (ret != HCCL_SUCCESS) {
      46            0 :         pimpl_ = nullptr;
      47            0 :         HCCL_ERROR("[LocalNotify]Init failed, ret[%d]", ret);
      48            0 :         return ret;
      49              :     }
      50              : 
      51              :     HcclSignalInfo notifyInfo;
      52         3218 :     CHK_RET(pimpl_->GetNotifyData(notifyInfo));
      53         3218 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      54              : 
      55         3218 :     notifyPtr = pimpl_->ptr();
      56         3218 :     return HCCL_SUCCESS;
      57              : }
      58              : 
      59          279 : HcclResult LocalNotify::InitNotifyLite(const HcclSignalInfo& notifyInfo)
      60              : {
      61          279 :     notifyOwner_ = false; // aicpu侧不需要申请新的notify资源
      62          279 :     notifyId_ = static_cast<u32>(notifyInfo.resId);
      63          279 :     HCCL_INFO("[LocalNotify]Init success. notify id [%u]", notifyId_);
      64          279 :     return HCCL_SUCCESS;
      65              : }
      66              : 
      67            0 : HcclResult LocalNotify::Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut)
      68              : {
      69            0 :     return pimpl_->Wait(stream, dispatcher, stage, timeOut);
      70              : }
      71              : 
      72            1 : HcclResult LocalNotify::Wait(Stream& stream, u32 timeOut) { return pimpl_->Wait(stream, timeOut); }
      73              : 
      74            0 : HcclResult LocalNotify::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage)
      75              : {
      76            0 :     return pimpl_->Post(stream, dispatcher, stage);
      77              : }
      78              : 
      79            1 : HcclResult LocalNotify::Post(Stream& stream) { return pimpl_->Post(stream); }
      80              : 
      81            0 : HcclResult LocalNotify::Wait(
      82              :     Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify>& notify, s32 stage, u32 timeOut)
      83              : {
      84            0 :     CHK_PTR_NULL(dispatcherPtr);
      85            0 :     CHK_SMART_PTR_NULL(notify);
      86              : 
      87              :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)
      88            0 :         ->SignalWait(
      89            0 :             notify->ptr(), stream, INVALID_VALUE_RANKID, INVALID_VALUE_RANKID, stage, true, notify->notifyId_, timeOut);
      90              : }
      91              : 
      92              : HcclResult
      93            0 : LocalNotify::Post(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify>& notify, s32 stage)
      94              : {
      95            0 :     CHK_PTR_NULL(dispatcherPtr);
      96            0 :     CHK_SMART_PTR_NULL(notify);
      97              : 
      98              :     return reinterpret_cast<DispatcherPub*>(dispatcherPtr)
      99            0 :         ->SignalRecord(
     100            0 :             notify->ptr(), stream, INVALID_VALUE_RANKID, INVALID_U64, stage, true, INVALID_U64, notify->notifyId_);
     101              : }
     102              : 
     103         5078 : HcclResult LocalNotify::Destroy()
     104              : {
     105         5078 :     if (notifyOwner_ == true && pimpl_ != nullptr) {
     106         1030 :         pimpl_->Destroy();
     107         1030 :         pimpl_ = nullptr;
     108         1030 :         notifyPtr = nullptr;
     109              :     }
     110         5078 :     return HCCL_SUCCESS;
     111              : }
     112              : 
     113           77 : HcclResult LocalNotify::SetIpc() { return pimpl_->SetIpc(); }
     114              : 
     115         2783 : HcclResult LocalNotify::GetNotifyData(HcclSignalInfo& notifyInfo) { return pimpl_->GetNotifyData(notifyInfo); }
     116              : 
     117            0 : HcclResult LocalNotify::SetNotifyData(HcclSignalInfo& notifyInfo) { return pimpl_->SetNotifyData(notifyInfo); }
     118              : 
     119            0 : HcclResult LocalNotify::GetNotifyOffset(u64& notifyOffset) { return pimpl_->GetNotifyOffset(notifyOffset); }
     120              : } // namespace hccl
        

Generated by: LCOV version 2.0-1