Logo AND Algorithmique Numérique Distribuée

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