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