Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaned up action code to destroy completed actions. This fixes a timing bug.
[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         xbt_os_timer_t    timer;
107         smx_mutex_t       timer_mutex;
108         smx_cond_t        timer_cond;
109         double            times[SMPI_MAX_TIMES];
110         int               times_max;
111         smx_mutex_t       times_mutex;
112
113 } s_smpi_global_t;
114 typedef struct smpi_global_t *smpi_global_t;
115 extern smpi_global_t smpi_global;
116
117 typedef struct smpi_host_data_t {
118         int index;
119 } s_smpi_host_data_t;
120 typedef struct smpi_host_data_t *smpi_host_data_t;
121
122 // function prototypes
123 void smpi_mpi_init(void);
124 void smpi_mpi_finalize(void);
125 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm);
126
127 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
128 int smpi_mpi_isend(smpi_mpi_request_t request);
129 int smpi_mpi_irecv(smpi_mpi_request_t request);
130 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
131
132 void smpi_bench_begin(void);
133 double smpi_bench_end(void);
134 void smpi_bench_skip(void);
135
136 void smpi_global_init(void);
137 void smpi_global_destroy(void);
138 int smpi_host_index(void);
139 int smpi_run_simulation(int *argc, char **argv);
140 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
141         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
142
143 int smpi_sender(int argc, char **argv);
144
145 int smpi_receiver(int argc, char **argv);
146
147 #endif