Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I forgot to update my tree before commiting (once again), and got conflicts as punishment
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 28 Apr 2012 07:48:39 +0000 (09:48 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 28 Apr 2012 07:48:39 +0000 (09:48 +0200)
46 files changed:
ChangeLog
buildtools/Cmake/DefinePackages.cmake
examples/msg/actions/actions.c
examples/msg/masterslave/masterslave_bypass.c
examples/msg/masterslave/masterslave_cluster.c
examples/msg/masterslave/masterslave_failure.c
examples/msg/masterslave/masterslave_forwarder.c
examples/msg/migration/migration.c
examples/msg/tracing/ms.c
examples/msg/tracing/user_variables.c
include/msg/datatypes.h
include/msg/msg.h
include/simgrid/simix.h [moved from include/simix/simix.h with 65% similarity]
include/simix/context.h [deleted file]
include/simix/datatypes.h [deleted file]
src/gras/Msg/sg_msg.c
src/gras/Transport/transport_interface.h
src/gras/Transport/transport_plugin_sg.c
src/gras/Virtu/virtu_private.h
src/gras/Virtu/virtu_sg.h
src/gras/rl_stubs.c
src/include/mc/mc.h
src/include/simix/context.h
src/instr/instr_msg_process.c
src/msg/msg_config.c
src/msg/msg_environment.c
src/msg/msg_gos.c
src/msg/msg_host.c
src/msg/msg_mailbox.c
src/msg/msg_mailbox.h
src/msg/msg_private.h
src/msg/msg_process.c
src/simix/smx_context_base.c
src/simix/smx_host_private.h
src/simix/smx_io_private.h
src/simix/smx_network.c
src/simix/smx_network_private.h
src/simix/smx_private.h
src/simix/smx_process_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/smpi/private.h
src/smpi/smpi_base.c
src/xbt/xbt_sg_synchro.c
src/xbt/xbt_sg_time.c
tools/gras/struct_diff.c

index 5583490..095ef38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,10 +43,11 @@ SimGrid (3.7) NOT RELEASED; urgency=low
     Switch to MSG_task_{send,recv} instead, or compile Simgrid command line
     'cmake -Dcustom_flags="-DMSG_USE_DEPRECATED" .' if you really need to
      use these (crappy) functions in your code.
-    These functions will be removed at some point. Stop using them now.
+    These functions will be removed soon. Stop using them now.
   * Deprecate MSG_get_host_{table,number}
     Implement MSG_hosts_as_dynar() instead.
   * Implement MSG_processes_as_dynar() (Closes gforge #13642)
+  * Remove the public field msg_host_t->name. Use MSG_host_get_name()
 
   Simix:
   * Stabilize the parallel execution mode of user contexts
index 45da846..bf28e63 100644 (file)
@@ -437,6 +437,7 @@ set(headers_to_install
        include/xbt/file_stat.h
        include/simgrid/platf.h
        include/simgrid/modelchecker.h
+       include/simgrid/simix.h
        include/msg/msg.h
        include/msg/datatypes.h
        include/simdag/simdag.h
@@ -460,9 +461,6 @@ set(headers_to_install
        include/instr/instr.h
        include/gras.h 
        include/xbt.h
-       include/simix/simix.h
-       include/simix/datatypes.h
-       include/simix/context.h
 )
 set(source_of_generated_headers
        include/simgrid_config.h.in
index d2c306c..e45e988 100644 (file)
@@ -7,7 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "msg/msg.h"            /* Yeah! If you want to use msg, you need to include msg/msg.h */
-#include "simix/simix.h"        /* semaphores for the barrier */
+#include "simgrid/simix.h"        /* semaphores for the barrier */
 #include "xbt.h"                /* calloc, printf */
 #include "instr/instr_private.h"
 
index 4c6f2a8..343c92f 100644 (file)
@@ -199,7 +199,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("\t %s", slaves[i]->name);
+    XBT_INFO("\t %s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -208,7 +208,7 @@ int master(int argc, char *argv[])
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
index 6f871fd..1e54f5e 100644 (file)
@@ -69,7 +69,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("\t %s", slaves[i]->name);
+    XBT_INFO("\t %s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -78,7 +78,7 @@ int master(int argc, char *argv[])
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
index c882244..39e7d7e 100644 (file)
@@ -55,7 +55,7 @@ int master(int argc, char *argv[])
 
   XBT_INFO("Got %d slave(s) :", slaves_count);
   for (i = 0; i < slaves_count; i++)
-    XBT_INFO("%s", slaves[i]->name);
+    XBT_INFO("%s", MSG_host_get_name(slaves[i]));
 
   XBT_INFO("Got %d task to process :", number_of_tasks);
 
@@ -79,13 +79,13 @@ int master(int argc, char *argv[])
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO
           ("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       XBT_INFO
           ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       free(task->data);
       MSG_task_destroy(task);
     } else {
@@ -109,16 +109,16 @@ int master(int argc, char *argv[])
       return 0;
     } else if (a == MSG_TRANSFER_FAILURE) {
       XBT_INFO("Mmh. Can't reach '%s'! Nevermind. Let's keep going!",
-            slaves[i]->name);
+          MSG_host_get_name(slaves[i]));
       MSG_task_destroy(task);
     } else if (a == MSG_TIMEOUT) {
       XBT_INFO
           ("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!",
-           slaves[i % slaves_count]->name);
+              MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_destroy(task);
     } else {
       XBT_INFO("Hey ?! What's up ? ");
-      xbt_die("Unexpected behavior with '%s': %d", slaves[i]->name, a);
+      xbt_die("Unexpected behavior with '%s': %d", MSG_host_get_name(slaves[i]), a);
     }
   }
 
index 1e0d779..4ebb580 100644 (file)
@@ -77,11 +77,11 @@ int master(int argc, char *argv[])
   XBT_INFO("Got %d slaves and %d tasks to process", slaves_count,
         number_of_tasks);
   for (i = 0; i < slaves_count; i++)
-    XBT_DEBUG("%s", slaves[i]->name);
+    XBT_DEBUG("%s", MSG_host_get_name(slaves[i]));
 
   for (i = 0; i < number_of_tasks; i++) {
     XBT_INFO("Sending \"%s\" to \"%s\"",
-          todo[i]->name, slaves[i % slaves_count]->name);
+          todo[i]->name, MSG_host_get_name(slaves[i % slaves_count]));
     if (MSG_host_self() == slaves[i % slaves_count]) {
       XBT_INFO("Hey ! It's me ! :)");
     }
@@ -165,7 +165,7 @@ int forwarder(int argc, char *argv[])
         break;
       }
       XBT_INFO("Sending \"%s\" to \"%s\"",
-            MSG_task_get_name(task), slaves[i % slaves_count]->name);
+            MSG_task_get_name(task), MSG_host_get_name(slaves[i % slaves_count]));
       MSG_task_send(task, MSG_host_get_name(slaves[i % slaves_count]));
       i++;
     } else {
index f0ec596..898ac25 100644 (file)
@@ -46,7 +46,7 @@ static int emigrant(int argc, char *argv[])
   xbt_mutex_release(mutex);
   MSG_process_suspend(MSG_process_self());
   m_host_t h = MSG_process_get_host(MSG_process_self());
-  XBT_INFO("I've been moved on this new host: %s", h->name);
+  XBT_INFO("I've been moved on this new host: %s", MSG_host_get_name(h));
   XBT_INFO("Uh, nothing to do here. Stopping now");
   return 0;
 }                               /* end_of_emigrant */
index 95b3a28..0b75720 100644 (file)
@@ -41,7 +41,7 @@ int master(int argc, char *argv[])
   long slaves_count = atol(argv[4]);
 
   //setting the variable "is_master" (previously declared) to value 1
-  TRACE_host_variable_set(MSG_host_self()->name, "is_master", 1);
+  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_master", 1);
 
   TRACE_mark("msmark", "start_send_tasks");
   int i;
@@ -50,7 +50,7 @@ int master(int argc, char *argv[])
     task = MSG_task_create("task", task_comp_size, task_comm_size, NULL);
 
     //setting the variable "task_creation" to value i
-    TRACE_host_variable_set(MSG_host_self()->name, "task_creation", i);
+    TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "task_creation", i);
 
     //setting the category of task to "compute"
     //the category of a task must be defined before it is sent or executed
