-/* Copyright (c) 2007-2019. The SimGrid Team.
+/* Copyright (c) 2007-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this msg example");
const int FAIL_ON_ERROR = 0;
-const int flop_amount = 100000000;
+const int flop_amount = 100000000; // 100Mf, so that computing this on a 1Gf core takes exactly 0.1s
int failed_test = 0;
double energy = 0;
static void run_test_process(const std::string& name, simgrid::s4u::Host* location, int size)
{
std::vector<std::string> arg = {std::to_string(size)};
- simgrid::s4u::Actor::create(std::move(name), location, computation_fun, arg);
+ simgrid::s4u::Actor::create(name, location, computation_fun, arg);
}
static void test_energy_consumption(const std::string& name, int nb_cores)
} else if (chooser == "( [o]1 [ ]1 )2") {
XBT_INFO("### Put two VMs on a PM, and put a task to one VM");
- vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
- simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2, 1);
run_test_process("( [X]1 [ ]1 )2", vm0, flop_amount);
simgrid::s4u::this_actor::sleep_for(2);
test_energy_consumption(chooser,1);
} else if (chooser == "( [o]1 [o]1 )2") {
XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
- vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
- simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2, 1);
run_test_process("( [X]1 [x]1 )2", vm0, flop_amount);
run_test_process("( [x]1 [X]1 )2", vm1, flop_amount);
simgrid::s4u::this_actor::sleep_for(2);
} else if (chooser == "( [o]1 [o]1 [ ]1 )2") {
XBT_INFO("### Put three VMs on a PM, and put a task to two VMs");
- vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
- simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
- simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2, 1);
+ auto* vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2, 1);
run_test_process("( [X]1 [x]1 [ ]1 )2", vm0, flop_amount);
run_test_process("( [x]1 [X]1 [ ]1 )2", vm1, flop_amount);
simgrid::s4u::this_actor::sleep_for(2);
} else if (chooser == "( [o]1 [o]1 [o]1 )2") {
XBT_INFO("### Put three VMs on a PM, and put a task to each VM");
- vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2,1);
- simgrid::s4u::VirtualMachine *vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2,1);
- simgrid::s4u::VirtualMachine *vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2,1);
+ vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 1);
+ auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm2, 1);
+ auto* vm2 = new simgrid::s4u::VirtualMachine("VM2", pm2, 1);
run_test_process("( [X]1 [o]1 [o]1 )2", vm0, flop_amount * 2 / 3);
run_test_process("( [o]1 [X]1 [o]1 )2", vm1, flop_amount * 2 / 3);
run_test_process("( [o]1 [o]1 [X]1 )2", vm2, flop_amount * 2 / 3);
XBT_INFO("### Put a VM on a PM, put one task to the PM and three tasks to the VM");
vm0 = new simgrid::s4u::VirtualMachine("VM0", pm2, 2);
run_test_process("( [ooo]2 X )2", pm2, flop_amount * 2 / 3);
- run_test_process("( [Xoo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
- run_test_process("( [oXo]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
- run_test_process("( [ooX]2 o )2", vm0, flop_amount * (2. / 3 * 2) / 3); // VM_share/3
+ run_test_process("( [Xoo]2 o )2", vm0, (flop_amount * 4 / 3) / 3); // VM_share/3
+ run_test_process("( [oXo]2 o )2", vm0, (flop_amount * 4 / 3) / 3); // VM_share/3
+ run_test_process("( [ooX]2 o )2", vm0, (flop_amount * 4 / 3) / 3); // VM_share/3
simgrid::s4u::this_actor::sleep_for(2);
test_energy_consumption(chooser,2);
vm0->destroy();
} else if (chooser == "( [ooo]2 ooo )4") {
XBT_INFO("### Put a VM on a PM, and put three tasks to the PM and three tasks to the VM");
vm0 = new simgrid::s4u::VirtualMachine("VM0", pm4, 2);
- run_test_process("( [Xoo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3); // The VM has 8/5 of the PM
- run_test_process("( [oXo]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
- run_test_process("( [ooX]2 ooo )4", vm0, flop_amount * (8. / 5) * 1 / 3);
+ run_test_process("( [Xoo]2 ooo )4", vm0, (flop_amount * 8 / 5) / 3); // The VM has 8/5 of the PM
+ run_test_process("( [oXo]2 ooo )4", vm0, (flop_amount * 8 / 5) / 3);
+ run_test_process("( [ooX]2 ooo )4", vm0, (flop_amount * 8 / 5) / 3);
run_test_process("( [ooo]2 Xoo )4", pm4, flop_amount * 4 / 5);
run_test_process("( [ooo]2 oXo )4", pm4, flop_amount * 4 / 5);