X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cfb9d34d05b3f539a28d03a2c5b8778c5a4478f8..23a2059333732be618364bbd4bb149e3b1f7c112:/src/simdag/sd_global.c diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index ff315b3721..a73ce53abd 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -12,13 +12,18 @@ #include "xbt/log.h" #include "xbt/str.h" #include "xbt/config.h" -#include "instr/private.h" +#include "instr/instr_private.h" +#include "surf/surfxml_parse.h" #ifdef HAVE_LUA #include #include #include #endif +#ifdef HAVE_JEDULE +#include "instr/jedule/jedule_sd_binding.h" +#endif + XBT_LOG_NEW_CATEGORY(sd, "Logging specific to SimDag"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_kernel, sd, "Logging specific to SimDag (kernel)"); @@ -87,6 +92,14 @@ void SD_init(int *argc, char **argv) xbt_cfg_setdefault_string(_surf_cfg_set, "workstation/model", "ptask_L07"); + +#ifdef HAVE_TRACING + TRACE_start (); +#endif + +#ifdef HAVE_JEDULE + jedule_sd_init(); +#endif } /** @@ -134,6 +147,12 @@ void SD_application_reinit(void) sd_global->failed_task_set = xbt_swag_new(xbt_swag_offset(task, state_hookup)); sd_global->task_number = 0; + +#ifdef HAVE_JEDULE + jedule_sd_cleanup(); + jedule_sd_init(); +#endif + } else { WARN0("SD_application_reinit called before initialization of SimDag"); /* we cannot use exceptions here because xbt is not running! */ @@ -166,11 +185,13 @@ void SD_create_environment(const char *platform_file) void *surf_workstation = NULL; void *surf_link = NULL; - SD_CHECK_INIT_DONE(); + platform_filename = bprintf("%s",platform_file); - DEBUG0("SD_create_environment"); - - surf_config_models_setup(platform_file); + // Reset callbacks + surf_parse_reset_callbacks(); + // Add config callbacks + surf_parse_add_callback_config(); + SD_CHECK_INIT_DONE(); parse_platform_file(platform_file); surf_config_models_create_elms(); @@ -187,9 +208,8 @@ void SD_create_environment(const char *platform_file) DEBUG2("Workstation number: %d, link number: %d", SD_workstation_get_number(), SD_link_get_number()); - -#ifdef HAVE_TRACING - TRACE_surf_save_onelink(); +#ifdef HAVE_JEDULE + jedule_setup_platform(); #endif } @@ -197,8 +217,11 @@ void SD_create_environment(const char *platform_file) * \brief Launches the simulation. * * The function will execute the \ref SD_RUNNABLE runnable tasks. - * The simulation will be stopped when its time reaches \a how_long, - * when a watch point is reached, or when no more task can be executed. + * If \a how_long is positive, then the simulation will be stopped either + * when time reaches \a how_long or when a watch point is reached. + * A nonpositive value for \a how_long means no time limit, in which case + * the simulation will be stopped either when a watch point is reached or + * when no more task can be executed. * Then you can call SD_simulate() again. * * \param how_long maximum duration of the simulation (a negative value means no time limit) @@ -218,17 +241,13 @@ xbt_dynar_t SD_simulate(double how_long) SD_CHECK_INIT_DONE(); - VERB0("Starting simulation..."); + if (first_time) { + VERB0("Starting simulation..."); - if (first_time) { surf_presolve(); /* Takes traces into account */ first_time = 0; } - if (how_long > 0) { - surf_timer_model->extension.timer.set(surf_get_clock() + how_long, - NULL, NULL); - } sd_global->watch_point_reached = 0; /* explore the runnable tasks */ @@ -246,13 +265,11 @@ xbt_dynar_t SD_simulate(double how_long) !sd_global->watch_point_reached) { surf_model_t model = NULL; /* dumb variables */ - void *fun = NULL; - void *arg = NULL; DEBUG1("Total time: %f", total_time); - elapsed_time = surf_solve(); + elapsed_time = surf_solve(how_long > 0 ? surf_get_clock() + how_long : -1.0); DEBUG1("surf_solve() returns %f", elapsed_time); if (elapsed_time > 0.0) total_time += elapsed_time; @@ -332,12 +349,23 @@ xbt_dynar_t SD_simulate(double how_long) xbt_dynar_push(changed_tasks, &task); } } + } - while (surf_timer_model->extension.timer.get(&fun, (void *) &arg)) { + if (!sd_global->watch_point_reached && how_long<0){ + if (xbt_swag_size(sd_global->done_task_set) < sd_global->task_number){ + WARN0("Simulation is finished but some tasks are still not done"); + xbt_swag_foreach_safe (task, task_safe,sd_global->not_scheduled_task_set){ + WARN1("%s is in SD_NOT_SCHEDULED state", SD_task_get_name(task)); + } + xbt_swag_foreach_safe (task, task_safe,sd_global->schedulable_task_set){ + WARN1("%s is in SD_SCHEDULABLE state", SD_task_get_name(task)); + } + xbt_swag_foreach_safe (task, task_safe,sd_global->scheduled_task_set){ + WARN1("%s is in SD_SCHEDULED state", SD_task_get_name(task)); + } } } - VERB0("Simulation finished"); DEBUG3("elapsed_time = %f, total_time = %f, watch_point_reached = %d", elapsed_time, total_time, sd_global->watch_point_reached); DEBUG1("current time = %f", surf_get_clock()); @@ -398,6 +426,14 @@ void SD_exit(void) xbt_free(sd_global); sd_global = NULL; +#ifdef HAVE_TRACING + TRACE_end(); +#endif +#ifdef HAVE_JEDULE + jedule_sd_dump(); + jedule_sd_cleanup(); +#endif + DEBUG0("Exiting Surf..."); surf_exit(); } else {