Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use C++ version of simulate
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Aug 2016 10:04:26 +0000 (12:04 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 9 Aug 2016 10:04:26 +0000 (12:04 +0200)
cannot check task equality anymore

examples/simdag/test/sd_test.cpp
include/simgrid/simdag.h

index f332f7a..07e3628 100644 (file)
@@ -9,15 +9,12 @@
 #include <xbt/ex.hpp>
 #include "xbt/log.h"
 #include <math.h>
+#include <set>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_test, "Logging specific to this SimDag example");
 
 int main(int argc, char **argv)
 {
-  unsigned int ctr;
-  SD_task_t checkB;
-  SD_task_t checkD;
-  xbt_dynar_t changed_tasks;
   sg_host_t host_list[2];
   double computation_amount[2];
   double communication_amount[4] = { 0 };
@@ -129,17 +126,12 @@ int main(int argc, char **argv)
   SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1);
   SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1);
 
-  changed_tasks = SD_simulate(-1.0);
-  xbt_dynar_foreach(changed_tasks, ctr, task) {
+  std::set<SD_task_t> *changed_tasks = simgrid::sd::simulate(-1.0);
+  for (auto task: *changed_tasks){
     XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task),
           SD_task_get_start_time(task), SD_task_get_finish_time(task));
   }
 
-  xbt_dynar_get_cpy(changed_tasks, 0, &checkB);
-  xbt_dynar_get_cpy(changed_tasks, 1, &checkD);
-
-  xbt_assert(checkD == taskD && checkB == taskB, "Unexpected simulation results");
-
   XBT_DEBUG("Destroying tasks...");
   SD_task_destroy(taskA);
   SD_task_destroy(taskB);
index cdebdc6..404d379 100644 (file)
@@ -14,6 +14,9 @@
 #include "xbt/log.h"
 #include "simgrid/link.h"
 #include "simgrid/host.h"
+#ifdef __cplusplus
+#include <set>
+#endif
 SG_BEGIN_DECL()
 
 /** @brief Link opaque datatype
@@ -168,7 +171,13 @@ XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename);
 XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename);
 XBT_PUBLIC(xbt_dynar_t) SD_dotload_with_sched(const char *filename);
 XBT_PUBLIC(xbt_dynar_t) SD_PTG_dotload(const char *filename);
-
+#ifdef __cplusplus
+namespace simgrid {
+namespace sd {
+XBT_PUBLIC(std::set<SD_task_t>*) simulate(double how_long);
+}
+}
+#endif
 /** @} */
 
 /* Support some backward compatibility */