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_process_t *processes;
21 smx_mutex_t barrier_mutex;
22 smx_cond_t barrier_cond;
23 } s_smpi_mpi_communicator_t;
26 typedef struct smpi_mpi_datatype_t {
28 } s_smpi_mpi_datatype_t;
31 typedef struct smpi_mpi_request_t {
32 smpi_mpi_communicator_t comm;
38 smpi_mpi_datatype_t datatype;
41 short int completed :1;
45 } s_smpi_mpi_request_t;
48 typedef struct smpi_mpi_op_t {
49 void (*func)(void *x, void *y, void *z);
52 // smpi received message
53 typedef struct smpi_received_message_t {
54 smpi_mpi_communicator_t comm;
59 } s_smpi_received_message_t;
60 typedef struct smpi_received_message_t *smpi_received_message_t;
62 typedef struct smpi_global_t {
65 double reference_speed;
69 int ready_process_count;
70 smx_mutex_t start_stop_mutex;
71 smx_cond_t start_stop_cond;
73 xbt_mallocator_t request_mallocator;
74 xbt_mallocator_t message_mallocator;
76 xbt_fifo_t *pending_send_request_queues;
77 smx_mutex_t *pending_send_request_queues_mutexes;
79 xbt_fifo_t *pending_recv_request_queues;
80 smx_mutex_t *pending_recv_request_queues_mutexes;
82 xbt_fifo_t *received_message_queues;
83 smx_mutex_t *received_message_queues_mutexes;
85 smx_process_t *sender_processes;
86 smx_process_t *receiver_processes;
88 int running_hosts_count;
89 smx_mutex_t running_hosts_count_mutex;
91 xbt_os_timer_t *timers;
92 smx_mutex_t *timers_mutexes;
95 typedef struct smpi_global_t *smpi_global_t;
96 extern smpi_global_t smpi_global;
98 // function prototypes
99 void smpi_mpi_init(void);
100 void smpi_mpi_finalize(void);
101 int smpi_mpi_comm_size(smpi_mpi_communicator_t comm);
102 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm, smx_host_t host);
103 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t comm);
104 int smpi_mpi_comm_world_rank_self(void);
105 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
106 int smpi_mpi_isend(smpi_mpi_request_t request);
107 int smpi_mpi_irecv(smpi_mpi_request_t request);
108 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
110 void smpi_bench_begin(void);
111 void smpi_bench_end(void);
113 void smpi_global_init(void);
114 void smpi_global_destroy(void);
115 int smpi_run_simulation(int argc, char **argv);
116 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
117 int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
119 int smpi_sender(int argc, char **argv);
121 int smpi_receiver(int argc, char **argv);