From: Frederic Suter Date: Tue, 9 Aug 2016 10:04:26 +0000 (+0200) Subject: use C++ version of simulate X-Git-Tag: v3_14~604 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/15de54cff47d4655bc84377fcd3d45cfe2836736 use C++ version of simulate cannot check task equality anymore --- diff --git a/examples/simdag/test/sd_test.cpp b/examples/simdag/test/sd_test.cpp index f332f7a4b8..07e3628147 100644 --- a/examples/simdag/test/sd_test.cpp +++ b/examples/simdag/test/sd_test.cpp @@ -9,15 +9,12 @@ #include #include "xbt/log.h" #include +#include 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 *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); diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index cdebdc678f..404d3798e4 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -14,6 +14,9 @@ #include "xbt/log.h" #include "simgrid/link.h" #include "simgrid/host.h" +#ifdef __cplusplus +#include +#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*) simulate(double how_long); +} +} +#endif /** @} */ /* Support some backward compatibility */