@@ -73,7 +73,7 @@ int slave(int argc, char *argv[])
 {
   m_task_t task = NULL;
 
-  TRACE_host_variable_set(MSG_host_self()->name, "is_slave", 1);
+  TRACE_host_variable_set(MSG_host_get_name(MSG_host_self()), "is_slave", 1);
   while (1) {
     MSG_task_receive(&(task), "master_mailbox");
 
@@ -83,7 +83,7 @@ int slave(int argc, char *argv[])
     }
     //adding the value returned by MSG_task_get_compute_duration(task)
     //to the variable "task_computation"
-    TRACE_host_variable_add(MSG_host_self()->name,
+    TRACE_host_variable_add(MSG_host_get_name(MSG_host_self()),
                             "task_computation",
                             MSG_task_get_compute_duration(task));
     MSG_task_execute(task);
index ea2b959..6c63b9d 100644 (file)
@@ -27,7 +27,7 @@ int master(int argc, char *argv[]);
 
 int master(int argc, char *argv[])
 {
-  char *hostname = MSG_host_self()->name;
+  const char *hostname = MSG_host_get_name(MSG_host_self());
   int i;
 
   //the hostname has an empty HDD with a capacity of 100000 (bytes)
index 08a6b26..79fc90a 100644 (file)
@@ -8,18 +8,33 @@
 #define MSG_DATATYPE_H
 #include "xbt/misc.h"
 #include "xbt/file_stat.h"
+#include "simgrid/simix.h"
 #include "simgrid_config.h"     // for HAVE_TRACING
 
 SG_BEGIN_DECL()
 
-/* ******************************** Host ************************************ */
+/* ******************************** Mailbox ************************************ */
+
+/** @brief Mailbox datatype
+ *  @ingroup msg_task_usage
+ *
+ * Object representing a communication rendez-vous point, on which
+ * the sender finds the receiver it wants to communicate with. As a
+ * MSG user, you will only rarely manipulate any of these objects
+ * directly, since most of the public interface (such as
+ * #MSG_task_send and friends) hide this object behind a string
+ * alias. That mean that you don't provide the mailbox on which you
+ * want to send your task, but only the name of this mailbox. */
+typedef struct s_smx_rvpoint *msg_mailbox_t;
 
-typedef struct simdata_host *simdata_host_t;
+
+/* ******************************** Host ************************************ */
 
 typedef struct m_host {
-  char *name;                   /**< @brief host name if any */
-  simdata_host_t simdata;       /**< @brief simulator data */
-  void *data;                   /**< @brief user data */
+  smx_host_t smx_host;          /**< SIMIX representation of this host   */
+#ifdef MSG_USE_DEPRECATED
+  msg_mailbox_t *mailboxes;     /**< the channels  */
+#endif
 } s_m_host_t;
 
 /** @brief Host datatype  
@@ -130,19 +145,6 @@ typedef struct s_smx_process *m_process_t;
 typedef int m_channel_t;
 #endif
 
-/* ******************************** Mailbox ************************************ */
-
-/** @brief Mailbox datatype
- *  @ingroup msg_task_usage
- * 
- * Object representing a communication rendez-vous point, on which
- * the sender finds the receiver it wants to communicate with. As a
- * MSG user, you will only rarely manipulate any of these objects
- * directly, since most of the public interface (such as
- * #MSG_task_send and friends) hide this object behind a string
- * alias. That mean that you don't provide the mailbox on which you
- * want to send your task, but only the name of this mailbox. */
-typedef struct s_smx_rvpoint *msg_mailbox_t;
 
 
 SG_END_DECL()
index 4d3bc10..d28939b 100644 (file)
@@ -12,6 +12,8 @@
 #include "msg/datatypes.h"
 #include "xbt/automaton.h"
 
+#include "simgrid/simix.h"
+
 SG_BEGIN_DECL()
 
 /** @brief Return code of most MSG functions
@@ -192,7 +194,7 @@ XBT_PUBLIC(MSG_error_t)
 XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias);
 XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(m_task_t task,
                                                     const char *alias,
-                                                    int (*match_fun)(void*,void*),
+                                                    int (*match_fun)(void*,void*, smx_action_t),
                                                     void *match_data);
 
 XBT_PUBLIC(void) MSG_task_dsend(m_task_t task, const char *alias, void_f_pvoid_t cleanup);
@@ -286,7 +288,6 @@ XBT_PUBLIC(int) MSG_get_channel_number(void);
 #include "instr/instr.h"
 
 /* Used only by the bindings */
-#include "simix/simix.h"
 XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(m_process_t process);
 
 SG_END_DECL()
similarity index 65%
rename from include/simix/simix.h
rename to include/simgrid/simix.h
index 59522ff..dec17ec 100644 (file)
 #include "xbt/dict.h"
 #include "xbt/file_stat.h"
 #include "xbt/function_types.h"
-#include "simix/datatypes.h"
-#include "simix/context.h"
+#include "xbt/parmap.h"
+#include "xbt/swag.h"
 
 SG_BEGIN_DECL()
 
+
+/* ******************************** Host ************************************ */
+/** @defgroup m_datatypes_management_details Details on SIMIX datatypes */
+/** @brief Host datatype
+    @ingroup m_datatypes_management
+
+    A <em>location</em> (or <em>host</em>) is any possible place where
+    a process may run. Thus it is represented as a <em>physical
+    resource with computing capabilities</em>, some <em>mailboxes</em>
+    to enable running process to communicate with remote ones, and
+    some <em>private data</em> that can be only accessed by local
+    process.
+
+    \see m_host_management
+  @{ */
+typedef struct s_smx_host *smx_host_t;
+typedef enum {
+  SIMIX_WAITING,
+  SIMIX_READY,
+  SIMIX_RUNNING,
+  SIMIX_DONE,
+  SIMIX_CANCELED,
+  SIMIX_FAILED,
+  SIMIX_SRC_HOST_FAILURE,
+  SIMIX_DST_HOST_FAILURE,
+  SIMIX_SRC_TIMEOUT,
+  SIMIX_DST_TIMEOUT,
+  SIMIX_LINK_FAILURE
+} e_smx_state_t;
+/** @} */
+
+
+typedef struct s_smx_timer* smx_timer_t;
+
+/* ******************************** Synchro ************************************ */
+typedef struct s_smx_mutex *smx_mutex_t;
+typedef struct s_smx_cond *smx_cond_t;
+typedef struct s_smx_sem *smx_sem_t;
+
+/********************************** File *************************************/
+typedef struct s_smx_file *smx_file_t;
+typedef struct s_smx_stat *smx_stat_t;
+
+/********************************** Action *************************************/
+typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
+
+
+
+/* ****************************** Process *********************************** */
+/** @brief Process datatype
+    @ingroup m_datatypes_management
+
+    A processt may be defined as a <em>code</em>, with some <em>private
+    data</em>, executing in a <em>location</em>.
+    \see m_process_management
+  @{ */
+typedef struct s_smx_process *smx_process_t;
+/** @} */
+
+
+/*
+ * Type of function that creates a process.
+ * The function must accept the following parameters:
+ * void* process: the process created will be stored there
+ * const char *name: a name for the object. It is for user-level information and can be NULL
+ * xbt_main_func_t code: is a function describing the behavior of the process
+ * void *data: data a pointer to any data one may want to attach to the new object.
+ * smx_host_t host: the location where the new process is executed
+ * int argc, char **argv: parameters passed to code
+ * xbt_dict_t pros: properties
+ */
+typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
+                                      /* name */ const char*,
+                                      /* code */ xbt_main_func_t,
+                                      /* userdata */ void*,
+                                      /* hostname */ const char*,
+                                      /* kill_time */ double,
+                                      /* argc */ int,
+                                      /* argv */ char**,
+                                      /* props */ xbt_dict_t);
+
+
+/******************************* Networking ***********************************/
+typedef struct s_smx_rvpoint *smx_rdv_t;
+
+/******************************** Context *************************************/
+typedef struct s_smx_context *smx_context_t;
+typedef struct s_smx_context_factory *smx_context_factory_t;
+
+/* Process creation/destruction callbacks */
+typedef void (*void_pfn_smxprocess_t) (smx_process_t);
+
+
+/* The following function pointer types describe the interface that any context
+   factory should implement */
+
+
+typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
+  (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
+typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
+typedef void (*smx_pfn_context_free_t) (smx_context_t);
+typedef void (*smx_pfn_context_start_t) (smx_context_t);
+typedef void (*smx_pfn_context_stop_t) (smx_context_t);
+typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
+typedef void (*smx_pfn_context_runall_t) (void);
+typedef smx_context_t (*smx_pfn_context_self_t) (void);
+typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
+
+/* interface of the context factories */
+typedef struct s_smx_context_factory {
+  const char *name;
+  smx_pfn_context_factory_create_context_t create_context;
+  smx_pfn_context_factory_finalize_t finalize;
+  smx_pfn_context_free_t free;
+  smx_pfn_context_stop_t stop;
+  smx_pfn_context_suspend_t suspend;
+  smx_pfn_context_runall_t runall;
+  smx_pfn_context_self_t self;
+  smx_pfn_context_get_data_t get_data;
+} s_smx_context_factory_t;
+
+/* Hack: let msg load directly the right factory */
+typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*);
+XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
+extern char* smx_context_factory_name;
+extern int smx_context_stack_size;
+
+#ifdef HAVE_THREAD_LOCAL_STORAGE
+extern __thread smx_context_t smx_current_context;
+#else
+extern smx_context_t smx_current_context;
+#endif
+
+/* *********************** */
+/* Context type definition */
+/* *********************** */
+/* the following function pointers types describe the interface that all context
+   concepts must implement */
+/* each context type derive from this structure, so they must contain this structure
+ * at their beginning -- OOP in C :/ */
+typedef struct s_smx_context {
+  s_xbt_swag_hookup_t hookup;
+  xbt_main_func_t code;
+  void_pfn_smxprocess_t cleanup_func;
+  void *data;   /* Here SIMIX stores the smx_process_t containing the context */
+  char **argv;
+  int argc;
+  int iwannadie:1;
+} s_smx_ctx_base_t;
+
+/* methods of this class */
+XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
+XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
+
+XBT_PUBLIC(smx_context_t)
+smx_ctx_base_factory_create_context_sized(size_t size,
+                                          xbt_main_func_t code, int argc,
+                                          char **argv,
+                                          void_pfn_smxprocess_t cleanup,
+                                          void* data);
+XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
+XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
+XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
+XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
+
+XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
+XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
+XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar(void);
+
+/* parallelism */
+XBT_PUBLIC(int) SIMIX_context_is_parallel(void);
+XBT_PUBLIC(int) SIMIX_context_get_nthreads(void);
+XBT_PUBLIC(void) SIMIX_context_set_nthreads(int nb_threads);
+XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void);
+XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold);
+XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void);
+XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
+
+
+
 /********************************** Global ************************************/
 /* Initialization and exit */
 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
