4 #include "xbt/mallocator.h"
5 #include "xbt/xbt_os_time.h"
8 #define SMPI_DEFAULT_SPEED 100
9 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
10 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
12 typedef struct smpi_mpi_communicator_simdata {
14 smx_process_t *processes;
16 smx_mutex_t barrier_mutex;
17 smx_cond_t barrier_cond;
18 } s_smpi_mpi_communicator_simdata_t;
20 typedef struct smpi_mpi_request_simdata {
23 } s_smpi_mpi_request_simdata_t;
25 typedef struct SMPI_Global {
28 double reference_speed;
32 int ready_process_count;
33 smx_mutex_t start_stop_mutex;
34 smx_cond_t start_stop_cond;
36 xbt_mallocator_t request_mallocator;
37 xbt_mallocator_t message_mallocator;
39 xbt_fifo_t *pending_send_request_queues;
40 smx_mutex_t *pending_send_request_queues_mutexes;
42 xbt_fifo_t *pending_recv_request_queues;
43 smx_mutex_t *pending_recv_request_queues_mutexes;
45 xbt_fifo_t *received_message_queues;
46 smx_mutex_t *received_message_queues_mutexes;
48 smx_process_t *sender_processes;
49 smx_process_t *receiver_processes;
51 int running_hosts_count;
52 smx_mutex_t running_hosts_count_mutex;
54 xbt_os_timer_t *timers;
55 smx_mutex_t *timers_mutexes;
57 } s_SMPI_Global_t, *SMPI_Global_t;
58 extern SMPI_Global_t smpi_global;
60 struct smpi_received_message_t {
61 smpi_mpi_communicator_t *comm;
67 typedef struct smpi_received_message_t smpi_received_message_t;
69 // function prototypes
70 int smpi_mpi_comm_size(smpi_mpi_communicator_t *comm);
71 int smpi_mpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
72 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t *comm);
73 int smpi_mpi_comm_world_rank_self(void);
74 int smpi_sender(int argc, char **argv);
75 int smpi_receiver(int argc, char **argv);
76 void *smpi_request_new(void);
77 void smpi_request_free(void *pointer);
78 void smpi_request_reset(void *pointer);
79 void *smpi_message_new(void);
80 void smpi_message_free(void *pointer);
81 void smpi_message_reset(void *pointer);
82 void smpi_global_init(void);
83 void smpi_global_destroy(void);
84 int smpi_run_simulation(int argc, char **argv);
85 void smpi_mpi_land_func(void *x, void *y, void *z);
86 void smpi_mpi_sum_func(void *x, void *y, void *z);
87 void smpi_mpi_init(void);
88 void smpi_mpi_finalize(void);
89 void smpi_bench_begin(void);
90 void smpi_bench_end(void);
91 void smpi_barrier(smpi_mpi_communicator_t *comm);
92 int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
93 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype,
94 int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request);
95 int smpi_isend(smpi_mpi_request_t *request);
96 int smpi_irecv(smpi_mpi_request_t *request);
97 void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status);