-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathregistered_memory.hpp
More file actions
77 lines (64 loc) · 2.06 KB
/
registered_memory.hpp
File metadata and controls
77 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#ifndef MSCCLPP_REGISTERED_MEMORY_HPP_
#define MSCCLPP_REGISTERED_MEMORY_HPP_
#include <mscclpp/core.hpp>
#include <mscclpp/errors.hpp>
#include <mscclpp/gpu.hpp>
#include "communicator.hpp"
#include "ib.hpp"
namespace mscclpp {
struct TransportInfo {
Transport transport;
// TODO: rewrite this using std::variant or something
bool ibLocal;
union {
struct {
cudaIpcMemHandle_t cudaIpcBaseHandle;
size_t cudaIpcOffsetFromBase;
};
struct {
const IbMr* ibMr;
IbMrInfo ibMrInfo;
};
struct {
union {
char shareableHandle[64];
struct {
// These are only defined for multicast (NVLS) capability
int rootFdId;
int rootLocalRankId;
};
};
size_t offsetFromBase;
};
};
};
struct RegisteredMemory::Impl {
// This is the data pointer returned by RegisteredMemory::data(), which may be different from the original data
// pointer for deserialized remote memory.
void* data;
// This is the original data pointer the RegisteredMemory was created with.
void* originalDataPtr;
size_t size;
// This is the size returned by cuMemGetAddressRange of data
size_t baseDataSize;
uint64_t hostHash;
uint64_t pidHash;
bool isCuMemMapAlloc;
TransportFlags transports;
std::vector<TransportInfo> transportInfos;
// Only used for IB transport
std::unordered_map<Transport, std::unique_ptr<const IbMr>> ibMrMap;
// For sharing memory handle via file descriptor
int fileDesc = -1;
Impl(void* data, size_t size, TransportFlags transports, Context::Impl& contextImpl);
Impl(const std::vector<char>::const_iterator& begin, const std::vector<char>::const_iterator& end);
/// Constructs a RegisteredMemory::Impl from a vector of data. The constructor should only be used for the remote
/// memory.
Impl(const std::vector<char>& data);
~Impl();
const TransportInfo& getTransportInfo(Transport transport) const;
};
} // namespace mscclpp
#endif // MSCCLPP_REGISTERED_MEMORY_HPP_