2 #include "xbt/mallocator.h"
3 #include "xbt/xbt_os_time.h"
5 #define SMPI_DEFAULT_SPEED 100
6 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
7 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
9 typedef struct SMPI_Global {
12 double reference_speed;
16 int ready_process_count;
17 smx_mutex_t start_stop_mutex;
18 smx_cond_t start_stop_cond;
20 xbt_mallocator_t request_mallocator;
21 xbt_mallocator_t message_mallocator;
23 xbt_fifo_t *pending_send_request_queues;
24 smx_mutex_t *pending_send_request_queues_mutexes;
26 xbt_fifo_t *pending_recv_request_queues;
27 smx_mutex_t *pending_recv_request_queues_mutexes;
29 xbt_fifo_t *received_message_queues;
30 smx_mutex_t *received_message_queues_mutexes;
32 smx_process_t *sender_processes;
33 smx_process_t *receiver_processes;
35 int running_hosts_count;
36 smx_mutex_t running_hosts_count_mutex;
38 xbt_os_timer_t *timers;
39 smx_mutex_t *timers_mutexes;
42 } s_SMPI_Global_t, *SMPI_Global_t;
44 extern SMPI_Global_t smpi_global;
46 struct smpi_received_message_t {
47 smpi_mpi_communicator_t *comm;
54 typedef struct smpi_received_message_t smpi_received_message_t;
56 // function prototypes
57 int smpi_mpi_comm_size(smpi_mpi_communicator_t *comm);
58 int smpi_mpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
59 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t *comm);
60 int smpi_mpi_comm_world_rank_self(void);
61 int smpi_sender(int argc, char **argv);
62 int smpi_receiver(int argc, char **argv);
63 void *smpi_request_new(void);
64 void smpi_request_free(void *pointer);
65 void smpi_request_reset(void *pointer);
66 void *smpi_message_new(void);
67 void smpi_message_free(void *pointer);
68 void smpi_message_reset(void *pointer);
69 void smpi_global_init(void);
70 void smpi_global_destroy(void);
71 int smpi_run_simulation(int argc, char **argv);
72 void smpi_mpi_land_func(void *x, void *y, void *z);
73 void smpi_mpi_sum_func(void *x, void *y, void *z);
74 void smpi_mpi_init(void);
75 void smpi_mpi_finalize(void);
76 void smpi_bench_begin(void);
77 void smpi_bench_end(void);
78 void smpi_barrier(smpi_mpi_communicator_t *comm);
79 int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
80 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype,
81 int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request);
82 int smpi_isend(smpi_mpi_request_t *request);
83 int smpi_irecv(smpi_mpi_request_t *request);
84 void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status);