Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "kill one simcall, simplify another"
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 12:05:57 +0000 (14:05 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 21 Jul 2017 12:05:57 +0000 (14:05 +0200)
This reverts commit 8639295f6bedeb3c9e1a60a1056925c4fe892fa4.

13 files changed:
include/simgrid/simix.h
src/msg/msg_gos.cpp
src/s4u/s4u_mutex.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/simix/smx_synchro.cpp
src/xbt/xbt_os_synchro.cpp

index d28bf42..021f9f5 100644 (file)
@@ -191,7 +191,7 @@ XBT_PUBLIC(smx_activity_t) simcall_execution_start(const char *name,
                                                 double priority, double bound);
 XBT_PUBLIC(smx_activity_t)
 simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount,
-                                 double* bytes_amount, double rate, double timeout);
+                                 double* bytes_amount, double amount, double rate, double timeout);
 XBT_PUBLIC(void) simcall_execution_cancel(smx_activity_t execution);
 XBT_PUBLIC(void) simcall_execution_set_priority(smx_activity_t execution, double priority);
 XBT_PUBLIC(void) simcall_execution_set_bound(smx_activity_t execution, double bound);
@@ -268,6 +268,7 @@ XBT_PUBLIC(smx_mutex_t) SIMIX_mutex_ref(smx_mutex_t mutex);
 XBT_PUBLIC(void) SIMIX_mutex_unref(smx_mutex_t mutex);
 XBT_PUBLIC(void) simcall_mutex_lock(smx_mutex_t mutex);
 XBT_PUBLIC(int) simcall_mutex_trylock(smx_mutex_t mutex);
+XBT_PUBLIC(void) simcall_mutex_unlock(smx_mutex_t mutex);
 
 XBT_PUBLIC(smx_cond_t) simcall_cond_init();
 XBT_PUBLIC(void) SIMIX_cond_unref(smx_cond_t cond);
index feb9577..53ea92d 100644 (file)
@@ -70,7 +70,7 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo
       simdata->compute =
           boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(simcall_execution_parallel_start(
               task->name, simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount,
-              simdata->bytes_parallel_amount, -1.0, timeout));
+              simdata->bytes_parallel_amount, 1.0, -1.0, timeout));
       XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get());
     } else {
       simdata->compute = boost::static_pointer_cast<simgrid::kernel::activity::ExecImpl>(
index 9e0e5d5..5e63f24 100644 (file)
@@ -24,8 +24,7 @@ void Mutex::lock()
  */
 void Mutex::unlock()
 {
-  smx_actor_t self = SIMIX_process_self();
-  simgrid::simix::kernelImmediate([this, self] { return mutex_->unlock(self); });
+  simcall_mutex_unlock(mutex_);
 }
 
 /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
index db526d4..424d851 100644 (file)
@@ -84,7 +84,8 @@ smx_activity_t simcall_execution_start(const char *name,
  * \return A new SIMIX execution synchronization
  */
 smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list,
-                                                double* flops_amount, double* bytes_amount, double rate, double timeout)
+                                                double* flops_amount, double* bytes_amount, double amount, double rate,
+                                                double timeout)
 {
   /* checking for infinite values */
   for (int i = 0 ; i < host_nb ; ++i) {
@@ -97,9 +98,11 @@ smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, s
     }
   }
 
+  xbt_assert(std::isfinite(amount), "amount is not finite!");
   xbt_assert(std::isfinite(rate), "rate is not finite!");
 
-  return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout);
+  return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate,
+                                               timeout);
 }
 
 /**
@@ -472,6 +475,15 @@ int simcall_mutex_trylock(smx_mutex_t mutex)
   return simcall_BODY_mutex_trylock(mutex);
 }
 
+/**
+ * \ingroup simix_synchro_management
+ *
+ */
+void simcall_mutex_unlock(smx_mutex_t mutex)
+{
+  simcall_BODY_mutex_unlock(mutex);
+}
+
 /**
  * \ingroup simix_synchro_management
  *
index a7f4b16..00ee149 100644 (file)
@@ -251,30 +251,42 @@ static inline void simcall_execution_parallel_start__set__bytes_amount(smx_simca
 {
   simgrid::simix::marshal<double*>(simcall->args[4], arg);
 }
-static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t simcall)
+static inline double simcall_execution_parallel_start__get__amount(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<double>(simcall->args[5]);
 }
-static inline double simcall_execution_parallel_start__getraw__rate(smx_simcall_t simcall)
+static inline double simcall_execution_parallel_start__getraw__amount(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<double>(simcall->args[5]);
 }
-static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg)
+static inline void simcall_execution_parallel_start__set__amount(smx_simcall_t simcall, double arg)
 {
   simgrid::simix::marshal<double>(simcall->args[5], arg);
 }
-static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall)
+static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<double>(simcall->args[6]);
 }
-static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall)
+static inline double simcall_execution_parallel_start__getraw__rate(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal_raw<double>(simcall->args[6]);
 }
-static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg)
+static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg)
 {
   simgrid::simix::marshal<double>(simcall->args[6], arg);
 }
+static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<double>(simcall->args[7]);
+}
+static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<double>(simcall->args[7]);
+}
+static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg)
+{
+  simgrid::simix::marshal<double>(simcall->args[7], arg);
+}
 static inline boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 simcall_execution_parallel_start__get__result(smx_simcall_t simcall)
 {
@@ -1147,6 +1159,19 @@ static inline void simcall_mutex_trylock__set__result(smx_simcall_t simcall, int
     simgrid::simix::marshal<int>(simcall->result, result);
 }
 
+static inline smx_mutex_t simcall_mutex_unlock__get__mutex(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[0]);
+}
+static inline smx_mutex_t simcall_mutex_unlock__getraw__mutex(smx_simcall_t simcall)
+{
+  return simgrid::simix::unmarshal_raw<smx_mutex_t>(simcall->args[0]);
+}
+static inline void simcall_mutex_unlock__set__mutex(smx_simcall_t simcall, smx_mutex_t arg)
+{
+  simgrid::simix::marshal<smx_mutex_t>(simcall->args[0], arg);
+}
+
 static inline smx_cond_t simcall_cond_init__get__result(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<smx_cond_t>(simcall->result);
@@ -1484,6 +1509,7 @@ XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall,
                                               size_t count);
 XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex);
+XBT_PRIVATE void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex);
 XBT_PRIVATE void simcall_HANDLER_cond_wait(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex);
 XBT_PRIVATE void simcall_HANDLER_cond_wait_timeout(smx_simcall_t simcall, smx_cond_t cond, smx_mutex_t mutex, double timeout);
 XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
index 0126796..ba18225 100644 (file)
@@ -83,14 +83,13 @@ inline static int simcall_BODY_process_sleep(double duration) {
 
   inline static boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
   simcall_BODY_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount,
-                                        double* bytes_amount, double rate, double timeout)
+                                        double* bytes_amount, double amount, double rate, double timeout)
   {
     /* Go to that function to follow the code flow through the simcall barrier */
