Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
requests were not being makred uncompleted before being recycled by mallocator.
[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 typedef struct smpi_mpi_communicator_t {
16         int            size;
17         smx_host_t    *hosts;
18         smx_process_t *processes;
19         int            barrier_count;
20         smx_mutex_t    barrier_mutex;
21         smx_cond_t     barrier_cond;
22 } s_smpi_mpi_communicator_t;
23
24 typedef struct smpi_mpi_request_t {
25         smpi_mpi_communicator_t comm;
26         int src;
27         int dst;
28         int tag;
29
30         void *buf;
31         smpi_mpi_datatype_t datatype;
32         int count;
33
34         short int completed :1;
35
36         smx_mutex_t mutex;
37         smx_cond_t  cond;
38 } s_smpi_mpi_request_t;
39
40 typedef struct SMPI_Global {
41
42         // config vars
43         double            reference_speed;
44
45         // state vars
46         int               root_ready:1;
47         int               ready_process_count;
48         smx_mutex_t       start_stop_mutex;
49         smx_cond_t        start_stop_cond;
50
51         xbt_mallocator_t  request_mallocator;
52         xbt_mallocator_t  message_mallocator;
53
54         xbt_fifo_t       *pending_send_request_queues;
55         smx_mutex_t      *pending_send_request_queues_mutexes;
56
57         xbt_fifo_t       *pending_recv_request_queues;
58         smx_mutex_t      *pending_recv_request_queues_mutexes;
59
60         xbt_fifo_t       *received_message_queues;
61         smx_mutex_t      *received_message_queues_mutexes;
62
63         smx_process_t    *sender_processes;
64         smx_process_t    *receiver_processes;
65
66         int               running_hosts_count;
67         smx_mutex_t       running_hosts_count_mutex;
68
69         xbt_os_timer_t   *timers;
70         smx_mutex_t      *timers_mutexes;
71
72 } s_SMPI_Global_t, *SMPI_Global_t;
73 extern SMPI_Global_t smpi_global;
74
75 typedef struct smpi_received_message_t {
76         smpi_mpi_communicator_t comm;
77         int src;
78         int dst;
79         int tag;
80         void *buf;
81 } s_smpi_received_message_t;
82 typedef struct smpi_received_message_t *smpi_received_message_t;
83
84 // function prototypes
85 int smpi_mpi_comm_size(smpi_mpi_communicator_t comm);
86 int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm, smx_host_t host);
87 int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t comm);
88 int smpi_mpi_comm_world_rank_self(void);
89 int smpi_sender(int argc, char **argv);
90 int smpi_receiver(int argc, char **argv);
91 void *smpi_request_new(void);
92 void smpi_request_free(void *pointer);
93 void smpi_request_reset(void *pointer);
94 void *smpi_message_new(void);
95 void smpi_message_free(void *pointer);
96 void smpi_message_reset(void *pointer);
97 void smpi_global_init(void);
98 void smpi_global_destroy(void);
99 int smpi_run_simulation(int argc, char **argv);
100 void smpi_mpi_land_func(void *x, void *y, void *z);
101 void smpi_mpi_sum_func(void *x, void *y, void *z);
102 void smpi_mpi_init(void);
103 void smpi_mpi_finalize(void);
104 void smpi_bench_begin(void);
105 void smpi_bench_end(void);
106 void smpi_barrier(smpi_mpi_communicator_t comm);
107 int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype,
108         int src, int dst, int tag, smpi_mpi_communicator_t comm, smpi_mpi_request_t *request);
109 int smpi_isend(smpi_mpi_request_t request);
110 int smpi_irecv(smpi_mpi_request_t request);
111 int smpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t *status);
112
113 #endif