X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/45c3f1cfee86fb48c96d53f8267f99b6db6e3d7a..9f646472eb2d52b33a9be7450259564ac890ea99:/examples/msg/cloud/bound.c?ds=sidebyside diff --git a/examples/msg/cloud/bound.c b/examples/msg/cloud/bound.c index ee5fc4971a..ffb7387505 100644 --- a/examples/msg/cloud/bound.c +++ b/examples/msg/cloud/bound.c @@ -1,11 +1,11 @@ -/* Copyright (c) 2007-2014. The SimGrid Team. +/* Copyright (c) 2007-2015. 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. */ #include -#include "msg/msg.h" /* Yeah! If you want to use msg, you need to include msg/msg.h */ +#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ #include "xbt/sysdep.h" /* calloc, printf */ /* Create a log channel to have nice outputs. */ @@ -24,9 +24,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, static int worker_main(int argc, char *argv[]) { - double computation_amount = atof(argv[1]); - int use_bound = atoi(argv[2]); - double bound = atof(argv[3]); + double computation_amount = xbt_str_parse_double(argv[1], "Invalid computation amount: %s"); + int use_bound = xbt_str_parse_int(argv[2], "Second parameter (use_bound) should be 0 or 1 but is: %s"); + double bound = xbt_str_parse_double(argv[3], "Invalid bound: %s"); { double clock_sta = MSG_get_clock(); @@ -92,11 +92,11 @@ static void test_dynamic_change(void) msg_process_t pr1 = MSG_process_create("worker1", worker_busy_loop_main, &task1, vm1); - double task0_remain_prev = MSG_task_get_remaining_computation(task0); - double task1_remain_prev = MSG_task_get_remaining_computation(task1); + double task0_remain_prev = MSG_task_get_flops_amount(task0); + double task1_remain_prev = MSG_task_get_flops_amount(task1); { - const double cpu_speed = MSG_get_host_speed(pm0); + const double cpu_speed = MSG_host_get_speed(pm0); int i = 0; for (i = 0; i < 10; i++) { double new_bound = (cpu_speed / 10) * i; @@ -104,8 +104,8 @@ static void test_dynamic_change(void) MSG_vm_set_bound(vm1, new_bound); MSG_process_sleep(100); - double task0_remain_now = MSG_task_get_remaining_computation(task0); - double task1_remain_now = MSG_task_get_remaining_computation(task1); + double task0_remain_now = MSG_task_get_flops_amount(task0); + double task1_remain_now = MSG_task_get_flops_amount(task1); double task0_flops_per_sec = task0_remain_prev - task0_remain_now; double task1_flops_per_sec = task1_remain_prev - task1_remain_now; @@ -129,45 +129,12 @@ static void test_dynamic_change(void) static void test_one_task(msg_host_t hostA) { - const double cpu_speed = MSG_get_host_speed(hostA); + const double cpu_speed = MSG_host_get_speed(hostA); const double computation_amount = cpu_speed * 10; const char *hostA_name = MSG_host_get_name(hostA); XBT_INFO("### Test: with/without MSG_task_set_bound"); -#if 0 - /* Easy-to-understand code (without calling MSG_task_set_bound) */ - { - double clock_sta = MSG_get_clock(); - - msg_task_t task = MSG_task_create("Task", computation_amount, 0, NULL); - MSG_task_execute(task); - MSG_task_destroy(task); - - double clock_end = MSG_get_clock(); - double duration = clock_end - clock_sta; - double flops_per_sec = computation_amount / duration; - - XBT_INFO("not bound => duration %f (%f flops/s)", duration, flops_per_sec); - } - - /* Easy-to-understand code (with calling MSG_task_set_bound) */ - { - double clock_sta = MSG_get_clock(); - - msg_task_t task = MSG_task_create("Task", computation_amount, 0, NULL); - MSG_task_set_bound(task, cpu_speed / 2); - MSG_task_execute(task); - MSG_task_destroy(task); - - double clock_end = MSG_get_clock(); - double duration = clock_end - clock_sta; - double flops_per_sec = computation_amount / duration; - - XBT_INFO("bound to 0.5 => duration %f (%f flops/s)", duration, flops_per_sec); - } -#endif - { XBT_INFO("### Test: no bound for Task1@%s", hostA_name); launch_worker(hostA, "worker0", computation_amount, 0, 0); @@ -207,8 +174,8 @@ static void test_one_task(msg_host_t hostA) static void test_two_tasks(msg_host_t hostA, msg_host_t hostB) { - const double cpu_speed = MSG_get_host_speed(hostA); - xbt_assert(cpu_speed == MSG_get_host_speed(hostB)); + const double cpu_speed = MSG_host_get_speed(hostA); + xbt_assert(cpu_speed == MSG_host_get_speed(hostB)); const double computation_amount = cpu_speed * 10; const char *hostA_name = MSG_host_get_name(hostA); const char *hostB_name = MSG_host_get_name(hostB); @@ -321,7 +288,7 @@ static int master_main(int argc, char *argv[]) { msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0"); - const double cpu_speed = MSG_get_host_speed(pm0); + const double cpu_speed = MSG_host_get_speed(pm0); MSG_vm_set_bound(vm0, cpu_speed / 10); MSG_vm_start(vm0); @@ -344,13 +311,13 @@ static int master_main(int argc, char *argv[]) { msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0"); - s_ws_params_t params; + s_vm_params_t params; memset(¶ms, 0, sizeof(params)); params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes MSG_host_set_params(vm0, ¶ms); MSG_vm_start(vm0); - const double cpu_speed = MSG_get_host_speed(pm0); + const double cpu_speed = MSG_host_get_speed(pm0); MSG_vm_start(vm0); XBT_INFO("# 10. Test migration");