Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix test s4u-exec-ptask: task needs to be canceled after timeout.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 1 May 2021 22:20:20 +0000 (00:20 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 3 May 2021 14:46:14 +0000 (16:46 +0200)
examples/cpp/exec-ptask/s4u-exec-ptask.cpp
examples/cpp/exec-ptask/s4u-exec-ptask.tesh

index 30e3cc0..a16c75f 100644 (file)
@@ -51,12 +51,14 @@ static void runner()
     for (size_t j = i + 1; j < hosts_count; j++)
       communication_amounts[i * hosts_count + j] = 1e7; // 10 MB
 
+  simgrid::s4u::ExecPtr activity =
+      simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   try {
-    simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts)
-        ->wait_for(10.0 /* timeout (in seconds)*/);
+    activity->wait_for(10.0 /* timeout (in seconds)*/);
     xbt_die("Woops, this did not timeout as expected... Please report that bug.");
   } catch (const simgrid::TimeoutException&) {
     XBT_INFO("Caught the expected timeout exception.");
+    activity->cancel();
   }
 
   /* ------[ test 3 ]----------------- */
@@ -75,8 +77,7 @@ static void runner()
   XBT_INFO("Then, Monitor the execution of a parallel activity");
   computation_amounts.assign(hosts_count, 1e6 /*1Mflop*/);
   communication_amounts = {0, 1e6, 0, 0, 0, 1e6, 1e6, 0, 0};
-  simgrid::s4u::ExecPtr activity =
-      simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
+  activity              = simgrid::s4u::this_actor::exec_init(hosts, computation_amounts, communication_amounts);
   activity->start();
 
   while (not activity->test()) {
index 3061414..817bdf5 100644 (file)
@@ -11,11 +11,11 @@ $ ${bindir:=.}/s4u-exec-ptask ${platfdir}/energy_platform.xml --cfg=host/model:p
 > [300.000000] (0:maestro@) UNCAT HOST [0.000000 - 300.000000] MyHost3 speed_used 3333333.333333
 > [300.000000] (0:maestro@) UNCAT LINK [0.000000 - 300.000000] bus bandwidth_used 100000.000000
 > [300.000000] (1:test@MyHost1) We can do the same with a timeout of 10 seconds enabled.
+> [310.000000] (1:test@MyHost1) Caught the expected timeout exception.
 > [310.000000] (0:maestro@) UNCAT HOST [300.000000 - 310.000000] MyHost1 speed_used 3333333.333333
 > [310.000000] (0:maestro@) UNCAT HOST [300.000000 - 310.000000] MyHost2 speed_used 3333333.333333
 > [310.000000] (0:maestro@) UNCAT HOST [300.000000 - 310.000000] MyHost3 speed_used 3333333.333333
 > [310.000000] (0:maestro@) UNCAT LINK [300.000000 - 310.000000] bus bandwidth_used 100000.000000
-> [310.000000] (1:test@MyHost1) Caught the expected timeout exception.
 > [310.000000] (1:test@MyHost1) Then, build a parallel activity involving only computations (of different amounts) and no communication
 > [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost1 speed_used 30000000.000000
 > [320.000000] (0:maestro@) UNCAT HOST [310.000000 - 320.000000] MyHost2 speed_used 60000000.000000