ROSS
network-mpi.h
Go to the documentation of this file.
1#ifndef INC_network_mpi_h
2#define INC_network_mpi_h
3
4#include "ross-types.h"
5#include "tw-opts.h"
6#include <mpi.h>
7
8typedef long tw_node;
9
10extern MPI_Comm MPI_COMM_ROSS;
11
12/**
13 * @brief Initalize the network library and parse options.
14 *
15 * argc and argv are pointers to the original command line; the
16 * network library may edit these before the option parser sees
17 * them allowing for network implementation specific argument
18 * handling to occur.
19 *
20 * It's possible for a model to init MPI itself, as this
21 * function will first check if MPI is already initialized before
22 * attempting to call MPI_Init().
23 *
24 * This function also sets the global variables
25 * g_tw_masternode and g_tw_mynode.
26 *
27 * @param[in] argc Pointer to command line arg count
28 * @param[in] argv Pointer to command line args
29 * @return tw_optdef array to be included in overall process
30 * command line argument display and parsing; NULL may be returned
31 * to indicate the implementation has no options it wants included.
32 */
33const tw_optdef *tw_net_init(int *argc, char ***argv);
34
35/**
36 * @brief Setup the MPI_COMM_ROSS communicator to use instead of MPI_COMM_WORLD.
37 *
38 * This function should be called before tw_net_init.
39 * @param[in] comm Custom MPI communicator for setting MPI_COMM_ROSS
40 */
41void tw_comm_set(MPI_Comm comm);
42
43/**
44 * @brief Starts the network library after option parsing.
45 *
46 * Makes calls to initialize the PE (g_tw_pe), create the hash/AVL tree
47 * (for optimistic modes), and queues for posted sends/recvs.
48 * Also pre-posts MPI Irecvs operations.
49 */
50void tw_net_start(void);
51
52/**
53 * @brief Stops the network library after simulation end.
54 *
55 * Checks to see if custom communicator was used. If not, finalizes MPI.
56 * Otherwise, the application is expected to finalize MPI itself.
57 */
58void tw_net_stop(void);
59
60/** Aborts the entire simulation when a grave error is found. */
61void tw_net_abort(void) NORETURN;
62
63/**
64 * @brief starts service_queues() to poll network
65 *
66 * @param[in] me pointer to the PE
67 */
68extern void tw_net_read(tw_pe *);
69
70/**
71 * @brief Adds the event to the outgoing queue of events to be sent,
72 * polls for finished sends, and attempts to start sends from outq.
73 *
74 * @param[in] e remote event to be sent
75 */
76extern void tw_net_send(tw_event *);
77
78/**
79 * @brief Cancel the given remote event by either removing from the outq
80 * or sending an antimessage, depending on the status of the original positive send.
81 *
82 * @param[in] e remote event to be canceled
83 */
84extern void tw_net_cancel(tw_event *);
85
86/** Obtain the total number of PEs executing the simulation.
87 *
88 * @return number of ROSS PEs/MPI world size
89 */
90extern unsigned tw_nnodes(void);
91
92/** Block until all nodes call the barrier. */
93extern void tw_net_barrier(void);
94
95/**
96 * @brief Obtain the lowest timestamp inside the network buffers.
97 *
98 * @return minimum timestamp for this PE's network buffers
99 */
100extern tw_stime tw_net_minimum(void);
101
102#ifdef USE_RAND_TIEBREAKER
103/**
104 * @brief Obtain the event signature for the lowest ordered event inside the network buffers.
105 *
106 * @return minimum event signature for this PE's network buffers
107 */
109#endif
110
111/**
112 * @brief Function to reduce all the statistics for output.
113 * @attention Notice that the MPI_Reduce "count" parameter is greater than one.
114 * We are reducing on multiple variables *simultaneously* so if you change
115 * this function or the struct tw_statistics, you must update the other.
116 **/
118
119#endif
void tw_net_cancel(tw_event *)
Cancel the given remote event by either removing from the outq or sending an antimessage,...
tw_statistics * tw_net_statistics(tw_pe *, tw_statistics *)
Function to reduce all the statistics for output.
void tw_net_read(tw_pe *)
starts service_queues() to poll network
void tw_net_abort(void)
tw_event_sig const * tw_net_minimum_sig_ptr(void)
Obtain the event signature for the lowest ordered event inside the network buffers.
void tw_net_start(void)
Starts the network library after option parsing.
void tw_net_send(tw_event *)
Adds the event to the outgoing queue of events to be sent, polls for finished sends,...
void tw_net_stop(void)
Stops the network library after simulation end.
const tw_optdef * tw_net_init(int *argc, char ***argv)
Initalize the network library and parse options.
Definition network-mpi.c:66
tw_stime tw_net_minimum(void)
Obtain the lowest timestamp inside the network buffers.
unsigned tw_nnodes(void)
void tw_net_barrier(void)
void tw_comm_set(MPI_Comm comm)
Setup the MPI_COMM_ROSS communicator to use instead of MPI_COMM_WORLD.
Definition network-mpi.c:59
long tw_node
Definition network-mpi.h:8
MPI_Comm MPI_COMM_ROSS
Definition network-mpi.c:4
double tw_stime
Definition ross-base.h:39
#define NORETURN
Definition ross-base.h:15
Definition of ROSS basic types.
Event Stucture.
Definition ross-types.h:277
Holds the entire PE state.
Definition ross-types.h:416
Statistics tallied over the duration of the simulation.
Definition ross-types.h:117