@@ -170,24 +350,24 @@ XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void);
 XBT_PUBLIC(void) simcall_comm_send(smx_rdv_t rdv, double task_size,
                                      double rate, void *src_buff,
                                      size_t src_buff_size,
-                                     int (*match_fun)(void *, void *),
+                                     int (*match_fun)(void *, void *, smx_action_t),
                                      void *data, double timeout);
 
 XBT_PUBLIC(smx_action_t) simcall_comm_isend(smx_rdv_t rdv, double task_size,
                                               double rate, void *src_buff,
                                               size_t src_buff_size,
-                                              int (*match_fun)(void *, void *),
+                                              int (*match_fun)(void *, void *, smx_action_t),
                                               void (*clean_fun)(void *),
                                               void *data, int detached);
 
 XBT_PUBLIC(void) simcall_comm_recv(smx_rdv_t rdv, void *dst_buff,
                                      size_t * dst_buff_size,
-                                     int (*match_fun)(void *, void *),
+                                     int (*match_fun)(void *, void *, smx_action_t),
                                      void *data, double timeout);
 
 XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
                                               size_t * dst_buff_size,
-                                              int (*match_fun)(void *, void *),
+                                              int (*match_fun)(void *, void *, smx_action_t),
                                               void *data);
 
 XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
diff --git a/include/simix/context.h b/include/simix/context.h
deleted file mode 100644 (file)
index 9408c19..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* a fast and simple context switching library                              */
-
-/* Copyright (c) 2009, 2010. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* 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 _SIMIX_CONTEXT_H
-#define _SIMIX_CONTEXT_H
-
-#include "xbt/swag.h"
-#include "xbt/parmap.h"
-#include "simix/datatypes.h"
-#include "simgrid_config.h"
-
-SG_BEGIN_DECL()
-/******************************** Context *************************************/
-typedef struct s_smx_context *smx_context_t;
-typedef struct s_smx_context_factory *smx_context_factory_t;
-
-/* Process creation/destruction callbacks */
-typedef void (*void_pfn_smxprocess_t) (smx_process_t);
-
-
-/* The following function pointer types describe the interface that any context
-   factory should implement */
-
-
-typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
-  (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
-typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
-typedef void (*smx_pfn_context_free_t) (smx_context_t);
-typedef void (*smx_pfn_context_start_t) (smx_context_t);
-typedef void (*smx_pfn_context_stop_t) (smx_context_t);
-typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
-typedef void (*smx_pfn_context_runall_t) (void);
-typedef smx_context_t (*smx_pfn_context_self_t) (void);
-typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
-
-/* interface of the context factories */
-typedef struct s_smx_context_factory {
-  const char *name;
-  smx_pfn_context_factory_create_context_t create_context;
-  smx_pfn_context_factory_finalize_t finalize;
-  smx_pfn_context_free_t free;
-  smx_pfn_context_stop_t stop;
-  smx_pfn_context_suspend_t suspend;
-  smx_pfn_context_runall_t runall;
-  smx_pfn_context_self_t self;
-  smx_pfn_context_get_data_t get_data;
-} s_smx_context_factory_t;
-
-/* Hack: let msg load directly the right factory */
-typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*);
-XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
-extern char* smx_context_factory_name;
-extern int smx_context_stack_size;
-
-#ifdef HAVE_THREAD_LOCAL_STORAGE
-extern __thread smx_context_t smx_current_context;
-#else
-extern smx_context_t smx_current_context;
-#endif
-
-/* *********************** */
-/* Context type definition */
-/* *********************** */
-/* the following function pointers types describe the interface that all context
-   concepts must implement */
-/* each context type derive from this structure, so they must contain this structure
- * at their beginning -- OOP in C :/ */
-typedef struct s_smx_context {
-  s_xbt_swag_hookup_t hookup;
-  xbt_main_func_t code;
-  void_pfn_smxprocess_t cleanup_func;
-  void *data;   /* Here SIMIX stores the smx_process_t containing the context */
-  char **argv;
-  int argc;
-  int iwannadie:1;
-} s_smx_ctx_base_t;
-
-/* methods of this class */
-XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
-XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
-
-XBT_PUBLIC(smx_context_t)
-smx_ctx_base_factory_create_context_sized(size_t size,
-                                          xbt_main_func_t code, int argc,
-                                          char **argv,
-                                          void_pfn_smxprocess_t cleanup,
-                                          void* data);
-XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
-XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
-XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
-XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
-
-XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
-XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
-XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar(void);
-
-/* parallelism */
-XBT_PUBLIC(int) SIMIX_context_is_parallel(void);
-XBT_PUBLIC(int) SIMIX_context_get_nthreads(void);
-XBT_PUBLIC(void) SIMIX_context_set_nthreads(int nb_threads);
-XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void);
-XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold);
-XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void);
-XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
-
-SG_END_DECL()
-
-#endif                          /* !_XBT_CONTEXT_H */
diff --git a/include/simix/datatypes.h b/include/simix/datatypes.h
deleted file mode 100644 (file)
index 97e8af5..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
- * All rights reserved.                                                     */
-
-/* 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 _SIMIX_DATATYPES_H
-#define _SIMIX_DATATYPES_H
-#include "xbt/misc.h"
-#include "xbt/swag.h"
-#include "xbt/fifo.h"
-#include "xbt/dict.h"
-
-SG_BEGIN_DECL()
-
-/* ******************************** Host ************************************ */
-/** @defgroup m_datatypes_management_details Details on SIMIX datatypes */
-/** @brief Host datatype  
-    @ingroup m_datatypes_management
-
-    A <em>location</em> (or <em>host</em>) is any possible place where
-    a process may run. Thus it is represented as a <em>physical
-    resource with computing capabilities</em>, some <em>mailboxes</em>
-    to enable running process to communicate with remote ones, and
-    some <em>private data</em> that can be only accessed by local
-    process.
-
-    \see m_host_management
-  @{ */
-typedef struct s_smx_host *smx_host_t;
-typedef enum {
-  SIMIX_WAITING,
-  SIMIX_READY,
-  SIMIX_RUNNING,
-  SIMIX_DONE,
-  SIMIX_CANCELED,
-  SIMIX_FAILED,
-  SIMIX_SRC_HOST_FAILURE,
-  SIMIX_DST_HOST_FAILURE,
-  SIMIX_SRC_TIMEOUT,
-  SIMIX_DST_TIMEOUT,
-  SIMIX_LINK_FAILURE
-} e_smx_state_t;
-/** @} */
-
-
-typedef struct s_smx_timer* smx_timer_t;
-
-/* ******************************** Synchro ************************************ */
-typedef struct s_smx_mutex *smx_mutex_t;
-typedef struct s_smx_cond *smx_cond_t;
-typedef struct s_smx_sem *smx_sem_t;
-
-/********************************** File *************************************/
-typedef struct s_smx_file *smx_file_t;
-typedef struct s_smx_stat *smx_stat_t;
-
-/********************************** Action *************************************/
-typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
-
-
-
-/* ****************************** Process *********************************** */
-/** @brief Process datatype  
-    @ingroup m_datatypes_management 
-
-    A processt may be defined as a <em>code</em>, with some <em>private
-    data</em>, executing in a <em>location</em>.
-    \see m_process_management
-  @{ */
-typedef struct s_smx_process *smx_process_t;
-/** @} */
-
-
-/*
- * Type of function that creates a process.
- * The function must accept the following parameters:
- * void* process: the process created will be stored there
- * const char *name: a name for the object. It is for user-level information and can be NULL
- * xbt_main_func_t code: is a function describing the behavior of the process
- * void *data: data a pointer to any data one may want to attach to the new object.
- * smx_host_t host: the location where the new process is executed
- * int argc, char **argv: parameters passed to code
- * xbt_dict_t pros: properties
- */
-typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
-                                      /* name */ const char*,
-                                      /* code */ xbt_main_func_t,
-                                      /* userdata */ void*,
-                                      /* hostname */ const char*,
-                                      /* kill_time */ double,
-                                      /* argc */ int,
-                                      /* argv */ char**,
-                                      /* props */ xbt_dict_t);
-
-
-/******************************* Networking ***********************************/
-typedef struct s_smx_rvpoint *smx_rdv_t;
-
-
-SG_END_DECL()
-#endif
index 0471d13..3816885 100644 (file)
@@ -18,7 +18,7 @@
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(gras_msg);
 
 typedef void *gras_trp_bufdata_;
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "simix/smx_private.h"
 
 /* Yeah, the following is awfull, breaking the encapsulation of at least 3 modules
index abbda60..c0bb894 100644 (file)
@@ -12,7 +12,7 @@
 #define GRAS_TRP_INTERFACE_H
 
 #include "portable.h"           /* sometimes needed for fd_set */
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "xbt/queue.h"
 
 /* Data of this module specific to each process
index ebdc3d9..6dbffd0 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "xbt/ex.h"
 
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "gras/Msg/msg_private.h"
 #include "gras/Transport/transport_private.h"
 #include "gras/Virtu/virtu_sg.h"
index 315214c..529ce83 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "xbt/dynar.h"
 #include "gras/Virtu/virtu_interface.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "gras/Msg/msg_private.h"
 
 /** @brief Data for each process */
