Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 12 May 2016 21:59:53 +0000 (23:59 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 12 May 2016 21:59:53 +0000 (23:59 +0200)
17 files changed:
examples/msg/async-wait/async-wait.tesh
include/simgrid/s4u.h
include/simgrid/s4u/Activity.hpp [moved from include/simgrid/s4u/async.hpp with 51% similarity]
include/simgrid/s4u/comm.hpp
include/simgrid/s4u/forward.hpp
src/s4u/s4u_activity.cpp [moved from src/s4u/s4u_async.cpp with 65% similarity]
src/s4u/s4u_comm.cpp
src/simix/SynchroComm.hpp
src/simix/SynchroExec.hpp
src/simix/SynchroRaw.cpp
src/simix/SynchroRaw.hpp
src/simix/SynchroSleep.hpp
src/simix/smx_host.cpp
src/simix/smx_host_private.h
src/simix/smx_process.cpp
src/simix/smx_synchro.cpp
tools/cmake/DefinePackages.cmake

index cb3387c..ad11802 100644 (file)
@@ -2,15 +2,14 @@
 
 p Test1 MSG_comm_test() with Sleep_sender > Sleep_receiver
 
-! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
 > [  0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
 > [  1.000000] (2:receiver@Ruby) Wait to receive a task
 > [  5.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
-> [  5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.100000] (2:receiver@Ruby) Received "Task_0"
 > [  5.100000] (2:receiver@Ruby) Processing "Task_0"
+> [  5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.609710] (2:receiver@Ruby) "Task_0" done
 > [  5.609710] (2:receiver@Ruby) Wait to receive a task
 > [  5.700000] (1:sender@Tremblay) Send to receiver-0 Task_2
@@ -24,21 +23,20 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml
 > [  6.829130] (2:receiver@Ruby) "Task_2" done
 > [  6.829130] (2:receiver@Ruby) Wait to receive a task
 > [  6.900000] (1:sender@Tremblay) Goodbye now!
-> [  6.929130] (0:maestro@) Simulation time 6.92913
 > [  6.929130] (2:receiver@Ruby) Received "finalize"
 > [  6.929130] (2:receiver@Ruby) I'm done. See you!
+> [  6.929130] (0:maestro@) Simulation time 6.92913
 
 p Test2 MSG_comm_test() with Sleep_sender < Sleep_receiver
 
-! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
 > [  0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
 > [  1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
 > [  5.000000] (2:receiver@Ruby) Wait to receive a task
-> [  5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.100000] (2:receiver@Ruby) Received "Task_0"
 > [  5.100000] (2:receiver@Ruby) Processing "Task_0"
+> [  5.100000] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.609710] (2:receiver@Ruby) "Task_0" done
 > [  5.609710] (2:receiver@Ruby) Wait to receive a task
 > [  5.700000] (1:sender@Tremblay) Send to receiver-0 Task_2
@@ -52,63 +50,61 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml
 > [  6.829130] (2:receiver@Ruby) "Task_2" done
 > [  6.829130] (2:receiver@Ruby) Wait to receive a task
 > [  6.900000] (1:sender@Tremblay) Goodbye now!
-> [  6.929130] (0:maestro@) Simulation time 6.92913
 > [  6.929130] (2:receiver@Ruby) Received "finalize"
 > [  6.929130] (2:receiver@Ruby) I'm done. See you!
+> [  6.929130] (0:maestro@) Simulation time 6.92913
 
 p Test1 MSG_comm_wait() with Sleep_sender > Sleep_receiver
 
-! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
 > [  0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
 > [  1.000000] (2:receiver@Ruby) Wait to receive a task
 > [  5.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
-> [  5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.004022] (2:receiver@Ruby) Received "Task_0"
 > [  5.004022] (2:receiver@Ruby) Processing "Task_0"
+> [  5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.513732] (2:receiver@Ruby) "Task_0" done
 > [  5.513732] (2:receiver@Ruby) Wait to receive a task
-> [  5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
 > [  5.517753] (2:receiver@Ruby) Received "Task_1"
 > [  5.517753] (2:receiver@Ruby) Processing "Task_1"
+> [  5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
 > [  6.027463] (2:receiver@Ruby) "Task_1" done
 > [  6.027463] (2:receiver@Ruby) Wait to receive a task
-> [  6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
 > [  6.031485] (2:receiver@Ruby) Received "Task_2"
 > [  6.031485] (2:receiver@Ruby) Processing "Task_2"
+> [  6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
 > [  6.541195] (2:receiver@Ruby) "Task_2" done
 > [  6.541195] (2:receiver@Ruby) Wait to receive a task
-> [  6.543146] (0:maestro@) Simulation time 6.54315
 > [  6.543146] (1:sender@Tremblay) Goodbye now!
 > [  6.543146] (2:receiver@Ruby) Received "finalize"
 > [  6.543146] (2:receiver@Ruby) I'm done. See you!
+> [  6.543146] (0:maestro@) Simulation time 6.54315
 
 
 p Test2 MSG_comm_wait() with Sleep_sender < Sleep_receiver
 
-! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
 > [  0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
 > [  1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0
 > [  5.000000] (2:receiver@Ruby) Wait to receive a task
-> [  5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.004022] (2:receiver@Ruby) Received "Task_0"
 > [  5.004022] (2:receiver@Ruby) Processing "Task_0"
+> [  5.004022] (1:sender@Tremblay) Send to receiver-0 Task_1
 > [  5.513732] (2:receiver@Ruby) "Task_0" done
 > [  5.513732] (2:receiver@Ruby) Wait to receive a task
-> [  5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
 > [  5.517753] (2:receiver@Ruby) Received "Task_1"
 > [  5.517753] (2:receiver@Ruby) Processing "Task_1"
+> [  5.517753] (1:sender@Tremblay) Send to receiver-0 Task_2
 > [  6.027463] (2:receiver@Ruby) "Task_1" done
 > [  6.027463] (2:receiver@Ruby) Wait to receive a task
-> [  6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
 > [  6.031485] (2:receiver@Ruby) Received "Task_2"
 > [  6.031485] (2:receiver@Ruby) Processing "Task_2"
+> [  6.031485] (1:sender@Tremblay) Send to receiver-0 finalize
 > [  6.541195] (2:receiver@Ruby) "Task_2" done
 > [  6.541195] (2:receiver@Ruby) Wait to receive a task
-> [  6.543146] (0:maestro@) Simulation time 6.54315
 > [  6.543146] (1:sender@Tremblay) Goodbye now!
 > [  6.543146] (2:receiver@Ruby) Received "finalize"
 > [  6.543146] (2:receiver@Ruby) I'm done. See you!
+> [  6.543146] (0:maestro@) Simulation time 6.54315
index e58b845..42cb73b 100644 (file)
@@ -11,7 +11,7 @@
 #include "s4u/engine.hpp"
 #include "s4u/host.hpp"
 
-#include "s4u/async.hpp"
+#include "s4u/Activity.hpp"
 #include "s4u/comm.hpp"
 
 #include "s4u/storage.hpp"
similarity index 51%
rename from include/simgrid/s4u/async.hpp
rename to include/simgrid/s4u/Activity.hpp
index 2f12e79..533a92d 100644 (file)
@@ -4,8 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SIMGRID_S4U_ASYNC_HPP
-#define SIMGRID_S4U_ASYNC_HPP
+#ifndef SIMGRID_S4U_ACTIVITY_HPP
+#define SIMGRID_S4U_ACTIVITY_HPP
 
 #include <stdlib.h>
 #include <xbt/base.h>
 SG_BEGIN_DECL();
 typedef enum {
   inited, started, finished
-} e_s4u_async_state_t;
+} e_s4u_activity_state_t;
 SG_END_DECL();
 
 namespace simgrid {
 namespace s4u {
 
-/** @brief Asynchronous Actions
+/** @brief Activities
  *
- * This class is the ancestor of every asynchronous actions, that is, of actions that do take time in the simulated world.
+ * This class is the ancestor of every activities that an actor can undertake, that is, of the actions that do take time in the simulated world.
  */
-XBT_PUBLIC_CLASS Async {
+XBT_PUBLIC_CLASS Activity {
   friend Comm;
 protected:
-  Async();
-  virtual ~Async();
+  Activity();
+  virtual ~Activity();
   
 private:
   simgrid::simix::Synchro *pimpl_ = NULL;
 
 private:
-  e_s4u_async_state_t state_ = inited;
+  e_s4u_activity_state_t state_ = inited;
 public:
-  /** Starts a previously created async.
+  /** Starts a previously created activity.
    *
    * This function is optional: you can call wait() even if you didn't call start()
    */
   virtual void start()=0;
-  /** Tests whether the given async is terminated yet */
+  /** Tests whether the given activity is terminated yet. This is a pure function. */
   //virtual bool test()=0;
-  /** Blocks until the async is terminated */
+  /** Blocks until the activity is terminated */
   virtual void wait()=0;
-  /** Blocks until the async is terminated, or until the timeout is elapsed
+  /** Blocks until the activity is terminated, or until the timeout is elapsed
    *  Raises: timeout exception.*/
   virtual void wait(double timeout)=0;
-  /** Cancel that async */
+  /** Cancel that activity */
   //virtual void cancel();
-  /** Retrieve the current state of the async */
-  e_s4u_async_state_t getState() {return state_;}
+  /** Retrieve the current state of the activity */
+  e_s4u_activity_state_t getState() {return state_;}
 
 private:
   double remains_ = 0;
 public:
-  /** Get the remaining amount of work that this Async entails. When it's 0, it's done. */
+  /** Get the remaining amount of work that this Activity entails. When it's 0, it's done. */
   double getRemains();
-  /** Set the [remaining] amount of work that this Async will entail
+  /** Set the [remaining] amount of work that this Activity will entail
    *
-   * It is forbidden to change the amount of work once the Async is started */
+   * It is forbidden to change the amount of work once the Activity is started */
   void setRemains(double remains);
 
 private:
   void *userData_ = NULL;
 public:
-  /** Put some user data onto the Async */
+  /** Put some user data onto the Activity */
   void setUserData(void *data) {userData_=data;}
-  /** Retrieve the user data of the Async */
+  /** Retrieve the user data of the Activity */
   void *getUserData() { return userData_; }
 }; // class
 
 }}; // Namespace simgrid::s4u
 
-#endif /* SIMGRID_S4U_ASYNC_HPP */
+#endif /* SIMGRID_S4U_ACTIVITY_HPP */
index b56e272..c9d615c 100644 (file)
@@ -8,8 +8,8 @@
 #define SIMGRID_S4U_COMM_HPP
 
 #include <xbt/base.h>
+#include <simgrid/s4u/Activity.hpp>
 #include <simgrid/s4u/forward.hpp>
-#include <simgrid/s4u/async.hpp>
 #include <simgrid/s4u/mailbox.hpp>
 
 namespace simgrid {
@@ -19,8 +19,8 @@ namespace s4u {
  *
  * Represents all asynchronous communications, that you can test or wait onto.
  */
-XBT_PUBLIC_CLASS Comm : public Async {
-  Comm() : Async() {}
+XBT_PUBLIC_CLASS Comm : public Activity {
+  Comm() : Activity() {}
 public:
   virtual ~Comm();
 
index 12a7894..b8f6b42 100644 (file)
@@ -9,7 +9,7 @@
 namespace simgrid {
 namespace s4u {
 
-class Async;
+class Activity;
 class Comm;
 class Engine;
 class Host;
similarity index 65%
rename from src/s4u/s4u_async.cpp
rename to src/s4u/s4u_activity.cpp
index bf2f951..c49e2c4 100644 (file)
@@ -7,21 +7,21 @@
 #include "xbt/log.h"
 #include "src/msg/msg_private.h"
 
-#include "simgrid/s4u/async.hpp"
+#include "simgrid/s4u/Activity.hpp"
 
 XBT_LOG_EXTERNAL_CATEGORY(s4u);
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_async,s4u,"S4U asynchronous actions");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_activity,s4u,"S4U activities");
 using namespace simgrid;
 
-s4u::Async::Async() {
+s4u::Activity::Activity() {
 
 }
-s4u::Async::~Async() {
+s4u::Activity::~Activity() {
 
 }
 
-void s4u::Async::setRemains(double remains) {
-  xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Async is started");
+void s4u::Activity::setRemains(double remains) {
+  xbt_assert(state_ == inited, "Cannot change the remaining amount of work once the Activity is started");
   remains_ = remains;
 }
 
index 1415742..fb272f4 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "simgrid/s4u/comm.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm,s4u_async,"S4U asynchronous communications");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_comm,s4u_activity,"S4U asynchronous communications");
 using namespace simgrid;
 
 s4u::Comm::~Comm() {
index b58c83c..d2c549b 100644 (file)
@@ -23,8 +23,8 @@ namespace simix {
     ~Comm();
   public:
     Comm(e_smx_comm_type_t type);
-    void suspend();
-    void resume();
+    void suspend() override;
+    void resume() override;
     void post() override;
     void cancel();
     double remains();
index d0abb29..20d26f8 100644 (file)
@@ -15,8 +15,8 @@ namespace simix {
   XBT_PUBLIC_CLASS Exec : public Synchro {
     ~Exec();
   public:
-    void suspend();
-    void resume();
+    void suspend() override;
+    void resume() override;
     void post() override;
     double remains();
 
index 872cf47..3bb881d 100644 (file)
@@ -9,6 +9,10 @@
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro);
 
+simgrid::simix::Raw::~Raw()
+{
+  sleep->unref();
+}
 void simgrid::simix::Raw::suspend()
 {
   /* The suspension of raw synchros is delayed to when the process is rescheduled. */
index 25d4c2d..7086bd3 100644 (file)
@@ -15,8 +15,9 @@ namespace simix {
   /** Used to implement mutexes, semaphores and conditions */
   XBT_PUBLIC_CLASS Raw : public Synchro {
   public:
-    void suspend();
-    void resume();
+    ~Raw();
+    void suspend() override;
+    void resume() override;
     void post() override;
 
     surf_action_t sleep;
index b999526..9f024ca 100644 (file)
@@ -14,8 +14,8 @@ namespace simix {
 
   XBT_PUBLIC_CLASS Sleep : public Synchro {
   public:
-    void suspend();
-    void resume();
+    void suspend() override;
+    void resume() override;
     void post() override;
 
     sg_host_t host;                /* The host that is sleeping */
index 2fc7eb4..bfc4f20 100644 (file)
@@ -384,16 +384,6 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro
     SIMIX_execution_finish(exec);
 }
 
-void SIMIX_execution_suspend(smx_synchro_t synchro)
-{
-  synchro->suspend(); // FIXME: USELESS
-}
-
-void SIMIX_execution_resume(smx_synchro_t synchro)
-{
-  synchro->resume(); // FIXME: USELESS
-}
-
 void SIMIX_execution_finish(simgrid::simix::Exec *exec)
 {
   xbt_fifo_item_t item;
index a96e5de..eb8b7e6 100644 (file)
@@ -50,8 +50,6 @@ XBT_PRIVATE void SIMIX_execution_set_priority(smx_synchro_t synchro, double prio
 XBT_PRIVATE void SIMIX_execution_set_bound(smx_synchro_t synchro, double bound);
 XBT_PRIVATE void SIMIX_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigned long mask);
 
-XBT_PRIVATE void SIMIX_execution_suspend(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_execution_resume(smx_synchro_t synchro);
 XBT_PRIVATE void SIMIX_execution_finish(simgrid::simix::Exec *exec);
 
 XBT_PRIVATE void SIMIX_set_category(smx_synchro_t synchro, const char *category);
index 32b5c8c..7b93e9c 100644 (file)
@@ -628,15 +628,14 @@ void SIMIX_process_change_host(smx_process_t process,
 
 void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_process_t process)
 {
-  smx_synchro_t sync_suspend =
-      SIMIX_process_suspend(process, simcall->issuer);
+  smx_synchro_t sync_suspend = SIMIX_process_suspend(process, simcall->issuer);
 
   if (process != simcall->issuer) {
     SIMIX_simcall_answer(simcall);
   } else {
     xbt_fifo_push(sync_suspend->simcalls, simcall);
     process->waiting_synchro = sync_suspend;
-    SIMIX_execution_suspend(process->waiting_synchro);
+    process->waiting_synchro->suspend();
   }
   /* If we are suspending ourselves, then just do not finish the simcall now */
 }
index 442695e..cb9212a 100644 (file)
@@ -69,7 +69,6 @@ void SIMIX_synchro_destroy(smx_synchro_t synchro)
   XBT_DEBUG("Destroying synchro %p", synchro);
   simgrid::simix::Raw *raw = static_cast<simgrid::simix::Raw*>(synchro);
 
-  raw->sleep->unref();
   delete raw;
 }
 
index 2a9c547..61bd33b 100644 (file)
@@ -372,7 +372,7 @@ endif()
 set(S4U_SRC
   src/s4u/s4u_actor.cpp
   src/s4u/s4u_as.cpp
-  src/s4u/s4u_async.cpp
+  src/s4u/s4u_activity.cpp
   src/s4u/s4u_comm.cpp
   src/s4u/s4u_engine.cpp  
   src/s4u/s4u_file.cpp  
@@ -634,7 +634,7 @@ set(headers_to_install
   include/simgrid/s4u/forward.hpp
   include/simgrid/s4u/actor.hpp
   include/simgrid/s4u/As.hpp
-  include/simgrid/s4u/async.hpp
+  include/simgrid/s4u/Activity.hpp
   include/simgrid/s4u/comm.hpp
   include/simgrid/s4u/engine.hpp  
   include/simgrid/s4u/file.hpp