Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaning up and refactoring some of the code to create execution actions.
[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 // FIXME: should probably be dynamic datatype...
15 // or could include code to dynamically expand when full
16 #define SMPI_MAX_TIMES 10
17
18 // smpi mpi communicator
19 typedef struct smpi_mpi_communicator_t {
20         int            size;
21         int            barrier_count;
22         smx_mutex_t    barrier_mutex;
23         smx_cond_t     barrier_cond;
24
25         int           *rank_to_index_map;
26         int           *index_to_rank_map;
27
28 } s_smpi_mpi_communicator_t;
29
30 // smpi mpi datatype
31 typedef struct smpi_mpi_datatype_t {
32   size_t size;
33 } s_smpi_mpi_datatype_t;
34
35 // smpi mpi request
36 typedef struct smpi_mpi_request_t {
37         smpi_mpi_communicator_t comm;
38         int src;
39         int dst;
40         int tag;
41
42         void *buf;
43         int count;
44         smpi_mpi_datatype_t datatype;
45
46         short int completed :1;
47
48         smx_mutex_t mutex;
49         smx_cond_t  cond;
50
51         void *data;
52         int forward;
53
54 } s_smpi_mpi_request_t;
55
56 // smpi mpi op
57 typedef struct smpi_mpi_op_t {
58   void (*func)(void *a, void *b, int *length, MPI_Datatype *datatype);
59 } s_smpi_mpi_op_t;
60
61 // smpi received message
62 typedef struct smpi_received_message_t {
63         smpi_mpi_communicator_t comm;
64         int src;
65         int tag;
66
67         void *buf;
68
69         void *data;
70         int forward;
71
72 } s_smpi_received_message_t;
73 typedef struct smpi_received_message_t *smpi_received_message_t;
74
75 typedef struct smpi_global_t {
76
77         // config vars
78         double            reference_speed;
79
80         // state vars
81         int               root_ready:1;
82         int               ready_process_count;
83         smx_mutex_t       start_stop_mutex;
84         smx_cond_t        start_stop_cond;
85
86         smx_host_t       *hosts;
87         int               host_count;
88         xbt_mallocator_t  request_mallocator;
89         xbt_mallocator_t  message_mallocator;
90
91         xbt_fifo_t       *pending_send_request_queues;
92         smx_mutex_t      *pending_send_request_queues_mutexes;
93
94         xbt_fifo_t       *pending_recv_request_queues;
95         smx_mutex_t      *pending_recv_request_queues_mutexes;
96
97         xbt_fifo_t       *received_message_queues;
98         smx_mutex_t      *received_message_queues_mutexes;
99
100         smx_process_t    *sender_processes;
101         smx_process_t    *receiver_processes;
102
103         int               running_hosts_count;
104         smx_mutex_t       running_hosts_count_mutex;
105
106         // FIXME: maybe all code needs to lock timer?
107         xbt_os_timer_t    timer;
108         smx_mutex_t       timer_mutex;
109         smx_cond_t        timer_cond;
110
111         // keeps track of previous times
112         double            times[SMPI_MAX_TIMES];
113         int               times_max;
114         smx_mutex_t       times_mutex;
115
116         smx_mutex_t       execute_mutex;
117         smx_cond_t        execute_cond;
118
119 } s_smpi_global_t;
120 typedef struct smpi_global_t *smpi_global_t;
121 extern smpi_global_t smpi_global;
122
123 typedef struct smpi_host_data_t {
124         int index;
125 } s_smpi_host_data_t;
126 typedef struct smpi_host_data_t *smpi_host_data_t;
127
128 // function prototypes
129 void smpi_mpi_init(void);
130 void smpi_mpi_finalize(void);
131 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
132
133 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
134 int smpi_mpi_isend(smpi_mpi_request_t request);
135 int smpi_mpi_irecv(smpi_mpi_request_t request);
136 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
137
138 void smpi_execute(double duration);
139 void smpi_bench_begin(void);
140 double smpi_bench_end(void);
141 void smpi_bench_skip(void);
142
143 void smpi_global_init(void);
144 void smpi_global_destroy(void);
145 int smpi_host_index(void);
146 int smpi_run_simulation(int *argc, char **argv);
147 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
148         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
149
150 int smpi_sender(int argc, char **argv);
151
152 int smpi_receiver(int argc, char **argv);
153
154 #endif