index 93e1cce..f4e7bab 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "gras/Virtu/virtu_private.h"
 #include "xbt/dynar.h"
-#include "simix/simix.h"        /* SimGrid header */
+#include "simgrid/simix.h"        /* SimGrid header */
 #include "gras/Transport/transport_private.h"
 
 typedef struct {
index 2a75a5f..a9d5ddf 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "xbt_modinter.h"
 #include "xbt/sysdep.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 
 void SIMIX_display_process_status(void)
 {
index 1bd8148..1fe6b57 100644 (file)
@@ -11,7 +11,7 @@
 #include "xbt/dict.h"
 #include "xbt/function_types.h"
 #include "mc/datatypes.h"
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "simgrid/modelchecker.h" /* our public interface (and definition of HAVE_MC) */
 #include "xbt/automaton.h"
 
index 072ab5d..eaa0bfc 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt/misc.h"           /* XBT_PUBLIC(), SG_BEGIN_DECL() and SG_END_DECL() definitions  */
 #include "xbt/function_types.h" /* function pointer types declarations                                                  */
 #include "xbt_modinter.h"       /* xbt_context_init() and xbt_context_exit() declarations               */
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 
 SG_BEGIN_DECL()
 
index fc96c0c..c1a8154 100644 (file)
@@ -45,7 +45,7 @@ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_hos
     PJ_container_free(existing_container);
 
     //create new container on the new_host location
-    msg = PJ_container_new(instr_process_id(process, str, len), INSTR_MSG_PROCESS, PJ_container_get(new_host->name));
+    msg = PJ_container_new(instr_process_id(process, str, len), INSTR_MSG_PROCESS, PJ_container_get(SIMIX_host_get_name(new_host->smx_host)));
 
     //end link
     msg = PJ_container_get(instr_process_id(process, str, len));
@@ -60,7 +60,7 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, m_host
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t host_container = PJ_container_get (host->name);
+    container_t host_container = PJ_container_get (SIMIX_host_get_name(host->smx_host));
     PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
   }
 }
