4 #include "xbt/mallocator.h"
5 #include "xbt/xbt_os_time.h"
7 #include "simix/simix.h"
11 #define SMPI_DEFAULT_SPEED 100
12 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
13 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
15 // smpi mpi communicator
16 typedef struct smpi_mpi_communicator_t {
19 smx_mutex_t barrier_mutex;
20 smx_cond_t barrier_cond;
22 int *rank_to_index_map;
23 int *index_to_rank_map;
25 } s_smpi_mpi_communicator_t;
28 typedef struct smpi_mpi_datatype_t {
30 } s_smpi_mpi_datatype_t;
33 typedef struct smpi_mpi_request_t {
34 smpi_mpi_communicator_t comm;
41 smpi_mpi_datatype_t datatype;
43 short int completed :1;
51 } s_smpi_mpi_request_t;
54 typedef struct smpi_mpi_op_t {
55 void (*func)(void *a, void *b, int *length, MPI_Datatype *datatype);
58 // smpi received message
59 typedef struct smpi_received_message_t {
60 smpi_mpi_communicator_t comm;
69 } s_smpi_received_message_t;
70 typedef struct smpi_received_message_t *smpi_received_message_t;
72 typedef struct smpi_do_once_duration_node_t {
76 struct smpi_do_once_duration_node_t *next;
77 } s_smpi_do_once_duration_node_t;
78 typedef struct smpi_do_once_duration_node_t *smpi_do_once_duration_node_t;
80 typedef struct smpi_global_t {
83 double reference_speed;
87 int ready_process_count;
88 smx_mutex_t start_stop_mutex;
89 smx_cond_t start_stop_cond;
93 xbt_mallocator_t request_mallocator;
94 xbt_mallocator_t message_mallocator;
96 // FIXME: request queues should be moved to host data...
97 xbt_fifo_t *pending_send_request_queues;
98 smx_mutex_t *pending_send_request_queues_mutexes;
100 xbt_fifo_t *pending_recv_request_queues;
101 smx_mutex_t *pending_recv_request_queues_mutexes;
103 xbt_fifo_t *received_message_queues;
104 smx_mutex_t *received_message_queues_mutexes;
106 smx_process_t *sender_processes;
107 smx_process_t *receiver_processes;
109 int running_hosts_count;
110 smx_mutex_t running_hosts_count_mutex;
112 xbt_os_timer_t timer;
113 smx_mutex_t timer_mutex;
114 smx_cond_t timer_cond;
116 // keeps track of previous times
117 smpi_do_once_duration_node_t do_once_duration_nodes;
118 smx_mutex_t do_once_mutex;
119 double *do_once_duration;
122 typedef struct smpi_global_t *smpi_global_t;
123 extern smpi_global_t smpi_global;
125 typedef struct smpi_host_data_t {
129 } s_smpi_host_data_t;
130 typedef struct smpi_host_data_t *smpi_host_data_t;
132 // function prototypes
133 void smpi_mpi_init(void);
134 void smpi_mpi_finalize(void);
135 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
137 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
138 int smpi_mpi_isend(smpi_mpi_request_t request);
139 int smpi_mpi_irecv(smpi_mpi_request_t request);
140 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
142 void smpi_execute(double duration);
143 void smpi_start_timer(void);
144 double smpi_stop_timer(void);
145 void smpi_bench_begin(void);
146 void smpi_bench_end(void);
147 void smpi_bench_skip(void);
149 void smpi_global_init(void);
150 void smpi_global_destroy(void);
151 int smpi_host_index(void);
152 smx_mutex_t smpi_host_mutex(void);
153 smx_cond_t smpi_host_cond(void);
154 int smpi_run_simulation(int *argc, char **argv);
155 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
156 int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
158 int smpi_sender(int argc, char **argv);
160 int smpi_receiver(int argc, char **argv);