1 /* Copyright (c) 2006-2010, 2012-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #ifndef SIMDAG_SIMDAG_H
8 #define SIMDAG_SIMDAG_H
11 #include "xbt/dynar.h"
14 #include "simgrid/link.h"
17 /** @brief Workstation datatype
18 @ingroup SD_datatypes_management
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>.
24 @see SD_workstation_management */
25 typedef sg_host_t SD_workstation_t;
27 /** @brief Link datatype
28 @ingroup SD_datatypes_management
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.
34 @see SD_link_management */
35 typedef Link *SD_link_t;
37 /** @brief Task datatype
38 @ingroup SD_datatypes_management
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.
46 @see SD_task_management */
47 typedef struct SD_task *SD_task_t;
49 /** @brief Task states
50 @ingroup SD_datatypes_management
52 @see SD_task_management */
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. */
65 @ingroup SD_datatypes_management
67 @see SD_task_management */
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) */
77 /** @brief Storage datatype
78 @ingroup SD_datatypes_management
82 @see SD_storage_management */
83 typedef xbt_dictelm_t SD_storage_t;
85 /************************** Workstation handling ****************************/
87 /** @defgroup SD_workstation_management Workstations
88 * @brief Functions for managing the workstations
90 * This section describes the functions for managing the workstations.
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>.
96 * The workstations are created when you call the function SD_create_environment.
98 * @see SD_workstation_t
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,
106 XBT_PUBLIC(void *) SD_workstation_get_data(SD_workstation_t workstation);
107 XBT_PUBLIC(const char *) SD_workstation_get_name(SD_workstation_t
109 /*property handling functions*/
110 XBT_PUBLIC(xbt_dict_t) SD_workstation_get_properties(SD_workstation_t
112 XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
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
124 XBT_PUBLIC(int) SD_workstation_get_cores(SD_workstation_t workstation);
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);
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);
143 /************************** Task handling ************************************/
145 /** @defgroup SD_task_management Tasks
146 * @brief Functions for managing the tasks
148 * This section describes the functions for managing the tasks.
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.
156 * @see SD_task_t, SD_task_dependency_management
159 XBT_PUBLIC(SD_task_t) SD_task_create(const char *name, void *data,
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);
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,
176 const SD_workstation_t *
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 *
184 const double *flops_amount,
185 const double *bytes_amount,
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
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);
199 XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char *name, void *data,
201 XBT_PUBLIC(SD_task_t) SD_task_create_comp_par_amdahl(const char *name,
205 XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char *name, void *data,
207 XBT_PUBLIC(SD_task_t) SD_task_create_comm_par_mxn_1d_block(const char *name,
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, ...);
217 /** @brief A constant to use in SD_task_schedule to mean that there is no cost.
219 * For example, create a pure computation task (no comm) like this:
221 * SD_task_schedule(task, my_workstation_nb,
222 * my_workstation_list,
224 * SD_TASK_SCHED_NO_COST,
227 #define SD_SCHED_NO_COST NULL
232 /** @defgroup SD_task_dependency_management Tasks dependencies
233 * @brief Functions for managing the task dependencies
235 * This section describes the functions for managing the dependencies between the tasks.
237 * @see SD_task_management
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,
245 XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src,
247 XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
250 /************************** Global *******************************************/
252 /** @defgroup SD_simulation Simulation
253 * @brief Functions for creating the environment and launching the simulation
255 * This section describes the functions for initializing SimDag, launching
256 * the simulation and exiting SimDag.
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);
276 #include "simgrid/instr.h"