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_IMPL_H
12 : #define LOCAL_NOTIFY_IMPL_H
13 :
14 : #include "notify_base.h"
15 :
16 : namespace hccl {
17 : class NotifyBase;
18 : class LocalNotifyImpl {
19 : public:
20 : LocalNotifyImpl();
21 : ~LocalNotifyImpl();
22 : HcclResult Init(const NotifyLoadType type);
23 : HcclResult Init(const s32 localDeviceId, const s32 remoteDeviceId, const NotifyLoadType type);
24 : HcclResult Init(const HcclSignalInfo ¬ifyInfo,
25 : const NotifyLoadType type = NotifyLoadType::DEVICE_NOTIFY); // aicpu侧依据notifyinfo初始化notify
26 :
27 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut);
28 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage);
29 :
30 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut,
31 : u32 userRank, u32 remoteUserRank);
32 : HcclResult Wait(Stream& stream, u32 timeOut);
33 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage,
34 : u32 remoteUserRank);
35 :
36 : HcclResult Post(Stream& stream);
37 :
38 : HcclResult SetIpc();
39 : HcclResult Grant(s64 recvId);
40 : HcclResult Destroy();
41 :
42 : void Break();
43 :
44 : HcclResult Serialize(std::vector<u8> &byteVector);
45 :
46 : // mc2获取aicpu notify信息 local&remote
47 : HcclResult GetNotifyData(HcclSignalInfo ¬ifyInfo);
48 : // aicpu device侧 set notify信息
49 : HcclResult SetNotifyData(HcclSignalInfo ¬ifyInfo);
50 :
51 4236 : inline HcclRtNotify ptr()
52 : {
53 4236 : return notify_->ptr();
54 : }
55 : // 获取offset
56 : HcclResult GetNotifyOffset(u64 ¬ifyOffset);
57 :
58 : void SetEventIdAndTid(const u32 eventId, const u32 tid);
59 : private:
60 : std::unique_ptr<NotifyBase> notify_;
61 : static std::atomic<bool> tidQueueInit_;
62 : };
63 :
64 : }
65 :
66 : #endif // LOCAL_NOTIFY_IMPL_H
|