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