index 733d2bf..c993773 100644 (file)
@@ -7,7 +7,7 @@
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 
 /** \brief set a configuration variable
  *
index c263080..5814f78 100644 (file)
@@ -43,7 +43,7 @@ void MSG_create_environment(const char *file)
   /* Initialize MSG hosts */
   xbt_lib_foreach(host_lib, cursor, name, data) {
     if(data[SIMIX_HOST_LEVEL])
-      __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL], NULL);
+      __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL]);
   }
 }
 
index 8e6d1d1..5081378 100644 (file)
@@ -53,7 +53,7 @@ MSG_error_t MSG_task_execute(m_task_t task)
   p_simdata = SIMIX_process_self_get_data(self);
   simdata->isused=1;
   simdata->compute =
-      simcall_host_execute(task->name, p_simdata->m_host->simdata->smx_host,
+      simcall_host_execute(task->name, p_simdata->m_host->smx_host,
                            simdata->computation_amount,
                            simdata->priority);
 #ifdef HAVE_TRACING
@@ -146,7 +146,7 @@ MSG_parallel_task_create(const char *name, int host_nb,
   simdata->comm_amount = communication_amount;
 
   for (i = 0; i < host_nb; i++)
-    simdata->host_list[i] = host_list[i]->simdata->smx_host;
+    simdata->host_list[i] = host_list[i]->smx_host;
 
   return task;
 }
@@ -175,7 +175,7 @@ MSG_error_t MSG_parallel_task_execute(m_task_t task)
   xbt_assert(simdata->host_nb,
               "This is not a parallel task. Go to hell.");
 
-  XBT_DEBUG("Parallel computing on %s", p_simdata->m_host->name);
+  XBT_DEBUG("Parallel computing on %s", SIMIX_host_get_name(p_simdata->m_host->smx_host));
 
   simdata->isused=1;
 
@@ -383,12 +383,15 @@ msg_comm_t MSG_task_isend(m_task_t task, const char *alias)
  *
  * \param task a #m_task_t to send on another location.
  * \param alias name of the mailbox to sent the task to
- * \param match_fun boolean function taking the match_data provided by sender (here), and the one of the receiver (if any) and returning whether they match
+ * \param match_fun boolean function which parameters are:
+ *        - match_data_provided_here
+ *        - match_data_provided_by_other_side_if_any
+ *        - the_smx_action_describing_the_other_side
  * \param match_data user provided data passed to match_fun
  * \return the msg_comm_t communication created
  */
 XBT_INLINE msg_comm_t MSG_task_isend_with_matching(m_task_t task, const char *alias,
-    int (*match_fun)(void*,void*),
+    int (*match_fun)(void*,void*, smx_action_t),
     void *match_data)
 {
   simdata_task_t t_simdata = NULL;
index ce32fdf..92f2cf1 100644 (file)
  */
 
 /********************************* Host **************************************/
-m_host_t __MSG_host_create(smx_host_t workstation, void *data)
+m_host_t __MSG_host_create(smx_host_t workstation)
 {
-  const char *name;
-  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
+  const char *name = SIMIX_host_get_name(workstation);
   m_host_t host = xbt_new0(s_m_host_t, 1);
 
-  name = SIMIX_host_get_name(workstation);
-  /* Host structure */
-  host->name = xbt_strdup(name);
-  host->simdata = simdata;
-  host->data = data;
-
-  simdata->smx_host = workstation;
+  host->smx_host = workstation;
 
 #ifdef MSG_USE_DEPRECATED
   int i;
   char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */
 
   if (msg_global->max_channel > 0)
-    simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
+    host->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);
 
   for (i = 0; i < msg_global->max_channel; i++) {
     sprintf(alias, "%s:%d", name, i);
 
     /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
-    simdata->mailboxes[i] = MSG_mailbox_new(alias);
+    host->mailboxes[i] = MSG_mailbox_new(alias);
     memset(alias, 0, MAX_ALIAS_NAME + 1);
   }
 #endif
@@ -87,11 +80,7 @@ m_host_t MSG_get_host_by_name(const char *name)
  */
 MSG_error_t MSG_host_set_data(m_host_t host, void *data)
 {
-  xbt_assert((host != NULL), "Invalid parameters");
-  xbt_assert((host->data == NULL), "Data already set");
-
-  /* Assign data */
-  host->data = data;
+  SIMIX_host_set_data(host->smx_host,data);
 
   return MSG_OK;
 }
@@ -106,10 +95,7 @@ MSG_error_t MSG_host_set_data(m_host_t host, void *data)
 void *MSG_host_get_data(m_host_t host)
 {
 
-  xbt_assert((host != NULL), "Invalid parameters");
-
-  /* Return data */
-  return (host->data);
+  return SIMIX_host_get_data(host->smx_host);
 }
 
 /** \ingroup m_host_management
@@ -119,14 +105,8 @@ void *MSG_host_get_data(m_host_t host)
  * This functions checks whether \a host is a valid pointer or not and return
    its name.
  */
-const char *MSG_host_get_name(m_host_t host)
-{
-
-  xbt_assert((host != NULL)
-              && (host->simdata != NULL), "Invalid parameters");
-
-  /* Return data */
-  return (host->name);
+const char *MSG_host_get_name(m_host_t host) {
+  return SIMIX_host_get_name(host->smx_host);
 }
 
 /** \ingroup m_host_management
@@ -140,26 +120,15 @@ m_host_t MSG_host_self(void)
 
 /** \ingroup m_host_management
  *
- * \brief Destroys a host
+ * \brief Destroys a host (internal call only)
  */
-void __MSG_host_destroy(m_host_t host)
-{
-  simdata_host_t simdata = NULL;
-
-  xbt_assert((host != NULL), "Invalid parameters");
-
-  /* Clean simulator data */
-  simdata = (host)->simdata;
+void __MSG_host_destroy(m_host_t host) {
 
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
-    free(simdata->mailboxes);
+    free(host->mailboxes);
 #endif
 
-  free(simdata);
-
-  /* Clean host structure */
-  free(host->name);
   free(host);
 }
 
@@ -227,7 +196,7 @@ double MSG_get_host_speed(m_host_t h)
 {
   xbt_assert((h != NULL), "Invalid parameters");
 
-  return (simcall_host_get_speed(h->simdata->smx_host));
+  return (simcall_host_get_speed(h->smx_host));
 }
 
 /** \ingroup m_host_management
@@ -252,7 +221,7 @@ xbt_dict_t MSG_host_get_properties(m_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
 
-  return (simcall_host_get_properties(host->simdata->smx_host));
+  return (simcall_host_get_properties(host->smx_host));
 }
 
 
@@ -265,5 +234,5 @@ xbt_dict_t MSG_host_get_properties(m_host_t host)
 int MSG_host_is_avail(m_host_t host)
 {
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
-  return (simcall_host_get_state(host->simdata->smx_host));
+  return (simcall_host_get_state(host->smx_host));
 }
index 7279654..9b94299 100644 (file)
@@ -41,7 +41,7 @@ MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
                                          m_host_t host)
 {
   return simcall_rdv_comm_count_by_host(mailbox,
-                                      host->simdata->smx_host);
+                                      host->smx_host);
 }
 
 msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
index cdfe0e6..851e77c 100644 (file)
@@ -8,7 +8,7 @@
 #define MSG_MAILBOX_H
 
 #include "xbt/fifo.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "msg/datatypes.h"
 
 
index c966362..55a22d6 100644 (file)
@@ -8,7 +8,7 @@
 #define METASIMGRID_PRIVATE_H
 
 #include "msg/msg.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "surf/surf.h"
 #include "xbt/fifo.h"
 #include "xbt/dynar.h"
 SG_BEGIN_DECL()
 
 /**************** datatypes **********************************/
-typedef struct simdata_host {
-  smx_host_t smx_host;          /* SURF modeling                                                                */
-  msg_mailbox_t *mailboxes;     /* mailboxes to store msg tasks of of the host  */
-} s_simdata_host_t;
 
 /********************************* Task **************************************/
 
@@ -125,7 +121,7 @@ XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
 #  define MSG_RETURN(val) return(val)
 #endif
 
-m_host_t __MSG_host_create(smx_host_t workstation, void *data);
+m_host_t __MSG_host_create(smx_host_t workstation);
 void __MSG_host_destroy(m_host_t host);
 
 void __MSG_display_process_status(void);
index e8bf1b7..6e9a904 100644 (file)
@@ -176,7 +176,7 @@ m_process_t MSG_process_create_with_environment(const char *name,
 
   /* Let's create the process: SIMIX may decide to start it right now,
    * even before returning the flow control to us */
-  simcall_process_create(&process, name, code, simdata, host->name, kill_time,
+  simcall_process_create(&process, name, code, simdata, SIMIX_host_get_name(host->smx_host), kill_time,
                            argc, argv, properties);
 
   if (!process) {
@@ -233,7 +233,7 @@ MSG_error_t MSG_process_migrate(m_process_t process, m_host_t host)
   m_host_t now = simdata->m_host;
   TRACE_msg_process_change_host(process, now, host);
 #endif
-  simcall_process_change_host(process, host->simdata->smx_host);
+  simcall_process_change_host(process, host->smx_host);
   return MSG_OK;
 }
 
index dc1fe2d..616f669 100644 (file)
@@ -8,7 +8,7 @@
 
 
 #include "xbt/function_types.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "simix/context.h"
 #include "smx_private.h"
 
index 55efda3..66d587e 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _SIMIX_HOST_PRIVATE_H
 #define _SIMIX_HOST_PRIVATE_H
 
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
 /** @brief Host datatype */
index f38cd9b..945538d 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _SIMIX_IO_PRIVATE_H
 #define _SIMIX_IO_PRIVATE_H
 
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
 void SIMIX_pre_file_read(smx_simcall_t simcall);
index db18929..82a372f 100644 (file)
@@ -20,7 +20,8 @@ static void SIMIX_comm_copy_data(smx_action_t comm);
 static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type);
 static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm);
 static smx_action_t SIMIX_rdv_get_comm(smx_rdv_t rdv, e_smx_comm_type_t type,
-                                         int (*match_fun)(void *, void *), void *);
+                                         int (*match_fun)(void *, void *,smx_action_t),
+                                         void *user_data, smx_action_t my_action);
 static void SIMIX_rdv_free(void *data);
 
 void SIMIX_network_init(void)
@@ -118,33 +119,28 @@ XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm)
   comm->comm.rdv = NULL;
 }
 
-/**
- *  \brief Wrapper to SIMIX_rdv_get_comm
- */
-smx_action_t SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data) {
-   return SIMIX_rdv_get_comm(rdv, SIMIX_COMM_SEND, match_fun, data);
-}
-
 /**
  *  \brief Checks if there is a communication action queued in a rendez-vous matching our needs
  *  \param type The type of communication we are looking for (comm_send, comm_recv)
  *  \return The communication action if found, NULL otherwise
  */
 smx_action_t SIMIX_rdv_get_comm(smx_rdv_t rdv, e_smx_comm_type_t type,
-                                   int (*match_fun)(void *, void *), void *data)
+                                   int (*match_fun)(void *, void *,smx_action_t),
+                                   void *this_user_data, smx_action_t my_action)
 {
-  // FIXME rewrite this function by using SIMIX_rdv_has_send/recv_match
   smx_action_t action;
   xbt_fifo_item_t item;
-  void* comm_data = NULL;
+  void* other_user_data = NULL;
 
   xbt_fifo_foreach(rdv->comm_fifo, item, action, smx_action_t) {
     if (action->comm.type == SIMIX_COMM_SEND) {
-      comm_data = action->comm.src_data;
+      other_user_data = action->comm.src_data;
     } else if (action->comm.type == SIMIX_COMM_RECEIVE) {
-      comm_data = action->comm.dst_data;
+      other_user_data = action->comm.dst_data;
     }
-    if (action->comm.type == type && (!match_fun || match_fun(data, comm_data))) {
+    if (action->comm.type == type &&
+        (!match_fun              ||              match_fun(this_user_data,  other_user_data, action)) &&
+        (!action->comm.match_fun || action->comm.match_fun(other_user_data, this_user_data,  my_action))) {
       XBT_DEBUG("Found a matching communication action %p", action);
       xbt_fifo_remove_item(rdv->comm_fifo, item);
       xbt_fifo_free_item(item);
@@ -153,63 +149,22 @@ smx_action_t SIMIX_rdv_get_comm(smx_rdv_t rdv, e_smx_comm_type_t type,
       return action;
     }
     XBT_DEBUG("Sorry, communication action %p does not match our needs:"
-           " its type is %d but we are looking for a comm of type %d",
+           " its type is %d but we are looking for a comm of type %d (or maybe the filtering didn't match)",
            action, (int)action->comm.type, (int)type);
   }
   XBT_DEBUG("No matching communication action found");
   return NULL;
 }
 
-/**
- *  \brief Checks if there is a send communication action
- *  queued in a rendez-vous matching our needs.
- *  \return 1 if found, 0 otherwise
- */
-int SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data) {
-
-  smx_action_t action;
-  xbt_fifo_item_t item;
-
-  xbt_fifo_foreach(rdv->comm_fifo, item, action, smx_action_t){
-    if (action->comm.type == SIMIX_COMM_SEND
-        && (!match_fun || match_fun(data, action->comm.src_data))) {
-      XBT_DEBUG("Found a matching communication action %p", action);
-      return 1;
-    }
-  }
-  XBT_DEBUG("No matching communication action found");
-  return 0;
-}
-
-/**
- *  \brief Checks if there is a recv communication action
- *  queued in a rendez-vous matching our needs.
- *  \return 1 if found, 0 otherwise
- */
-int SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data) {
-
-  smx_action_t action;
-  xbt_fifo_item_t item;
-
-  xbt_fifo_foreach(rdv->comm_fifo, item, action, smx_action_t) {
-    if (action->comm.type == SIMIX_COMM_RECEIVE
-        && (!match_fun || match_fun(data, action->comm.dst_data))) {
-      XBT_DEBUG("Found a matching communication action %p", action);
-      return 1;
-    }
-  }
-  XBT_DEBUG("No matching communication action found");
-  return 0;
-}
 
 /******************************************************************************/
