4 #include "simix/simix.h"
5 #include "xbt/mallocator.h"
6 #include "xbt/xbt_os_time.h"
9 #define SMPI_DEFAULT_SPEED 100
10 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
11 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
13 typedef struct smpi_mpi_communicator_simdata {
15 smx_process_t *processes;
17 smx_mutex_t barrier_mutex;
18 smx_cond_t barrier_cond;
19 } s_smpi_mpi_communicator_simdata_t;
21 typedef struct smpi_mpi_request_simdata {
24 } s_smpi_mpi_request_simdata_t;
26 typedef struct SMPI_Global {
29 double reference_speed;
33 int ready_process_count;
34 smx_mutex_t start_stop_mutex;
35 smx_cond_t start_stop_cond;
37 xbt_mallocator_t request_mallocator;
38 xbt_mallocator_t message_mallocator;
40 xbt_fifo_t *pending_send_request_queues;
41 smx_mutex_t *pending_send_request_queues_mutexes;
43 xbt_fifo_t *pending_recv_request_queues;
44 smx_mutex_t *pending_recv_request_queues_mutexes;
46 xbt_fifo_t *received_message_queues;
47 smx_mutex_t *received_message_queues_mutexes;
49 smx_process_t *sender_processes;
50 smx_process_t *receiver_processes;
52 int running_hosts_count;
53 smx_mutex_t running_hosts_count_mutex;
55 xbt_os_timer_t *timers;
56 smx_mutex_t *timers_mutexes;
58 } s_SMPI_Global_t, *SMPI_Global_t;
59 extern SMPI_Global_t smpi_global;
61 struct smpi_received_message_t {
62 smpi_mpi_communicator_t *comm;
68 typedef struct smpi_received_message_t smpi_received_message_t;
70 // function prototypes
71 int smpi_mpi_comm_size(smpi_mpi_communicator_t *comm);
72 int smpi_mpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
73 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t *comm);
74 int smpi_mpi_comm_world_rank_self(void);
75 int smpi_sender(int argc, char **argv);
76 int smpi_receiver(int argc, char **argv);
77 void *smpi_request_new(void);
78 void smpi_request_free(void *pointer);
79 void smpi_request_reset(void *pointer);
80 void *smpi_message_new(void);
81 void smpi_message_free(void *pointer);
82 void smpi_message_reset(void *pointer);
83 void smpi_global_init(void);
84 void smpi_global_destroy(void);
85 int smpi_run_simulation(int argc, char **argv);
86 void smpi_mpi_land_func(void *x, void *y, void *z);
87 void smpi_mpi_sum_func(void *x, void *y, void *z);
88 void smpi_mpi_init(void);
89 void smpi_mpi_finalize(void);
90 void smpi_bench_begin(void);
91 void smpi_bench_end(void);
92 void smpi_barrier(smpi_mpi_communicator_t *comm);
93 int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
94 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype,
95 int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request);
96 int smpi_isend(smpi_mpi_request_t *request);
97 int smpi_irecv(smpi_mpi_request_t *request);
98 void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status);