Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I'm so glad that this line is useless
[simgrid.git] / src / msg / msg_private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. 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 "xbt/fifo.h"
13 #include "xbt/dynar.h"
14 #include "xbt/swag.h"
15 #include "xbt/dict.h"
16 #include "xbt/config.h"
17 #include "instr/instr_private.h"
18 SG_BEGIN_DECL()
19
20 /**************** datatypes **********************************/
21
22 /********************************* Task **************************************/
23
24 typedef struct simdata_task {
25   smx_action_t compute;         /* SIMIX modeling of computation */
26   smx_action_t comm;            /* SIMIX modeling of communication */
27   double message_size;          /* Data size */
28   double computation_amount;    /* Computation size */
29   msg_process_t sender;
30   msg_process_t receiver;
31   msg_host_t source;
32   double priority;
33   double rate;
34   int isused;  /* Indicates whether the task is used in SIMIX currently */
35   int host_nb;                  /* ==0 if sequential task; parallel task if not */
36   /*******  Parallel Tasks Only !!!! *******/
37   smx_host_t *host_list;
38   double *comp_amount;
39   double *comm_amount;
40 } s_simdata_task_t;
41
42 /********************************* File **************************************/
43 typedef struct simdata_file {
44   smx_file_t smx_file;
45 } s_simdata_file_t;
46
47 /*************** Begin GPU ***************/
48 typedef struct simdata_gpu_task {
49   double computation_amount;    /* Computation size */
50   double dispatch_latency;
51   double collect_latency;
52   int isused;  /* Indicates whether the task is used in SIMIX currently */
53 } s_simdata_gpu_task_t;
54 /*************** End GPU ***************/
55
56 /******************************* Process *************************************/
57
58 typedef struct simdata_process {
59   msg_host_t m_host;              /* the host on which the process is running */
60   int PID;                      /* used for debugging purposes */
61   int PPID;                     /* The parent PID */
62   msg_host_t put_host;            /* used for debugging purposes */
63 #ifdef MSG_USE_DEPRECATED
64   m_channel_t put_channel;      /* used for debugging purposes */
65 #endif
66   smx_action_t waiting_action;
67   msg_task_t waiting_task;
68   char **argv;                  /* arguments table if any */
69   int argc;                     /* arguments number if any */
70   msg_error_t last_errno;       /* the last value returned by a MSG_function */
71
72   msg_vm_t vm;                 /* virtual machine the process is in */
73
74   void* data;                   /* user data */
75 } s_simdata_process_t, *simdata_process_t;
76
77 typedef struct process_arg {
78   const char *name;
79   xbt_main_func_t code;
80   void *data;
81   msg_host_t m_host;
82   int argc;
83   char **argv;
84   double kill_time;
85 } s_process_arg_t, *process_arg_t;
86
87 typedef struct msg_comm {
88   smx_action_t s_comm;          /* SIMIX communication object encapsulated (the same for both processes) */
89   msg_task_t task_sent;           /* task sent (NULL for the receiver) */
90   msg_task_t *task_received;      /* where the task will be received (NULL for the sender) */
91   msg_error_t status;           /* status of the communication once finished */
92 } s_msg_comm_t;
93
94 typedef enum {
95   msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
96 } e_msg_vm_state_t;
97
98 typedef struct msg_vm {
99   s_xbt_swag_hookup_t all_vms_hookup;
100   s_xbt_swag_hookup_t host_vms_hookup;
101   xbt_dynar_t processes;
102   e_msg_vm_state_t state;
103   msg_host_t location;
104   int coreAmount;
105 } s_msg_vm_t;
106
107 /************************** Global variables ********************************/
108 typedef struct MSG_Global {
109   xbt_fifo_t host;
110 #ifdef MSG_USE_DEPRECATED
111   int max_channel;
112 #endif
113   int PID;
114   int session;
115   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
116   void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
117   void_f_pvoid_t process_data_cleanup;
118   xbt_swag_t vms;
119 } s_MSG_Global_t, *MSG_Global_t;
120
121 /*extern MSG_Global_t msg_global;*/
122 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
123
124
125 /*************************************************************/
126
127 #ifdef MSG_USE_DEPRECATED
128 #  define PROCESS_SET_ERRNO(val) \
129   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
130 #  define PROCESS_GET_ERRNO() \
131   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
132 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
133 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
134
135 #else
136 #  define MSG_RETURN(val) return(val)
137 #endif
138
139 msg_host_t __MSG_host_create(smx_host_t workstation);
140 void __MSG_host_destroy(msg_host_t host);
141
142 void __MSG_display_process_status(void);
143
144 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
145 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
146                                    xbt_main_func_t code, void *data,
147                                    const char *hostname, double kill_time,  int argc,
148                                    char **argv, xbt_dict_t properties, int auto_restart);
149 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
150
151 void _MSG_action_init(void);
152 void _MSG_action_exit(void);
153
154 void MSG_post_create_environment(void);
155
156 SG_END_DECL()
157 #endif