Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c69ddb41fa2f214129880497f1e97eccd998811b
[simgrid.git] / src / smpi / private.h
1 #ifndef SMPI_PRIVATE_H
2 #define SMPI_PRIVATE_H
3
4 #include "xbt/mallocator.h"
5 #include "xbt/xbt_os_time.h"
6
7 #include "simix/simix.h"
8
9 #include "smpi/smpi.h"
10
11 #define SMPI_DEFAULT_SPEED 100
12 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
13 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
14
15 // smpi mpi communicator
16 typedef struct smpi_mpi_communicator_t {
17         int            size;
18         int            barrier_count;
19         smx_mutex_t    barrier_mutex;
20         smx_cond_t     barrier_cond;
21
22         int           *rank_to_index_map;
23         int           *index_to_rank_map;
24
25 } s_smpi_mpi_communicator_t;
26
27 // smpi mpi datatype
28 typedef struct smpi_mpi_datatype_t {
29   size_t size;
30 } s_smpi_mpi_datatype_t;
31
32 // smpi mpi request
33 typedef struct smpi_mpi_request_t {
34         smpi_mpi_communicator_t comm;
35         int src;
36         int dst;
37         int tag;
38
39         void *buf;
40         int count;
41         smpi_mpi_datatype_t datatype;
42
43         short int completed :1;
44
45         smx_mutex_t mutex;
46         smx_cond_t  cond;
47
48         void *data;
49
50 } s_smpi_mpi_request_t;
51
52 // smpi mpi op
53 typedef struct smpi_mpi_op_t {
54   void (*func)(void *a, void *b, int *length, MPI_Datatype *datatype);
55 } s_smpi_mpi_op_t;
56
57 // smpi received message
58 typedef struct smpi_received_message_t {
59         smpi_mpi_communicator_t comm;
60         int src;
61         int tag;
62
63         void *buf;
64
65         void *data;
66
67 } s_smpi_received_message_t;
68 typedef struct smpi_received_message_t *smpi_received_message_t;
69
70 typedef struct smpi_global_t {
71
72         // config vars
73         double            reference_speed;
74
75         // state vars
76         int               root_ready:1;
77         int               ready_process_count;
78         smx_mutex_t       start_stop_mutex;
79         smx_cond_t        start_stop_cond;
80
81         smx_host_t       *hosts;
82         int               host_count;
83         xbt_mallocator_t  request_mallocator;
84         xbt_mallocator_t  message_mallocator;
85
86         xbt_fifo_t       *pending_send_request_queues;
87         smx_mutex_t      *pending_send_request_queues_mutexes;
88
89         xbt_fifo_t       *pending_recv_request_queues;
90         smx_mutex_t      *pending_recv_request_queues_mutexes;
91
92         xbt_fifo_t       *received_message_queues;
93         smx_mutex_t      *received_message_queues_mutexes;
94
95         smx_process_t    *sender_processes;
96         smx_process_t    *receiver_processes;
97
98         int               running_hosts_count;
99         smx_mutex_t       running_hosts_count_mutex;
100
101         xbt_os_timer_t   *timers;
102         smx_mutex_t      *timers_mutexes;
103
104 } s_smpi_global_t;
105 typedef struct smpi_global_t *smpi_global_t;
106 extern smpi_global_t smpi_global;
107
108 typedef struct smpi_host_data_t {
109         int index;
110 } s_smpi_host_data_t;
111 typedef struct smpi_host_data_t *smpi_host_data_t;
112
113 // function prototypes
114 void smpi_mpi_init(void);
115 void smpi_mpi_finalize(void);
116 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
117
118 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
119 int smpi_mpi_isend(smpi_mpi_request_t request);
120 int smpi_mpi_irecv(smpi_mpi_request_t request);
121 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
122
123 void smpi_bench_begin(void);
124 void smpi_bench_end(void);
125
126 void smpi_global_init(void);
127 void smpi_global_destroy(void);
128 int smpi_host_index(void);
129 int smpi_run_simulation(int argc, char **argv);
130 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
131         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
132
133 int smpi_sender(int argc, char **argv);
134
135 int smpi_receiver(int argc, char **argv);
136
137 #endif