Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
On windows, try_compile may use another compiler than the one we want.
[simgrid.git] / src / msg / msg_private.h
1 /* Copyright (c) 2004-2013. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef METASIMGRID_PRIVATE_H
8 #define METASIMGRID_PRIVATE_H
9
10 #include "msg/msg.h"
11 #include "simgrid/simix.h"
12 #include "surf/surf.h"
13 #include "xbt/fifo.h"
14 #include "xbt/dynar.h"
15 #include "xbt/swag.h"
16 #include "xbt/dict.h"
17 #include "xbt/config.h"
18 #include "instr/instr_private.h"
19 SG_BEGIN_DECL()
20
21 /**************** datatypes **********************************/
22
23 /********************************* Task **************************************/
24
25 typedef struct simdata_task {
26   smx_action_t compute;         /* SIMIX modeling of computation */
27   smx_action_t comm;            /* SIMIX modeling of communication */
28   double message_size;          /* Data size */
29   double computation_amount;    /* Computation size */
30   msg_process_t sender;
31   msg_process_t receiver;
32   msg_host_t source;
33   double priority;
34   double rate;
35   int isused;  /* Indicates whether the task is used in SIMIX currently */
36   int host_nb;                  /* ==0 if sequential task; parallel task if not */
37   /*******  Parallel Tasks Only !!!! *******/
38   smx_host_t *host_list;
39   double *comp_amount;
40   double *comm_amount;
41 } s_simdata_task_t;
42
43 /********************************* File **************************************/
44 typedef struct simdata_file {
45   smx_file_t smx_file;
46 } s_simdata_file_t;
47
48 /********************************* Storage **************************************/
49 typedef struct simdata_storage {
50   smx_storage_t smx_storage;
51 } s_simdata_storage_t;
52
53 /*************** Begin GPU ***************/
54 typedef struct simdata_gpu_task {
55   double computation_amount;    /* Computation size */
56   double dispatch_latency;
57   double collect_latency;
58   int isused;  /* Indicates whether the task is used in SIMIX currently */
59 } s_simdata_gpu_task_t;
60 /*************** End GPU ***************/
61
62 /******************************* Process *************************************/
63
64 typedef struct simdata_process {
65   msg_host_t m_host;              /* the host on which the process is running */
66   msg_host_t put_host;            /* used for debugging purposes */
67 #ifdef MSG_USE_DEPRECATED
68   m_channel_t put_channel;      /* used for debugging purposes */
69 #endif
70   smx_action_t waiting_action;
71   msg_task_t waiting_task;
72   char **argv;                  /* arguments table if any */
73   int argc;                     /* arguments number if any */
74   msg_error_t last_errno;       /* the last value returned by a MSG_function */
75
76   msg_vm_t vm;                 /* virtual machine the process is in */
77
78   void* data;                   /* user data */
79 } s_simdata_process_t, *simdata_process_t;
80
81 typedef struct process_arg {
82   const char *name;
83   xbt_main_func_t code;
84   void *data;
85   msg_host_t m_host;
86   int argc;
87   char **argv;
88   double kill_time;
89 } s_process_arg_t, *process_arg_t;
90
91 typedef struct msg_comm {
92   smx_action_t s_comm;          /* SIMIX communication object encapsulated (the same for both processes) */
93   msg_task_t task_sent;           /* task sent (NULL for the receiver) */
94   msg_task_t *task_received;      /* where the task will be received (NULL for the sender) */
95   msg_error_t status;           /* status of the communication once finished */
96 } s_msg_comm_t;
97 /*
98 typedef enum {
99   msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
100 } e_msg_vm_state_t;
101
102 typedef struct msg_vm {
103   const char *name;
104   s_xbt_swag_hookup_t all_vms_hookup;
105   s_xbt_swag_hookup_t host_vms_hookup;
106   xbt_dynar_t processes;
107   e_msg_vm_state_t state;
108   msg_host_t location;
109   int coreAmount;
110 } s_msg_vm_t;
111 */
112 /************************** Global variables ********************************/
113 typedef struct MSG_Global {
114   xbt_fifo_t host;
115 #ifdef MSG_USE_DEPRECATED
116   int max_channel;
117 #endif
118   int session;
119   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
120   void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
121   void_f_pvoid_t process_data_cleanup;
122   xbt_swag_t vms;
123 } s_MSG_Global_t, *MSG_Global_t;
124
125 /*extern MSG_Global_t msg_global;*/
126 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
127
128
129 /*************************************************************/
130
131 #ifdef MSG_USE_DEPRECATED
132 #  define PROCESS_SET_ERRNO(val) \
133   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
134 #  define PROCESS_GET_ERRNO() \
135   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
136 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
137 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
138
139 #else
140 #  define MSG_RETURN(val) return(val)
141 #endif
142
143 msg_host_t __MSG_host_create(smx_host_t workstation);
144 msg_storage_t __MSG_storage_create(smx_storage_t storage);
145 void __MSG_host_destroy(msg_host_priv_t host);
146 void __MSG_storage_destroy(msg_storage_priv_t host);
147
148 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
149 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
150                                    xbt_main_func_t code, void *data,
151                                    const char *hostname, double kill_time,  int argc,
152                                    char **argv, xbt_dict_t properties, int auto_restart);
153 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
154
155 void _MSG_action_init(void);
156 void _MSG_action_exit(void);
157
158 void MSG_post_create_environment(void);
159
160 /********** Tracing **********/
161 /* declaration of instrumentation functions from msg_task_instr.c */
162 void TRACE_msg_set_task_category(msg_task_t task, const char *category);
163 void TRACE_msg_task_create(msg_task_t task);
164 void TRACE_msg_task_execute_start(msg_task_t task);
165 void TRACE_msg_task_execute_end(msg_task_t task);
166 void TRACE_msg_task_destroy(msg_task_t task);
167 void TRACE_msg_task_get_start(void);
168 void TRACE_msg_task_get_end(double start_time, msg_task_t task);
169 int TRACE_msg_task_put_start(msg_task_t task);    //returns TRUE if the task_put_end must be called
170 void TRACE_msg_task_put_end(void);
171
172 /* declaration of instrumentation functions from msg_process_instr.c */
173 char *instr_process_id (msg_process_t proc, char *str, int len);
174 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len);
175 void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host,
176                                    msg_host_t new_host);
177 void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host);
178 void TRACE_msg_process_destroy (const char *process_name, int process_pid, msg_host_t host);
179 void TRACE_msg_process_kill(msg_process_t process);
180 void TRACE_msg_process_suspend(msg_process_t process);
181 void TRACE_msg_process_resume(msg_process_t process);
182 void TRACE_msg_process_sleep_in(msg_process_t process);   //called from msg/gos.c
183 void TRACE_msg_process_sleep_out(msg_process_t process);
184 void TRACE_msg_process_end(msg_process_t process);
185
186 /* declaration of instrumentation functions from instr_msg_vm.c */
187 char *instr_vm_id (msg_vm_t vm, char *str, int len);
188 char *instr_vm_id_2 (const char *vm_name, char *str, int len);
189 void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host,
190                                    msg_host_t new_host);
191 void TRACE_msg_vm_create (const char *vm_name, msg_host_t host);
192 void TRACE_msg_vm_kill(msg_vm_t process);
193 void TRACE_msg_vm_suspend(msg_vm_t vm);
194 void TRACE_msg_vm_resume(msg_vm_t vm);
195 void TRACE_msg_vm_sleep_in(msg_vm_t vm);
196 void TRACE_msg_vm_sleep_out(msg_vm_t vm);
197 void TRACE_msg_vm_end(msg_vm_t vm);
198
199 SG_END_DECL()
200 #endif