-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathutils.hpp
60 lines (41 loc) · 1.46 KB
/
utils.hpp
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#ifndef MSCCLPP_UTILS_HPP_
#define MSCCLPP_UTILS_HPP_
#include <chrono>
#include <mscclpp/core.hpp>
#include <string>
namespace mscclpp {
struct Timer {
std::chrono::steady_clock::time_point start_;
int timeout_;
Timer(int timeout = -1);
~Timer();
/// Returns the elapsed time in microseconds.
int64_t elapsed() const;
void set(int timeout);
void reset();
void print(const std::string& name);
};
struct ScopedTimer : public Timer {
const std::string name_;
ScopedTimer(const std::string& name);
~ScopedTimer();
};
std::string getHostName(int maxlen, const char delim);
/// Get the number of available InfiniBand devices.
///
/// @return The number of available InfiniBand devices.
int getIBDeviceCount();
/// Get the name of the InfiniBand device associated with the specified transport.
///
/// @param ibTransport The InfiniBand transport to get the device name for.
/// @return The name of the InfiniBand device associated with the specified transport.
std::string getIBDeviceName(Transport ibTransport);
/// Get the InfiniBand transport associated with the specified device name.
///
/// @param ibDeviceName The name of the InfiniBand device to get the transport for.
/// @return The InfiniBand transport associated with the specified device name.
Transport getIBTransportByDeviceName(const std::string& ibDeviceName);
} // namespace mscclpp
#endif // MSCCLPP_UTILS_HPP_