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
14 // FIXME: should probably be dynamic datatype...
15 // or could include code to dynamically expand when full
16 #define SMPI_MAX_TIMES 10
18 // smpi mpi communicator
19 typedef struct smpi_mpi_communicator_t {
22 smx_mutex_t barrier_mutex;
23 smx_cond_t barrier_cond;
25 int *rank_to_index_map;
26 int *index_to_rank_map;
28 } s_smpi_mpi_communicator_t;
31 typedef struct smpi_mpi_datatype_t {
33 } s_smpi_mpi_datatype_t;
36 typedef struct smpi_mpi_request_t {
37 smpi_mpi_communicator_t comm;
44 smpi_mpi_datatype_t datatype;
46 short int completed :1;
54 } s_smpi_mpi_request_t;
57 typedef struct smpi_mpi_op_t {
58 void (*func)(void *a, void *b, int *length, MPI_Datatype *datatype);
61 // smpi received message
62 typedef struct smpi_received_message_t {
63 smpi_mpi_communicator_t comm;
72 } s_smpi_received_message_t;
73 typedef struct smpi_received_message_t *smpi_received_message_t;
75 typedef struct smpi_global_t {
78 double reference_speed;
82 int ready_process_count;
83 smx_mutex_t start_stop_mutex;
84 smx_cond_t start_stop_cond;
88 xbt_mallocator_t request_mallocator;
89 xbt_mallocator_t message_mallocator;
91 xbt_fifo_t *pending_send_request_queues;
92 smx_mutex_t *pending_send_request_queues_mutexes;
94 xbt_fifo_t *pending_recv_request_queues;
95 smx_mutex_t *pending_recv_request_queues_mutexes;
97 xbt_fifo_t *received_message_queues;
98 smx_mutex_t *received_message_queues_mutexes;
100 smx_process_t *sender_processes;
101 smx_process_t *receiver_processes;
103 int running_hosts_count;
104 smx_mutex_t running_hosts_count_mutex;
106 xbt_os_timer_t timer;
107 smx_mutex_t timer_mutex;
108 smx_cond_t timer_cond;
109 double times[SMPI_MAX_TIMES];
111 smx_mutex_t times_mutex;
114 typedef struct smpi_global_t *smpi_global_t;
115 extern smpi_global_t smpi_global;
117 typedef struct smpi_host_data_t {
119 } s_smpi_host_data_t;
120 typedef struct smpi_host_data_t *smpi_host_data_t;
122 // function prototypes
123 void smpi_mpi_init(void);
124 void smpi_mpi_finalize(void);
125 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
127 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
128 int smpi_mpi_isend(smpi_mpi_request_t request);
129 int smpi_mpi_irecv(smpi_mpi_request_t request);
130 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
132 void smpi_bench_begin(void);
133 double smpi_bench_end(void);
134 void smpi_bench_skip(void);
136 void smpi_global_init(void);
137 void smpi_global_destroy(void);
138 int smpi_host_index(void);
139 int smpi_run_simulation(int *argc, char **argv);
140 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
141 int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
143 int smpi_sender(int argc, char **argv);
145 int smpi_receiver(int argc, char **argv);