Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add test for multicore speed/state file
authorBruno Donassolo <bruno.donassolo@inria.fr>
Fri, 6 Aug 2021 18:36:27 +0000 (20:36 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Mon, 9 Aug 2021 08:46:53 +0000 (10:46 +0200)
MANIFEST.in
src/surf/cpu_cas01.cpp
teshsuite/s4u/CMakeLists.txt
teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp [new file with mode: 0644]
teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.tesh [new file with mode: 0644]

index da8b7be..fb0bf5c 100644 (file)
@@ -733,6 +733,8 @@ include teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
 include teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
 include teshsuite/s4u/evaluate-get-route-time/evaluate-get-route-time.cpp
 include teshsuite/s4u/evaluate-parse-time/evaluate-parse-time.cpp
+include teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp
+include teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.tesh
 include teshsuite/s4u/host-on-off-actors/host-on-off-actors.cpp
 include teshsuite/s4u/host-on-off-actors/host-on-off-actors.tesh
 include teshsuite/s4u/host-on-off-recv/host-on-off-recv.cpp
index 8ac6a36..88aab66 100644 (file)
@@ -107,17 +107,11 @@ void CpuCas01::on_speed_change()
 void CpuCas01::apply_event(profile::Event* event, double value)
 {
   if (event == speed_.event) {
-    /* TODO (Hypervisor): do the same thing for constraint_core[i] */
-    xbt_assert(get_core_count() == 1, "FIXME: add speed scaling code also for constraint_core[i]");
-
     speed_.scale = value;
     on_speed_change();
 
     tmgr_trace_event_unref(&speed_.event);
   } else if (event == state_event_) {
-    /* TODO (Hypervisor): do the same thing for constraint_core[i] */
-    xbt_assert(get_core_count() == 1, "FIXME: add state change code also for constraint_core[i]");
-
     if (value > 0) {
       if (not is_on()) {
         XBT_VERB("Restart actors on host %s", get_iface()->get_cname());
index 64c74c7..1a4c45e 100644 (file)
@@ -3,7 +3,7 @@ foreach(x actor actor-autorestart actor-suspend
         comm-get-sender comm-pt2pt wait-all-for wait-any-for
         cloud-interrupt-migration cloud-two-execs
         concurrent_rw 
-        host-on-off host-on-off-actors host-on-off-recv io-set-bw
+        host-on-off host-on-off-actors host-on-off-recv host-multicore-speed-file io-set-bw
         basic-link-test basic-parsing-test evaluate-get-route-time evaluate-parse-time is-router
         storage_client_server listen_async pid
         trace-integration
@@ -34,7 +34,7 @@ foreach(x actor actor-autorestart actor-suspend
   ADD_TESH_FACTORIES(tesh-s4u-${x} "*" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
 endforeach()
 
-foreach(x basic-link-test basic-parsing-test host-on-off host-on-off-actors host-on-off-recv is-router listen_async 
+foreach(x basic-link-test basic-parsing-test host-on-off host-on-off-actors host-on-off-recv host-multicore-speed-file is-router listen_async 
                pid storage_client_server trace-integration seal-platform issue71)
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
   ADD_TESH(tesh-s4u-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
diff --git a/teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp b/teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp
new file mode 100644 (file)
index 0000000..56d133e
--- /dev/null
@@ -0,0 +1,113 @@
+/* Copyright (c) 2010-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/kernel/ProfileBuilder.hpp"
+#include "simgrid/s4u.hpp"
+
+namespace sg4 = simgrid::s4u;
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void run_activities(int n, double size, double rate = -1.0)
+{
+  double start = sg4::Engine::get_clock();
+  std::vector<sg4::ExecPtr> activities;
+
+  // initialize exec activities
+  for (int i = 0; i < n; i++) {
+    sg4::ExecPtr op = sg4::this_actor::exec_init(size);
+    if (rate != -1.0)
+      op->set_bound(rate);
+    op->start();
+    activities.emplace_back(op);
+  }
+
+  // waiting for executions
+  for (const auto& act : activities)
+    act->wait();
+  XBT_INFO("Finished running 2 activities, elapsed %lf", sg4::Engine::get_clock() - start);
+}
+
+static void worker()
+{
+  XBT_INFO("Running 1 tasks (1.5e6) in a 2*(1e6) speed host. Should take 2s (1 (limited by core) + 1 (limited by speed "
+           "file)");
+  run_activities(1, 1.5e6);
+
+  XBT_INFO("Running 1 tasks (.8e6) in a 2*(1e6) speed host with limited rate (.4e6). Should take 2s (limited by rate)");
+  run_activities(1, .8e6, .4e6);
+
+  XBT_INFO("Running 1 tasks (1.1e6) in a 2*(1e6) speed host with limited rate (.6e6). Should take 2s (.6 limited by "
+           "rate + .5 limited by speed file)");
+  run_activities(1, 1.1e6, .6e6);
+
+  XBT_INFO("Running 2 tasks (1e6) in a 2*(1e6) speed host. Should take 1s");
+  run_activities(2, 1e6);
+
+  XBT_INFO("Running 2 tasks (.5e6) in a .5*2*(1e6) speed host. Should take 1s");
+  run_activities(2, .5e6);
+
+  XBT_INFO("Running 2 tasks (1.1e6) with limited rate (.6e6). Should take 2s (0.6 limited by rate + 0.5 limited by "
+           "speed file)");
+  run_activities(2, 1.1e6, .6e6);
+
+  XBT_INFO("Running 2 tasks (.8e6) with limited rate (.4e6). Should take 2s (limited by rate)");
+  run_activities(2, .8e6, .4e6);
+
+  XBT_INFO("I'm done. See you!");
+}
+
+static void failed_worker()
+{
+  XBT_INFO("Running a 2 tasks: a small .5e6 and a big 2e6.");
+  sg4::ExecPtr ok   = sg4::this_actor::exec_init(.5e6);
+  sg4::ExecPtr fail = sg4::this_actor::exec_init(2e6);
+  ok->wait();
+  XBT_INFO("Finished the small task");
+  try {
+    XBT_INFO("Waiting big task to finish");
+    fail->wait();
+  } catch (simgrid::ForcefulKillException&) {
+    XBT_INFO("Unable to finish big task, host went down");
+  }
+}
+
+int main(int argc, char* argv[])
+{
+  sg4::Engine e(&argc, argv);
+
+  /* speed and state file description */
+  const char* erin_state_file  = R"(
+0 1
+1 0
+50 1
+100 1
+)";
+  const char* carol_speed_file = R"(
+0 1.0
+1 0.5
+)";
+  /* simple platform containing 1 host and 2 disk */
+  auto* zone = sg4::create_full_zone("red");
+  zone->create_host("erin", 1e6)
+      ->set_core_count(2)
+      ->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("erin_state", erin_state_file, 0))
+      ->seal();
+  zone->create_host("carol", 1e6)
+      ->set_core_count(2)
+      ->set_speed_profile(simgrid::kernel::profile::ProfileBuilder::from_string("carol_speed", carol_speed_file, 1))
+      ->seal();
+  zone->seal();
+
+  sg4::Actor::create("carol", simgrid::s4u::Host::by_name("carol"), worker);
+  sg4::Actor::create("erin", simgrid::s4u::Host::by_name("erin"), failed_worker)->set_auto_restart(true);
+
+  e.run();
+
+  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+
+  return 0;
+}
diff --git a/teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.tesh b/teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.tesh
new file mode 100644 (file)
index 0000000..f6596d3
--- /dev/null
@@ -0,0 +1,23 @@
+
+$ ./host-multicore-speed-file
+> [carol:carol:(1) 0.000000] [s4u_test/INFO] Running 1 tasks (1.5e6) in a 2*(1e6) speed host. Should take 2s (1 (limited by core) + 1 (limited by speed file)
+> [erin:erin:(2) 0.000000] [s4u_test/INFO] Running a 2 tasks: a small .5e6 and a big 2e6.
+> [erin:erin:(3) 0.000000] [s4u_test/INFO] Running a 2 tasks: a small .5e6 and a big 2e6.
+> [erin:erin:(3) 0.500000] [s4u_test/INFO] Finished the small task
+> [erin:erin:(3) 0.500000] [s4u_test/INFO] Waiting big task to finish
+> [erin:erin:(3) 1.000000] [s4u_test/INFO] Unable to finish big task, host went down
+> [carol:carol:(1) 2.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 2.000000
+> [carol:carol:(1) 2.000000] [s4u_test/INFO] Running 1 tasks (.8e6) in a 2*(1e6) speed host with limited rate (.4e6). Should take 2s (limited by rate)
+> [carol:carol:(1) 4.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 2.000000
+> [carol:carol:(1) 4.000000] [s4u_test/INFO] Running 1 tasks (1.1e6) in a 2*(1e6) speed host with limited rate (.6e6). Should take 2s (.6 limited by rate + .5 limited by speed file)
+> [carol:carol:(1) 6.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 2.000000
+> [carol:carol:(1) 6.000000] [s4u_test/INFO] Running 2 tasks (1e6) in a 2*(1e6) speed host. Should take 1s
+> [carol:carol:(1) 7.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 1.000000
+> [carol:carol:(1) 7.000000] [s4u_test/INFO] Running 2 tasks (.5e6) in a .5*2*(1e6) speed host. Should take 1s
+> [carol:carol:(1) 8.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 1.000000
+> [carol:carol:(1) 8.000000] [s4u_test/INFO] Running 2 tasks (1.1e6) with limited rate (.6e6). Should take 2s (0.6 limited by rate + 0.5 limited by speed file)
+> [carol:carol:(1) 10.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 2.000000
+> [carol:carol:(1) 10.000000] [s4u_test/INFO] Running 2 tasks (.8e6) with limited rate (.4e6). Should take 2s (limited by rate)
+> [carol:carol:(1) 12.000000] [s4u_test/INFO] Finished running 2 activities, elapsed 2.000000
+> [carol:carol:(1) 12.000000] [s4u_test/INFO] I'm done. See you!
+> [12.000000] [s4u_test/INFO] Simulation time 12