Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify and fix cycle detection
[simgrid.git] / src / simdag / sd_global.cpp
index 3ffd43c..38a5852 100644 (file)
@@ -46,7 +46,6 @@ std::set<SD_task_t>* simulate(double how_long){
   double total_time = 0.0;
   /* main loop */
   while (elapsed_time >= 0 && (how_long < 0 || 0.00001 < (how_long -total_time)) && !sd_global->watch_point_reached) {
-    surf_model_t model = nullptr;
 
     XBT_DEBUG("Total time: %f", total_time);
 
@@ -56,8 +55,7 @@ std::set<SD_task_t>* simulate(double how_long){
       total_time += elapsed_time;
 
     /* let's see which tasks are done */
-    unsigned int iter;
-    xbt_dynar_foreach(all_existing_models, iter, model) {
+    for (auto model : *all_existing_models) {
       surf_action_t action = surf_model_extract_done_action_set(model);
       while (action != nullptr) {
         SD_task_t task = static_cast<SD_task_t>(action->getData());
@@ -140,8 +138,9 @@ std::set<SD_task_t>* simulate(double how_long){
  * \return the equivalent as a readable string
  */
 const char *__get_state_name(e_SD_task_state_t state){
-  std::string state_names[7] = { "not scheduled", "schedulable", "scheduled", "runnable","running", "done", "failed" };
-  return state_names[(int)log2(state)].data();
+  static std::string state_names[7] =
+    { "not scheduled", "schedulable", "scheduled", "runnable","running", "done", "failed" };
+  return state_names[static_cast<int>(log2(static_cast<double>(state)))].data();
 }
 
 /**
@@ -163,10 +162,6 @@ void SD_init(int *argc, char **argv)
 
   xbt_cfg_setdefault_string("host/model", "ptask_L07");
 
-#if HAVE_JEDULE
-  jedule_sd_init();
-#endif
-
   if (_sg_cfg_exit_asap) {
     SD_exit();
     exit(0);
@@ -208,7 +203,7 @@ void SD_create_environment(const char *platform_file)
 
   XBT_DEBUG("Host number: %zu, link number: %d", sg_host_count(), sg_link_count());
 #if HAVE_JEDULE
-  jedule_setup_platform();
+  jedule_sd_init();
 #endif
   XBT_VERB("Starting simulation...");
   surf_presolve();            /* Takes traces into account */
@@ -250,7 +245,6 @@ double SD_get_clock() {
 void SD_exit()
 {
 #if HAVE_JEDULE
-  jedule_sd_cleanup();
   jedule_sd_exit();
 #endif
   delete sd_global;