Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Extend 1 unit test and add 1 other for multicore ptast exec. Both don't pass right...
authorMael Madon <mael.madon@irit.fr>
Fri, 17 Sep 2021 14:23:44 +0000 (16:23 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 24 Dec 2021 18:45:30 +0000 (19:45 +0100)
.gitignore
examples/cpp/CMakeLists.txt
examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.cpp [new file with mode: 0644]
examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.tesh [new file with mode: 0644]
examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore.cpp
examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore.tesh

index 03c3a44..a43677c 100644 (file)
@@ -196,6 +196,7 @@ examples/cpp/exec-dependent/s4u-exec-dependent
 examples/cpp/exec-dvfs/s4u-exec-dvfs
 examples/cpp/exec-ptask/s4u-exec-ptask
 examples/cpp/exec-ptask-multicore/s4u-exec-ptask-multicore
+examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency
 examples/cpp/exec-remote/s4u-exec-remote
 examples/cpp/exec-unassigned/s4u-exec-unassigned
 examples/cpp/exec-waitany/s4u-exec-waitany
index 0c1929a..5899286 100644 (file)
@@ -103,7 +103,7 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
                  engine-filtering engine-run-partial
                  exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
-                 exec-ptask-multicore exec-cpu-nonlinear exec-cpu-factors exec-failure
+                 exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure
                  maestro-set
                  mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-electric-fence mc-failing-assert
                  network-ns3 network-ns3-wifi network-wifi
diff --git a/examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.cpp b/examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.cpp
new file mode 100644 (file)
index 0000000..42797f1
--- /dev/null
@@ -0,0 +1,70 @@
+/* Copyright (c) 2017-2021. 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>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_ptask_multicore, "Messages specific for this s4u example");
+
+namespace sg4 = simgrid::s4u;
+
+static void runner()
+{
+  auto e = sg4::Engine::get_instance();
+  std::vector<double> comp(2, 1e9);
+  std::vector<double> comm(4, 0.0);
+  // Different hosts.
+  std::vector<sg4::Host*> hosts_diff = {e->host_by_name("MyHost1"), e->host_by_name("MyHost2")};
+  double start_time                  = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(hosts_diff, comp, comm);
+  XBT_INFO("Computed 2-core activity on two different hosts. Took %g s", e->get_clock() - start_time);
+
+  // Same host, multicore.
+  std::vector<sg4::Host*> multicore_host = {e->host_by_name("MyHost1"), e->host_by_name("MyHost1")};
+  start_time                             = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+  XBT_INFO("Computed 2-core activity on one 4-core host. Took %g s", e->get_clock() - start_time);
+
+  // Same host, using too many cores
+  std::vector<double> comp6(6, 1e9);
+  std::vector<double> comm6(36, 0.0);
+  std::vector<sg4::Host*> multicore_overload(6, e->host_by_name("MyHost1"));
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_overload, comp6, comm6);
+  XBT_INFO("Computed 6-core activity on a 4-core host. Took %g s", e->get_clock() - start_time);
+
+  // Same host, adding some communication
+  std::vector<double> comm2 = {0, 1E7, 1E7, 0};
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm2);
+  XBT_INFO("Computed 2-core activity on a 4-core host with some communication. Took %g s", e->get_clock() - start_time);
+
+  // See if the multicore execution continues to work after changing pstate
+  XBT_INFO("Switching machine multicore to pstate 1.");
+  e->host_by_name("MyHost1")->set_pstate(1);
+  XBT_INFO("Switching back to pstate 0.");
+  e->host_by_name("MyHost1")->set_pstate(0);
+
+  start_time                             = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+  XBT_INFO("Computed 2-core activity on one 4-core host. Took %g s", e->get_clock() - start_time);
+
+  start_time                  = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(hosts_diff, comp, comm);
+  XBT_INFO("Computed 2-core activity on two different hosts. Took %g s", e->get_clock() - start_time);
+}
+
+int main(int argc, char* argv[])
+{
+  sg4::Engine e(&argc, argv);
+
+  xbt_assert(argc == 2, "Usage: %s <platform file>", argv[0]);
+
+  e.load_platform(argv[1]);
+  sg4::Actor::create("test", sg4::Host::by_name("MyHost1"), runner);
+
+  e.run();
+  XBT_INFO("Simulation done.");
+  return 0;
+}
diff --git a/examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.tesh b/examples/cpp/exec-ptask-multicore-latency/s4u-exec-ptask-multicore-latency.tesh
new file mode 100644 (file)
index 0000000..6c28987
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-exec-ptask-multicore-latency ${platfdir}/energy_cluster.xml --cfg=host/model:ptask_L07 --log=no_loc "--log=root.fmt:[%10.6r]%e%m%n"
+> [  0.000000] Configuration change: Set 'host/model' to 'ptask_L07'
+> [  0.000000] Switching to the L07 model to handle parallel tasks.
+> [ 10.000000] Computed 2-core activity on two different hosts. Took 10 s
+> [ 20.000000] Computed 2-core activity on one 4-core host. Took 10 s
+> [ 35.000000] Computed 6-core activity on a 4-core host. Took 15 s
+> [ 40.000600] Computed 2-core activity on a 4-core host with some communication. Took 10.0006 s
+> [ 40.000600] Switching machine multicore to pstate 1.
+> [ 40.000600] Switching back to pstate 0.
+> [ 50.000600] Computed 2-core activity on one 4-core host. Took 10 s
+> [ 60.000600] Computed 2-core activity on two different hosts. Took 10 s
+> [ 60.000600] Simulation done.
\ No newline at end of file
index 1aeceb7..1692dab 100644 (file)
@@ -30,7 +30,7 @@ static void runner()
   std::vector<sg4::Host*> multicore_host = {e->host_by_name("MyHost1"), e->host_by_name("MyHost1")};
   start_time                             = sg4::Engine::get_clock();
   sg4::this_actor::parallel_execute(multicore_host, comp, comm);
-  XBT_INFO("Computed 2-core activity on one 2-core host. Took %g s", e->get_clock() - start_time);
+  XBT_INFO("Computed 2-core activity on one 4-core host. Took %g s", e->get_clock() - start_time);
 
   // Same host, using too many cores
   std::vector<double> comp6(6, 1e9);
@@ -38,7 +38,48 @@ static void runner()
   std::vector<sg4::Host*> multicore_overload(6, e->host_by_name("MyHost1"));
   start_time = sg4::Engine::get_clock();
   sg4::this_actor::parallel_execute(multicore_overload, comp6, comm6);
-  XBT_INFO("Computed 6-core activity of a 4-core host. Took %g s", e->get_clock() - start_time);
+  XBT_INFO("Computed 6-core activity on a 4-core host. Took %g s", e->get_clock() - start_time);
+
+  // Same host, adding some communication
+  std::vector<double> comm2 = {0, 1E7, 1E7, 0};
+  start_time                = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm2);
+  XBT_INFO("Computed 2-core activity on a 4-core host with some communication. Took %g s", e->get_clock() - start_time);
+
+  // See if the multicore execution continues to work after changing pstate
+  XBT_INFO("Switching machine multicore to pstate 1.");
+  e->host_by_name("MyHost1")->set_pstate(1);
+  XBT_INFO("Switching back to pstate 0.");
+  e->host_by_name("MyHost1")->set_pstate(0);
+
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+  XBT_INFO("Computed 2-core activity on one 4-core host. Took %g s", e->get_clock() - start_time);
+
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(hosts_diff, comp, comm);
+  XBT_INFO("Computed 2-core activity on two different hosts. Took %g s", e->get_clock() - start_time);
+
+  // Add a background task and change ptask on the fly
+  auto MyHost1                          = e->host_by_name("MyHost1");
+  simgrid::s4u::ExecPtr background_task = MyHost1->exec_async(5e9);
+  background_task->start();
+  XBT_INFO("Start a 1-core background task on the 4-core host.");
+
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+  XBT_INFO("Computed 2-core activity on the 4-core host. Took %g s", e->get_clock() - start_time);
+  XBT_INFO("Remaining amount of work for the background task: %.0f%%",
+           100 * background_task->get_remaining_ratio());
+
+  XBT_INFO("Switching to pstate 1 while background task is still running.");
+  MyHost1->set_pstate(1);
+  start_time = sg4::Engine::get_clock();
+  sg4::this_actor::parallel_execute(multicore_host, comp, comm);
+  XBT_INFO("Computed again the same 2-core activity on it. Took %g s", e->get_clock() - start_time);
+
+  background_task->wait();
+  XBT_INFO("The background task has ended.");
 }
 
 int main(int argc, char* argv[])
index 2dadba2..9d3172a 100644 (file)
@@ -7,4 +7,10 @@ $ ${bindir:=.}/s4u-exec-ptask-multicore ${platfdir}/energy_platform.xml --cfg=ho
 > [ 30.000000] Computed 2-core activity one 1-core host. Took 20 s
 > [ 40.000000] Computed 2-core activity on one 2-core host. Took 10 s
 > [ 55.000000] Computed 6-core activity of a 4-core host. Took 15 s
+> [ 65.000000] Computed 2-core activity on a 4-core host with some communication. Took 10 s
+> [ 65.000000] Switching machine multicore to pstate 1.
+> [ 65.000000] Switching back to pstate 0.
+> [ 75.000000] Computed 2-core activity on one 4-core host. Took 10 s
+> [ 85.000000] Computed 2-core activity on two different hosts. Took 10 s
+> [ 85.000000] Simulation done.
 > [ 55.000000] Simulation done.
\ No newline at end of file