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 typedef struct smpi_mpi_communicator_t {
18 smx_process_t *processes;
20 smx_mutex_t barrier_mutex;
21 smx_cond_t barrier_cond;
22 } s_smpi_mpi_communicator_t;
24 typedef struct smpi_mpi_request_t {
25 smpi_mpi_communicator_t comm;
31 smpi_mpi_datatype_t datatype;
34 short int completed :1;
38 } s_smpi_mpi_request_t;
40 typedef struct SMPI_Global {
43 double reference_speed;
47 int ready_process_count;
48 smx_mutex_t start_stop_mutex;
49 smx_cond_t start_stop_cond;
51 xbt_mallocator_t request_mallocator;
52 xbt_mallocator_t message_mallocator;
54 xbt_fifo_t *pending_send_request_queues;
55 smx_mutex_t *pending_send_request_queues_mutexes;
57 xbt_fifo_t *pending_recv_request_queues;
58 smx_mutex_t *pending_recv_request_queues_mutexes;
60 xbt_fifo_t *received_message_queues;
61 smx_mutex_t *received_message_queues_mutexes;
63 smx_process_t *sender_processes;
64 smx_process_t *receiver_processes;
66 int running_hosts_count;
67 smx_mutex_t running_hosts_count_mutex;
69 xbt_os_timer_t *timers;
70 smx_mutex_t *timers_mutexes;
72 } s_SMPI_Global_t, *SMPI_Global_t;
73 extern SMPI_Global_t smpi_global;
75 typedef struct smpi_received_message_t {
76 smpi_mpi_communicator_t comm;
81 } s_smpi_received_message_t;
82 typedef struct smpi_received_message_t *smpi_received_message_t;
84 // function prototypes
85 int smpi_mpi_comm_size(smpi_mpi_communicator_t comm);
86 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm, smx_host_t host);
87 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t comm);
88 int smpi_mpi_comm_world_rank_self(void);
89 int smpi_sender(int argc, char **argv);
90 int smpi_receiver(int argc, char **argv);
91 void *smpi_request_new(void);
92 void smpi_request_free(void *pointer);
93 void smpi_request_reset(void *pointer);
94 void *smpi_message_new(void);
95 void smpi_message_free(void *pointer);
96 void smpi_message_reset(void *pointer);
97 void smpi_global_init(void);
98 void smpi_global_destroy(void);
99 int smpi_run_simulation(int argc, char **argv);
100 void smpi_mpi_land_func(void *x, void *y, void *z);
101 void smpi_mpi_sum_func(void *x, void *y, void *z);
102 void smpi_mpi_init(void);
103 void smpi_mpi_finalize(void);
104 void smpi_bench_begin(void);
105 void smpi_bench_end(void);
106 void smpi_barrier(smpi_mpi_communicator_t comm);
107 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
108 int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
109 int smpi_isend(smpi_mpi_request_t request);
110 int smpi_irecv(smpi_mpi_request_t request);
111 int smpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);