-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
/
communicator-inl.h
65 lines (57 loc) · 1.33 KB
/
communicator-inl.h
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
/**
* Copyright 2022-2024, XGBoost contributors
*/
#pragma once
#include <string>
#include "xgboost/json.h" // for Json
namespace xgboost::collective {
/**
* @brief Initialize the collective communicator.
*/
void Init(Json const& config);
/**
* @brief Finalize the collective communicator.
*
* Call this function after you finished all jobs.
*/
void Finalize();
/**
* @brief Get rank of current process.
*
* @return Rank of the worker.
*/
[[nodiscard]] std::int32_t GetRank() noexcept;
/**
* @brief Get total number of processes.
*
* @return Total world size.
*/
[[nodiscard]] std::int32_t GetWorldSize() noexcept;
/**
* @brief Get if the communicator is distributed.
*
* @return True if the communicator is distributed.
*/
[[nodiscard]] bool IsDistributed() noexcept;
/**
* @brief Get if the communicator is federated.
*
* @return True if the communicator is federated.
*/
[[nodiscard]] bool IsFederated();
/**
* @brief Print the message to the communicator.
*
* This function can be used to communicate the information of the progress to the user who monitors
* the communicator.
*
* @param message The message to be printed.
*/
void Print(std::string const& message);
/**
* @brief Get the name of the processor.
*
* @return Name of the processor.
*/
std::string GetProcessorName();
} // namespace xgboost::collective