Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
renamed some functions and moved some data structures to make things more
[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         smx_host_t    *hosts;
19         smx_process_t *processes;
20         int            barrier_count;
21         smx_mutex_t    barrier_mutex;
22         smx_cond_t     barrier_cond;
23 } s_smpi_mpi_communicator_t;
24
25 // smpi mpi datatype
26 typedef struct smpi_mpi_datatype_t {
27   size_t size;
28 } s_smpi_mpi_datatype_t;
29
30 // smpi mpi request
31 typedef struct smpi_mpi_request_t {
32         smpi_mpi_communicator_t comm;
33         int src;
34         int dst;
35         int tag;
36
37         void *buf;
38         smpi_mpi_datatype_t datatype;
39         int count;
40
41         short int completed :1;
42
43         smx_mutex_t mutex;
44         smx_cond_t  cond;
45 } s_smpi_mpi_request_t;
46
47 // smpi mpi op
48 typedef struct smpi_mpi_op_t {
49   void (*func)(void *x, void *y, void *z);
50 } s_smpi_mpi_op_t;
51
52 // smpi received message
53 typedef struct smpi_received_message_t {
54         smpi_mpi_communicator_t comm;
55         int src;
56         int dst;
57         int tag;
58         void *buf;
59 } s_smpi_received_message_t;
60 typedef struct smpi_received_message_t *smpi_received_message_t;
61
62 typedef struct smpi_global_t {
63
64         // config vars
65         double            reference_speed;
66
67         // state vars
68         int               root_ready:1;
69         int               ready_process_count;
70         smx_mutex_t       start_stop_mutex;
71         smx_cond_t        start_stop_cond;
72
73         xbt_mallocator_t  request_mallocator;
74         xbt_mallocator_t  message_mallocator;
75
76         xbt_fifo_t       *pending_send_request_queues;
77         smx_mutex_t      *pending_send_request_queues_mutexes;
78
79         xbt_fifo_t       *pending_recv_request_queues;
80         smx_mutex_t      *pending_recv_request_queues_mutexes;
81
82         xbt_fifo_t       *received_message_queues;
83         smx_mutex_t      *received_message_queues_mutexes;
84
85         smx_process_t    *sender_processes;
86         smx_process_t    *receiver_processes;
87
88         int               running_hosts_count;
89         smx_mutex_t       running_hosts_count_mutex;
90
91         xbt_os_timer_t   *timers;
92         smx_mutex_t      *timers_mutexes;
93
94 } s_smpi_global_t;
95 typedef struct smpi_global_t *smpi_global_t;
96 extern smpi_global_t smpi_global;
97
98 // function prototypes
99 void smpi_mpi_init(void);
100 void smpi_mpi_finalize(void);
101 int smpi_mpi_comm_size(smpi_mpi_communicator_t comm);
102 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm, smx_host_t host);
103 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t comm);
104 int smpi_mpi_comm_world_rank_self(void);
105 int smpi_mpi_barrier(smpi_mpi_communicator_t comm);
106 int smpi_mpi_isend(smpi_mpi_request_t request);
107 int smpi_mpi_irecv(smpi_mpi_request_t request);
108 int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
109
110 void smpi_bench_begin(void);
111 void smpi_bench_end(void);
112
113 void smpi_global_init(void);
114 void smpi_global_destroy(void);
115 int smpi_run_simulation(int argc, char **argv);
116 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
117         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
118
119 int smpi_sender(int argc, char **argv);
120
121 int smpi_receiver(int argc, char **argv);
122
123 #endif