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)
1  2 
include/msg/msg.h
include/simgrid/simix.h
src/msg/msg_private.h
src/msg/msg_process.c
src/simix/smx_process_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/xbt/xbt_sg_synchro.c
tools/gras/struct_diff.c

diff --combined include/msg/msg.h
@@@ -12,8 -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
@@@ -102,6 -100,7 +102,7 @@@ XBT_PUBLIC(m_process_t) MSG_process_cre
                                                              code,
                                                              void *data,
                                                              m_host_t host,
+                                                             double kill_time,
                                                              int argc,
                                                              char **argv,
                                                              xbt_dict_t
@@@ -193,7 -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);
@@@ -287,6 -286,7 +288,6 @@@ XBT_PUBLIC(int) MSG_get_channel_number(
  #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()
diff --combined include/simgrid/simix.h
  #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);
@@@ -307,6 -128,7 +308,7 @@@ XBT_PUBLIC(void) simcall_process_create
                                            xbt_main_func_t code,
                                            void *data,
                                            const char *hostname,
+                                           double kill_time,
                                            int argc, char **argv,
                                            xbt_dict_t properties);
  
@@@ -348,24 -170,24 +350,24 @@@ XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_po
  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 --combined src/msg/msg_private.h
@@@ -8,7 -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 **************************************/
  
@@@ -121,7 -125,7 +121,7 @@@ XBT_PUBLIC_DATA(MSG_Global_t) msg_globa
  #  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);
  void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
  void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
                                     xbt_main_func_t code, void *data,
-                                    const char *hostname, int argc,
+                                    const char *hostname, double kill_time,  int argc,
                                     char **argv, xbt_dict_t properties);
  void MSG_process_kill_from_SIMIX(smx_process_t p);
  void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
diff --combined src/msg/msg_process.c
@@@ -58,12 -58,12 +58,12 @@@ void MSG_process_cleanup_from_SIMIX(smx
  /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */
  void MSG_process_create_from_SIMIX(smx_process_t* process, const char *name,
                                      xbt_main_func_t code, void *data,
-                                     const char *hostname, int argc, char **argv,
+                                     const char *hostname, double kill_time, int argc, char **argv,
                                      xbt_dict_t properties)
  {
    m_host_t host = MSG_get_host_by_name(hostname);
    m_process_t p = MSG_process_create_with_environment(name, code, data,
-                                                       host, argc, argv,
+                                                       host, kill_time, argc, argv,
                                                        properties);
    *((m_process_t*) process) = p;
  }
@@@ -79,7 -79,7 +79,7 @@@ m_process_t MSG_process_create(const ch
                                 xbt_main_func_t code, void *data,
                                 m_host_t host)
  {
-   return MSG_process_create_with_environment(name, code, data, host, -1,
+   return MSG_process_create_with_environment(name, code, data, host, -1, -1,
                                               NULL, NULL);
  }
  
@@@ -113,7 -113,7 +113,7 @@@ m_process_t MSG_process_create_with_arg
                                                void *data, m_host_t host,
                                                int argc, char **argv)
  {
-   return MSG_process_create_with_environment(name, code, data, host,
+   return MSG_process_create_with_environment(name, code, data, host, -1.0,
                                               argc, argv, NULL);
  }
  
     object.  It is for user-level information and can be NULL. It can
     be retrieved with the function \ref MSG_process_get_data.
   * \param host the location where the new process is executed.
+  * \param kill_time the time when the process is killed.
   * \param argc first argument passed to \a code
   * \param argv second argument passed to \a code
   * \param properties list a properties defined for this process
  m_process_t MSG_process_create_with_environment(const char *name,
                                                  xbt_main_func_t code,
                                                  void *data, m_host_t host,
+                                                 double kill_time,
                                                  int argc, char **argv,
                                                  xbt_dict_t properties)
  {
  
    /* 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, SIMIX_host_get_name(host->smx_host),
 -  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) {
@@@ -231,7 -233,7 +233,7 @@@ MSG_error_t MSG_process_migrate(m_proce
    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;
  }
  
@@@ -7,7 -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 */
@@@ -50,6 -50,7 +50,7 @@@ void SIMIX_process_create(smx_process_
                            xbt_main_func_t code,
                            void *data,
                            const char *hostname,
+                           double kill_time,
                            int argc, char **argv,
                            xbt_dict_t properties);
  void SIMIX_process_runall(void);
@@@ -223,6 -223,7 +223,7 @@@ typedef struct s_smx_simcall 
        xbt_main_func_t code;
        void *data;
        const char *hostname;
+       double kill_time;
        int argc;
        char **argv;
        xbt_dict_t properties;
        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;
        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;
        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;
        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;
  
diff --combined src/simix/smx_user.c
@@@ -343,6 -343,7 +343,7 @@@ e_smx_state_t simcall_host_execution_wa
   * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
   * It can be retrieved with the function \ref simcall_process_get_data.
   * \param hostname name of the host where the new agent is executed.
+  * \param kill_time time when the process is killed
   * \param argc first argument passed to \a code
   * \param argv second argument passed to \a code
   * \param properties the properties of the process
@@@ -351,6 -352,7 +352,7 @@@ void simcall_process_create(smx_process
                                xbt_main_func_t code,
                                void *data,
                                const char *hostname,
+                               double kill_time,
                                int argc, char **argv,
                                xbt_dict_t properties)
  {
    simcall->process_create.code = code;
    simcall->process_create.data = data;
    simcall->process_create.hostname = hostname;
+   simcall->process_create.kill_time = kill_time;
    simcall->process_create.argc = argc;
    simcall->process_create.argv = argv;
    simcall->process_create.properties = properties;
@@@ -697,7 -700,7 +700,7 @@@ smx_action_t simcall_rdv_get_head(smx_r
  
  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 */
  
  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)
  }
  
  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");
  }
  
  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");
  
diff --combined src/xbt/xbt_sg_synchro.c
@@@ -13,7 -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,
@@@ -65,7 -66,7 +65,7 @@@ xbt_thread_t xbt_thread_create(const ch
    /*   char*name = bprintf("%s#%p",SIMIX_process_self_get_name(), param); */
    simcall_process_create(&res->s_process, name,
                             xbt_thread_create_wrapper, res,
-                            SIMIX_host_self_get_name(), 0, NULL,
+                            SIMIX_host_self_get_name(), -1.0, 0, NULL,
                             /*props */ NULL);
    res->joinable = joinable;
    res->done = 0;
diff --combined tools/gras/struct_diff.c
@@@ -18,7 -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/simix.h"
 -#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) {