Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
804ea9ef2a1d556e3e7ec9023b742ac9909a2bab
[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 } s_smpi_mpi_request_t;
48
49 // smpi mpi op
50 // FIXME: type should be (void *a, void *b, int *length, MPI_Datatype *datatype)
51 //, oper is b[i] = a[i] op b[i]
52 typedef struct smpi_mpi_op_t {
53   void (*func)(void *x, void *y, void *z);
54 } s_smpi_mpi_op_t;
55
56 // smpi received message
57 typedef struct smpi_received_message_t {
58         smpi_mpi_communicator_t comm;
59         int src;
60         int tag;
61
62         void *buf;
63 } s_smpi_received_message_t;
64 typedef struct smpi_received_message_t *smpi_received_message_t;
65
66 typedef struct smpi_global_t {
67
68         // config vars
69         double            reference_speed;
70
71         // state vars
72         int               root_ready:1;
73         int               ready_process_count;
74         smx_mutex_t       start_stop_mutex;
75         smx_cond_t        start_stop_cond;
76
77         smx_host_t       *hosts;
78         int               host_count;
79         xbt_mallocator_t  request_mallocator;
80         xbt_mallocator_t  message_mallocator;
81
82         xbt_fifo_t       *pending_send_request_queues;
83         smx_mutex_t      *pending_send_request_queues_mutexes;
84
85         xbt_fifo_t       *pending_recv_request_queues;
86         smx_mutex_t      *pending_recv_request_queues_mutexes;
87
88         xbt_fifo_t       *received_message_queues;
89         smx_mutex_t      *received_message_queues_mutexes;
90
91         smx_process_t    *sender_processes;
92         smx_process_t    *receiver_processes;
93
94         int               running_hosts_count;
95         smx_mutex_t       running_hosts_count_mutex;
96
97         xbt_os_timer_t   *timers;
98         smx_mutex_t      *timers_mutexes;
99
100 } s_smpi_global_t;
101 typedef struct smpi_global_t *smpi_global_t;
102 extern smpi_global_t smpi_global;
103
104 // function prototypes
105 void smpi_mpi_init(void);
106 void smpi_mpi_finalize(void);
107 int smpi_mpi_comm_size(smpi_mpi_communicator_t comm, int *size);
108 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm, int *rank);
109 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
110 int smpi_mpi_isend(smpi_mpi_request_t request);
111 int smpi_mpi_irecv(smpi_mpi_request_t request);
112 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
113
114 void smpi_bench_begin(void);
115 void smpi_bench_end(void);
116
117 void smpi_global_init(void);
118 void smpi_global_destroy(void);
119 int smpi_host_index(void);
120 int smpi_run_simulation(int argc, char **argv);
121 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
122         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
123
124 int smpi_sender(int argc, char **argv);
125
126 int smpi_receiver(int argc, char **argv);
127
128 #endif