Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless std::move.
[simgrid.git] / teshsuite / s4u / cloud-sharing / cloud-sharing.cpp
index ec01f8c..5d86a64 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
@@ -12,7 +12,7 @@
 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;
@@ -39,13 +39,13 @@ static int computation_fun(std::vector<std::string> argv)
   return 0;
 }
 
-static void run_test_process(std::string name, simgrid::s4u::Host *location, int size)
+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(name, location, computation_fun, arg);
 }
 
-static void test_energy_consumption(std::string name, int nb_cores)
+static void test_energy_consumption(const std::string& name, int nb_cores)
 {
   double new_energy = 0;
   
@@ -67,7 +67,7 @@ static void test_energy_consumption(std::string name, int nb_cores)
   }
 }
 
-static void run_test(std::string chooser)
+static void run_test(const std::string& chooser)
 {
   simgrid::s4u::Host *pm0 = simgrid::s4u::Host::by_name("node-0.1core.org");
   simgrid::s4u::Host *pm1 = simgrid::s4u::Host::by_name("node-1.1core.org");
@@ -206,8 +206,8 @@ static void run_test(std::string chooser)
 
   } 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);
@@ -216,8 +216,8 @@ static void run_test(std::string chooser)
 
   } 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);
@@ -227,9 +227,9 @@ static void run_test(std::string chooser)
 
   } 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);
@@ -240,9 +240,9 @@ static void run_test(std::string chooser)
 
   } 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);
@@ -310,9 +310,9 @@ static void run_test(std::string chooser)
     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();
@@ -480,9 +480,9 @@ static void run_test(std::string chooser)
   } 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);