Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First complete implementation of a new MSG call (starting from MSG down
[simgrid.git] / include / msg / datatypes.h
1 /* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef MSG_DATATYPE_H
7 #define MSG_DATATYPE_H
8 #include "xbt/misc.h"
9 #include "xbt/file_stat.h"
10 #include "xbt/lib.h"
11 #include "simgrid/simix.h"
12 #include "simgrid_config.h"     // for HAVE_TRACING
13
14 SG_BEGIN_DECL()
15
16 /* ******************************** Mailbox ************************************ */
17
18 /** @brief Mailbox datatype
19  *  @ingroup msg_task_usage
20  *
21  * Object representing a communication rendez-vous point, on which
22  * the sender finds the receiver it wants to communicate with. As a
23  * MSG user, you will only rarely manipulate any of these objects
24  * directly, since most of the public interface (such as
25  * #MSG_task_send and friends) hide this object behind a string
26  * alias. That mean that you don't provide the mailbox on which you
27  * want to send your task, but only the name of this mailbox. */
28 typedef struct s_smx_rvpoint *msg_mailbox_t;
29
30
31 /* ******************************** Host ************************************ */
32
33 extern int MSG_HOST_LEVEL;
34
35 /** @brief Host datatype.
36     @ingroup m_host_management
37
38     A <em>location</em> (or <em>host</em>) is any possible place where
39     a process may run. Thus it is represented as a <em>physical
40     resource with computing capabilities</em>, some <em>mailboxes</em>
41     to enable running process to communicate with remote ones, and
42     some <em>private data</em> that can be only accessed by local
43     process.
44  */
45 typedef xbt_dictelm_t msg_host_t;
46 typedef s_xbt_dictelm_t s_msg_host_t;
47
48 typedef struct msg_host_priv {
49
50         // TODO Warning keeping such vms attribut may lead to some complexity at the SURF Level.
51         // Please check with Arnaud
52         xbt_dynar_t vms;
53 #ifdef MSG_USE_DEPRECATED
54   msg_mailbox_t *mailboxes;     /**< the channels  */
55 #endif
56 } s_msg_host_priv_t, *msg_host_priv_t;
57
58 static inline msg_host_priv_t MSG_host_priv(msg_host_t host){
59   return xbt_lib_get_level(host, MSG_HOST_LEVEL);
60 }
61
62
63
64 /* ******************************** Task ************************************ */
65
66 typedef struct simdata_task *simdata_task_t;
67
68 typedef struct msg_task {
69   char *name;                   /**< @brief task name if any */
70   simdata_task_t simdata;       /**< @brief simulator data */
71   void *data;                   /**< @brief user data */
72 #ifdef HAVE_TRACING
73   long long int counter;        /* task unique identifier for instrumentation */
74   char *category;               /* task category for instrumentation */
75 #endif
76 } s_msg_task_t;
77
78 /** @brief Task datatype.
79     @ingroup m_task_management 
80
81     A <em>task</em> may then be defined by a <em>computing
82     amount</em>, a <em>message size</em> and some <em>private
83     data</em>.
84  */
85 typedef struct msg_task *msg_task_t;
86
87 /* ******************************** Hypervisor ************************************* */
88 typedef struct msg_hypervisor *msg_hypervisor_t;
89
90 typedef struct msg_hypervisor {
91         const char *name;
92         s_xbt_swag_hookup_t all_hypervisor_hookup;
93         xbt_dynar_t vms;   // vms on this hypervisor
94         msg_host_t host;  // physical host of this hypervisor
95
96   /* The hypervisor object does not have parameters like the number of CPU
97  Ê * cores and the size of memory. These parameters come from those of the
98  Ê * physical host.
99  Ê **/
100         int overcommit;
101
102 } s_msg_hypervisor_t;
103
104 /* ********************************  VM ************************************* */
105 typedef msg_host_t msg_vm_t;
106
107 /* todo: make it clear */
108 typedef enum {
109 msg_vm_state_created,
110 msg_vm_state_booting,
111 msg_vm_state_running,
112 msg_vm_state_sleeping,
113 msg_vm_state_migrating,
114 msg_vm_state_resuming,
115 msg_vm_state_suspending,
116 msg_vm_state_saving,
117 msg_vm_state_restoring,
118 } e_msg_vm_state_t;
119
120
121
122 /* ******************************** File ************************************ */
123 typedef struct simdata_file *simdata_file_t;
124
125 typedef struct msg_file {
126   char *name;                   /**< @brief file name */
127   simdata_file_t simdata;                /**< @brief simulator data  */
128   void *data;                   /**< @brief user data */
129 } s_msg_file_t;
130
131 /** @brief File datatype.
132     @ingroup msg_file_management 
133  
134     You should consider this as an opaque object.
135  */
136 typedef struct msg_file *msg_file_t;
137
138
139 /** @brief File datatype.
140     @ingroup msg_file_management
141
142     You should consider this as an opaque object.
143  */
144 typedef s_file_stat_t s_msg_stat_t, *msg_stat_t;
145
146
147 /*************** Begin GPU ***************/
148 typedef struct simdata_gpu_task *simdata_gpu_task_t;
149
150 typedef struct msg_gpu_task {
151   char *name;                   /**< @brief task name if any */
152   simdata_gpu_task_t simdata;       /**< @brief simulator data */
153 #ifdef HAVE_TRACING
154   long long int counter;        /* task unique identifier for instrumentation */
155   char *category;               /* task category for instrumentation */
156 #endif
157 } s_msg_gpu_task_t;
158
159 /** @brief GPU task datatype.
160     @ingroup m_task_management
161
162     A <em>task</em> may then be defined by a <em>computing
163     amount</em>, a <em>dispatch latency</em> and a <em>collect latency</em>.
164     \see m_task_management
165 */
166 typedef struct msg_gpu_task *msg_gpu_task_t;
167 /*************** End GPU ***************/
168
169 /**
170  * \brief @brief Communication action.
171  * \ingroup msg_task_usage
172  *
173  * Object representing an ongoing communication between processes. Such beast is usually obtained by using #MSG_task_isend, #MSG_task_irecv or friends.
174  */
175 typedef struct msg_comm *msg_comm_t;
176
177 /** \brief Default value for an uninitialized #msg_task_t.
178     \ingroup m_task_management 
179 */
180 #define MSG_TASK_UNINITIALIZED NULL
181
182 /* ****************************** Process *********************************** */
183
184 /** @brief Process datatype.
185     @ingroup m_process_management
186
187     A process may be defined as a <em>code</em>, with some
188     <em>private data</em>, executing in a <em>location</em>. 
189  
190     You should not access directly to the fields of the pointed
191     structure, but always use the provided API to interact with
192     processes.
193  */
194 typedef struct s_smx_process *msg_process_t;
195
196 #ifdef MSG_USE_DEPRECATED
197
198 /* Compatibility typedefs */
199 typedef int                     m_channel_t;
200 typedef msg_gpu_task_t          m_gpu_task_t;
201 typedef msg_host_t              m_host_t;
202 typedef msg_process_t           m_process_t;
203 typedef msg_task_t              m_task_t;
204 typedef s_msg_gpu_task_t        s_m_gpu_task_t;
205 typedef s_msg_host_t            s_m_host_t;
206 typedef s_msg_task_t            s_m_task_t;
207 #endif
208
209 SG_END_DECL()
210 #endif