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