Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
extend the example with heterogeneous parallel task
[simgrid.git] / examples / s4u / exec-ptask / s4u-exec-ptask.cpp
index a09f342..ef3bac1 100644 (file)
@@ -28,7 +28,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_energyptask, "Messages specific for this s4u ex
 static void runner()
 {
   /* Retrieve the list of all hosts as an array of hosts */
-  std::vector<simgrid::s4u::Host*> hosts = simgrid::s4u::Engine::getInstance()->getAllHosts();
+  std::vector<simgrid::s4u::Host*> hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
   int hosts_count = hosts.size();
 
   XBT_INFO("First, build a classical parallel task, with 1 Gflop to execute on each node, "
@@ -71,6 +71,12 @@ static void runner()
     computation_amounts[i] = 1e9; // 1 Gflop
   simgrid::s4u::this_actor::parallel_execute(hosts_count, hosts.data(), computation_amounts, nullptr /* no comm */);
 
+  XBT_INFO("Then, build a parallel task involving only heterogeneous computations and no communication");
+  computation_amounts = new double[hosts_count]();
+  for (int i               = 0; i < hosts_count; i++)
+    computation_amounts[i] = 5 * (i + 1) * 1e8; // 500Mflop, 1Gflop, 1.5Gflop
+  simgrid::s4u::this_actor::parallel_execute(hosts_count, hosts.data(), computation_amounts, nullptr /* no comm */);
+
   XBT_INFO("Then, build a parallel task with no computation nor communication (synchro only)");
   computation_amounts   = new double[hosts_count]();
   communication_amounts = new double[hosts_count * hosts_count]();
@@ -95,10 +101,10 @@ int main(int argc, char* argv[])
   if (argc == 3 && argv[2][2] == 'e')
     sg_host_energy_plugin_init();
 
-  e.loadPlatform(argv[1]);
+  e.load_platform(argv[1]);
 
   /* Pick a process, no matter which, from the platform file */
-  simgrid::s4u::Actor::createActor("test", simgrid::s4u::Host::by_name("MyHost1"), runner);
+  simgrid::s4u::Actor::create("test", simgrid::s4u::Host::by_name("MyHost1"), runner);
 
   e.run();
   XBT_INFO("Simulation done.");