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