Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate the C API of parallel_execute
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 27 Oct 2018 14:31:49 +0000 (16:31 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 4 Nov 2018 03:31:33 +0000 (04:31 +0100)
include/simgrid/s4u/Actor.hpp
src/plugins/file_system/s4u_FileSystem.cpp
src/s4u/s4u_Actor.cpp
src/smpi/plugins/sampi_loadbalancer.cpp

index 098c8b9..926cefb 100644 (file)
@@ -475,9 +475,11 @@ XBT_PUBLIC void parallel_execute(std::vector<s4u::Host*> hosts, std::vector<doub
                                  std::vector<double> bytes_amounts, double timeout);
 
 #ifndef DOXYGEN
-XBT_PUBLIC void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount);
-XBT_PUBLIC void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount,
-                                 double timeout);
+XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
+    void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount);
+XBT_ATTRIB_DEPRECATED_v325("Please use std::vectors as parameters") XBT_PUBLIC
+    void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount,
+                          double timeout);
 #endif
 
 XBT_PUBLIC ExecPtr exec_init(double flops_amounts);
index e65a763..35e539c 100644 (file)
@@ -105,11 +105,11 @@ sg_size_t File::read(sg_size_t size)
   if (strcmp(host->get_cname(), Host::current()->get_cname())) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), read_size);
-    Host* m_host_list[]  = {Host::current(), host};
-    double* flops_amount = new double[2]{0, 0};
-    double* bytes_amount = new double[4]{0, 0, static_cast<double>(read_size), 0};
+    std::vector<Host*> m_host_list   = {Host::current(), host};
+    std::vector<double> flops_amount = {0., 0.};
+    std::vector<double> bytes_amount = {0., 0., static_cast<double>(read_size), 0.};
 
-    this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+    this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
   }
 
   return read_size;
@@ -131,11 +131,11 @@ sg_size_t File::write(sg_size_t size)
   if (strcmp(host->get_cname(), Host::current()->get_cname())) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
     XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
-    Host* m_host_list[]  = {Host::current(), host};
-    double* flops_amount = new double[2]{0, 0};
-    double* bytes_amount = new double[4]{0, static_cast<double>(size), 0, 0};
+    std::vector<Host*> m_host_list   = {Host::current(), host};
+    std::vector<double> flops_amount = {0, 0};
+    std::vector<double> bytes_amount = {0, static_cast<double>(size), 0, 0};
 
-    this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+    this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
   }
 
   XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", get_path(), local_storage_->get_cname(), size, size_);
@@ -264,11 +264,11 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
 
   XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
             storage_dest->get_host()->get_cname());
-  Host* m_host_list[]     = {src_host, dst_host};
-  double* flops_amount    = new double[2]{0, 0};
-  double* bytes_amount    = new double[4]{0, static_cast<double>(read_size), 0, 0};
+  std::vector<Host*> m_host_list   = {src_host, dst_host};
+  std::vector<double> flops_amount = {0, 0};
+  std::vector<double> bytes_amount = {0, static_cast<double>(read_size), 0, 0};
 
-  this_actor::parallel_execute(2, m_host_list, flops_amount, bytes_amount);
+  this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount);
 
   /* Create file on remote host, write it and close it */
   File* fd = new File(fullpath, dst_host, nullptr);
index 56d2827..506841b 100644 (file)
@@ -318,6 +318,7 @@ void parallel_execute(std::vector<s4u::Host*> hosts, std::vector<double> flops_a
   simcall_execution_wait(s);
 }
 
+// deprecated
 void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount, double* bytes_amount, double timeout)
 {
   smx_activity_t s =
@@ -327,9 +328,14 @@ void parallel_execute(int host_nb, s4u::Host** host_list, double* flops_amount,
   delete[] bytes_amount;
 }
 
+// deprecated
 void parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount)
 {
-  parallel_execute(host_nb, host_list, flops_amount, bytes_amount, /* timeout */ -1);
+  smx_activity_t s = simcall_execution_parallel_start("", host_nb, host_list, flops_amount, bytes_amount,
+                                                      /* rate */ -1, /*timeout*/ -1);
+  simcall_execution_wait(s);
+  delete[] flops_amount;
+  delete[] bytes_amount;
 }
 
 ExecPtr exec_init(double flops_amount)
index 375a624..a49f1c9 100644 (file)
@@ -80,14 +80,13 @@ public:
 
     migrate_to_host = lb.get_mapping(simgrid::s4u::Actor::self());
     if (cur_host != migrate_to_host) { // Origin and dest are not the same -> migrate
-      sg_host_t migration_hosts[2] = {cur_host, migrate_to_host};
-      // Changing this to double[2] ... will cause trouble with parallel_execute, because that fct is trying to call free().
-      double* comp_amount  = new double[2]{0, 0};
-      double* comm_amount  = new double[4]{0, /*must not be 0*/std::max(args.memory_consumption, 1.0), 0, 0};
+      std::vector<simgrid::s4u::Host*> migration_hosts = {cur_host, migrate_to_host};
+      std::vector<double> comp_amount                  = {0, 0};
+      std::vector<double> comm_amount = {0, /*must not be 0*/ std::max(args.memory_consumption, 1.0), 0, 0};
 
       xbt_os_timer_t timer = smpi_process()->timer();
       xbt_os_threadtimer_start(timer);
-      simgrid::s4u::this_actor::parallel_execute(2, migration_hosts, comp_amount, comm_amount, -1.0);
+      simgrid::s4u::this_actor::parallel_execute(migration_hosts, comp_amount, comm_amount, -1.0);
       xbt_os_threadtimer_stop(timer);
       smpi_execute(xbt_os_timer_elapsed(timer));