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 ESCHED_NOTIFY_H
12 : #define ESCHED_NOTIFY_H
13 :
14 : #include <atomic>
15 : #include "notify_base.h"
16 :
17 : namespace hccl {
18 : // 订阅事件相关的参数
19 : struct CpuSendInfo {
20 : int32_t devId;
21 : uint32_t grpId;
22 : uint32_t threadId;
23 : uint64_t eventBitMap;
24 : };
25 :
26 : class EschedNotify : public NotifyBase {
27 : public:
28 : explicit EschedNotify(NotifyType notifyType);
29 : EschedNotify(NotifyType notifyType, HcclNotifyInfo notifyInfo);
30 : ~EschedNotify() override;
31 :
32 : HcclResult Alloc() override;
33 : HcclResult Open() override;
34 : HcclResult Close() override;
35 :
36 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut) override;
37 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage) override;
38 :
39 : HcclResult Wait(Stream& stream, HcclDispatcher dispatcher, s32 stage, u32 timeOut,
40 : u32 userRank, u32 remoteUserRank) override;
41 : HcclResult Wait(Stream& stream, u32 timeOut) override;
42 : HcclResult Post(Stream& stream, HcclDispatcher dispatcher, s32 stage,
43 : u32 remoteUserRank) override;
44 : HcclResult Post(Stream& stream) override;
45 :
46 : HcclResult SetIpc() override;
47 : HcclResult Grant(s64 recvId) override;
48 : HcclResult Destroy() override;
49 : void Break() override;
50 :
51 0 : static void SetEventIdAndTid(const u32 &eventId, const u32 &tid)
52 : {
53 0 : eventId_ = eventId;
54 0 : initialThreadId_ = tid;
55 0 : return;
56 : }
57 :
58 : static void ThreadIdQueInit();
59 :
60 : private:
61 : HcclResult ThreadIdCreate(uint32_t &threadId);
62 :
63 : static HcclResult InitGroupId();
64 : static HcclResult GetGroupId();
65 :
66 : bool isDestroyed{false};
67 : CpuSendInfo sendinfo_{};
68 : std::atomic<bool> break_ = {false};
69 : std::atomic<bool> isWaiting_ = {false};
70 :
71 : static u32 groupId_;
72 : static u32 eventId_;
73 : static u32 initialThreadId_;
74 : };
75 :
76 : }
77 :
78 : #endif // ESCHED_NOTIFY_H
|