Logo AND Algorithmique Numérique Distribuée

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