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;
89 xbt_mallocator_t request_mallocator;
90 xbt_mallocator_t message_mallocator;
92 // FIXME: request queues should be moved to host data...
93 xbt_fifo_t *pending_send_request_queues;
94 xbt_fifo_t *received_message_queues;
96 smx_process_t *main_processes;
97 smx_process_t *sender_processes;
98 smx_process_t *receiver_processes;
100 int running_hosts_count;
102 xbt_os_timer_t timer;
103 smx_mutex_t timer_mutex;
104 smx_cond_t timer_cond;
106 // keeps track of previous times
107 smpi_do_once_duration_node_t do_once_duration_nodes;
108 smx_mutex_t do_once_mutex;
109 double *do_once_duration;
112 typedef struct smpi_global_t *smpi_global_t;
113 extern smpi_global_t smpi_global;
115 typedef struct smpi_host_data_t {
121 smx_process_t sender;
122 smx_process_t receiver;
124 xbt_fifo_t pending_recv_request_queue;
125 } s_smpi_host_data_t;
126 typedef struct smpi_host_data_t *smpi_host_data_t;
128 // function prototypes
129 void smpi_process_init(void);
130 void smpi_process_finalize(void);
131 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
133 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
134 int smpi_mpi_isend(smpi_mpi_request_t request);
135 int smpi_mpi_irecv(smpi_mpi_request_t request);
136 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t * status);
138 void smpi_execute(double duration);
139 void smpi_start_timer(void);
140 double smpi_stop_timer(void);
141 void smpi_bench_begin(void);
142 void smpi_bench_end(void);
143 void smpi_bench_skip(void);
145 void smpi_global_init(void);
146 void smpi_global_destroy(void);
147 int smpi_host_index(void);
148 smx_mutex_t smpi_host_mutex(void);
149 smx_cond_t smpi_host_cond(void);
150 int smpi_run_simulation(int *argc, char **argv);
151 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
152 int src, int dst, int tag,
153 smpi_mpi_communicator_t comm,
154 smpi_mpi_request_t * request);
156 int smpi_sender(int argc,char*argv[]);
157 int smpi_receiver(int argc, char*argv[]);