A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Documentation fixups: Marc was a bit quick at copy/pasting (+ DTD renamed)
[simgrid.git]
/
src
/
simdag
/
sd_global.c
diff --git
a/src/simdag/sd_global.c
b/src/simdag/sd_global.c
index
0f7a75d
..
ce76515
100644
(file)
--- a/
src/simdag/sd_global.c
+++ b/
src/simdag/sd_global.c
@@
-4,6
+4,7
@@
#include "surf/surf.h"
#include "xbt/ex.h"
#include "xbt/log.h"
#include "surf/surf.h"
#include "xbt/ex.h"
#include "xbt/log.h"
+#include "xbt/str.h"
#include "xbt/config.h"
XBT_LOG_NEW_CATEGORY(sd,"Logging specific to SimDag");
#include "xbt/config.h"
XBT_LOG_NEW_CATEGORY(sd,"Logging specific to SimDag");
@@
-34,8
+35,8
@@
static void _sd_cfg_cb__workstation_model(const char *name, int pos)
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_
resource_description(surf_workstation_resource
_description,
- surf_workstation_
resource
_description_size,
+ find_
model_description(surf_workstation_model
_description,
+ surf_workstation_
model
_description_size,
val);
}
val);
}
@@
-48,8
+49,8
@@
static void _sd_cfg_cb__cpu_model(const char *name, int pos)
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_
resource_description(surf_cpu_resource
_description,
- surf_cpu_
resource
_description_size, val);
+ find_
model_description(surf_cpu_model
_description,
+ surf_cpu_
model
_description_size, val);
}
/* callback of the workstation_model variable */
}
/* callback of the workstation_model variable */
@@
-61,10
+62,14
@@
static void _sd_cfg_cb__network_model(const char *name, int pos)
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
"Cannot change the model after the initialization");
val = xbt_cfg_get_string(_sd_cfg_set, name);
- find_
resource_description(surf_network_resource
_description,
- surf_network_
resource
_description_size, val);
+ find_
model_description(surf_network_model
_description,
+ surf_network_
model
_description_size, val);
}
}
+XBT_LOG_EXTERNAL_CATEGORY(sd_kernel);
+XBT_LOG_EXTERNAL_CATEGORY(sd_task);
+XBT_LOG_EXTERNAL_CATEGORY(sd_workstation);
+
/* create the config set and register what should be */
static void sd_config_init(void)
{
/* create the config set and register what should be */
static void sd_config_init(void)
{
@@
-72,6
+77,11
@@
static void sd_config_init(void)
if (_sd_init_status)
return; /* Already inited, nothing to do */
if (_sd_init_status)
return; /* Already inited, nothing to do */
+ /* Connect our log channels: that must be done manually under windows */
+ XBT_LOG_CONNECT(sd_kernel, sd);
+ XBT_LOG_CONNECT(sd_task, sd);
+ XBT_LOG_CONNECT(sd_workstation, sd);
+
_sd_init_status = 1;
_sd_cfg_set = xbt_cfg_new();
_sd_init_status = 1;
_sd_cfg_set = xbt_cfg_new();
@@
-123,7
+133,7
@@
static void sd_cfg_control_set(const char *control_string)
/* To split the string in commands, and the cursors */
xbt_dynar_t set_strings;
char *str;
/* To split the string in commands, and the cursors */
xbt_dynar_t set_strings;
char *str;
- int cpt;
+
unsigned
int cpt;
if (!control_string)
return;
if (!control_string)
return;
@@
-280,7
+290,7
@@
void SD_application_reinit(void) {
*
* The XML file follows this DTD:
*
*
* The XML file follows this DTD:
*
- * \include s
urfxml
.dtd
+ * \include s
imgrid
.dtd
*
* Here is a small example of such a platform:
*
*
* Here is a small example of such a platform:
*
@@
-299,15
+309,15
@@
void SD_create_environment(const char *platform_file) {
DEBUG0("SD_create_environment");
sd_config_init();
DEBUG0("SD_create_environment");
sd_config_init();
- surf_timer_
resource
_init(platform_file);
+ surf_timer_
model
_init(platform_file);
workstation_model_name =
xbt_cfg_get_string(_sd_cfg_set, "workstation_model");
DEBUG1("Model : %s", workstation_model_name);
workstation_id =
workstation_model_name =
xbt_cfg_get_string(_sd_cfg_set, "workstation_model");
DEBUG1("Model : %s", workstation_model_name);
workstation_id =
- find_
resource_description(surf_workstation_resource
_description,
- surf_workstation_
resource
_description_size,
+ find_
model_description(surf_workstation_model
_description,
+ surf_workstation_
model
_description_size,
workstation_model_name);
if (!strcmp(workstation_model_name, "compound")) {
xbt_ex_t e;
workstation_model_name);
if (!strcmp(workstation_model_name, "compound")) {
xbt_ex_t e;
@@
-343,21
+353,23
@@
void SD_create_environment(const char *platform_file) {
}
network_id =
}
network_id =
- find_
resource_description(surf_network_resource
_description,
- surf_network_
resource
_description_size,
+ find_
model_description(surf_network_model
_description,
+ surf_network_
model
_description_size,
network_model_name);
cpu_id =
network_model_name);
cpu_id =
- find_
resource_description(surf_cpu_resource
_description,
- surf_cpu_
resource
_description_size,
+ find_
model_description(surf_cpu_model
_description,
+ surf_cpu_
model
_description_size,
cpu_model_name);
cpu_model_name);
- surf_cpu_
resource_description[cpu_id].resource
_init(platform_file);
- surf_network_
resource_description[network_id].resource
_init(platform_file);
+ surf_cpu_
model_description[cpu_id].model
_init(platform_file);
+ surf_network_
model_description[network_id].model
_init(platform_file);
}
}
- DEBUG0("Call workstation_resource_init");
- surf_workstation_resource_description[workstation_id].
- resource_init(platform_file);
+ DEBUG0("Call workstation_model_init");
+ surf_workstation_model_description[workstation_id].
+ model_init(platform_file);
+
+ parse_platform_file(platform_file);
_sd_init_status = 2;
_sd_init_status = 2;
@@
-366,7
+378,7
@@
void SD_create_environment(const char *platform_file) {
__SD_workstation_create(surf_workstation, NULL);
}
__SD_workstation_create(surf_workstation, NULL);
}
- xbt_dict_foreach(
network_
link_set, cursor, name, surf_link) {
+ xbt_dict_foreach(link_set, cursor, name, surf_link) {
__SD_link_create(surf_link, NULL);
}
__SD_link_create(surf_link, NULL);
}
@@
-389,13
+401,13
@@
SD_task_t* SD_simulate(double how_long)
{
double total_time = 0.0; /* we stop the simulation when total_time >= how_long */
double elapsed_time = 0.0;
{
double total_time = 0.0; /* we stop the simulation when total_time >= how_long */
double elapsed_time = 0.0;
- SD_task_t task, dst;
+ SD_task_t task,
task_safe,
dst;
SD_dependency_t dependency;
surf_action_t action;
SD_task_t *changed_tasks = NULL;
int changed_task_number = 0;
int changed_task_capacity = sd_global->task_number + 1;
SD_dependency_t dependency;
surf_action_t action;
SD_task_t *changed_tasks = NULL;
int changed_task_number = 0;
int changed_task_capacity = sd_global->task_number + 1;
-
int i
;
+
unsigned int iter
;
static int first_time = 1;
SD_CHECK_INIT_DONE();
static int first_time = 1;
SD_CHECK_INIT_DONE();
@@
-412,13
+424,13
@@
SD_task_t* SD_simulate(double how_long)
}
if(how_long>0) {
}
if(how_long>0) {
- surf_timer_
resource
->extension_public->set(surf_get_clock()+how_long,
+ surf_timer_
model
->extension_public->set(surf_get_clock()+how_long,
NULL,NULL);
}
sd_global->watch_point_reached = 0;
/* explore the ready tasks */
NULL,NULL);
}
sd_global->watch_point_reached = 0;
/* explore the ready tasks */
- xbt_swag_foreach
(task
, sd_global->ready_task_set) {
+ xbt_swag_foreach
_safe(task, task_safe
, sd_global->ready_task_set) {
INFO1("Executing task '%s'", SD_task_get_name(task));
if ((task->state_changed = __SD_task_try_to_run(task))) {
changed_tasks[changed_task_number++] = task; /* replace NULL by the task */
INFO1("Executing task '%s'", SD_task_get_name(task));
if ((task->state_changed = __SD_task_try_to_run(task))) {
changed_tasks[changed_task_number++] = task; /* replace NULL by the task */
@@
-437,7
+449,7
@@
SD_task_t* SD_simulate(double how_long)
while (elapsed_time >= 0.0 &&
(how_long < 0.0 || total_time < how_long) &&
!sd_global->watch_point_reached) {
while (elapsed_time >= 0.0 &&
(how_long < 0.0 || total_time < how_long) &&
!sd_global->watch_point_reached) {
- surf_
resource_t resource
= NULL;
+ surf_
model_t model
= NULL;
/* dumb variables */
void *fun = NULL;
void *arg = NULL;
/* dumb variables */
void *fun = NULL;
void *arg = NULL;
@@
-451,8
+463,8
@@
SD_task_t* SD_simulate(double how_long)
total_time += elapsed_time;
/* let's see which tasks are done */
total_time += elapsed_time;
/* let's see which tasks are done */
- xbt_dynar_foreach(
resource_list, i, resource
) {
- while ((action = xbt_swag_extract(
resource
->common_public->
+ xbt_dynar_foreach(
model_list, iter, model
) {
+ while ((action = xbt_swag_extract(
model
->common_public->
states.done_action_set))) {
task = action->data;
INFO1("Task '%s' done", SD_task_get_name(task));
states.done_action_set))) {
task = action->data;
INFO1("Task '%s' done", SD_task_get_name(task));
@@
-497,11
+509,11
@@
SD_task_t* SD_simulate(double how_long)
}
/* let's see which tasks have just failed */
}
/* let's see which tasks have just failed */
- while ((action = xbt_swag_extract(
resource
->common_public->states.failed_action_set))) {
+ while ((action = xbt_swag_extract(
model
->common_public->states.failed_action_set))) {
task = action->data;
INFO1("Task '%s' failed", SD_task_get_name(task));
__SD_task_set_state(task, SD_FAILED);
task = action->data;
INFO1("Task '%s' failed", SD_task_get_name(task));
__SD_task_set_state(task, SD_FAILED);
- surf_workstation_
resource
->common_public->action_free(action);
+ surf_workstation_
model
->common_public->action_free(action);
task->surf_action = NULL;
if (!task->state_changed) {
task->surf_action = NULL;
if (!task->state_changed) {
@@
-518,15
+530,15
@@
SD_task_t* SD_simulate(double how_long)
}
}
}
}
- while (surf_timer_
resource
->extension_public->get(&fun,(void*)&arg)) {
+ while (surf_timer_
model
->extension_public->get(&fun,(void*)&arg)) {
}
}
/* we must reset every task->state_changed */
}
}
/* we must reset every task->state_changed */
- i = 0;
- while (changed_tasks[i] != NULL) {
- changed_tasks[i]->state_changed = 0;
- i++;
+ i
ter
= 0;
+ while (changed_tasks[i
ter
] != NULL) {
+ changed_tasks[i
ter
]->state_changed = 0;
+ i
ter
++;
}
INFO0("Simulation finished");
}
INFO0("Simulation finished");