Medial Code Documentation
Loading...
Searching...
No Matches
engine.h
Go to the documentation of this file.
1
7#ifndef RABIT_INTERNAL_ENGINE_H_
8#define RABIT_INTERNAL_ENGINE_H_
9#include <string>
10#include "rabit/serializable.h"
11
12namespace MPI { // NOLINT
14class Datatype;
15}
16
18namespace rabit {
20namespace engine {
22class IEngine {
23 public:
29 typedef void (PreprocFunction) (void *arg); // NOLINT
41 typedef void (ReduceFunction) (const void *src, // NOLINT
42 void *dst, int count,
43 const MPI::Datatype &dtype);
45 ~IEngine() = default;
59 virtual void Allgather(void *sendrecvbuf,
60 size_t total_size,
61 size_t slice_begin,
62 size_t slice_end,
63 size_t size_prev_slice) = 0;
76 virtual void Allreduce(void *sendrecvbuf_,
77 size_t type_nbytes,
78 size_t count,
79 ReduceFunction reducer,
80 PreprocFunction prepare_fun = nullptr,
81 void *prepare_arg = nullptr) = 0;
88 virtual void Broadcast(void *sendrecvbuf_, size_t size, int root) = 0;
92 virtual int LoadCheckPoint() = 0;
96 virtual void CheckPoint() = 0;
102 virtual int VersionNumber() const = 0;
104 virtual int GetRingPrevRank() const = 0;
106 virtual int GetRank() const = 0;
108 virtual int GetWorldSize() const = 0;
110 virtual bool IsDistributed() const = 0;
112 virtual std::string GetHost() const = 0;
119 virtual void TrackerPrint(const std::string &msg) = 0;
120};
121
123bool Init(int argc, char *argv[]);
125bool Finalize();
128
130namespace mpi {
132enum OpType {
133 kMax = 0,
134 kMin = 1,
135 kSum = 2,
136 kBitwiseAND = 3,
137 kBitwiseOR = 4,
138 kBitwiseXOR = 5,
139};
142 kChar = 0,
143 kUChar = 1,
144 kInt = 2,
145 kUInt = 3,
146 kLong = 4,
147 kULong = 5,
148 kFloat = 6,
149 kDouble = 7,
150 kLongLong = 8,
151 kULongLong = 9
152};
153} // namespace mpi
167void Allgather(void* sendrecvbuf,
168 size_t total_size,
169 size_t slice_begin,
170 size_t slice_end,
171 size_t size_prev_slice);
187void Allreduce_(void *sendrecvbuf, // NOLINT
188 size_t type_nbytes,
189 size_t count,
191 mpi::DataType dtype,
192 mpi::OpType op,
193 IEngine::PreprocFunction prepare_fun = nullptr,
194 void *prepare_arg = nullptr);
195} // namespace engine
196} // namespace rabit
197#endif // RABIT_INTERNAL_ENGINE_H_
Definition allreduce_base.h:32
interface of core Allreduce engine
Definition engine.h:22
virtual bool IsDistributed() const =0
whether we run in distribted mode
virtual void Allreduce(void *sendrecvbuf_, size_t type_nbytes, size_t count, ReduceFunction reducer, PreprocFunction prepare_fun=nullptr, void *prepare_arg=nullptr)=0
performs in-place Allreduce, on sendrecvbuf this function is NOT thread-safe
~IEngine()=default
virtual destructor
virtual void TrackerPrint(const std::string &msg)=0
prints the msg in the tracker, this function can be used to communicate progress information to the u...
virtual int GetRank() const =0
gets rank of current node
void() PreprocFunction(void *arg)
Preprocessing function, that is called before AllReduce, used to prepare the data used by AllReduce.
Definition engine.h:29
void() ReduceFunction(const void *src, void *dst, int count, const MPI::Datatype &dtype)
reduce function, the same form of MPI reduce function is used, to be compatible with MPI interface In...
Definition engine.h:41
virtual int LoadCheckPoint()=0
virtual int VersionNumber() const =0
virtual void Broadcast(void *sendrecvbuf_, size_t size, int root)=0
broadcasts data from root to every other node
virtual int GetWorldSize() const =0
gets total number of nodes
virtual std::string GetHost() const =0
gets the host name of the current node
virtual int GetRingPrevRank() const =0
gets rank of previous node in ring topology
virtual void CheckPoint()=0
Increase internal version number. Deprecated.
virtual void Allgather(void *sendrecvbuf, size_t total_size, size_t slice_begin, size_t slice_end, size_t size_prev_slice)=0
Allgather function, each node have a segment of data in the ring of sendrecvbuf, the data provided by...
DataType
enum of supported data types
Definition engine.h:141
OpType
enum of all operators
Definition engine.h:132
bool Init(int argc, char *argv[])
initializes the engine module
Definition engine.cc:43
void Allreduce_(void *sendrecvbuf, size_t type_nbytes, size_t count, IEngine::ReduceFunction red, mpi::DataType dtype, mpi::OpType op, IEngine::PreprocFunction prepare_fun=nullptr, void *prepare_arg=nullptr)
perform in-place Allreduce, on sendrecvbuf this is an internal function used by rabit to be able to c...
Definition engine.cc:95
bool Finalize()
finalizes the engine module
Definition engine.cc:55
void Allgather(void *sendrecvbuf, size_t total_size, size_t slice_begin, size_t slice_end, size_t size_prev_slice)
Allgather function, each node have a segment of data in the ring of sendrecvbuf, the data provided by...
Definition engine.cc:85
IEngine * GetEngine()
singleton method to get engine
Definition engine.cc:71
namespace of rabit
Definition engine.h:18
defines serializable interface of rabit