LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/notify - local_notify_impl.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 61.3 % 62 38
Test Date: 2026-08-18 17:47:01 Functions: 60.0 % 20 12

            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_notify_impl.h"
      12              : #include "rts_notify.h"
      13              : #include "bare_notify.h"
      14              : #include "esched_notify.h"
      15              : 
      16              : namespace hccl {
      17              : std::atomic<bool> LocalNotifyImpl::tidQueueInit_ = {false};
      18         4270 : LocalNotifyImpl::LocalNotifyImpl() {}
      19              : 
      20         4271 : LocalNotifyImpl::~LocalNotifyImpl() {}
      21              : 
      22         1037 : HcclResult LocalNotifyImpl::Init(const NotifyLoadType type)
      23              : {
      24         1037 :     if (type == NotifyLoadType::DEVICE_NOTIFY) {
      25          486 :         notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY_MC2));
      26              :     } else {
      27          551 :         notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY));
      28              :     }
      29              : 
      30         1039 :     HCCL_DEBUG("[Create][LocalNotify]notify load type[%d].", type);
      31              : 
      32         1046 :     CHK_SMART_PTR_NULL(notify_);
      33              : 
      34         1042 :     CHK_RET(notify_->Alloc());
      35         1042 :     return HCCL_SUCCESS;
      36              : }
      37              : 
      38            1 : HcclResult LocalNotifyImpl::Init(const s32 localDeviceId, const s32 remoteDeviceId, const NotifyLoadType type)
      39              : {
      40            1 :     if (type == NotifyLoadType::DEVICE_NOTIFY) {
      41            1 :         notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY_MC2));
      42              :     } else {
      43            0 :         if (localDeviceId != HOST_DEVICE_ID && remoteDeviceId != HOST_DEVICE_ID) {
      44            0 :             notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY));
      45            0 :         } else if (localDeviceId != HOST_DEVICE_ID && remoteDeviceId == HOST_DEVICE_ID) {
      46            0 :             notify_.reset(new (std::nothrow) BareNotify(NotifyType::BARE_NOTIFY));
      47            0 :         } else if (localDeviceId == HOST_DEVICE_ID && remoteDeviceId != HOST_DEVICE_ID) {
      48            0 :             if (!tidQueueInit_) {
      49            0 :                 EschedNotify::ThreadIdQueInit();
      50            0 :                 tidQueueInit_ = true;
      51              :             }
      52            0 :             notify_.reset(new (std::nothrow) EschedNotify(NotifyType::ESCHED_EVENT));
      53              :         } else {
      54            0 :             HCCL_ERROR(
      55              :                 "[Create][LocalNotify]not support create notify, notify load type[%d], localDeviceId[%d], "
      56              :                 "remoteDeviceId[%d]",
      57              :                 type, localDeviceId, remoteDeviceId);
      58              :         }
      59              :     }
      60              : 
      61            1 :     HCCL_DEBUG(
      62              :         "[Create][LocalNotify]notify load type[%d], localDeviceId[%d], remoteDeviceId[%d].", type, localDeviceId,
      63              :         remoteDeviceId);
      64              : 
      65            1 :     CHK_SMART_PTR_NULL(notify_);
      66              : 
      67            1 :     CHK_RET(notify_->Alloc());
      68            1 :     return HCCL_SUCCESS;
      69              : }
      70              : 
      71         3224 : HcclResult LocalNotifyImpl::Init(const HcclSignalInfo& notifyInfo, const NotifyLoadType type)
      72              : {
      73         3224 :     if (type == NotifyLoadType::DEVICE_NOTIFY) {
      74         3221 :         notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY_MC2, notifyInfo));
      75              :     } else {
      76            3 :         notify_.reset(new (std::nothrow) RtsNotify(NotifyType::RUNTIME_NOTIFY, notifyInfo));
      77              :     }
      78              : 
      79         3224 :     HCCL_DEBUG("[Create][LocalNotify]notify load type[%d].", type);
      80              : 
      81         3224 :     CHK_SMART_PTR_NULL(notify_);
      82              : 
      83              : #ifdef CCL_KERNEL
      84         3224 :     if (type == NotifyLoadType::DEVICE_NOTIFY) {
      85         3221 :         CHK_RET(static_cast<RtsNotify*>(notify_.get())->InitAndVerifySingleSignal());
      86              :     }
      87              : #endif
      88              : 
      89         3224 :     return HCCL_SUCCESS;
      90              : }
      91              : 
      92            0 : HcclResult LocalNotifyImpl::Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut)
      93              : {
      94            0 :     return notify_->Wait(stream, dispatcher, stage, timeOut);
      95              : }
      96              : 
      97            0 : HcclResult LocalNotifyImpl::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage)
      98              : {
      99            0 :     return notify_->Post(stream, dispatcher, stage);
     100              : }
     101              : 
     102            1 : HcclResult LocalNotifyImpl::Post(Stream& stream) { return notify_->Post(stream); }
     103              : 
     104            0 : HcclResult LocalNotifyImpl::Wait(
     105              :     Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut, u32 userRank, u32 remoteUserRank)
     106              : {
     107            0 :     return notify_->Wait(stream, dispatcher, stage, timeOut, userRank, remoteUserRank);
     108              : }
     109              : 
     110            1 : HcclResult LocalNotifyImpl::Wait(Stream& stream, u32 timeOut) { return notify_->Wait(stream, timeOut); }
     111              : 
     112            0 : HcclResult LocalNotifyImpl::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 remoteUserRank)
     113              : {
     114            0 :     return notify_->Post(stream, dispatcher, stage, remoteUserRank);
     115              : }
     116              : 
     117           80 : HcclResult LocalNotifyImpl::SetIpc() { return notify_->SetIpc(); }
     118              : 
     119            0 : HcclResult LocalNotifyImpl::Grant(s64 recvId) { return notify_->Grant(recvId); }
     120              : 
     121         1043 : HcclResult LocalNotifyImpl::Destroy()
     122              : {
     123         1043 :     HcclResult ret = HCCL_SUCCESS;
     124         1043 :     if (notify_) {
     125         1043 :         ret = notify_->Destroy();
     126              :     }
     127         1043 :     notify_ = nullptr;
     128         1043 :     return ret;
     129              : }
     130              : 
     131            1 : HcclResult LocalNotifyImpl::Serialize(std::vector<u8>& byteVector) { return notify_->Serialize(byteVector); }
     132              : 
     133         7046 : HcclResult LocalNotifyImpl::GetNotifyData(HcclSignalInfo& notifyInfo) { return notify_->GetNotifyData(notifyInfo); }
     134              : 
     135            0 : HcclResult LocalNotifyImpl::SetNotifyData(HcclSignalInfo& notifyInfo) { return notify_->SetNotifyData(notifyInfo); }
     136              : 
     137            7 : HcclResult LocalNotifyImpl::GetNotifyOffset(u64& notifyOffset) { return notify_->GetNotifyOffset(notifyOffset); }
     138              : 
     139            0 : void LocalNotifyImpl::Break() { return notify_->Break(); }
     140              : 
     141            0 : void LocalNotifyImpl::SetEventIdAndTid(const u32 eventId, const u32 tid)
     142              : {
     143            0 :     EschedNotify::SetEventIdAndTid(eventId, tid);
     144            0 :     return;
     145              : }
     146              : } // namespace hccl
        

Generated by: LCOV version 2.0-1