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>
Fri, 22 Apr 2016 10:26:05 +0000 (12:26 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 22 Apr 2016 10:26:05 +0000 (12:26 +0200)
28 files changed:
ChangeLog
examples/msg/dht-chord/dht-chord.c
examples/msg/dht-chord/dht-chord.tesh
examples/msg/dht-kademlia/dht-kademlia.c
examples/msg/dht-kademlia/dht-kademlia.tesh
examples/msg/dht-pastry/dht-pastry.c
examples/msg/dht-pastry/dht-pastry.tesh
include/simgrid/msg.h
include/simgrid/simix.h
include/xbt/fifo.h
include/xbt/synchro_core.h
src/bindings/java/jmsg_task.cpp
src/bindings/java/org/simgrid/msg/Task.java
src/mc/ModelChecker.cpp
src/msg/msg_gos.cpp
src/msg/msg_mailbox.cpp
src/msg/msg_private.h
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_global.cpp
src/simix/smx_network.cpp
src/simix/smx_network_private.h
src/smpi/smpi_global.cpp
src/xbt/xbt_os_synchro.c

index 7eed1ff..1c45681 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,12 @@ SimGrid (3.13) UNRELEASED; urgency=low
      Lua can still be used to describe platforms
    - Removed Java kernel plug-ins.
      Will be reintroduced after the ongoing major internals reorg.
+   - In MSG
+      - the following functions were removed.
+        They were too specific and should be reimplemented in a generic
+        way, with filter function.
+       - MSG_task_listen_from_host
+       - MSG_mailbox_get_count_host_waiting_tasks
    - In SimDag 
       - the SD_application_reinit function was removed. It was a noop for a while. 
       - The ACCESS_MODE of SD_workstation has been removed. This feature was not really usable and should soon be 
index 976fa83..420d502 100644 (file)
@@ -34,8 +34,6 @@ static int periodic_lookup_delay = 10;
 
 static const double sleep_delay = 4.9999;
 
-extern long int smx_total_comms;
-
 /* Finger element. */
 typedef struct s_finger {
   int id;
@@ -1043,7 +1041,6 @@ int main(int argc, char *argv[])
   MSG_launch_application(application_file);
 
   msg_error_t res = MSG_main();
-  XBT_CRITICAL("Messages created: %ld", smx_total_comms);
   XBT_INFO("Simulated time: %g", MSG_get_clock());
 
   chord_exit();
index 166a9a2..d3a4cb8 100644 (file)
@@ -184,7 +184,6 @@ $ $SG_TEST_EXENV ${bindir:=.}/dht-chord$EXEEXT -nb_bits=6 ${srcdir:=.}/cluster.x
 > [115.044536] (2:node@node-1.acme.org)   40  | 366680
 > [115.044536] (2:node@node-1.acme.org)   56  | 366680
 > [115.044536] (2:node@node-1.acme.org) Predecessor: 1319738
-> [1151.814423] (0:maestro@) Messages created: 2452
 > [1151.814423] (0:maestro@) Simulated time: 1151.81
 > [130.161328] (3:node@node-2.acme.org) My finger table:
 > [130.161328] (3:node@node-2.acme.org) Start | Succ
@@ -3223,5 +3222,4 @@ $ $SG_TEST_EXENV ${bindir:=.}/dht-chord$EXEEXT ${srcdir:=.}/routing_none.xml ${s
 > [ 990.991700] (8:node@node-7.acme.org)  14199064  | 10004760
 > [ 990.991700] (8:node@node-7.acme.org)  1616152  | 10004760
 > [ 990.991700] (8:node@node-7.acme.org) Predecessor: 6518808
-> [1201.991400] (0:maestro@) Messages created: 2208
 > [1201.991400] (0:maestro@) Simulated time: 1201.99
index 1177377..186c620 100644 (file)
@@ -15,8 +15,6 @@
   */
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia, "Messages specific for this msg example");
 
-extern long unsigned int smx_total_comms;
-
 /* Main loop for the process */
 static void main_loop(node_t node, double deadline)
 {
@@ -441,7 +439,6 @@ int main(int argc, char *argv[])
 
   msg_error_t res = MSG_main();
 
-  XBT_CRITICAL("Messages created: %ld", smx_total_comms);
   XBT_INFO("Simulated time: %g", MSG_get_clock());
 
   return res != MSG_OK;
index 22ecfa1..61f4fd8 100644 (file)
@@ -30,5 +30,4 @@ $ $SG_TEST_EXENV ${bindir:=.}/dht-kademlia ${srcdir:=.}/cluster.xml ${srcdir:=.}
 > [780.000000] (10:node@node-9.acme.org) 5/5 FIND_NODE have succeeded
 > [780.000000] (12:node@node-11.acme.org) 6/6 FIND_NODE have succeeded
 > [780.000000] ( 4:node@node-3.acme.org) 5/5 FIND_NODE have succeeded
-> [780.000000] ( 0:maestro@) Messages created: 1179
 > [780.000000] ( 0:maestro@) Simulated time: 780
index df37565..d0afa78 100644 (file)
@@ -29,8 +29,6 @@ static int nb_bits = 16;
 static int timeout = 50;
 static int max_simulation_time = 1000;
 
-extern long int smx_total_comms;
-
 typedef struct s_node {
   int id;                                 //128bits generated random(2^128 -1)
   int known_id;
@@ -571,7 +569,6 @@ int main(int argc, char *argv[])
   MSG_launch_application(options[1]);
 
   msg_error_t res = MSG_main();
-  XBT_CRITICAL("Messages created: %ld", smx_total_comms);
   XBT_INFO("Simulated time: %g", MSG_get_clock());
 
   return res != MSG_OK;
index ee9138d..8a52ccb 100644 (file)
@@ -2,5 +2,4 @@
 
 p Testing the Chord implementation with MSG
 
-! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/dht-pastry$EXEEXT -nb_bits=6 ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/dht-pastry_d.xml --cfg=network/crosstraffic:0 --log=msg_pastry.thres:verbose "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
index 7642313..ea973f2 100644 (file)
@@ -440,7 +440,6 @@ XBT_PUBLIC(msg_task_t) MSG_comm_get_task(msg_comm_t comm);
 XBT_PUBLIC(msg_error_t) MSG_comm_get_status(msg_comm_t comm);
 
 XBT_PUBLIC(int) MSG_task_listen(const char *alias);
-XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias, msg_host_t host);
 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout);
 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate);
 XBT_PUBLIC(msg_error_t) MSG_task_send(msg_task_t task, const char *alias);
@@ -487,14 +486,6 @@ XBT_PUBLIC(void) MSG_mailbox_set_async(const char *alias);
  */
 XBT_PUBLIC(msg_task_t) MSG_mailbox_get_head(msg_mailbox_t mailbox);
 
-/* @brief MSG_mailbox_get_count_host_waiting_tasks
- * Return the number of tasks waiting to be received in a mailbox and sent by a host.
- * @param  mailbox  The mailbox concerned by the operation.
- * @param  host     The host containing the processes that sended the tasks.
- * @return          The number of tasks in the mailbox specified by the parameter mailbox and sended by all the
- *                  processes located on the host specified by the parameter host.
- */
-XBT_PUBLIC(int) MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, msg_host_t host);
 XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host,
                                                  double timeout);
 XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t *task, msg_host_t host,