-/*                            Comunication Actions                            */
+/*                            Communication Actions                            */
 /******************************************************************************/
 
 /**
- *  \brief Creates a new comunicate action
+ *  \brief Creates a new communicate action
  *  \param type The direction of communication (comm_send, comm_recv)
- *  \return The new comunicate action
+ *  \return The new communicate action
  */
 smx_action_t SIMIX_comm_new(e_smx_comm_type_t type)
 {
@@ -303,86 +258,101 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t action)
 smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
                               double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
-                              int (*match_fun)(void *, void *),
+                              int (*match_fun)(void *, void *,smx_action_t),
                               void (*clean_fun)(void *), // used to free the action in case of problem after a detached send
                               void *data,
                               int detached)
 {
-  smx_action_t action;
+  /* Prepare an action describing us, so that it gets passed to the user-provided filter of other side */
+  smx_action_t this_action = SIMIX_comm_new(SIMIX_COMM_SEND);
 
-  /* Look for communication action matching our needs.
-     If it is not found then create it and push it into the rendez-vous point */
-  action = SIMIX_rdv_get_comm(rdv, SIMIX_COMM_RECEIVE, match_fun, data);
+  /* Look for communication action matching our needs. We also provide a description of
+   * 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_action_t other_action = SIMIX_rdv_get_comm(rdv, SIMIX_COMM_RECEIVE, match_fun, data, this_action);
 
-  if (!action) {
-    action = SIMIX_comm_new(SIMIX_COMM_SEND);
-    SIMIX_rdv_push(rdv, action);
+  if (!other_action) {
+    other_action = this_action;
+    SIMIX_rdv_push(rdv, this_action);
   } else {
-    action->state = SIMIX_READY;
-    action->comm.type = SIMIX_COMM_READY;
+    SIMIX_comm_destroy(this_action);
+    --smx_total_comms; // this creation was a pure waste
+
+    other_action->state = SIMIX_READY;
+    other_action->comm.type = SIMIX_COMM_READY;
   }
-  xbt_fifo_push(src_proc->comms, action);
+  xbt_fifo_push(src_proc->comms, other_action);
 
   /* if the communication action is detached then decrease the refcount
    * by one, so it will be eliminated by the receiver's destroy call */
   if (detached) {
-    action->comm.detached = 1;
-    action->comm.refcount--;
-    action->comm.clean_fun = clean_fun;
+    other_action->comm.detached = 1;
+    other_action->comm.refcount--;
+    other_action->comm.clean_fun = clean_fun;
   } else {
-    action->comm.clean_fun = NULL;
+    other_action->comm.clean_fun = NULL;
   }
 
   /* Setup the communication action */
-  action->comm.src_proc = src_proc;
-  action->comm.task_size = task_size;
-  action->comm.rate = rate;
-  action->comm.src_buff = src_buff;
-  action->comm.src_buff_size = src_buff_size;
-  action->comm.src_data = data;
+  other_action->comm.src_proc = src_proc;
+  other_action->comm.task_size = task_size;
+  other_action->comm.rate = rate;
+  other_action->comm.src_buff = src_buff;
+  other_action->comm.src_buff_size = src_buff_size;
+  other_action->comm.src_data = data;
+
+  other_action->comm.match_fun = match_fun;
 
   if (MC_IS_ENABLED) {
-    action->state = SIMIX_RUNNING;
-    return action;
+    other_action->state = SIMIX_RUNNING;
+    return other_action;
   }
 
-  SIMIX_comm_start(action);
-  return (detached ? NULL : action);
+  SIMIX_comm_start(other_action);
+  return (detached ? NULL : other_action);
 }
 
 smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
                       void *dst_buff, size_t *dst_buff_size,
