forked from microsoft/Multiverso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet.cpp
More file actions
45 lines (36 loc) · 974 Bytes
/
net.cpp
File metadata and controls
45 lines (36 loc) · 974 Bytes
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
#include "multiverso/net.h"
#include <limits>
#include <mutex>
#include "multiverso/message.h"
#include "multiverso/util/log.h"
#include "multiverso/net/zmq_net.h"
#include "multiverso/net/mpi_net.h"
namespace multiverso {
NetInterface* NetInterface::Get() {
#ifdef MULTIVERSO_USE_ZMQ
static ZMQNetWrapper net_impl;
return &net_impl;
#else
// #ifdef MULTIVERSO_USE_MPI
// Use MPI by default
static MPINetWrapper net_impl;
return &net_impl;
// #endif
#endif
}
namespace net {
template <typename Typename>
void Allreduce(Typename* data, size_t elem_count) {
#ifdef MULTIVERSO_USE_MPI
CHECK(NetInterface::Get()->active());
MPINetWrapper::Allreduce(data, elem_count);
#else
Log::Fatal("Not implemented yet");
#endif
}
template void Allreduce<char>(char*, size_t);
template void Allreduce<int>(int*, size_t);
template void Allreduce<float>(float*, size_t);
template void Allreduce<double>(double*, size_t);
} // namespace net
} // namespace multiverso