Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill one simcall, simplify another
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Jul 2017 14:12:56 +0000 (16:12 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Jul 2017 14:12:56 +0000 (16:12 +0200)
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 81cf238..d0fa5c4 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 amount, double rate, double timeout);
+                                 double* bytes_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);
@@ -269,7 +269,6 @@ 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 53ea92d..feb9577 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, -1.0, timeout));
+              simdata->bytes_parallel_amount, -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 5e63f24..9e0e5d5 100644 (file)
@@ -24,7 +24,8 @@ void Mutex::lock()
  */
 void Mutex::unlock()
 {
-  simcall_mutex_unlock(mutex_);
+  smx_actor_t self = SIMIX_process_self();
+  simgrid::simix::kernelImmediate([this, self] { return mutex_->unlock(self); });
 }
 
 /** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
index 1d1b2a6..993d28d 100644 (file)
@@ -84,8 +84,7 @@ 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 amount, double rate,
-                                                double timeout)
+                                                double* flops_amount, double* bytes_amount, double rate, double timeout)
 {
   /* checking for infinite values */
   for (int i = 0 ; i < host_nb ; ++i) {
@@ -98,11 +97,9 @@ 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, amount, rate,
-                                               timeout);
+  return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout);
 }
 
 /**
@@ -483,15 +480,6 @@ 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 2cf9ba5..28975af 100644 (file)
@@ -251,41 +251,29 @@ 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__amount(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<double>(simcall->args[5]);
-}
-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__amount(smx_simcall_t simcall, double arg)
-{
-  simgrid::simix::marshal<double>(simcall->args[5], arg);
-}
 static inline double simcall_execution_parallel_start__get__rate(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal<double>(simcall->args[6]);
+  return simgrid::simix::unmarshal<double>(simcall->args[5]);
 }
 static inline double simcall_execution_parallel_start__getraw__rate(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal_raw<double>(simcall->args[6]);
+  return simgrid::simix::unmarshal_raw<double>(simcall->args[5]);
 }
 static inline void simcall_execution_parallel_start__set__rate(smx_simcall_t simcall, double arg)
 {
-  simgrid::simix::marshal<double>(simcall->args[6], arg);
+  simgrid::simix::marshal<double>(simcall->args[5], arg);
 }
 static inline double simcall_execution_parallel_start__get__timeout(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal<double>(simcall->args[7]);
+  return simgrid::simix::unmarshal<double>(simcall->args[6]);
 }
 static inline double simcall_execution_parallel_start__getraw__timeout(smx_simcall_t simcall)
 {
-  return simgrid::simix::unmarshal_raw<double>(simcall->args[7]);
+  return simgrid::simix::unmarshal_raw<double>(simcall->args[6]);
 }
 static inline void simcall_execution_parallel_start__set__timeout(smx_simcall_t simcall, double arg)
 {
-  simgrid::simix::marshal<double>(simcall->args[7], arg);
+  simgrid::simix::marshal<double>(simcall->args[6], arg);
 }
 static inline boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>
 simcall_execution_parallel_start__get__result(smx_simcall_t simcall)
@@ -1195,19 +1183,6 @@ 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);
@@ -1632,7 +1607,6 @@ XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall,
 XBT_PRIVATE smx_mutex_t simcall_HANDLER_mutex_init(smx_simcall_t simcall);
 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_release(smx_simcall_t simcall, smx_sem_t sem);
index 8d687e5..88b4533 100644 (file)
@@ -83,13 +83,14 @@ 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 amount, double rate, double timeout)
+                                        double* bytes_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, amount, rate, timeout);
+    if (0)
+      SIMIX_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, rate, timeout);
     return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ExecImpl>, const char*, int, sg_host_t*, double*,
-                   double*, double, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list,
-                                                    flops_amount, bytes_amount, amount, rate, timeout);
+                   double*, double, double>(SIMCALL_EXECUTION_PARALLEL_START, name, host_nb, host_list, flops_amount,
+                                            bytes_amount, rate, timeout);
   }
 
   inline static void
@@ -236,12 +237,6 @@ 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 9b88602..0499e1c 100644 (file)
@@ -45,7 +45,6 @@ typedef enum {
   SIMCALL_MUTEX_INIT,
   SIMCALL_MUTEX_LOCK,
   SIMCALL_MUTEX_TRYLOCK,
-  SIMCALL_MUTEX_UNLOCK,
   SIMCALL_COND_INIT,
   SIMCALL_COND_SIGNAL,
   SIMCALL_COND_WAIT,
index d5e4940..69010c2 100644 (file)
@@ -51,7 +51,6 @@ const char* simcall_names[] = {
     "SIMCALL_MUTEX_INIT",
     "SIMCALL_MUTEX_LOCK",
     "SIMCALL_MUTEX_TRYLOCK",
-    "SIMCALL_MUTEX_UNLOCK",
     "SIMCALL_COND_INIT",
     "SIMCALL_COND_SIGNAL",
     "SIMCALL_COND_WAIT",
@@ -126,7 +125,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[7])));
+          simgrid::simix::unmarshal<double>(simcall->args[6])));
   SIMIX_simcall_answer(simcall);
   break;
 
@@ -249,11 +248,6 @@ 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 25fc2e3..1dccd29 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 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 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]];
@@ -65,7 +65,6 @@ int            comm_testany(boost::intrusive_ptr<simgrid::kernel::activity::Acti
 smx_mutex_t mutex_init();
 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 bc6c5a7..268d3c7 100644 (file)
@@ -29,17 +29,14 @@ namespace simgrid {
     {
       /* Clean Simulator data */
       if (xbt_swag_size(process_list) != 0) {
-        char *msg = xbt_strdup("Shutting down host, but it's not empty:");
-        char *tmp;
+        std::string msg     = std::string("Shutting down host, but it's not empty:");
         smx_actor_t process = nullptr;
 
         xbt_swag_foreach(process, process_list) {
-          tmp = bprintf("%s\n\t%s", msg, process->name.c_str());
-          free(msg);
-          msg = tmp;
+          msg = msg + "\n\t" + process->name.c_str();
         }
         SIMIX_display_process_status();
-        THROWF(arg_error, 0, "%s", msg);
+        THROWF(arg_error, 0, "%s", msg.c_str());
       }
       for (auto arg : auto_restart_processes)
         delete arg;
@@ -186,7 +183,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 amount, double rate, double timeout)
+                               double* bytes_amount, double rate, double timeout)
 {
 
   /* alloc structures and initialize */
index a642409..ffdcd20 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 amount, double rate, double timeout);
+                               double* bytes_amount, double rate, double timeout);
 
 #endif
 
index 6f53958..93f437b 100644 (file)
@@ -221,11 +221,6 @@ 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 748faa2..d27ae64 100644 (file)
@@ -10,6 +10,7 @@
 #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");
 
@@ -31,7 +32,7 @@ int xbt_mutex_try_acquire(xbt_mutex_t mutex)
 
 void xbt_mutex_release(xbt_mutex_t mutex)
 {
-  simcall_mutex_unlock((smx_mutex_t)mutex);
+  ((smx_mutex_t)mutex)->unlock(SIMIX_process_self());
 }
 
 void xbt_mutex_destroy(xbt_mutex_t mutex)