X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/228b00a7592e4b107be9b3fb49e75617f92189f8..9caf173e476622d309cc5653a83d224d05787cc7:/teshsuite/msg/task_progress/task_progress.cpp diff --git a/teshsuite/msg/task_progress/task_progress.cpp b/teshsuite/msg/task_progress/task_progress.cpp index feefbfcdc9..3971b80b0c 100644 --- a/teshsuite/msg/task_progress/task_progress.cpp +++ b/teshsuite/msg/task_progress/task_progress.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -7,6 +6,8 @@ #include #include "simgrid/msg.h" +#include /* snprintf */ + XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); static std::vector tasks = std::vector(); @@ -15,34 +16,32 @@ static int seq_task(int /*argc*/, char* /*argv*/ []) { double task_comp_size = 5E7; double task_comm_size = 1E6; - double progress = 0; + double progress; msg_task_t task = MSG_task_create("simple", task_comp_size, task_comm_size, NULL); tasks.push_back(task); XBT_INFO("get the progress of %s before the task starts", task->name); progress = MSG_task_get_remaining_work_ratio(task); - xbt_assert(progress == 0, "Progress should be 0 not %f", progress); + xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress); XBT_INFO("Executing task: \"%s\"", task->name); MSG_task_execute(task); XBT_INFO("get the progress of %s after the task finishes", task->name); progress = MSG_task_get_remaining_work_ratio(task); - xbt_assert(progress == 0, "Progress should be equal to 1 not %f", progress); + xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress); + MSG_task_destroy(task); XBT_INFO("Goodbye now!"); return 0; } static int par_task(int /*argc*/, char* /*argv*/ []) { - int nb_res = 2; - //double * computation_amount = xbt_new(double, nb_res); double * computation_amount = new double[2] {10E7, 10E7}; - //double * communication_amount = xbt_new(double, nb_res); double * communication_amount = new double[4] {1E6, 1E6, 1E6, 1E6}; - double progress = 0; + double progress; std::vector hosts_to_use = std::vector(); hosts_to_use.push_back(MSG_get_host_by_name("Tremblay")); @@ -53,14 +52,18 @@ static int par_task(int /*argc*/, char* /*argv*/ []) XBT_INFO("get the progress of %s before the task starts", task->name); progress = MSG_task_get_remaining_work_ratio(task); - xbt_assert(progress == 0, "Progress should be 0 not %f", progress); + xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress); XBT_INFO("Executing task: \"%s\"", task->name); MSG_parallel_task_execute(task); XBT_INFO("get the progress of %s after the task finishes", task->name); progress = MSG_task_get_remaining_work_ratio(task); - xbt_assert(progress == 0, "Progress should be equal to 1 not %f", progress); + xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress); + + MSG_task_destroy(task); + delete[] computation_amount; + delete[] communication_amount; XBT_INFO("Goodbye now!"); return 0; @@ -71,8 +74,8 @@ static int get_progress(int /*argc*/, char* /*argv*/ []) while (tasks.empty()) { MSG_process_sleep(0.5); } + double progress; for(auto const& task: tasks) { - double progress; double progress_prev = 1; for (int i = 0; i < 3; i++) { MSG_process_sleep(0.2); @@ -83,6 +86,7 @@ static int get_progress(int /*argc*/, char* /*argv*/ []) progress_prev = progress; } } + return 0; } int main(int argc, char *argv[])