index 7c77c0b..4ac35a1 100644 (file)
@@ -366,15 +366,11 @@ XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
 /***** Rendez-vous points *****/
 
 XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name);
-XBT_PUBLIC(void) simcall_mbox_destroy(smx_mailbox_t mbox);
 XBT_PUBLIC(smx_mailbox_t) simcall_mbox_get_by_name(const char *name);
-XBT_PUBLIC(int) simcall_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host);
 XBT_PUBLIC(smx_synchro_t) simcall_mbox_get_head(smx_mailbox_t mbox);
 XBT_PUBLIC(smx_process_t) simcall_mbox_get_receiver(smx_mailbox_t mbox);
 XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_process_t process);
 
-XBT_PUBLIC(xbt_dict_t) SIMIX_get_mailboxes(void);
-
 /***** Communication simcalls *****/
 
 XBT_PUBLIC(void) simcall_comm_send(smx_process_t sender, smx_mailbox_t mbox, double task_size,
index ec66ad1..1f152d5 100644 (file)
@@ -79,8 +79,8 @@ XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_prev_item(xbt_fifo_item_t i);
  * asserts and stuff
  * \param f a list (#xbt_fifo_t)
  * \param i a bucket (#xbt_fifo_item_t)
- * \param type a type
  * \param n an object of type \a type.
+ * \param type the type of objects contained in the fifo
  * @hideinitializer
  *
  * Iterates over the whole list. 
index 9f94e82..50684ed 100644 (file)
@@ -31,7 +31,7 @@ SG_BEGIN_DECL()
 /** @brief Thread mutex data type (opaque object)
  *  @hideinitializer
  */
-typedef struct s_xbt_mutex_ *xbt_mutex_t;
+typedef struct s_smx_mutex_ *xbt_mutex_t;
 
 /** @brief Creates a new mutex variable */
 XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
@@ -57,7 +57,7 @@ XBT_PUBLIC(void) xbt_mutex_destroy(xbt_mutex_t mutex);
 /** @brief Thread condition data type (opaque object)
  *  @hideinitializer
  */
-typedef struct s_xbt_cond_ *xbt_cond_t;
+typedef struct s_smx_cond_ *xbt_cond_t;
 
 /** @brief Creates a condition variable */
 XBT_PUBLIC(xbt_cond_t) xbt_cond_init(void);
index d904fb3..b6b45ee 100644 (file)
@@ -652,24 +652,6 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Task_listen(JNIEnv * env, jclass
   return (jboolean) rv;
 }
 
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFromHost(JNIEnv * env, jclass cls, jstring jalias, jobject jhost)
-{
-  int rv;
-  const char *alias;
-
-  msg_host_t host = jhost_get_native(env, jhost);
-
-  if (!host) {
-    jxbt_throw_notbound(env, "host", jhost);
-    return -1;
-  }
-  alias = env->GetStringUTFChars(jalias, 0);
-  rv = MSG_task_listen_from_host(alias, host);
-  env->ReleaseStringUTFChars(jalias, alias);
-
-  return (jint) rv;
-}
-
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFrom(JNIEnv * env, jclass cls, jstring jalias)
 {
   int rv;
index ac034b6..5007cc4 100644 (file)
@@ -358,11 +358,6 @@ public class Task {
         */
        public native static boolean listen(String mailbox);
 
-       /**
-        * Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
-        */
-       public native static int listenFromHost(String alias, Host host);
-
        /**
         * Class initializer, to initialize various JNI stuff
         */
index 956f5f1..ea14a19 100644 (file)
@@ -149,9 +149,6 @@ void ModelChecker::setup_ignore()
 
   /* Static variable used for tracing */
   process.ignore_global_variable("counter");
-
-  /* SIMIX */
-  process.ignore_global_variable("smx_total_comms");
 }
 
 void ModelChecker::shutdown()
index 5329078..9632b26 100644 (file)
@@ -825,22 +825,8 @@ msg_error_t MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alia
  */
 int MSG_task_listen(const char *alias)
 {
-  smx_mailbox_t rdv = MSG_mailbox_get_by_alias(alias);
-  return !MSG_mailbox_is_empty(rdv) || (rdv->permanent_receiver && xbt_fifo_size(rdv->done_comm_fifo)!=0);
-}
-
-/** \ingroup msg_task_usage
- * \brief Check the number of communication actions of a given host pending in a mailbox.
- *
- * \param alias the name of the mailbox to be considered
- * \param host the host to check for communication
- *
- * \return Returns the number of pending communication actions of the host in the given mailbox, 0 if there is no
- *         pending communication actions.
- */
-int MSG_task_listen_from_host(const char *alias, msg_host_t host)
-{
-  return MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias(alias), host);
+  smx_mailbox_t mbox = MSG_mailbox_get_by_alias(alias);
+  return !MSG_mailbox_is_empty(mbox) || (mbox->permanent_receiver && !mbox->done_comm_queue->empty());
 }
 
 /** \ingroup msg_task_usage
index 5235ffb..122c0ae 100644 (file)
@@ -16,11 +16,6 @@ msg_mailbox_t MSG_mailbox_new(const char *alias)
   return simcall_mbox_create(alias);
 }
 
-void MSG_mailbox_free(void *mailbox)
-{
-  simcall_mbox_destroy((msg_mailbox_t)mailbox);
-}
-
 int MSG_mailbox_is_empty(msg_mailbox_t mailbox)
 {
   return (NULL == simcall_mbox_get_head(mailbox));
@@ -36,11 +31,6 @@ msg_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox)
   return (msg_task_t) simcall_comm_get_src_data(comm);
 }
 
-int MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, msg_host_t host)
-{
-  return simcall_mbox_comm_count_by_host(mailbox, host);
-}
-
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
 {
   msg_mailbox_t mailbox = simcall_mbox_get_by_name(alias);
index efe693f..3edff2f 100644 (file)
@@ -148,11 +148,6 @@ XBT_PRIVATE void MSG_post_create_environment(void);
 
 XBT_PRIVATE void MSG_host_add_task(msg_host_t host, msg_task_t task);
 XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task);
-/* @brief MSG_mailbox_free - release a mailbox from the memory.
- * Releases a mailbox from the memory but does not remove it from the dictionary.
- * @param   mailbox  The mailbox to release.
- */
-XBT_PRIVATE void MSG_mailbox_free(void *mailbox);
 
 /********** Tracing **********/
 /* declaration of instrumentation functions from msg_task_instr.c */
index 4406c4e..3058bad 100644 (file)
@@ -738,16 +738,6 @@ smx_mailbox_t simcall_mbox_create(const char *name)
   return simcall_BODY_mbox_create(name);
 }
 
-
-/**
- *  \ingroup simix_mbox_management
- *  \brief Destroy a rendez-vous point
- *  \param mbox The rendez-vous point to destroy
- */
-void simcall_mbox_destroy(smx_mailbox_t mbox)
-{
-  simcall_BODY_mbox_destroy(mbox);
-}
 /**
  *  \ingroup simix_mbox_management
  *  \brief Returns a rendez-vous point knowing its name
@@ -761,19 +751,6 @@ smx_mailbox_t simcall_mbox_get_by_name(const char *name)
   return SIMIX_mbox_get_by_name(name);
 }
 
-/**
- *  \ingroup simix_mbox_management
- *  \brief Counts the number of communication synchros of a given host pending
- *         on a rendez-vous point.
- *  \param mbox The rendez-vous point
- *  \param host The host to be counted
- *  \return The number of comm synchros pending in the mbox
- */
-int simcall_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host)
-{
-  return simcall_BODY_mbox_comm_count_by_host(mbox, host);
-}
-
 /**
  *  \ingroup simix_mbox_management
  *  \brief returns the communication at the head of the rendez-vous
index 63b0c03..fe2c29c 100644 (file)
@@ -445,32 +445,6 @@ static inline void simcall_mbox_create__set__result(smx_simcall_t simcall, void*
     simcall->result.dp = result;
 }
 
-static inline smx_mailbox_t simcall_mbox_destroy__get__mbox(smx_simcall_t simcall) {
-  return (smx_mailbox_t) simcall->args[0].dp;
-}
-static inline void simcall_mbox_destroy__set__mbox(smx_simcall_t simcall, void* arg) {
-    simcall->args[0].dp = arg;
-}
-
-static inline smx_mailbox_t simcall_mbox_comm_count_by_host__get__mbox(smx_simcall_t simcall) {
-  return (smx_mailbox_t) simcall->args[0].dp;
-}
-static inline void simcall_mbox_comm_count_by_host__set__mbox(smx_simcall_t simcall, void* arg) {
-    simcall->args[0].dp = arg;
-}
-static inline sg_host_t simcall_mbox_comm_count_by_host__get__host(smx_simcall_t simcall) {
-  return (sg_host_t) simcall->args[1].dp;
-}
-static inline void simcall_mbox_comm_count_by_host__set__host(smx_simcall_t simcall, void* arg) {
-    simcall->args[1].dp = arg;
-}
-static inline unsigned int simcall_mbox_comm_count_by_host__get__result(smx_simcall_t simcall){
-    return  simcall->result.ui;
-}
-static inline void simcall_mbox_comm_count_by_host__set__result(smx_simcall_t simcall, unsigned int result){
-    simcall->result.ui = result;
-}
-
 static inline smx_mailbox_t simcall_mbox_get_head__get__mbox(smx_simcall_t simcall) {
   return (smx_mailbox_t) simcall->args[0].dp;
 }
index 88ff816..bfc0c86 100644 (file)
@@ -654,49 +654,6 @@ inline static smx_mailbox_t simcall_BODY_mbox_create(const char* name) {
     return (smx_mailbox_t) self->simcall.result.dp;
   }
   
-inline static void simcall_BODY_mbox_destroy(smx_mailbox_t mbox) {
-    smx_process_t self = SIMIX_process_self();
-
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_mbox_destroy(mbox);
-    /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
-    self->simcall.call = SIMCALL_MBOX_DESTROY;
-    memset(&self->simcall.result, 0, sizeof(self->simcall.result));
-    memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].dp = (void*) mbox;
-    if (self != simix_global->maestro_process) {
-      XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
-                SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
-      SIMIX_process_yield(self);
-    } else {
-      SIMIX_simcall_handle(&self->simcall, 0);
-    }    
-    
-  }
-  
-inline static unsigned int simcall_BODY_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host) {
-    smx_process_t self = SIMIX_process_self();
-
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_mbox_comm_count_by_host(mbox, host);
-    /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
-    self->simcall.call = SIMCALL_MBOX_COMM_COUNT_BY_HOST;
-    memset(&self->simcall.result, 0, sizeof(self->simcall.result));
-    memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].dp = (void*) mbox;
-    self->simcall.args[1].dp = (void*) host;
-    if (self != simix_global->maestro_process) {
-      XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
-                SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
-      SIMIX_process_yield(self);
-    } else {
-      SIMIX_simcall_handle(&self->simcall, 0);
-    }    
-    return (unsigned int) self->simcall.result.ui;
-  }
-  
 inline static smx_synchro_t simcall_BODY_mbox_get_head(smx_mailbox_t mbox) {
     smx_process_t self = SIMIX_process_self();
 
index 8dca2b7..f2af98f 100644 (file)
@@ -47,8 +47,6 @@ typedef enum {
   SIMCALL_PROCESS_AUTO_RESTART_SET,
   SIMCALL_PROCESS_RESTART,
   SIMCALL_MBOX_CREATE,
-  SIMCALL_MBOX_DESTROY,
-  SIMCALL_MBOX_COMM_COUNT_BY_HOST,
   SIMCALL_MBOX_GET_HEAD,
   SIMCALL_MBOX_SET_RECEIVER,
   SIMCALL_MBOX_GET_RECEIVER,
index 0e5b55a..3498a66 100644 (file)
@@ -52,8 +52,6 @@ const char* simcall_names[] = {
   "SIMCALL_PROCESS_AUTO_RESTART_SET",
   "SIMCALL_PROCESS_RESTART",
   "SIMCALL_MBOX_CREATE",
-  "SIMCALL_MBOX_DESTROY",
-  "SIMCALL_MBOX_COMM_COUNT_BY_HOST",
   "SIMCALL_MBOX_GET_HEAD",
   "SIMCALL_MBOX_SET_RECEIVER",
   "SIMCALL_MBOX_GET_RECEIVER",
@@ -259,16 +257,6 @@ case SIMCALL_MBOX_CREATE:
       SIMIX_simcall_answer(simcall);
       break;  
 
-case SIMCALL_MBOX_DESTROY:
-       SIMIX_mbox_destroy((smx_mailbox_t) simcall->args[0].dp);
-      SIMIX_simcall_answer(simcall);
-      break;  
-
-case SIMCALL_MBOX_COMM_COUNT_BY_HOST:
-      simcall->result.ui = SIMIX_mbox_comm_count_by_host((smx_mailbox_t) simcall->args[0].dp,(sg_host_t) simcall->args[1].dp);
-      SIMIX_simcall_answer(simcall);
-      break;  
-
 case SIMCALL_MBOX_GET_HEAD:
       simcall->result.dp = SIMIX_mbox_get_head((smx_mailbox_t) simcall->args[0].dp);
       SIMIX_simcall_answer(simcall);
index 07cc862..8a0b4b3 100644 (file)
@@ -79,8 +79,6 @@ Proc - process_auto_restart_set (void) (process, void*, smx_process_t) (auto_res
 Func H process_restart (void*, smx_process_t) (process, void*, smx_process_t)
 
 Func - mbox_create (void*, smx_mailbox_t) (name, const char*)
-Proc - mbox_destroy (void) (mbox, void*, smx_mailbox_t)
-Func - mbox_comm_count_by_host (unsigned int) (mbox, void*, smx_mailbox_t) (host, void*, sg_host_t)
 Func - mbox_get_head (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t)
 Proc - mbox_set_receiver (void) (mbox, void*, smx_mailbox_t) (receiver, void*, smx_process_t)
 Func - mbox_get_receiver (void*, smx_process_t) (mbox, void*, smx_mailbox_t)
index d039e8c..6e71f22 100644 (file)
@@ -230,8 +230,6 @@ void SIMIX_global_init(int *argc, char **argv)
     __xbt_running_ctx_fetch = SIMIX_process_get_running_context;
     __xbt_ex_terminate = SIMIX_process_exception_terminate;
 
-    SIMIX_network_init();
-
     /* Prepare to display some more info when dying on Ctrl-C pressing */
     signal(SIGINT, inthandler);
 
@@ -298,7 +296,7 @@ void SIMIX_clean(void)
   SIMIX_process_killall(simix_global->maestro_process, 1);
 
   /* Exit the SIMIX network module */
-  SIMIX_network_exit();
+  SIMIX_mailbox_exit();
 
   xbt_heap_free(simix_timers);
   simix_timers = NULL;
index b3d4c06..61338c6 100644 (file)
 #include "mc/mc.h"
 #include "src/mc/mc_replay.h"
 #include "xbt/dict.h"
+#include "simgrid/s4u/mailbox.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization");
 
-static xbt_dict_t mailboxes = NULL;
-XBT_EXPORT_NO_IMPORT(unsigned long int) smx_total_comms = 0;
+static void SIMIX_mbox_free(void *data);
+static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
 
 static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall);
 static void SIMIX_comm_copy_data(smx_synchro_t comm);
