Logo AND Algorithmique Numérique Distribuée

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