27 #ifndef GALOIS_RUNTIME_NETWORK_H
28 #define GALOIS_RUNTIME_NETWORK_H
40 namespace galois::runtime {
67 #ifdef GALOIS_USE_BARE_MPI
70 inline void incrementMemUsage(uint64_t size) {
74 inline void decrementMemUsage(uint64_t size) {
104 template <
typename... Args>
105 void sendSimple(uint32_t dest,
void (*recv)(uint32_t, Args...),
123 template <
typename... Args>
136 virtual std::optional<std::pair<uint32_t, RecvBuffer>>
137 recieveTagged(uint32_t tag, std::unique_lock<substrate::SimpleLock>* rlg,
141 virtual void flush() = 0;
164 virtual std::vector<unsigned long>
reportExtra()
const = 0;
167 virtual std::vector<std::pair<std::string, unsigned long>>
181 void destroySystemNetworkInterface();
206 template <
typename... Args>
207 static void genericLandingPad(uint32_t src,
RecvBuffer& buf) {
208 void (*fp)(uint32_t, Args...);
209 std::tuple<Args...> args;
211 std::apply([fp, src](Args... params) { fp(src, params...); }, args);
216 template <
typename... Args>
217 void NetworkInterface::sendSimple(uint32_t dest,
218 void (*recv)(uint32_t, Args...),
221 gSerialize(buf, (uintptr_t)recv, param...,
222 (uintptr_t)genericLandingPad<Args...>);
223 sendTagged(dest, 0, buf);
226 template <
typename... Args>
227 void NetworkInterface::broadcastSimple(
void (*recv)(uint32_t, Args...),
230 gSerialize(buf, (uintptr_t)recv, param...);
231 broadcast(genericLandingPad<Args...>, buf,
false);
uint32_t getHostID()
Gets this host's ID.
Definition: Network.cpp:41
void resetMemUsage()
Reset mem usage and max mem usage to 0.
Definition: MemUsage.h:68
void sendMsg(uint32_t dest, void(*recv)(uint32_t, RecvBuffer &), SendBuffer &buf)
Send a message to a given (dest) host.
Definition: Network.cpp:92
virtual void sendTagged(uint32_t dest, uint32_t tag, SendBuffer &buf, int type=0)=0
Send a message to a given (dest) host.
virtual std::vector< unsigned long > reportExtra() const =0
Get any other extra statistics that might need to be reported; varies depending on implementation...
virtual unsigned long reportRecvMsgs() const =0
Get how many messages were received.
void handleReceives()
Receive and dispatch messages.
Definition: Network.cpp:115
DeSerializeBuffer RecvBuffer
typedef for buffer that received data is saved into
Definition: Network.h:45
Buffer for serialization of data.
Definition: Serialize.h:56
Class that tracks memory usage (mainly of send and receive buffers).
Definition: MemUsage.h:38
virtual bool anyPendingSends()=0
void gDeserialize(DeSerializeBuffer &buf, T1 &&t1, Args &&...args)
Deserialize data in a buffer into a series of objects.
Definition: Serialize.h:1032
static uint32_t ID
This machine's host ID.
Definition: Network.h:81
virtual void flush()=0
move send buffers out to network
virtual unsigned long reportSendBytes() const =0
Get how many bytes were sent.
substrate::Barrier & getHostFence()
Returns a fence that ensures all pending messages are delivered, acting like a memory-barrier.
Definition: libdist/src/Barrier.cpp:114
std::atomic< size_t > inflightSends
Number of inflight sends and receives.
Definition: Network.h:64
virtual std::vector< std::pair< std::string, unsigned long > > reportExtraNamed() const =0
Get the names of the extra things that are returned by reportExtra.
static uint32_t Num
The total number of machines in the current program.
Definition: Network.h:83
void broadcastSimple(void(*recv)(uint32_t, Args...), Args...param)
Broadcast a message allowing the network to handle serialization and deserialization.
Definition: Network.h:227
NetworkInterface & makeNetworkLCI()
Returns a LCINetwork interface.
void incrementMemUsage(uint64_t size)
Increment memory usage.
Definition: MemUsage.h:52
MemUsageTracker memUsageTracker
Memory usage tracker.
Definition: Network.h:61
virtual unsigned long reportSendMsgs() const =0
Get how many messages were sent.
NetworkInterface & getSystemNetworkInterface()
Get the network interface.
Definition: Network.cpp:131
virtual bool anyPendingReceives()=0
void resetMemUsage()
Wrapper to reset the mem usage tracker's stats.
Definition: Network.h:130
void initializeMPI()
Initialize the MPI system. Should only be called once per process.
Definition: Network.cpp:45
void sendSimple(uint32_t dest, void(*recv)(uint32_t, Args...), Args...param)
Send a message letting the network handle the serialization and deserialization slightly slower...
Definition: Network.h:217
Contains MemUsageTracker, a class that tracks memory usage throughout runtime of a program of send/re...
void finalizeMPI()
Finalize the MPI system. Should only be called once per process.
Definition: Network.cpp:58
void decrementMemUsage(uint64_t size)
Decrement memory usage.
Definition: MemUsage.h:63
void broadcast(void(*recv)(uint32_t, RecvBuffer &), SendBuffer &buf, bool self=false)
Send a message to all hosts.
Definition: Network.cpp:99
Contains functions that serialize/deserialize data, mainly for sending out serialized data over the n...
substrate::Barrier & getHostBarrier()
Returns a host barrier, which is a regular MPI-Like Barrier for all hosts.
Definition: libdist/src/Barrier.cpp:109
NetworkInterface()
Constructor for interface.
Definition: Network.cpp:68
virtual unsigned long reportRecvBytes() const =0
Get how many bytes were received.
uint32_t evilPhase
Variable that keeps track of which network send/recv phase a program is currently on...
Definition: Network.cpp:36
Buffer for deserialization of data.
Definition: Serialize.h:147
virtual std::optional< std::pair< uint32_t, RecvBuffer > > recieveTagged(uint32_t tag, std::unique_lock< substrate::SimpleLock > *rlg, int type=0)=0
Receive a tagged message.
A class that defines functions that a network interface in Galois should have.
Definition: Network.h:52
virtual ~NetworkInterface()
Destructor destroys MPI (if it exists).
Definition: Network.cpp:70
NetworkInterface & makeNetworkBuffered()
Returns a BufferedNetwork interface.
Definition: NetworkBuffered.cpp:562
std::atomic< size_t > inflightRecvs
Definition: Network.h:65
void reportMemUsage() const
Reports the memory usage tracker's statistics to the stat manager.
Definition: Network.cpp:72