Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9afe61d50908ce9c5a8db7542cc2be300e424d4f
[simgrid.git] / include / simdag / simdag.h
1 /* Copyright (c) 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 SIMDAG_SIMDAG_H
8 #define SIMDAG_SIMDAG_H
9
10 #include "simdag/datatypes.h"
11 #include "xbt/misc.h"
12 #include "xbt/dynar.h"
13 #include "xbt/dict.h"
14
15
16 SG_BEGIN_DECL()
17
18 /************************** AS handling *************************************/
19 XBT_PUBLIC(xbt_dict_t) SD_as_router_get_properties(const char *as);
20 XBT_PUBLIC(const char*) SD_as_router_get_property_value(const char * as,
21                                                   const char *name);
22
23 /************************** Link handling ***********************************/
24 /** @defgroup SD_link_management Links
25  *  @brief Functions for managing the network links
26  *
27  *  This section describes the functions for managing the network links.
28  *
29  *  A link is a network node represented as a <em>name</em>, a <em>current
30  *  bandwidth</em> and a <em>current latency</em>. The links are created
31  *  when you call the function SD_create_environment.
32  *
33  *  @see SD_link_t
34  *  @{
35  */
36 XBT_PUBLIC(const SD_link_t *) SD_link_get_list(void);
37 XBT_PUBLIC(int) SD_link_get_number(void);
38 XBT_PUBLIC(void *) SD_link_get_data(SD_link_t link);
39 XBT_PUBLIC(void) SD_link_set_data(SD_link_t link, void *data);
40 XBT_PUBLIC(const char *) SD_link_get_name(SD_link_t link);
41 XBT_PUBLIC(double) SD_link_get_current_bandwidth(SD_link_t link);
42 XBT_PUBLIC(double) SD_link_get_current_latency(SD_link_t link);
43 XBT_PUBLIC(e_SD_link_sharing_policy_t) SD_link_get_sharing_policy(SD_link_t
44                                                                   link);
45 /** @} */
46
47 /************************** Workstation handling ****************************/
48
49 /** @defgroup SD_workstation_management Workstations
50  *  @brief Functions for managing the workstations
51  *
52  *  This section describes the functions for managing the workstations.
53  *
54  *  A workstation is a place where a task can be executed.
55  *  A workstation is represented as a <em>physical
56  *  resource with computing capabilities</em> and has a <em>name</em>.
57  *
58  *  The workstations are created when you call the function SD_create_environment.
59  *
60  *  @see SD_workstation_t
61  *  @{
62  */
63 XBT_PUBLIC(SD_workstation_t) SD_workstation_get_by_name(const char *name);
64 XBT_PUBLIC(const SD_workstation_t *) SD_workstation_get_list(void);
65 XBT_PUBLIC(int) SD_workstation_get_number(void);
66 XBT_PUBLIC(void) SD_workstation_set_data(SD_workstation_t workstation,
67                                          void *data);
68 XBT_PUBLIC(void *) SD_workstation_get_data(SD_workstation_t workstation);
69 XBT_PUBLIC(const char *) SD_workstation_get_name(SD_workstation_t
70                                                  workstation);
71 /*property handling functions*/
72 XBT_PUBLIC(xbt_dict_t) SD_workstation_get_properties(SD_workstation_t
73                                                      workstation);
74 XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
75                                                            workstation,
76                                                            const char
77                                                            *name);
78 XBT_PUBLIC(void) SD_workstation_dump(SD_workstation_t ws);
79 XBT_PUBLIC(const SD_link_t *) SD_route_get_list(SD_workstation_t src,
80                                                 SD_workstation_t dst);
81 XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src,
82                                   SD_workstation_t dst);
83 XBT_PUBLIC(double) SD_workstation_get_power(SD_workstation_t workstation);
84 XBT_PUBLIC(double) SD_workstation_get_available_power(SD_workstation_t
85                                                       workstation);
86 XBT_PUBLIC(e_SD_workstation_access_mode_t)
87     SD_workstation_get_access_mode(SD_workstation_t workstation);
88 XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t
89                                                 workstation,
90                                                 e_SD_workstation_access_mode_t
91                                                 access_mode);
92
93 XBT_PUBLIC(double) SD_workstation_get_computation_time(SD_workstation_t
94                                                        workstation,
95                                                        double
96                                                        computation_amount);
97 XBT_PUBLIC(double) SD_route_get_current_latency(SD_workstation_t src,
98                                                 SD_workstation_t dst);
99 XBT_PUBLIC(double) SD_route_get_current_bandwidth(SD_workstation_t src,
100                                                   SD_workstation_t dst);
101 XBT_PUBLIC(double) SD_route_get_communication_time(SD_workstation_t src,
102                                                    SD_workstation_t dst,
103                                                    double
104                                                    communication_amount);
105
106 XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task(SD_workstation_t
107                                                       workstation);
108 /** @} */
109
110 /************************** Task handling ************************************/
111
112 /** @defgroup SD_task_management Tasks
113  *  @brief Functions for managing the tasks
114  *
115  *  This section describes the functions for managing the tasks.
116  *
117  *  A task is some <em>working amount</em> that can be executed
118  *  in parallel on several workstations. A task may depend on other
119  *  tasks, this means that the task cannot start until the other tasks are done.
120  *  Each task has a <em>\ref e_SD_task_state_t "state"</em> indicating whether
121  *  the task is scheduled, running, done, etc.
122  *
123  *  @see SD_task_t, SD_task_dependency_management
124  *  @{
125  */
126 XBT_PUBLIC(SD_task_t) SD_task_create(const char *name, void *data,
127                                      double amount);
128 XBT_PUBLIC(void *) SD_task_get_data(SD_task_t task);
129 XBT_PUBLIC(void) SD_task_set_data(SD_task_t task, void *data);
130 XBT_PUBLIC(e_SD_task_state_t) SD_task_get_state(SD_task_t task);
131 XBT_PUBLIC(const char *) SD_task_get_name(SD_task_t task);
132 XBT_PUBLIC(void) SD_task_set_name(SD_task_t task, const char *name);
133 XBT_PUBLIC(void) SD_task_set_rate(SD_task_t task, double rate);
134
135 XBT_PUBLIC(void) SD_task_watch(SD_task_t task, e_SD_task_state_t state);
136 XBT_PUBLIC(void) SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
137 XBT_PUBLIC(double) SD_task_get_amount(SD_task_t task);
138 XBT_PUBLIC(double) SD_task_get_alpha(SD_task_t task);
139 XBT_PUBLIC(double) SD_task_get_remaining_amount(SD_task_t task);
140 XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
141                                               int workstation_nb,
142                                               const SD_workstation_t *
143                                               workstation_list,
144                                               const double
145                                               *computation_amount, const double
146                                               *communication_amount);
147 XBT_PUBLIC(int) SD_task_get_kind(SD_task_t task);
148 XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
149                                   const SD_workstation_t *
150                                   workstation_list,
151                                   const double *computation_amount,
152                                   const double *communication_amount,
153                                   double rate);
154 XBT_PUBLIC(void) SD_task_unschedule(SD_task_t task);
155 XBT_PUBLIC(double) SD_task_get_start_time(SD_task_t task);
156 XBT_PUBLIC(double) SD_task_get_finish_time(SD_task_t task);
157 XBT_PUBLIC(xbt_dynar_t) SD_task_get_parents(SD_task_t task);
158 XBT_PUBLIC(xbt_dynar_t) SD_task_get_children(SD_task_t task);
159 XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task);
160 XBT_PUBLIC(SD_workstation_t *) SD_task_get_workstation_list(SD_task_t
161                                                             task);
162 XBT_PUBLIC(void) SD_task_destroy(SD_task_t task);
163 XBT_PUBLIC(void) SD_task_dump(SD_task_t task);
164 XBT_PUBLIC(void) SD_task_dotty(SD_task_t task, void *out_FILE);
165
166 XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char *name, void *data,
167                                               double amount);
168 XBT_PUBLIC(SD_task_t) SD_task_create_comp_par_amdahl(const char *name,
169                                                      void *data,
170                                                      double amount,
171                                                      double alpha);
172 XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char *name, void *data,
173                                               double amount);
174 XBT_PUBLIC(SD_task_t) SD_task_create_comm_par_mxn_1d_block(const char *name,
175                                                            void *data,
176                                                            double amount);
177
178 XBT_PUBLIC(void) SD_task_distribute_comp_amdhal(SD_task_t task, int ws_count);
179 XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count,
180                                    const SD_workstation_t * list);
181 XBT_PUBLIC(void) SD_task_schedulel(SD_task_t task, int count, ...);
182
183
184 /** @brief A constant to use in SD_task_schedule to mean that there is no cost.
185  *
186  *  For example, create a pure computation task (no comm) like this:
187  *
188  *  SD_task_schedule(task, my_workstation_nb,
189  *                   my_workstation_list,
190  *                   my_computation_amount,
191  *                   SD_TASK_SCHED_NO_COST,
192  *                   my_rate);
193  */
194 #define SD_SCHED_NO_COST NULL
195
196 /** @} */
197
198
199 /** @defgroup SD_task_dependency_management Tasks dependencies
200  *  @brief Functions for managing the task dependencies
201  *
202  *  This section describes the functions for managing the dependencies between the tasks.
203  *
204  *  @see SD_task_management
205  *  @{
206  */
207 XBT_PUBLIC(void) SD_task_dependency_add(const char *name, void *data,
208                                         SD_task_t src, SD_task_t dst);
209 XBT_PUBLIC(void) SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
210 XBT_PUBLIC(const char *) SD_task_dependency_get_name(SD_task_t src,
211                                                      SD_task_t dst);
212 XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src,
213                                                SD_task_t dst);
214 XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
215 /** @} */
216
217 /************************** Global *******************************************/
218
219 /** @defgroup SD_simulation Simulation
220  *  @brief Functions for creating the environment and launching the simulation
221  *
222  *  This section describes the functions for initialising SimDag, launching
223  *  the simulation and exiting SimDag.
224  *
225  *  @{
226  */
227 XBT_PUBLIC(void) SD_init(int *argc, char **argv);
228 XBT_PUBLIC(void) SD_application_reinit(void);
229 XBT_PUBLIC(void) SD_create_environment(const char *platform_file);
230 XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
231 XBT_PUBLIC(double) SD_get_clock(void);
232 XBT_PUBLIC(void) SD_exit(void);
233 XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename);
234 XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename);
235 XBT_PUBLIC(xbt_dynar_t) SD_PTG_dotload(const char *filename);
236 XBT_PUBLIC(xbt_dynar_t) SD_dotload_with_sched(const char *filename);
237 XBT_PUBLIC(void) uniq_transfer_task_name(SD_task_t task);
238
239 /** @} */
240
241 #include "instr/instr.h"
242
243 SG_END_DECL()
244 #endif