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 : #ifndef LOCAL_NOTIFY_H
12 : #define LOCAL_NOTIFY_H
13 :
14 : #include "stream_pub.h"
15 : #include "dispatcher.h"
16 : #include "hccl_common.h"
17 :
18 : namespace hccl {
19 : class LocalNotifyImpl;
20 : class LocalNotify {
21 : public:
22 : LocalNotify();
23 : ~LocalNotify();
24 : HcclResult Init(const NotifyLoadType type = NotifyLoadType::HOST_NOTIFY);
25 : HcclResult Init(const HcclSignalInfo ¬ifyInfo,
26 : const NotifyLoadType type = NotifyLoadType::DEVICE_NOTIFY);
27 : HcclResult InitNotifyLite(const HcclSignalInfo ¬ifyInfo);
28 :
29 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher,
30 : s32 stage = INVALID_VALUE_STAGE, u32 timeOut = NOTIFY_INVALID_WAIT_TIME);
31 : HcclResult Wait(Stream& stream, u32 timeOut);
32 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher,
33 : s32 stage = INVALID_VALUE_STAGE);
34 : HcclResult Post(Stream& stream);
35 : virtual HcclResult Destroy();
36 : virtual HcclResult SetIpc();
37 :
38 : // mc2获取aicpu notify信息 local&remote
39 : HcclResult GetNotifyData(HcclSignalInfo ¬ifyInfo);
40 : // aicpu device 侧set notify信息
41 : HcclResult SetNotifyData(HcclSignalInfo ¬ifyInfo);
42 :
43 : // 使用时需判空
44 2 : inline HcclRtNotify ptr()
45 : {
46 2 : return notifyPtr;
47 : }
48 :
49 : // 获取offset
50 : HcclResult GetNotifyOffset(u64 ¬ifyOffset);
51 :
52 : static HcclResult Wait(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify> ¬ify,
53 : s32 stage = INVALID_VALUE_STAGE, u32 timeOut = NOTIFY_INVALID_WAIT_TIME);
54 : static HcclResult Post(Stream& stream, HcclDispatcher dispatcherPtr, const std::shared_ptr<LocalNotify> ¬ify,
55 : s32 stage = INVALID_VALUE_STAGE);
56 :
57 : u32 notifyId_{INVALID_UINT};
58 : protected:
59 : std::unique_ptr<LocalNotifyImpl> pimpl_;
60 : HcclRtNotify notifyPtr = nullptr;
61 : /* 标记notify是否是本对象申请的,如果有notify不是用户传入, 而是代码申请的,
62 : * 在析构时需要销毁 */
63 : bool notifyOwner_ = true;
64 : };
65 : }
66 :
67 : #endif // LOCAL_NOTIFY_H
|