-                      int (*match_fun)(void *, void *), void *data)
+                      int (*match_fun)(void *, void *, smx_action_t), void *data)
 {
-  smx_action_t action;
+  /* Prepare an action describing us, so that it gets passed to the user-provided filter of other side */
+  smx_action_t this_action = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
 
-  /* Look for communication action matching our needs.
-   * If it is not found then create it and push it into the rendez-vous point
-   */
-  action = SIMIX_rdv_get_comm(rdv, SIMIX_COMM_SEND, match_fun, data);
+  /* Look for communication action matching our needs. We also provide a description of
+   * 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_action_t other_action = SIMIX_rdv_get_comm(rdv, SIMIX_COMM_SEND, match_fun, data, this_action);
 
-  if (!action) {
-    action = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
-    SIMIX_rdv_push(rdv, action);
+  if (!other_action) {
+    other_action = this_action;
+    SIMIX_rdv_push(rdv, this_action);
   } else {
-    action->state = SIMIX_READY;
-    action->comm.type = SIMIX_COMM_READY;
+    SIMIX_comm_destroy(this_action);
+    --smx_total_comms; // this creation was a pure waste
+
+    other_action->state = SIMIX_READY;
+    other_action->comm.type = SIMIX_COMM_READY;
   }
-  xbt_fifo_push(dst_proc->comms, action);
+  xbt_fifo_push(dst_proc->comms, other_action);
 
   /* Setup communication action */
-  action->comm.dst_proc = dst_proc;
-  action->comm.dst_buff = dst_buff;
-  action->comm.dst_buff_size = dst_buff_size;
-  action->comm.dst_data = data;
+  other_action->comm.dst_proc = dst_proc;
+  other_action->comm.dst_buff = dst_buff;
+  other_action->comm.dst_buff_size = dst_buff_size;
+  other_action->comm.dst_data = data;
+
+  other_action->comm.match_fun = match_fun;
 
   if (MC_IS_ENABLED) {
-    action->state = SIMIX_RUNNING;
-    return action;
+    other_action->state = SIMIX_RUNNING;
+    return other_action;
   }
 
-  SIMIX_comm_start(action);
-  return action;
+  SIMIX_comm_start(other_action);
+  return other_action;
 }
 
 void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout, int idx)