@@ -23,18 +24,12 @@ static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm);
 static smx_synchro_t SIMIX_fifo_probe_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
                                         int (*match_fun)(void *, void *,smx_synchro_t),
                                         void *user_data, smx_synchro_t my_synchro);
-static smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
+static smx_synchro_t SIMIX_deque_get_filtered(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
                                         int (*match_fun)(void *, void *,smx_synchro_t),
                                         void *user_data, smx_synchro_t my_synchro);
-static void SIMIX_mbox_free(void *data);
 static void SIMIX_comm_start(smx_synchro_t synchro);
 
-void SIMIX_network_init(void)
-{
-  mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
-}
-
-void SIMIX_network_exit(void)
+void SIMIX_mailbox_exit(void)
 {
   xbt_dict_free(&mailboxes);
 }
@@ -45,69 +40,42 @@ void SIMIX_network_exit(void)
 
 smx_mailbox_t SIMIX_mbox_create(const char *name)
 {
+  xbt_assert(name, "Mailboxes must have a name");
   /* two processes may have pushed the same mbox_create simcall at the same time */
-  smx_mailbox_t mbox = name ? (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name) : NULL;
+  smx_mailbox_t mbox = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name);
 
   if (!mbox) {
     mbox = xbt_new0(s_smx_mailbox_t, 1);
-    mbox->name = name ? xbt_strdup(name) : NULL;
-    mbox->comm_fifo = xbt_fifo_new();
-    mbox->done_comm_fifo = xbt_fifo_new();
+    mbox->name = xbt_strdup(name);
+    mbox->comm_queue = new std::deque<smx_synchro_t>();
+    mbox->done_comm_queue = nullptr; // Allocated on need only
     mbox->permanent_receiver=NULL;
 
     XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
-
-    if (mbox->name)
-      xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
+    xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
   }
   return mbox;
 }
 
