-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathcontext.hpp
More file actions
53 lines (36 loc) · 1.1 KB
/
context.hpp
File metadata and controls
53 lines (36 loc) · 1.1 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#ifndef MSCCLPP_CONTEXT_HPP_
#define MSCCLPP_CONTEXT_HPP_
#include <mscclpp/core.hpp>
#include <mscclpp/gpu_utils.hpp>
#include <unordered_map>
#include <vector>
#include "ib.hpp"
namespace mscclpp {
class CudaIpcStream {
private:
std::shared_ptr<CudaStreamWithFlags> stream_;
int deviceId_;
bool dirty_;
void setStreamIfNeeded();
public:
CudaIpcStream(int deviceId);
void memcpyD2D(void *dst, const void *src, size_t nbytes);
void memcpyH2D(void *dst, const void *src, size_t nbytes);
void sync();
operator cudaStream_t() const { return *stream_; }
int deviceId() const { return deviceId_; }
};
class TokenPool;
struct Context::Impl {
std::unordered_map<Transport, std::unique_ptr<IbCtx>> ibContexts_;
std::vector<std::shared_ptr<CudaIpcStream>> ipcStreams_;
std::shared_ptr<TokenPool> tokenPool_;
const size_t maxNumTokens_ = 1 << 15; // 32K tokens
Impl();
IbCtx *getIbContext(Transport ibTransport);
std::shared_ptr<uint64_t> getToken();
};
} // namespace mscclpp
#endif // MSCCLPP_CONTEXT_HPP_