index d9e2fcf..d14ec57 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _SIMIX_NETWORK_PRIVATE_H
 #define _SIMIX_NETWORK_PRIVATE_H
 
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
 /** @brief Rendez-vous point datatype */
@@ -34,22 +34,22 @@ void SIMIX_comm_start(smx_action_t action);
 void SIMIX_comm_send(smx_process_t src_proc, smx_rdv_t rdv,
                      double task_size, double rate,
                      void *src_buff, size_t src_buff_size,
-                     int (*)(void *, void *), void *data,
+                     int (*match_fun)(void *, void *,smx_action_t), void *data,
                      double timeout);
 smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
                               double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
-                              int (*)(void *, void *),
+                              int (*match_fun)(void *, void *, smx_action_t),
                               void (*clean_fun)(void *), // used to free the action in case of problem after a detached send
                               void *data,
                               int detached);
 void SIMIX_comm_recv(smx_process_t dst_proc, smx_rdv_t rdv,
                      void *dst_buff, size_t *dst_buff_size,
-                     int (*)(void *, void *), void *data,
+                     int (*)(void *, void *,smx_action_t), void *data,
                      double timeout);
 smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
                               void *dst_buff, size_t *dst_buff_size,
-                              int (*)(void *, void *), void *data);
+                              int (*)(void *, void *, smx_action_t), void *data);
 void SIMIX_comm_destroy(smx_action_t action);
 void SIMIX_comm_destroy_internal_actions(smx_action_t action);
 void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double timeout, int idx);
index 824239f..b19e966 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _SIMIX_PRIVATE_H
 #define _SIMIX_PRIVATE_H
 
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "surf/surf.h"
 #include "xbt/fifo.h"
 #include "xbt/swag.h"
@@ -123,6 +123,9 @@ typedef struct s_smx_action {
       int detached;                   /* If detached or not */
 
       void (*clean_fun)(void*);       /* Function to clean the detached src_buf if something goes wrong */
+      int (*match_fun)(void*,void*,smx_action_t);  /* Filter function used by the other side. It is used when
+                                         looking if a given communication matches my needs. For that, myself must match the
+                                         expectations of the other side, too. See  */
 
       /* Surf action data */
       surf_action_t surf_comm;        /* The Surf communication action encapsulated */
index d5295c9..2b9359b 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _SIMIX_PROCESS_PRIVATE_H
 #define _SIMIX_PROCESS_PRIVATE_H
 
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "smx_smurf_private.h"
 
 /** @brief Process datatype */
index c16c605..13233a7 100644 (file)
@@ -320,7 +320,7 @@ typedef struct s_smx_simcall {
       double rate;
       void *src_buff;
       size_t src_buff_size;
-      int (*match_fun)(void *, void *);
+      int (*match_fun)(void *, void *, smx_action_t);
       void *data;
       double timeout;
     } comm_send;
@@ -331,7 +331,7 @@ typedef struct s_smx_simcall {
       double rate;
       void *src_buff;
       size_t src_buff_size;
-      int (*match_fun)(void *, void *);
+      int (*match_fun)(void *, void *, smx_action_t);
       void (*clean_fun)(void *);
       void *data;
       int detached;
@@ -342,7 +342,7 @@ typedef struct s_smx_simcall {
       smx_rdv_t rdv;
       void *dst_buff;
       size_t *dst_buff_size;
-      int (*match_fun)(void *, void *);
+      int (*match_fun)(void *, void *, smx_action_t);
       void *data;
       double timeout;
     } comm_recv;
@@ -351,8 +351,8 @@ typedef struct s_smx_simcall {
       smx_rdv_t rdv;
       void *dst_buff;
       size_t *dst_buff_size;
-      int (*match_fun)(void *, void *);
-          void *data;
+      int (*match_fun)(void *, void *, smx_action_t);
+      void *data;
       smx_action_t result;
     } comm_irecv;
 
index 2663088..455b98d 100644 (file)
@@ -700,7 +700,7 @@ smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
 
 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
                          void *src_buff, size_t src_buff_size,
-                         int (*match_fun)(void *, void *), void *data,
+                         int (*match_fun)(void *, void *, smx_action_t), void *data,
                          double timeout)
 {
   /* checking for infinite values */
@@ -735,7 +735,7 @@ void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
 
 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
-                              int (*match_fun)(void *, void *),
+                              int (*match_fun)(void *, void *, smx_action_t),
                               void (*clean_fun)(void *),
                               void *data,
                               int detached)
@@ -764,7 +764,7 @@ smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
 }
 
 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
-                         int (*match_fun)(void *, void *), void *data, double timeout)
+                         int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
 {
   xbt_assert(isfinite(timeout), "timeout is not finite!");
   xbt_assert(rdv, "No rendez-vous point defined for recv");
@@ -791,7 +791,7 @@ void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
 }
 
 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
-                                  int (*match_fun)(void *, void *), void *data)
+                                  int (*match_fun)(void *, void *, smx_action_t), void *data)
 {
   xbt_assert(rdv, "No rendez-vous point defined for irecv");
 
index 6105faa..a01ffef 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "xbt.h"
 #include "xbt/xbt_os_time.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 #include "smpi/smpi.h"
 #include "smpi/smpif.h"
 #include "smpi/smpi_cocci.h"
index d27f40c..d98b98a 100644 (file)
@@ -11,7 +11,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi,
                                 "Logging specific to SMPI (base)");
 
-static int match_recv(void* a, void* b) {
+static int match_recv(void* a, void* b, smx_action_t ignored) {
    MPI_Request ref = (MPI_Request)a;
    MPI_Request req = (MPI_Request)b;
 
@@ -21,7 +21,7 @@ static int match_recv(void* a, void* b) {
           && (ref->tag == MPI_ANY_TAG || req->tag == ref->tag);
 }
 
-static int match_send(void* a, void* b) {
+static int match_send(void* a, void* b,smx_action_t ignored) {
    MPI_Request ref = (MPI_Request)a;
    MPI_Request req = (MPI_Request)b;
 
index db92f65..d485ba3 100644 (file)
@@ -13,8 +13,7 @@
 
 #include "xbt/synchro.h"        /* This module */
 
-#include "simix/simix.h"        /* used implementation */
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"        /* used implementation */
 #include "../simix/smx_private.h" /* FIXME */
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt,
index 726b0c2..8a3722f 100644 (file)
@@ -7,7 +7,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "gras/Virtu/virtu_sg.h"
-#include "simix/simix.h"
+#include "simgrid/simix.h"
 
 /*
  * Time elapsed since the begining of the simulation.
index edb9aec..8e25f90 100644 (file)
@@ -18,7 +18,7 @@
 #include "xbt/datadesc.h"
 #include "xbt/file_stat.h"
 #include "../../src/xbt/datadesc/datadesc_private.h" // RAAAAH! ugly relative path, but it's late, I want it to be done NOW.
-#include "simix/datatypes.h"
+#include "simgrid/simix.h"
 #include "../../src/simix/smx_smurf_private.h" // RAAAAH! ugly relative path, but it's even later and it still doesn't work
 
 static void define_types(void) {