-void SIMIX_mbox_destroy(smx_mailbox_t mbox)
-{
-  if (mbox->name)
-    xbt_dict_remove(mailboxes, mbox->name);
-}
-
 void SIMIX_mbox_free(void *data)
 {
   XBT_DEBUG("mbox free %p", data);
   smx_mailbox_t mbox = (smx_mailbox_t) data;
   xbt_free(mbox->name);
-  xbt_fifo_free(mbox->comm_fifo);
-  xbt_fifo_free(mbox->done_comm_fifo);
+  delete mbox->comm_queue;
+  delete mbox->done_comm_queue;
 
   xbt_free(mbox);
 }
 
-xbt_dict_t SIMIX_get_mailboxes()
-{
-  return mailboxes;
-}
-
 smx_mailbox_t SIMIX_mbox_get_by_name(const char *name)
 {
   return (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name);
 }
 
-int SIMIX_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host)
-{
-  smx_synchro_t comm = NULL;
-  xbt_fifo_item_t item = NULL;
-  int count = 0;
-
-  xbt_fifo_foreach(mbox->comm_fifo, item, comm, smx_synchro_t) {
-    if (comm->comm.src_proc->host == host)
-      count++;
-  }
-
-  return count;
-}
-
 smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox)
 {
-  return (smx_synchro_t) xbt_fifo_get_item_content(
-    xbt_fifo_get_first_item(mbox->comm_fifo));
+  return mbox->comm_queue->front();
 }
 
 /**
@@ -128,6 +96,8 @@ smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox)
 void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
 {
   mbox->permanent_receiver=process;
+  if (mbox->done_comm_queue == nullptr)
+    mbox->done_comm_queue = new std::deque<smx_synchro_t>();
 }
 
 /**
@@ -137,7 +107,7 @@ void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
  */
 static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm)
 {
-  xbt_fifo_push(mbox->comm_fifo, comm);
+  mbox->comm_queue->push_back(comm);
   comm->comm.mbox = mbox;
 }
 
