1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010. 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 "simdag/datatypes.h"
13 #include "xbt/dynar.h"
19 /************************** Link handling ***********************************/
20 /** @defgroup SD_link_management Links
21 * @brief Functions for managing the network links
23 * This section describes the functions for managing the network links.
25 * A link is a network node represented as a <em>name</em>, a <em>current
26 * bandwidth</em> and a <em>current latency</em>. The links are created
27 * when you call the function SD_create_environment.
32 XBT_PUBLIC(const SD_link_t *) SD_link_get_list(void);
33 XBT_PUBLIC(int) SD_link_get_number(void);
34 XBT_PUBLIC(void *) SD_link_get_data(SD_link_t link);
35 XBT_PUBLIC(void) SD_link_set_data(SD_link_t link, void *data);
36 XBT_PUBLIC(const char *) SD_link_get_name(SD_link_t link);
37 XBT_PUBLIC(double) SD_link_get_current_bandwidth(SD_link_t link);
38 XBT_PUBLIC(double) SD_link_get_current_latency(SD_link_t link);
39 XBT_PUBLIC(e_SD_link_sharing_policy_t) SD_link_get_sharing_policy(SD_link_t
43 /************************** Workstation handling ****************************/
45 /** @defgroup SD_workstation_management Workstations
46 * @brief Functions for managing the workstations
48 * This section describes the functions for managing the workstations.
50 * A workstation is a place where a task can be executed.
51 * A workstation is represented as a <em>physical
52 * resource with computing capabilities</em> and has a <em>name</em>.
54 * The workstations are created when you call the function SD_create_environment.
56 * @see SD_workstation_t
59 XBT_PUBLIC(SD_workstation_t) SD_workstation_get_by_name(const char *name);
60 XBT_PUBLIC(const SD_workstation_t *) SD_workstation_get_list(void);
61 XBT_PUBLIC(int) SD_workstation_get_number(void);
62 XBT_PUBLIC(void) SD_workstation_set_data(SD_workstation_t workstation,
64 XBT_PUBLIC(void *) SD_workstation_get_data(SD_workstation_t workstation);
65 XBT_PUBLIC(const char *) SD_workstation_get_name(SD_workstation_t
67 /*property handling functions*/
68 XBT_PUBLIC(xbt_dict_t) SD_workstation_get_properties(SD_workstation_t
70 XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
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, SD_workstation_t dst);
77 XBT_PUBLIC(double) SD_workstation_get_power(SD_workstation_t workstation);
78 XBT_PUBLIC(double) SD_workstation_get_available_power(SD_workstation_t
80 XBT_PUBLIC(e_SD_workstation_access_mode_t)
81 SD_workstation_get_access_mode(SD_workstation_t workstation);
82 XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t workstation,
83 e_SD_workstation_access_mode_t
86 XBT_PUBLIC(double) SD_workstation_get_computation_time(SD_workstation_t
90 XBT_PUBLIC(double) SD_route_get_current_latency(SD_workstation_t src,
91 SD_workstation_t dst);
92 XBT_PUBLIC(double) SD_route_get_current_bandwidth(SD_workstation_t src,
93 SD_workstation_t dst);
94 XBT_PUBLIC(double) SD_route_get_communication_time(SD_workstation_t src,
97 communication_amount);
99 XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task (SD_workstation_t workstation);
102 /************************** Task handling ************************************/
104 /** @defgroup SD_task_management Tasks
105 * @brief Functions for managing the tasks
107 * This section describes the functions for managing the tasks.
109 * A task is some <em>working amount</em> that can be executed
110 * in parallel on several workstations. A task may depend on other
111 * tasks, this means that the task cannot start until the other tasks are done.
112 * Each task has a <em>\ref e_SD_task_state_t "state"</em> indicating whether
113 * the task is scheduled, running, done, etc.
115 * @see SD_task_t, SD_task_dependency_management
118 XBT_PUBLIC(SD_task_t) SD_task_create(const char *name, void *data,
120 XBT_PUBLIC(void *) SD_task_get_data(SD_task_t task);
121 XBT_PUBLIC(void) SD_task_set_data(SD_task_t task, void *data);
122 XBT_PUBLIC(e_SD_task_state_t) SD_task_get_state(SD_task_t task);
123 XBT_PUBLIC(const char *) SD_task_get_name(SD_task_t task);
124 XBT_PUBLIC(void) SD_task_set_name(SD_task_t task, const char *name);
125 XBT_PUBLIC(void) SD_task_watch(SD_task_t task, e_SD_task_state_t state);
126 XBT_PUBLIC(void) SD_task_unwatch(SD_task_t task, e_SD_task_state_t state);
127 XBT_PUBLIC(double) SD_task_get_amount(SD_task_t task);
128 XBT_PUBLIC(double) SD_task_get_remaining_amount(SD_task_t task);
129 XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
131 const SD_workstation_t *
132 workstation_list, const double
133 *computation_amount, const double
134 *communication_amount);
135 XBT_PUBLIC(int) SD_task_get_kind(SD_task_t task);
136 XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
137 const SD_workstation_t * workstation_list,
138 const double *computation_amount,
139 const double *communication_amount,
141 XBT_PUBLIC(void) SD_task_unschedule(SD_task_t task);
142 XBT_PUBLIC(double) SD_task_get_start_time(SD_task_t task);
143 XBT_PUBLIC(double) SD_task_get_finish_time(SD_task_t task);
144 XBT_PUBLIC(xbt_dynar_t) SD_task_get_parents(SD_task_t task);
145 XBT_PUBLIC(xbt_dynar_t) SD_task_get_children(SD_task_t task);
146 XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task);
147 XBT_PUBLIC(SD_workstation_t*) SD_task_get_workstation_list(SD_task_t task);
148 XBT_PUBLIC(void) SD_task_destroy(SD_task_t task);
149 XBT_PUBLIC(void) SD_task_dump(SD_task_t task);
150 XBT_PUBLIC(void) SD_task_dotty(SD_task_t task,void* out_FILE);
152 XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char*name,void *data,double amount);
153 XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char*name,void *data,double amount);
154 XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list);
155 XBT_PUBLIC(void) SD_task_schedulel(SD_task_t task, int count, ...);
157 /** @brief A constant to use in SD_task_schedule to mean that there is no cost.
159 * For example, create a pure computation task (no comm) like this:
161 * SD_task_schedule(task, my_workstation_nb,
162 * my_workstation_list,
163 * my_computation_amount,
164 * SD_TASK_SCHED_NO_COST,
167 #define SD_SCHED_NO_COST NULL
172 /** @defgroup SD_task_dependency_management Tasks dependencies
173 * @brief Functions for managing the task dependencies
175 * This section describes the functions for managing the dependencies between the tasks.
177 * @see SD_task_management
180 XBT_PUBLIC(void) SD_task_dependency_add(const char *name, void *data,
181 SD_task_t src, SD_task_t dst);
182 XBT_PUBLIC(void) SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
183 XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src, SD_task_t dst);
184 XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
187 /************************** Global *******************************************/
189 /** @defgroup SD_simulation Simulation
190 * @brief Functions for creating the environment and launching the simulation
192 * This section describes the functions for initialising SimDag, launching
193 * the simulation and exiting SimDag.
197 XBT_PUBLIC(void) SD_init(int *argc, char **argv);
198 XBT_PUBLIC(void) SD_application_reinit(void);
199 XBT_PUBLIC(void) SD_create_environment(const char *platform_file);
200 XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
201 XBT_PUBLIC(double) SD_get_clock(void);
202 XBT_PUBLIC(void) SD_exit(void);
203 XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char*filename);
204 XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char*filename);
205 XBT_PUBLIC(xbt_dynar_t) SD_dotload_FILE(FILE* in_file);