Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of simdag tracing. was superficial anyway
[simgrid.git] / include / simgrid / simdag.h
1 /* Copyright (c) 2006-2010, 2012-2015. 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 SIMDAG_SIMDAG_H
8 #define SIMDAG_SIMDAG_H
9
10 #include "xbt/misc.h"
11 #include "xbt/dynar.h"
12 #include "xbt/dict.h"
13
14 #include "simgrid/link.h"
15
16 SG_BEGIN_DECL()
17 /** @brief Workstation datatype
18     @ingroup SD_datatypes_management
19
20     A workstation is a place where a task can be executed.
21     A workstation is represented as a <em>physical
22     resource with computing capabilities</em> and has a <em>name</em>.
23
24     @see SD_workstation_management */
25 typedef sg_host_t SD_workstation_t;
26
27 /** @brief Link datatype
28     @ingroup SD_datatypes_management
29
30     A link is a network node represented as a <em>name</em>, a <em>current
31     bandwidth</em> and a <em>current latency</em>. A route is a list of
32     links between two workstations.
33
34     @see SD_link_management */
35 typedef Link *SD_link_t;
36
37 /** @brief Task datatype
38     @ingroup SD_datatypes_management
39
40     A task is some <em>computing amount</em> that can be executed
41     in parallel on several workstations. A task may depend on other
42     tasks, this means that the task cannot start until the other tasks are done.
43     Each task has a <em>\ref e_SD_task_state_t "state"</em> indicating whether
44     the task is scheduled, running, done, etc.
45
46     @see SD_task_management */
47 typedef struct SD_task *SD_task_t;
48
49 /** @brief Task states
50     @ingroup SD_datatypes_management
51
52     @see SD_task_management */
53 typedef enum {
54   SD_NOT_SCHEDULED = 0,      /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
55   SD_SCHEDULABLE = 0x0001,   /**< @brief A task becomes SD_SCHEDULABLE as soon as its dependencies are satisfied */
56   SD_SCHEDULED = 0x0002,     /**< @brief A task becomes SD_SCHEDULED when you call function
57                                   SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
58   SD_RUNNABLE = 0x0004,      /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
59   SD_RUNNING = 0x0008,       /**< @brief An SD_RUNNABLE task becomes SD_RUNNING when it is launched. */
60   SD_DONE = 0x0010,          /**< @brief The task is successfully finished. */
61   SD_FAILED = 0x0020         /**< @brief A problem occurred during the execution of the task. */
62 } e_SD_task_state_t;
63
64 /** @brief Task kinds
65     @ingroup SD_datatypes_management
66
67     @see SD_task_management */
68 typedef enum {
69   SD_TASK_NOT_TYPED = 0,      /**< @brief no specified type */
70   SD_TASK_COMM_E2E = 1,       /**< @brief end to end communication */
71   SD_TASK_COMP_SEQ = 2,        /**< @brief sequential computation */
72   SD_TASK_COMP_PAR_AMDAHL = 3, /**< @brief parallel computation (Amdahl's law) */
73   SD_TASK_COMM_PAR_MXN_1D_BLOCK = 4 /**< @brief MxN data redistribution (1D Block distribution) */
74 } e_SD_task_kind_t;
75
76
77 /** @brief Storage datatype
78     @ingroup SD_datatypes_management
79
80  TODO PV: comment it !
81
82     @see SD_storage_management */
83 typedef xbt_dictelm_t SD_storage_t;
84
85 /************************** Workstation handling ****************************/
86
87 /** @defgroup SD_workstation_management Workstations
88  *  @brief Functions for managing the workstations
89  *
90  *  This section describes the functions for managing the workstations.
91  *
92  *  A workstation is a place where a task can be executed.
93  *  A workstation is represented as a <em>physical
94  *  resource with computing capabilities</em> and has a <em>name</em>.
95  *
96  *  The workstations are created when you call the function SD_create_environment.
97  *
98  *  @see SD_workstation_t
99  *  @{
100  */
101 XBT_PUBLIC(SD_workstation_t) SD_workstation_get_by_name(const char *name);
102 XBT_PUBLIC(const SD_workstation_t *) SD_workstation_get_list(void);
103 XBT_PUBLIC(int) SD_workstation_get_count(void);
104 XBT_PUBLIC(void) SD_workstation_set_data(SD_workstation_t workstation,
105                                          void *data);
106 XBT_PUBLIC(void *) SD_workstation_get_data(SD_workstation_t workstation);
107 XBT_PUBLIC(const char *) SD_workstation_get_name(SD_workstation_t
108                                                  workstation);
109 /*property handling functions*/
110 XBT_PUBLIC(xbt_dict_t) SD_workstation_get_properties(SD_workstation_t
111                                                      workstation);
112 XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
113                                                            workstation,
114                                                            const char
115                                                            *name);
116 XBT_PUBLIC(void) SD_workstation_dump(SD_workstation_t ws);
117 XBT_PUBLIC(const SD_link_t *) SD_route_get_list(SD_workstation_t src,
118                                                 SD_workstation_t dst);
119 XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src,
120                                   SD_workstation_t dst);
121 XBT_PUBLIC(double) SD_workstation_get_speed(SD_workstation_t workstation);
122 XBT_PUBLIC(double) SD_workstation_get_available_speed(SD_workstation_t
123                                                       workstation);
124 XBT_PUBLIC(int) SD_workstation_get_cores(SD_workstation_t workstation);
125
126 XBT_PUBLIC(double) SD_workstation_get_computation_time(SD_workstation_t workstation,
127                                                        double flops_amount);
128 XBT_PUBLIC(double) SD_route_get_latency(SD_workstation_t src,
129                                                 SD_workstation_t dst);
130 XBT_PUBLIC(double) SD_route_get_bandwidth(SD_workstation_t src,
131                                                   SD_workstation_t dst);
132 XBT_PUBLIC(double) SD_route_get_communication_time(SD_workstation_t src,
133                                                    SD_workstation_t dst,
134                                                    double bytes_amount);
135
136 XBT_PUBLIC(xbt_dict_t)
137     SD_workstation_get_mounted_storage_list(SD_workstation_t workstation);
138 XBT_PUBLIC(xbt_dynar_t)
139     SD_workstation_get_attached_storage_list(SD_workstation_t workstation);
140 XBT_PUBLIC(const char*) SD_storage_get_host(SD_storage_t storage);
141 /** @} */
142
143 /************************** Task handling ************************************/
144
145 /** @defgroup SD_task_management Tasks
146  *  @brief Functions for managing the tasks
147  *
148  *  This section describes the functions for managing the tasks.
149  *
150  *  A task is some <em>working amount</em> that can be executed
151  *  in parallel on several workstations. A task may depend on other
152  *  tasks, this means that the task cannot start until the other tasks are done.
153  *  Each task has a <em>\ref e_SD_task_state_t "state"</em> indicating whether
154  *  the task is scheduled, running, done, etc.
155  *
156  *  @see SD_task_t, SD_task_dependency_management
157  *  @{
158  */
159 XBT_PUBLIC(SD_task_t) SD_task_create(const char *name, void *data,
160                                      double amount);
161 XBT_PUBLIC(void *) SD_task_get_data(SD_task_t task);
162 XBT_PUBLIC(void) SD_task_set_data(SD_task_t task, void *data);
163 XBT_PUBLIC(e_SD_task_state_t) SD_task_get_state(SD_task_t task);
164 XBT_PUBLIC(const char *) SD_task_get_name(SD_task_t task);
165 XBT_PUBLIC(void) SD_task_set_name(SD_task_t task, const char *name);
166 XBT_PUBLIC(void) SD_task_set_rate(SD_task_t task, double rate);
167
168 XBT_PUBLIC(void) SD_task_watch(SD_task_t task, e_SD_task_state_t state);
169 XBT_PUBLIC(void) SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
170 XBT_PUBLIC(double) SD_task_get_amount(SD_task_t task);
171 XBT_PUBLIC(void) SD_task_set_amount(SD_task_t task, double amount);
172 XBT_PUBLIC(double) SD_task_get_alpha(SD_task_t task);
173 XBT_PUBLIC(double) SD_task_get_remaining_amount(SD_task_t task);
174 XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
175                                               int workstation_nb,
176                                               const SD_workstation_t *
177                                               workstation_list,
178                                               const double *flops_amount,
179                                               const double *bytes_amount);
180 XBT_PUBLIC(e_SD_task_kind_t) SD_task_get_kind(SD_task_t task);
181 XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
182                                   const SD_workstation_t *
183                                   workstation_list,
184                                   const double *flops_amount,
185                                   const double *bytes_amount,
186                                   double rate);
187 XBT_PUBLIC(void) SD_task_unschedule(SD_task_t task);
188 XBT_PUBLIC(double) SD_task_get_start_time(SD_task_t task);
189 XBT_PUBLIC(double) SD_task_get_finish_time(SD_task_t task);
190 XBT_PUBLIC(xbt_dynar_t) SD_task_get_parents(SD_task_t task);
191 XBT_PUBLIC(xbt_dynar_t) SD_task_get_children(SD_task_t task);
192 XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task);
193 XBT_PUBLIC(SD_workstation_t *) SD_task_get_workstation_list(SD_task_t
194                                                             task);
195 XBT_PUBLIC(void) SD_task_destroy(SD_task_t task);
196 XBT_PUBLIC(void) SD_task_dump(SD_task_t task);
197 XBT_PUBLIC(void) SD_task_dotty(SD_task_t task, void *out_FILE);
198
199 XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char *name, void *data,
200                                               double amount);
201 XBT_PUBLIC(SD_task_t) SD_task_create_comp_par_amdahl(const char *name,
202                                                      void *data,
203                                                      double amount,
204                                                      double alpha);
205 XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char *name, void *data,
206                                               double amount);
207 XBT_PUBLIC(SD_task_t) SD_task_create_comm_par_mxn_1d_block(const char *name,
208                                                            void *data,
209                                                            double amount);
210
211 XBT_PUBLIC(void) SD_task_distribute_comp_amdahl(SD_task_t task, int ws_count);
212 XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count,
213                                    const SD_workstation_t * list);
214 XBT_PUBLIC(void) SD_task_schedulel(SD_task_t task, int count, ...);
215
216
217 /** @brief A constant to use in SD_task_schedule to mean that there is no cost.
218  *
219  *  For example, create a pure computation task (no comm) like this:
220  *
221  *  SD_task_schedule(task, my_workstation_nb,
222  *                   my_workstation_list,
223  *                   my_flops_amount,
224  *                   SD_TASK_SCHED_NO_COST,
225  *                   my_rate);
226  */
227 #define SD_SCHED_NO_COST NULL
228
229 /** @} */
230
231
232 /** @defgroup SD_task_dependency_management Tasks dependencies
233  *  @brief Functions for managing the task dependencies
234  *
235  *  This section describes the functions for managing the dependencies between the tasks.
236  *
237  *  @see SD_task_management
238  *  @{
239  */
240 XBT_PUBLIC(void) SD_task_dependency_add(const char *name, void *data,
241                                         SD_task_t src, SD_task_t dst);
242 XBT_PUBLIC(void) SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
243 XBT_PUBLIC(const char *) SD_task_dependency_get_name(SD_task_t src,
244                                                      SD_task_t dst);
245 XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src,
246                                                SD_task_t dst);
247 XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
248 /** @} */
249
250 /************************** Global *******************************************/
251
252 /** @defgroup SD_simulation Simulation
253  *  @brief Functions for creating the environment and launching the simulation
254  *
255  *  This section describes the functions for initializing SimDag, launching
256  *  the simulation and exiting SimDag.
257  *
258  *  @{
259  */
260 XBT_PUBLIC(void) SD_init(int *argc, char **argv);
261 XBT_PUBLIC(void) SD_config(const char *key, const char *value);
262 XBT_PUBLIC(void) SD_application_reinit(void);
263 XBT_PUBLIC(void) SD_create_environment(const char *platform_file);
264 XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
265 XBT_PUBLIC(double) SD_get_clock(void);
266 XBT_PUBLIC(void) SD_exit(void);
267 XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename);
268 XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename);
269 XBT_PUBLIC(xbt_dynar_t) SD_PTG_dotload(const char *filename);
270 XBT_PUBLIC(xbt_dynar_t) SD_dotload_with_sched(const char *filename);
271
272 /** @} */
273
274 SG_END_DECL()
275
276 #include "simgrid/instr.h"
277
278 #endif