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 "remote_notify.h"
12 : #include "remote_notify_impl.h"
13 :
14 : namespace hccl {
15 :
16 1127 : RemoteNotify::RemoteNotify()
17 : {
18 1127 : }
19 :
20 1127 : RemoteNotify::~RemoteNotify()
21 : {
22 1127 : }
23 :
24 1 : HcclResult RemoteNotify::Init(const std::vector<u8>& byteVector)
25 : {
26 1 : pimpl_.reset((new (std::nothrow) RemoteNotifyImpl()));
27 1 : CHK_SMART_PTR_NULL(pimpl_);
28 1 : HcclResult ret = pimpl_->Init(byteVector);
29 1 : if (ret != HCCL_SUCCESS) {
30 0 : pimpl_ = nullptr;
31 0 : HCCL_ERROR("[RemoteNotify]Init failed, ret[%p]", ret);
32 0 : return ret;
33 : }
34 :
35 1 : return HCCL_SUCCESS;
36 : }
37 :
38 1126 : HcclResult RemoteNotify::Init(const HcclSignalInfo ¬ifyInfo, const NotifyLoadType type)
39 : {
40 1126 : pimpl_.reset((new (std::nothrow) RemoteNotifyImpl()));
41 1126 : CHK_SMART_PTR_NULL(pimpl_);
42 1126 : HcclResult ret = pimpl_->Init(notifyInfo, type);
43 1126 : if (ret != HCCL_SUCCESS) {
44 0 : pimpl_ = nullptr;
45 0 : HCCL_ERROR("[LocalNotify]Init failed, ret[%d]", ret);
46 0 : return ret;
47 : }
48 :
49 1126 : notifyPtr = pimpl_->ptr();
50 1126 : return HCCL_SUCCESS;
51 : }
52 :
53 1 : HcclResult RemoteNotify::Open()
54 : {
55 1 : CHK_RET(pimpl_->Open());
56 :
57 1 : notifyPtr = pimpl_->ptr();
58 :
59 1 : return HCCL_SUCCESS;
60 : }
61 :
62 4 : HcclResult RemoteNotify::Close()
63 : {
64 4 : if (pimpl_ != nullptr) {
65 4 : pimpl_->Close();
66 4 : pimpl_ = nullptr;
67 4 : notifyPtr = nullptr;
68 : }
69 4 : return HCCL_SUCCESS;
70 : }
71 :
72 0 : HcclResult RemoteNotify::Post(Stream& stream, HcclDispatcher dispatcher, s32 stage)
73 : {
74 0 : CHK_SMART_PTR_NULL(pimpl_);
75 0 : return pimpl_->Post(stream, dispatcher, stage);
76 : }
77 :
78 1131 : HcclResult RemoteNotify::GetNotifyData(HcclSignalInfo ¬ifyInfo)
79 : {
80 1131 : CHK_SMART_PTR_NULL(pimpl_);
81 1131 : return pimpl_->GetNotifyData(notifyInfo);
82 : }
83 :
84 3 : HcclResult RemoteNotify::SetNotifyData(HcclSignalInfo ¬ifyInfo)
85 : {
86 3 : CHK_SMART_PTR_NULL(pimpl_);
87 3 : return pimpl_->SetNotifyData(notifyInfo);
88 : }
89 :
90 4 : HcclResult RemoteNotify::GetNotifyOffset(u64 ¬ifyOffset)
91 : {
92 4 : CHK_SMART_PTR_NULL(pimpl_);
93 4 : return pimpl_->GetNotifyOffset(notifyOffset);
94 : }
95 : }
|