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 : #ifndef HCCLV2_IPC_REMOTE_NOTIFY_H
11 : #define HCCLV2_IPC_REMOTE_NOTIFY_H
12 :
13 : #include "rts_notify.h"
14 : #include "stream.h"
15 : #include "rma_type.h"
16 : #include "serializable.h"
17 :
18 : namespace Hccl {
19 :
20 : class BaseRemoteNotify {
21 : public:
22 2 : explicit BaseRemoteNotify(const RmaType &type) : type(type)
23 : {
24 2 : }
25 :
26 2 : virtual ~BaseRemoteNotify() = default;
27 :
28 : virtual string Describe() const = 0;
29 :
30 : virtual void Post(const Stream &stream) const = 0; // 待修改: will move this method to synchronizer
31 :
32 : protected:
33 : RmaType type;
34 : };
35 :
36 : class IpcRemoteNotify : public BaseRemoteNotify {
37 : public:
38 : IpcRemoteNotify();
39 :
40 : explicit IpcRemoteNotify(const Serializable &rmtDto);
41 :
42 : IpcRemoteNotify(const IpcRemoteNotify &that) = delete;
43 :
44 : IpcRemoteNotify &operator=(const IpcRemoteNotify &that) = delete;
45 :
46 : void Post(const Stream &stream) const override;
47 :
48 : string Describe() const override;
49 :
50 0 : inline u32 GetId() const
51 : {
52 0 : return id;
53 : }
54 :
55 0 : inline u64 GetAddr() const
56 : {
57 0 : return addr;
58 : }
59 :
60 0 : inline u32 GetSize() const
61 : {
62 0 : return size;
63 : }
64 :
65 : private:
66 : char_t name[RTS_IPC_MEM_NAME_LEN]{0};
67 : u64 handleAddr{0}; // 两rank处于相同Server, 相同进程下, 携带指针 RtNotify 的值
68 : u32 id{0};
69 : u32 rmtPid{0};
70 : u32 rmtDevPhyId{0};
71 : bool devUsed{false};
72 : RtNotify_t handle{};
73 : u64 addr{0};
74 : u32 size{0};
75 : };
76 :
77 : } // namespace Hccl
78 :
79 : #endif // !HCCLV2_IPC_REMOTE_NOTIFY_H
|