@@ -148,24 +118,29 @@ static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm)
  */
 void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm)
 {
-  xbt_fifo_remove(mbox->comm_fifo, comm);
+  for (auto it = mbox->comm_queue->begin(); it != mbox->comm_queue->end(); it++)
+    if (*it == comm) {
+      mbox->comm_queue->erase(it);
+      break;
+    }
+
   comm->comm.mbox = NULL;
 }
 
 /**
- *  \brief Checks if there is a communication synchro queued in a fifo matching our needs
+ *  \brief Checks if there is a communication synchro queued in a deque matching our needs
  *  \param type The type of communication we are looking for (comm_send, comm_recv)
  *  \return The communication synchro if found, NULL otherwise
  */
-smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
-                                 int (*match_fun)(void *, void *,smx_synchro_t),
-                                 void *this_user_data, smx_synchro_t my_synchro)
+static smx_synchro_t
+SIMIX_deque_get_filtered(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
+                    int (*match_fun)(void *, void *,smx_synchro_t),
+                    void *this_user_data, smx_synchro_t my_synchro)
 {
-  smx_synchro_t synchro;
-  xbt_fifo_item_t item;
   void* other_user_data = NULL;
 
-  xbt_fifo_foreach(fifo, item, synchro, smx_synchro_t) {
+  for(auto it = deque->begin(); it != deque->end(); it++){
+    smx_synchro_t synchro = *it;
     if (synchro->comm.type == SIMIX_COMM_SEND) {
       other_user_data = synchro->comm.src_data;
     } else if (synchro->comm.type == SIMIX_COMM_RECEIVE) {
@@ -175,8 +150,7 @@ smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
         (!match_fun              ||              match_fun(this_user_data,  other_user_data, synchro)) &&
         (!synchro->comm.match_fun || synchro->comm.match_fun(other_user_data, this_user_data,  my_synchro))) {
       XBT_DEBUG("Found a matching communication synchro %p", synchro);
-      xbt_fifo_remove_item(fifo, item);
-      xbt_fifo_free_item(item);
+      deque->erase(it);
       synchro->comm.refcount++;
 #if HAVE_MC
       synchro->comm.mbox_cpy = synchro->comm.mbox;
@@ -255,7 +229,6 @@ smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type)
   synchro->category = NULL;
 
   XBT_DEBUG("Create communicate synchro %p", synchro);
-  ++smx_total_comms;
 
   return synchro;
 }
@@ -345,7 +318,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
    * ourself so that the other side also gets a chance of choosing if it wants to match with us.
    *
    * If it is not found then push our communication into the rendez-vous point */
-  smx_synchro_t other_synchro = SIMIX_fifo_get_comm(mbox->comm_fifo, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro);
+  smx_synchro_t other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro);
 
   if (!other_synchro) {
     other_synchro = this_synchro;
@@ -355,7 +328,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
       other_synchro->state = SIMIX_READY;
       other_synchro->comm.dst_proc=mbox->permanent_receiver;
       other_synchro->comm.refcount++;
-      xbt_fifo_push(mbox->done_comm_fifo,other_synchro);
+      mbox->done_comm_queue->push_back(other_synchro);
       other_synchro->comm.mbox=mbox;
       XBT_DEBUG("pushing a message into the permanent receive fifo %p, comm %p", mbox, &(other_synchro->comm));
 
@@ -366,7 +339,6 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
     XBT_DEBUG("Receive already pushed");
 
     SIMIX_comm_destroy(this_synchro);
-    --smx_total_comms; // this creation was a pure waste
 
     other_synchro->state = SIMIX_READY;
     other_synchro->comm.type = SIMIX_COMM_READY;
@@ -431,16 +403,16 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
     void (*copy_data_fun)(smx_synchro_t, void*, size_t), // used to copy data if not default one
     void *data, double rate)
 {
-  XBT_DEBUG("recv from %p %p", mbox, mbox->comm_fifo);
+  XBT_DEBUG("recv from %p %p", mbox, mbox->comm_queue);
   smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
 
   smx_synchro_t other_synchro;
   //communication already done, get it inside the fifo of completed comms
-  if (mbox->permanent_receiver && xbt_fifo_size(mbox->done_comm_fifo)!=0) {
+  if (mbox->permanent_receiver && ! mbox->done_comm_queue->empty()) {
 
     XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
     //find a match in the already received fifo
-    other_synchro = SIMIX_fifo_get_comm(mbox->done_comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+    other_synchro = SIMIX_deque_get_filtered(mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
     //if not found, assume the receiver came first, register it to the mailbox in the classical way
     if (!other_synchro)  {
       XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into fifo");
@@ -455,7 +427,6 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
       }
       other_synchro->comm.refcount--;
       SIMIX_comm_destroy(this_synchro);
-      --smx_total_comms; // this creation was a pure waste
     }
   } else {
     /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
@@ -464,15 +435,14 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
      * ourself so that the other side also gets a chance of choosing if it wants to match with us.
      *
      * If it is not found then push our communication into the rendez-vous point */
-    other_synchro = SIMIX_fifo_get_comm(mbox->comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+    other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
 
     if (!other_synchro) {
-      XBT_DEBUG("Receive pushed first %d", xbt_fifo_size(mbox->comm_fifo));
+      XBT_DEBUG("Receive pushed first %lu", mbox->comm_queue->size());
       other_synchro = this_synchro;
       SIMIX_mbox_push(mbox, this_synchro);
     } else {
       SIMIX_comm_destroy(this_synchro);
-      --smx_total_comms; // this creation was a pure waste
       other_synchro->state = SIMIX_READY;
       other_synchro->comm.type = SIMIX_COMM_READY;
       //other_synchro->comm.refcount--;
@@ -511,7 +481,7 @@ smx_synchro_t simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t m
 smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
                               int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data)
 {
-  XBT_DEBUG("iprobe from %p %p", mbox, mbox->comm_fifo);
+  XBT_DEBUG("iprobe from %p %p", mbox, mbox->comm_queue);
   smx_synchro_t this_synchro;
   int smx_type;
   if(type == 1){
@@ -522,26 +492,21 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int
     smx_type = SIMIX_COMM_SEND;
   } 
   smx_synchro_t other_synchro=NULL;
-  if(mbox->permanent_receiver && xbt_fifo_size(mbox->done_comm_fifo)!=0){
+  if(mbox->permanent_receiver && ! mbox->done_comm_queue->empty()){
     //find a match in the already received fifo
-      XBT_DEBUG("first try in the perm recv mailbox");
+      XBT_DEBUG("first check in the perm recv mailbox");
 
-    other_synchro = SIMIX_fifo_probe_comm(
-      mbox->done_comm_fifo, (e_smx_comm_type_t) smx_type,
-      match_fun, data, this_synchro);
+    other_synchro = SIMIX_deque_get_filtered(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
   }
  // }else{
-    if(!other_synchro){
+    if (!other_synchro){
         XBT_DEBUG("try in the normal mailbox");
-        other_synchro = SIMIX_fifo_probe_comm(
-          mbox->comm_fifo, (e_smx_comm_type_t) smx_type,
-          match_fun, data, this_synchro);
+        other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
     }
 //  }
   if(other_synchro)other_synchro->comm.refcount--;
 
   SIMIX_comm_destroy(this_synchro);
-  --smx_total_comms;
   return other_synchro;
 }
 
index f2a93b8..cc6e381 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef _SIMIX_NETWORK_PRIVATE_H
 #define _SIMIX_NETWORK_PRIVATE_H
 
+#include <deque>
 #include <xbt/base.h>
 
 #include "simgrid/simix.h"
 /** @brief Rendez-vous point datatype */
 typedef struct s_smx_mailbox {
   char *name;
-  xbt_fifo_t comm_fifo;
+  std::deque<smx_synchro_t> *comm_queue;
   void *data;
   smx_process_t permanent_receiver; //process which the mailbox is attached to
-  xbt_fifo_t done_comm_fifo;//messages already received in the permanent receive mode
+  std::deque<smx_synchro_t> *done_comm_queue;//messages already received in the permanent receive mode
 } s_smx_mailbox_t;
 
-XBT_PRIVATE void SIMIX_network_init(void);
-XBT_PRIVATE void SIMIX_network_exit(void);
+XBT_PRIVATE void SIMIX_mailbox_exit(void);
 
 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name);
-XBT_PRIVATE void SIMIX_mbox_destroy(smx_mailbox_t mbox);
 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name);
 XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm);
-XBT_PRIVATE int SIMIX_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host);
 XBT_PRIVATE smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox);
 XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc);
 XBT_PRIVATE smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox);
index a6be249..6ef4b19 100644 (file)
@@ -460,8 +460,6 @@ void smpi_global_destroy(void)
       smpi_comm_destroy(process_data[i]->comm_intra);
     }
     xbt_os_timer_free(process_data[i]->timer);
-    simcall_mbox_destroy(process_data[i]->mailbox);
-    simcall_mbox_destroy(process_data[i]->mailbox_small);
     xbt_mutex_destroy(process_data[i]->mailboxes_mutex);
     xbt_free(process_data[i]);
   }
index 5ece743..52b1762 100644 (file)
 #include "xbt/synchro_core.h"
 
 #include "simgrid/simix.h"        /* used implementation */
-#include "../simix/smx_private.h" /* FIXME */
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism");
 
 /****** mutex related functions ******/
-struct s_xbt_mutex_ {
-  s_smx_mutex_t mutex;
-};
-
 xbt_mutex_t xbt_mutex_init(void)
 {
   return (xbt_mutex_t) simcall_mutex_init();
@@ -48,10 +43,6 @@ void xbt_mutex_destroy(xbt_mutex_t mutex)
 }
 
 /***** condition related functions *****/
-struct s_xbt_cond_ {
-  s_smx_cond_t cond;
-};
-
 xbt_cond_t xbt_cond_init(void)
 {
   return (xbt_cond_t) simcall_cond_init();