-    if (0)
-      SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout);
+    if (0) SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate, timeout);
     return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>, const char*, int, sg_host_t*, double*,
-                   double*, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount,
-                                            bytes_amount, rate, timeout);
+                   double*, double, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list,
+                                                    flops_amount, bytes_amount, amount, rate, timeout);
   }
 
   inline static void
@@ -225,6 +224,12 @@ inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex) {
     return simcall<int, smx_mutex_t>(SIMCALL_MUTEX_TRYLOCK, mutex);
   }
 
+inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex) {
+    /* Go to that function to follow the code flow through the simcall barrier */
+    if (0) simcall_HANDLER_mutex_unlock(&SIMIX_process_self()->simcall, mutex);
+    return simcall<void, smx_mutex_t>(SIMCALL_MUTEX_UNLOCK, mutex);
+  }
+
 inline static smx_cond_t simcall_BODY_cond_init() {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) SIMIX_cond_init();
index be3e298..8c5c937 100644 (file)
@@ -43,6 +43,7 @@ typedef enum {
   SIMCALL_COMM_TESTANY,
   SIMCALL_MUTEX_LOCK,
   SIMCALL_MUTEX_TRYLOCK,
+  SIMCALL_MUTEX_UNLOCK,
   SIMCALL_COND_INIT,
   SIMCALL_COND_SIGNAL,
   SIMCALL_COND_WAIT,
index 592c22f..a240ef3 100644 (file)
@@ -49,6 +49,7 @@ const char* simcall_names[] = {
     "SIMCALL_COMM_TESTANY",
     "SIMCALL_MUTEX_LOCK",
     "SIMCALL_MUTEX_TRYLOCK",
+    "SIMCALL_MUTEX_UNLOCK",
     "SIMCALL_COND_INIT",
     "SIMCALL_COND_SIGNAL",
     "SIMCALL_COND_WAIT",
@@ -119,7 +120,7 @@ case SIMCALL_EXECUTION_PARALLEL_START:
           simgrid::simix::unmarshal<const char*>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1]),
           simgrid::simix::unmarshal<sg_host_t*>(simcall->args[2]), simgrid::simix::unmarshal<double*>(simcall->args[3]),
           simgrid::simix::unmarshal<double*>(simcall->args[4]), simgrid::simix::unmarshal<double>(simcall->args[5]),
