From 18a179b256812ad12be148861da689953f141d85 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 12 Dec 2017 09:46:49 +0100 Subject: [PATCH] finally add this converted test the S4U version does not include the last subtest on migration: 1) there will be a dedicated example on migration once the migration code has been ported to S4U 2) This test says it's not implemented ## Test 6 (started): Check migration impact (not yet implemented neither on the CPU resource nor on the network one --- .gitignore | 1 + examples/s4u/CMakeLists.txt | 2 + .../s4u/cloud-simple/s4u-cloud-simple.cpp | 208 ++++++++++++++++++ .../s4u/cloud-simple/s4u-cloud-simple.tesh | 52 +++++ 4 files changed, 263 insertions(+) create mode 100644 examples/s4u/cloud-simple/s4u-cloud-simple.cpp create mode 100644 examples/s4u/cloud-simple/s4u-cloud-simple.tesh diff --git a/.gitignore b/.gitignore index 3b6b966eb0..4a02fc7f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -183,6 +183,7 @@ examples/s4u/app-token-ring/s4u-app-token-ring examples/s4u/async-wait/s4u-async-wait examples/s4u/async-waitall/s4u-async-waitall examples/s4u/async-waitany/s4u-async-waitany +examples/s4u/cloud-simple/s4u-cloud-simple examples/s4u/dht-chord/s4u-dht-chord examples/s4u/energy-link/s4u-energy-link examples/s4u/energy-ptask/s4u-energy-ptask diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index cb6e47a65a..4e1b704a69 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -1,6 +1,7 @@ foreach (example actor-create actor-daemon actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-yield app-masterworker app-pingpong app-token-ring async-wait async-waitany async-waitall + cloud-simple energy-link energy-pstate energy-ptask energy-vm exec-async exec-basic exec-monitor exec-remote io-file-system io-file-remote io-storage-raw @@ -69,6 +70,7 @@ set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-re foreach(example actor-create actor-daemon actor-join actor-kill actor-lifetime actor-migration actor-suspend actor-yield app-bittorrent app-masterworker app-pingpong app-token-ring async-wait async-waitall async-waitany + cloud-simple dht-chord energy-link energy-pstate energy-ptask energy-vm exec-async exec-basic exec-monitor exec-remote diff --git a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp new file mode 100644 index 0000000000..667551924c --- /dev/null +++ b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp @@ -0,0 +1,208 @@ +/* Copyright (c) 2007-2017. 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 "simgrid/s4u.hpp" +#include "simgrid/s4u/VirtualMachine.hpp" +XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example"); + +static void computation_fun() +{ + double clock_sta = simgrid::s4u::Engine::getClock(); + simgrid::s4u::this_actor::execute(1000000); + double clock_end = simgrid::s4u::Engine::getClock(); + + XBT_INFO("%s:%s task executed %g", simgrid::s4u::this_actor::getHost()->getCname(), + simgrid::s4u::this_actor::getName().c_str(), clock_end - clock_sta); +} + +static void launch_computation_worker(s4u_Host* host) +{ + simgrid::s4u::Actor::createActor("compute", host, computation_fun); +} + +struct s_payload { + s4u_Host* tx_host; + const char* tx_actor_name; + double clock_sta; +}; + +static void communication_tx_fun(std::vector args) +{ + simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(args.at(0)); + struct s_payload* payload = xbt_new(struct s_payload, 1); + payload->tx_actor_name = simgrid::s4u::Actor::self()->getCname(); + payload->tx_host = simgrid::s4u::this_actor::getHost(); + payload->clock_sta = simgrid::s4u::Engine::getClock(); + + mbox->put(payload, 1000000); +} + +static void communication_rx_fun(std::vector args) +{ + const char* actor_name = simgrid::s4u::Actor::self()->getCname(); + const char* host_name = simgrid::s4u::this_actor::getHost()->getCname(); + simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(args.at(0)); + + struct s_payload* payload = static_cast(mbox->get()); + double clock_end = simgrid::s4u::Engine::getClock(); + + XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->getCname(), payload->tx_actor_name, host_name, actor_name, + clock_end - payload->clock_sta); + + xbt_free(payload); +} + +static void launch_communication_worker(s4u_Host* tx_host, s4u_Host* rx_host) +{ + std::string mbox_name = std::string("MBOX:") + tx_host->getName() + "-" + rx_host->getName(); + std::vector args; + args.push_back(mbox_name); + + simgrid::s4u::Actor::createActor("comm_tx", tx_host, communication_tx_fun, args); + + simgrid::s4u::Actor::createActor("comm_rx", rx_host, communication_rx_fun, args); +} + +static void master_main() +{ + s4u_Host* pm0 = simgrid::s4u::Host::by_name("Fafard"); + s4u_Host* pm1 = simgrid::s4u::Host::by_name("Tremblay"); + + XBT_INFO("## Test 1 (started): check computation on normal PMs"); + + XBT_INFO("### Put a task on a PM"); + launch_computation_worker(pm0); + simgrid::s4u::this_actor::sleep_for(2); + + XBT_INFO("### Put two tasks on a PM"); + launch_computation_worker(pm0); + launch_computation_worker(pm0); + simgrid::s4u::this_actor::sleep_for(2); + + XBT_INFO("### Put a task on each PM"); + launch_computation_worker(pm0); + launch_computation_worker(pm1); + simgrid::s4u::this_actor::sleep_for(2); + + XBT_INFO("## Test 1 (ended)"); + + XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)"); + + XBT_INFO("### Put a VM on a PM, and put a task to the VM"); + simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm0->start(); + launch_computation_worker(vm0); + simgrid::s4u::this_actor::sleep_for(2); + vm0->destroy(); + + XBT_INFO("## Test 2 (ended)"); + + XBT_INFO( + "## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)"); + + XBT_INFO("### Put a VM on a PM, and put a task to the PM"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm0->start(); + launch_computation_worker(pm0); + simgrid::s4u::this_actor::sleep_for(2); + vm0->destroy(); + XBT_INFO("## Test 3 (ended)"); + + XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for" + " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1"); + + XBT_INFO("### Put two VMs on a PM, and put a task to each VM"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm0->start(); + simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1); + launch_computation_worker(vm0); + launch_computation_worker(vm1); + simgrid::s4u::this_actor::sleep_for(2); + vm0->destroy(); + vm1->destroy(); + + XBT_INFO("### Put a VM on each PM, and put a task to each VM"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm1 = new simgrid::s4u::VirtualMachine("VM1", pm1, 1); + vm0->start(); + vm1->start(); + launch_computation_worker(vm0); + launch_computation_worker(vm1); + simgrid::s4u::this_actor::sleep_for(2); + vm0->destroy(); + vm1->destroy(); + XBT_INFO("## Test 4 (ended)"); + + XBT_INFO("## Test 5 (started): Analyse network impact"); + XBT_INFO("### Make a connection between PM0 and PM1"); + launch_communication_worker(pm0, pm1); + simgrid::s4u::this_actor::sleep_for(5); + + XBT_INFO("### Make two connection between PM0 and PM1"); + launch_communication_worker(pm0, pm1); + launch_communication_worker(pm0, pm1); + simgrid::s4u::this_actor::sleep_for(5); + + XBT_INFO("### Make a connection between PM0 and VM0@PM0"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm0->start(); + launch_communication_worker(pm0, vm0); + simgrid::s4u::this_actor::sleep_for(5); + vm0->destroy(); + + XBT_INFO("### Make a connection between PM0 and VM0@PM1"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm1, 1); + launch_communication_worker(pm0, vm0); + simgrid::s4u::this_actor::sleep_for(5); + vm0->destroy(); + + XBT_INFO("### Make two connections between PM0 and VM0@PM1"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm1, 1); + vm0->start(); + launch_communication_worker(pm0, vm0); + launch_communication_worker(pm0, vm0); + simgrid::s4u::this_actor::sleep_for(5); + vm0->destroy(); + + XBT_INFO("### Make a connection between PM0 and VM0@PM1, and also make a connection between PM0 and PM1"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm1, 1); + vm0->start(); + launch_communication_worker(pm0, vm0); + launch_communication_worker(pm0, pm1); + simgrid::s4u::this_actor::sleep_for(5); + vm0->destroy(); + + XBT_INFO("### Make a connection between VM0@PM0 and PM1@PM1, and also make a connection between VM0@PM0 and VM1@PM1"); + vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1); + vm1 = new simgrid::s4u::VirtualMachine("VM1", pm1, 1); + vm0->start(); + vm1->start(); + launch_communication_worker(vm0, vm1); + launch_communication_worker(vm0, vm1); + simgrid::s4u::this_actor::sleep_for(5); + vm0->destroy(); + vm1->destroy(); + + XBT_INFO("## Test 5 (ended)"); +} + +static void launch_master(s4u_Host* host) +{ + simgrid::s4u::Actor::createActor("master_", host, master_main); +} + +int main(int argc, char* argv[]) +{ + simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv); + e->loadPlatform(argv[1]); /* - Load the platform description */ + + launch_master(simgrid::s4u::Host::by_name("Fafard")); + + e->run(); + + XBT_INFO("Simulation time %g", e->getClock()); + + return 0; +} diff --git a/examples/s4u/cloud-simple/s4u-cloud-simple.tesh b/examples/s4u/cloud-simple/s4u-cloud-simple.tesh new file mode 100644 index 0000000000..595d3f85d3 --- /dev/null +++ b/examples/s4u/cloud-simple/s4u-cloud-simple.tesh @@ -0,0 +1,52 @@ +#! ./tesh + +p Testing a vm with two successive tasks + +$ $SG_TEST_EXENV ${bindir:=.}/s4u-cloud-simple$EXEEXT --log=no_loc ${platfdir:=.}/small_platform.xml +> [Fafard:master_:(1) 0.000000] [s4u_test/INFO] ## Test 1 (started): check computation on normal PMs +> [Fafard:master_:(1) 0.000000] [s4u_test/INFO] ### Put a task on a PM +> [Fafard:compute:(2) 0.013107] [s4u_test/INFO] Fafard:compute task executed 0.0131068 +> [Fafard:master_:(1) 2.000000] [s4u_test/INFO] ### Put two tasks on a PM +> [Fafard:compute:(4) 2.026214] [s4u_test/INFO] Fafard:compute task executed 0.0262137 +> [Fafard:compute:(3) 2.026214] [s4u_test/INFO] Fafard:compute task executed 0.0262137 +> [Fafard:master_:(1) 4.000000] [s4u_test/INFO] ### Put a task on each PM +> [Tremblay:compute:(6) 4.010194] [s4u_test/INFO] Tremblay:compute task executed 0.0101942 +> [Fafard:compute:(5) 4.013107] [s4u_test/INFO] Fafard:compute task executed 0.0131068 +> [Fafard:master_:(1) 6.000000] [s4u_test/INFO] ## Test 1 (ended) +> [Fafard:master_:(1) 6.000000] [s4u_test/INFO] ## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment) +> [Fafard:master_:(1) 6.000000] [s4u_test/INFO] ### Put a VM on a PM, and put a task to the VM +> [VM0:compute:(7) 6.013107] [s4u_test/INFO] VM0:compute task executed 0.0131068 +> [Fafard:master_:(1) 8.000000] [s4u_test/INFO] ## Test 2 (ended) +> [Fafard:master_:(1) 8.000000] [s4u_test/INFO] ## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment) +> [Fafard:master_:(1) 8.000000] [s4u_test/INFO] ### Put a VM on a PM, and put a task to the PM +> [Fafard:compute:(8) 8.013107] [s4u_test/INFO] Fafard:compute task executed 0.0131068 +> [Fafard:master_:(1) 10.000000] [s4u_test/INFO] ## Test 3 (ended) +> [Fafard:master_:(1) 10.000000] [s4u_test/INFO] ## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1 +> [Fafard:master_:(1) 10.000000] [s4u_test/INFO] ### Put two VMs on a PM, and put a task to each VM +> [VM0:compute:(9) 10.026214] [s4u_test/INFO] VM0:compute task executed 0.0262137 +> [VM1:compute:(10) 10.026214] [s4u_test/INFO] VM1:compute task executed 0.0262137 +> [Fafard:master_:(1) 12.000000] [s4u_test/INFO] ### Put a VM on each PM, and put a task to each VM +> [VM1:compute:(12) 12.010194] [s4u_test/INFO] VM1:compute task executed 0.0101942 +> [VM0:compute:(11) 12.013107] [s4u_test/INFO] VM0:compute task executed 0.0131068 +> [Fafard:master_:(1) 14.000000] [s4u_test/INFO] ## Test 4 (ended) +> [Fafard:master_:(1) 14.000000] [s4u_test/INFO] ## Test 5 (started): Analyse network impact +> [Fafard:master_:(1) 14.000000] [s4u_test/INFO] ### Make a connection between PM0 and PM1 +> [Tremblay:comm_rx:(14) 14.158397] [s4u_test/INFO] Fafard:comm_tx to Tremblay:comm_rx => 0.158397 sec +> [Fafard:master_:(1) 19.000000] [s4u_test/INFO] ### Make two connection between PM0 and PM1 +> [Tremblay:comm_rx:(18) 19.291085] [s4u_test/INFO] Fafard:comm_tx to Tremblay:comm_rx => 0.291085 sec +> [Tremblay:comm_rx:(16) 19.291085] [s4u_test/INFO] Fafard:comm_tx to Tremblay:comm_rx => 0.291085 sec +> [Fafard:master_:(1) 24.000000] [s4u_test/INFO] ### Make a connection between PM0 and VM0@PM0 +> [VM0:comm_rx:(20) 24.002265] [s4u_test/INFO] Fafard:comm_tx to VM0:comm_rx => 0.00226529 sec +> [Fafard:master_:(1) 29.000000] [s4u_test/INFO] ### Make a connection between PM0 and VM0@PM1 +> [VM0:comm_rx:(22) 29.158397] [s4u_test/INFO] Fafard:comm_tx to VM0:comm_rx => 0.158397 sec +> [Fafard:master_:(1) 34.000000] [s4u_test/INFO] ### Make two connections between PM0 and VM0@PM1 +> [VM0:comm_rx:(26) 34.291085] [s4u_test/INFO] Fafard:comm_tx to VM0:comm_rx => 0.291085 sec +> [VM0:comm_rx:(24) 34.291085] [s4u_test/INFO] Fafard:comm_tx to VM0:comm_rx => 0.291085 sec +> [Fafard:master_:(1) 39.000000] [s4u_test/INFO] ### Make a connection between PM0 and VM0@PM1, and also make a connection between PM0 and PM1 +> [Tremblay:comm_rx:(30) 39.291085] [s4u_test/INFO] Fafard:comm_tx to Tremblay:comm_rx => 0.291085 sec +> [VM0:comm_rx:(28) 39.291085] [s4u_test/INFO] Fafard:comm_tx to VM0:comm_rx => 0.291085 sec +> [Fafard:master_:(1) 44.000000] [s4u_test/INFO] ### Make a connection between VM0@PM0 and PM1@PM1, and also make a connection between VM0@PM0 and VM1@PM1 +> [VM1:comm_rx:(34) 44.291085] [s4u_test/INFO] VM0:comm_tx to VM1:comm_rx => 0.291085 sec +> [VM1:comm_rx:(32) 44.291085] [s4u_test/INFO] VM0:comm_tx to VM1:comm_rx => 0.291085 sec +> [Fafard:master_:(1) 49.000000] [s4u_test/INFO] ## Test 5 (ended) +> [49.000000] [s4u_test/INFO] Simulation time 49 -- 2.20.1