Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
413d6d1c5557dee81fbfe768aef15e32f566ed8b
[simgrid.git] / src / smpi / private.h
1 #ifndef SMPI_PRIVATE_H
2 #define SMPI_PRIVATE_H
3
4 #include "simix/simix.h"
5 #include "xbt/mallocator.h"
6 #include "xbt/xbt_os_time.h"
7 #include "smpi/smpi.h"
8
9 #define SMPI_DEFAULT_SPEED 100
10 #define SMPI_REQUEST_MALLOCATOR_SIZE 100
11 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100
12
13 typedef struct smpi_mpi_communicator_simdata {
14         smx_host_t    *hosts;
15         smx_process_t *processes;
16         int            barrier_count;
17         smx_mutex_t    barrier_mutex;
18         smx_cond_t     barrier_cond;
19 } s_smpi_mpi_communicator_simdata_t;
20
21 typedef struct smpi_mpi_request_simdata {
22         smx_mutex_t mutex;
23         smx_cond_t  cond;
24 } s_smpi_mpi_request_simdata_t;
25
26 typedef struct SMPI_Global {
27
28         // config vars
29         double            reference_speed;
30
31         // state vars
32         int               root_ready:1;
33         int               ready_process_count;
34         smx_mutex_t       start_stop_mutex;
35         smx_cond_t        start_stop_cond;
36
37         xbt_mallocator_t  request_mallocator;
38         xbt_mallocator_t  message_mallocator;
39
40         xbt_fifo_t       *pending_send_request_queues;
41         smx_mutex_t      *pending_send_request_queues_mutexes;
42
43         xbt_fifo_t       *pending_recv_request_queues;
44         smx_mutex_t      *pending_recv_request_queues_mutexes;
45
46         xbt_fifo_t       *received_message_queues;
47         smx_mutex_t      *received_message_queues_mutexes;
48
49         smx_process_t    *sender_processes;
50         smx_process_t    *receiver_processes;
51
52         int               running_hosts_count;
53         smx_mutex_t       running_hosts_count_mutex;
54
55         xbt_os_timer_t   *timers;
56         smx_mutex_t      *timers_mutexes;
57
58 } s_SMPI_Global_t, *SMPI_Global_t;
59 extern SMPI_Global_t smpi_global;
60
61 struct smpi_received_message_t {
62         smpi_mpi_communicator_t *comm;
63         int src;
64         int dst;
65         int tag;
66         void *buf;
67 };
68 typedef struct smpi_received_message_t smpi_received_message_t;
69
70 // function prototypes
71 int smpi_mpi_comm_size(smpi_mpi_communicator_t *comm);
72 int smpi_mpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
73 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t *comm);
74 int smpi_mpi_comm_world_rank_self(void);
75 int smpi_sender(int argc, char **argv);
76 int smpi_receiver(int argc, char **argv);
77 void *smpi_request_new(void);
78 void smpi_request_free(void *pointer);
79 void smpi_request_reset(void *pointer);
80 void *smpi_message_new(void);
81 void smpi_message_free(void *pointer);
82 void smpi_message_reset(void *pointer);
83 void smpi_global_init(void);
84 void smpi_global_destroy(void);
85 int smpi_run_simulation(int argc, char **argv);
86 void smpi_mpi_land_func(void *x, void *y, void *z);
87 void smpi_mpi_sum_func(void *x, void *y, void *z);
88 void smpi_mpi_init(void);
89 void smpi_mpi_finalize(void);
90 void smpi_bench_begin(void);
91 void smpi_bench_end(void);
92 void smpi_barrier(smpi_mpi_communicator_t *comm);
93 int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host);
94 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype,
95         int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request);
96 int smpi_isend(smpi_mpi_request_t *request);
97 int smpi_irecv(smpi_mpi_request_t *request);
98 void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status);
99
100 #endif