-          simgrid::simix::unmarshal<double>(simcall->args[6])));
+          simgrid::simix::unmarshal<double>(simcall->args[6]), simgrid::simix::unmarshal<double>(simcall->args[7])));
   SIMIX_simcall_answer(simcall);
   break;
 
@@ -232,6 +233,11 @@ case SIMCALL_MUTEX_TRYLOCK:
       SIMIX_simcall_answer(simcall);
       break;
 
+case SIMCALL_MUTEX_UNLOCK:
+      simcall_HANDLER_mutex_unlock(simcall, simgrid::simix::unmarshal<smx_mutex_t>(simcall->args[0]));
+      SIMIX_simcall_answer(simcall);
+      break;
+
 case SIMCALL_COND_INIT:
       simgrid::simix::marshal<smx_cond_t>(simcall->result, SIMIX_cond_init());
       SIMIX_simcall_answer(simcall);
index bf67a8e..a271396 100644 (file)
@@ -43,7 +43,7 @@ int  process_join(smx_actor_t process, double timeout) [[block]];
 int  process_sleep(double duration) [[block]];
 
 boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_start(const char* name, double flops_amount, double priority, double bound);
-boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double rate, double timeout) [[nohandler]];
+boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl> execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double amount, double rate, double timeout) [[nohandler]];
 void          execution_cancel(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution) [[nohandler]];
 void          execution_set_priority(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution, double priority) [[nohandler]];
 void          execution_set_bound(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> execution, double bound) [[nohandler]];
@@ -63,6 +63,7 @@ int            comm_testany(boost::intrusive_ptr<simgrid::kernel::activity::Acti
 
 void        mutex_lock(smx_mutex_t mutex) [[block]];
 int         mutex_trylock(smx_mutex_t mutex);
+void        mutex_unlock(smx_mutex_t mutex);
 
 smx_cond_t cond_init() [[nohandler]];
 void       cond_signal(smx_cond_t cond) [[nohandler]];
index 268d3c7..bc6c5a7 100644 (file)
@@ -29,14 +29,17 @@ namespace simgrid {
     {
       /* Clean Simulator data */
       if (xbt_swag_size(process_list) != 0) {
-        std::string msg     = std::string("Shutting down host, but it's not empty:");
+        char *msg = xbt_strdup("Shutting down host, but it's not empty:");
+        char *tmp;
         smx_actor_t process = nullptr;
 
         xbt_swag_foreach(process, process_list) {
-          msg = msg + "\n\t" + process->name.c_str();
+          tmp = bprintf("%s\n\t%s", msg, process->name.c_str());
+          free(msg);
+          msg = tmp;
         }
         SIMIX_display_process_status();
-        THROWF(arg_error, 0, "%s", msg.c_str());
+        THROWF(arg_error, 0, "%s", msg);
       }
       for (auto arg : auto_restart_processes)
         delete arg;
@@ -183,7 +186,7 @@ SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount,
 
 boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount,
-                               double* bytes_amount, double rate, double timeout)
+                               double* bytes_amount, double amount, double rate, double timeout)
 {
 
   /* alloc structures and initialize */
index ffdcd20..a642409 100644 (file)
@@ -62,7 +62,7 @@ XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_start(smx_actor_t issuer, const char* name, double flops_amount, double priority, double bound);
 XBT_PRIVATE boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 SIMIX_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount,
-                               double* bytes_amount, double rate, double timeout);
+                               double* bytes_amount, double amount, double rate, double timeout);
 
 #endif
 
index 66375d4..bad673a 100644 (file)
@@ -216,6 +216,11 @@ int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex)
   return mutex->try_lock(simcall->issuer);
 }
 
+void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex)
+{
+  mutex->unlock(simcall->issuer);
+}
+
 /********************************* Condition **********************************/
 
 /**
index d27ae64..748faa2 100644 (file)
@@ -10,7 +10,6 @@
 #include "xbt/synchro.h"
 
 #include "simgrid/simix.h" /* used implementation */
-#include "src/simix/smx_synchro_private.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism");
 
@@ -32,7 +31,7 @@ int xbt_mutex_try_acquire(xbt_mutex_t mutex)
 
 void xbt_mutex_release(xbt_mutex_t mutex)
 {
-  ((smx_mutex_t)mutex)->unlock(SIMIX_process_self());
+  simcall_mutex_unlock((smx_mutex_t)mutex);
 }
 
 void xbt_mutex_destroy(xbt_mutex_t mutex)