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(
25 : const HcclSignalInfo& notifyInfo,
26 : const NotifyLoadType type = NotifyLoadType::DEVICE_NOTIFY); // aicpu侧依据notifyinfo初始化notify
27 :
28 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut);
29 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage);
30 :
31 : HcclResult
32 : Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut, u32 userRank, u32 remoteUserRank);
33 : HcclResult Wait(Stream& stream, u32 timeOut);
34 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage, 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& notifyInfo);
48 : // aicpu device侧 set notify信息
49 : HcclResult SetNotifyData(HcclSignalInfo& notifyInfo);
50 :
51 4264 : inline HcclRtNotify ptr() { return notify_->ptr(); }
52 : // 获取offset
53 : HcclResult GetNotifyOffset(u64& notifyOffset);
54 :
55 : void SetEventIdAndTid(const u32 eventId, const u32 tid);
56 :
57 : private:
58 : std::unique_ptr<NotifyBase> notify_;
59 : static std::atomic<bool> tidQueueInit_;
60 : };
61 :
62 : } // namespace hccl
63 :
64 : #endif // LOCAL_NOTIFY_IMPL_H
|