/*OUT*/ double *sec, double *bw);
XBT_PUBLIC(void) amok_bw_request(const char *from_name,
- unsigned int from_port, const char *to_name,
- unsigned int to_port,
+ unsigned int from_port,
+ const char *to_name, unsigned int to_port,
unsigned long int buf_size,
unsigned long int msg_size,
unsigned long int msg_amount,
XBT_PUBLIC(double *) amok_bw_matrix(xbt_dynar_t hosts, /* dynar of xbt_host_t */
int buf_size_bw, int msg_size_bw,
- int msg_amount_bw, double min_duration);
+ int msg_amount_bw,
+ double min_duration);
/* ***************************************************************************
* Link saturation
unsigned int to_port,
unsigned int msg_size,
double duration,
- /*out */ double *elapsed, double *bw);
+ /*out */ double *elapsed,
+ double *bw);
XBT_PUBLIC(void) amok_bw_saturate_stop(const char *from_name,
unsigned int from_port,
/** @} */
-#endif /* AMOK_BANDWIDTH_H */
+#endif /* AMOK_BANDWIDTH_H */
XBT_PUBLIC(void) amok_base_exit(void);
-#endif /* AMOK_BASE_H */
+#endif /* AMOK_BASE_H */
/** @} */
-#endif /* AMOK_peer_MANAGEMENT_H */
+#endif /* AMOK_peer_MANAGEMENT_H */
XBT_PUBLIC(void) gras_init(int *argc, char **argv);
XBT_PUBLIC(void) gras_exit(void);
-#endif /* GRAS_H */
+#endif /* GRAS_H */
*/
/* @{ */
/** @brief Opaque type describing a type description. */
- typedef struct s_gras_datadesc_type *gras_datadesc_type_t;
+typedef struct s_gras_datadesc_type *gras_datadesc_type_t;
/** \brief Search a type description from its name */
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_by_name(const char *name);
/* @} */
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_parse(const char *name, const char *C_statement);
+ gras_datadesc_parse(const char *name, const char *C_statement);
/** @defgroup GRAS_dd_manual Simple manual data description
* @ingroup GRAS_dd
/** \brief Opaque type describing a type description callback persistant state. */
- typedef struct s_gras_cbps *gras_cbps_t;
+typedef struct s_gras_cbps *gras_cbps_t;
/* callbacks prototypes */
/** \brief Prototype of type callbacks returning nothing. */
- typedef void (*gras_datadesc_type_cb_void_t) (gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
- void *data);
+typedef void (*gras_datadesc_type_cb_void_t) (gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
/** \brief Prototype of type callbacks returning an int. */
- typedef int (*gras_datadesc_type_cb_int_t) (gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
- void *data);
+typedef int (*gras_datadesc_type_cb_int_t) (gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
/** \brief Prototype of type callbacks selecting a type. */
- typedef
+typedef
+
-
- gras_datadesc_type_t(*gras_datadesc_selector_t) (gras_datadesc_type_t
- typedesc,
- gras_cbps_t vars,
- void *data);
+gras_datadesc_type_t(*gras_datadesc_selector_t) (gras_datadesc_type_t
+ typedesc,
+ gras_cbps_t vars,
+ void *data);
/******************************************
******************************************/
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_struct(const char *name);
-XBT_PUBLIC(void) gras_datadesc_struct_append(gras_datadesc_type_t struct_type,
- const char *name,
- gras_datadesc_type_t field_type);
-XBT_PUBLIC(void) gras_datadesc_struct_close(gras_datadesc_type_t struct_type);
+XBT_PUBLIC(void) gras_datadesc_struct_append(gras_datadesc_type_t
+ struct_type, const char *name,
+ gras_datadesc_type_t
+ field_type);
+XBT_PUBLIC(void) gras_datadesc_struct_close(gras_datadesc_type_t
+ struct_type);
XBT_PUBLIC(gras_datadesc_type_t) gras_datadesc_union(const char *name,
gras_datadesc_type_cb_int_t
selector);
-XBT_PUBLIC(void) gras_datadesc_union_append(gras_datadesc_type_t union_type,
- const char *name,
- gras_datadesc_type_t field_type);
-XBT_PUBLIC(void) gras_datadesc_union_close(gras_datadesc_type_t union_type);
+XBT_PUBLIC(void) gras_datadesc_union_append(gras_datadesc_type_t
+ union_type, const char *name,
+ gras_datadesc_type_t
+ field_type);
+XBT_PUBLIC(void) gras_datadesc_union_close(gras_datadesc_type_t
+ union_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref(const char *name, gras_datadesc_type_t referenced_type);
+ gras_datadesc_ref(const char *name, gras_datadesc_type_t referenced_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_copy(const char *name, gras_datadesc_type_t copied_type);
+ gras_datadesc_copy(const char *name, gras_datadesc_type_t copied_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref_generic(const char *name,
+ gras_datadesc_ref_generic(const char *name,
gras_datadesc_selector_t selector);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_array_fixed(const char *name,
+ gras_datadesc_array_fixed(const char *name,
gras_datadesc_type_t element_type,
long int fixed_size);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_array_dyn(const char *name,
+ gras_datadesc_array_dyn(const char *name,
gras_datadesc_type_t element_type,
gras_datadesc_type_cb_int_t dynamic_size);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type);
+ gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func);
+ gras_datadesc_dynar(gras_datadesc_type_t elm_t, void_f_pvoid_t free_func);
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_matrix(gras_datadesc_type_t elm_t, void_f_pvoid_t const free_f);
+ gras_datadesc_matrix(gras_datadesc_type_t elm_t,
+ void_f_pvoid_t const free_f);
/*********************************
* Change stuff within datadescs *
XBT_PUBLIC(void) gras_datadesc_cb_field_push(gras_datadesc_type_t type,
const char *field_name);
/** \brief Add a pre-send callback to the given field resulting in its value multiplied to any previously pushed value and then pushed back */
-XBT_PUBLIC(void) gras_datadesc_cb_field_push_multiplier(gras_datadesc_type_t
- type, const char
- *field_name);
+XBT_PUBLIC(void)
+gras_datadesc_cb_field_push_multiplier(gras_datadesc_type_t type,
+ const char
+ *field_name);
/******************************
* Get stuff within datadescs *
XBT_PUBLIC(void) gras_datadesc_cb_push_ulint(gras_datadesc_type_t typedesc,
gras_cbps_t vars, void *data);
-XBT_PUBLIC(void) gras_datadesc_cb_push_int_mult(gras_datadesc_type_t typedesc,
- gras_cbps_t vars, void *data);
+XBT_PUBLIC(void) gras_datadesc_cb_push_int_mult(gras_datadesc_type_t
+ typedesc, gras_cbps_t vars,
+ void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_uint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_lint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
XBT_PUBLIC(void) gras_datadesc_cb_push_ulint_mult(gras_datadesc_type_t
- typedesc, gras_cbps_t vars,
+ typedesc,
+ gras_cbps_t vars,
void *data);
/**
* Basic types we can embeed in DataDescriptors.
*/
- typedef enum
- { CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
- UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE
- } DataTypes;
+typedef enum
+ { CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
+ UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE
+} DataTypes;
#define SIMPLE_TYPE_COUNT 9
/** \brief Describe a collection of data.
** padding bytes the compiler adds to the end of the structure.
*/
- typedef struct DataDescriptorStruct {
- DataTypes type;
- size_t repetitions;
- size_t offset;
- /*@null@ */ struct DataDescriptorStruct *members;
- size_t length;
- size_t tailPadding;
- } DataDescriptor;
+typedef struct DataDescriptorStruct {
+ DataTypes type;
+ size_t repetitions;
+ size_t offset;
+ /*@null@ */ struct DataDescriptorStruct *members;
+ size_t length;
+ size_t tailPadding;
+} DataDescriptor;
/** DataDescriptor for an array */
#define SIMPLE_DATA(type,repetitions) \
{type, repetitions, 0, NULL, 0, 0}
sizeof(memberType) * repetitions
XBT_PUBLIC(gras_datadesc_type_t)
- gras_datadesc_import_nws(const char *name,
- const DataDescriptor * desc, unsigned long howmany);
+ gras_datadesc_import_nws(const char *name,
+ const DataDescriptor * desc,
+ unsigned long howmany);
SG_END_DECL()
-#endif /* GRAS_DATADESC_H */
+#endif /* GRAS_DATADESC_H */
/** @} */
SG_END_DECL()
-#endif /* GRAS_COND_H */
+#endif /* GRAS_COND_H */
*/
/** @{ */
/** \brief Opaque type */
- typedef struct s_gras_msgtype *gras_msgtype_t;
+typedef struct s_gras_msgtype *gras_msgtype_t;
XBT_PUBLIC(void) gras_msgtype_declare(const char *name,
gras_datadesc_type_t payload);
XBT_PUBLIC(gras_msgtype_t) gras_msgtype_by_namev(const char *name,
short int version);
XBT_PUBLIC(gras_msgtype_t) gras_msgtype_by_id(int id);
-XBT_PUBLIC(const char*) gras_msgtype_get_name(gras_msgtype_t type);
+XBT_PUBLIC(const char *) gras_msgtype_get_name(gras_msgtype_t type);
XBT_PUBLIC(void) gras_msgtype_dumpall(void);
*/
/** \brief Context of callbacks (opaque structure, created by the middleware only, never by user) */
- typedef struct s_gras_msg_cb_ctx *gras_msg_cb_ctx_t;
+typedef struct s_gras_msg_cb_ctx *gras_msg_cb_ctx_t;
XBT_PUBLIC(void) gras_msg_cb_ctx_free(gras_msg_cb_ctx_t ctx);
XBT_PUBLIC(gras_socket_t) gras_msg_cb_ctx_from(gras_msg_cb_ctx_t ctx);
*
* If the callback accepts the message, it should free it after use.
*/
- typedef int (*gras_msg_cb_t) (gras_msg_cb_ctx_t ctx, void *payload);
+typedef int (*gras_msg_cb_t) (gras_msg_cb_ctx_t ctx, void *payload);
/**
* @brief Bind the given callback to the given message type (described by its name)
*/
#define gras_cb_unregister(msgtype_name, cb) gras_cb_unregister_(gras_msgtype_by_name(msgtype_name),cb)
-XBT_PUBLIC(void) gras_cb_register_(gras_msgtype_t msgtype, gras_msg_cb_t cb);
+XBT_PUBLIC(void) gras_cb_register_(gras_msgtype_t msgtype,
+ gras_msg_cb_t cb);
XBT_PUBLIC(void) gras_cb_unregister_(gras_msgtype_t msgtype,
gras_msg_cb_t cb);
* @hideinitializer
*/
#define gras_msg_rpc_async_call(server,timeout,msg,req) gras_msg_rpc_async_call_(server,timeout,gras_msgtype_by_name(msg),req)
- gras_msg_rpc_async_call_(gras_socket_t server,
+ gras_msg_rpc_async_call_(gras_socket_t server,
double timeOut,
gras_msgtype_t msgtype, void *request);
-XBT_PUBLIC(void) gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx, void *answer);
+XBT_PUBLIC(void) gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx,
+ void *answer);
/* server side */
XBT_PUBLIC(void) gras_msg_rpcreturn(double timeOut, gras_msg_cb_ctx_t ctx,
/** @{ */
/** @brief Message kind (internal enum) */
- typedef enum {
- e_gras_msg_kind_unknown = 0,
+typedef enum {
+ e_gras_msg_kind_unknown = 0,
- e_gras_msg_kind_oneway = 1,
+ e_gras_msg_kind_oneway = 1,
/**< good old regular messages */
- e_gras_msg_kind_rpccall = 2,
+ e_gras_msg_kind_rpccall = 2,
/**< RPC request */
- /* HACK: e_gras_msg_kind_rpccall also designate RPC message *type* in
- msgtype_t, not only in msg_t */
- e_gras_msg_kind_rpcanswer = 3,
+ /* HACK: e_gras_msg_kind_rpccall also designate RPC message *type* in
+ msgtype_t, not only in msg_t */
+ e_gras_msg_kind_rpcanswer = 3,
/**< RPC successful answer */
- e_gras_msg_kind_rpcerror = 4,
+ e_gras_msg_kind_rpcerror = 4,
/**< RPC failure on server (payload=exception); should not leak to user-space */
- /* future:
- call cancel, and others
- even after:
- forwarding request and other application level routing stuff
- group communication
- */
+ /* future:
+ call cancel, and others
+ even after:
+ forwarding request and other application level routing stuff
+ group communication
+ */
- e_gras_msg_kind_count = 5 /* sentinel, dont mess with */
- } e_gras_msg_kind_t;
+ e_gras_msg_kind_count = 5 /* sentinel, dont mess with */
+} e_gras_msg_kind_t;
/** @brief Message instance (internal struct) */
- typedef struct {
- gras_socket_t expe;
- e_gras_msg_kind_t kind;
- gras_msgtype_t type;
- unsigned long int ID;
- void *payl;
- int payl_size;
- } s_gras_msg_t, *gras_msg_t;
+typedef struct {
+ gras_socket_t expe;
+ e_gras_msg_kind_t kind;
+ gras_msgtype_t type;
+ unsigned long int ID;
+ void *payl;
+ int payl_size;
+} s_gras_msg_t, *gras_msg_t;
- typedef int (*gras_msg_filter_t) (gras_msg_t msg, void *ctx);
+typedef int (*gras_msg_filter_t) (gras_msg_t msg, void *ctx);
#define gras_msg_wait_ext(timeout, msg, expe, filter, fctx,got) gras_msg_wait_ext_(timeout, gras_msgtype_by_name(msg), expe, filter, fctx,got)
XBT_PUBLIC(void) gras_msg_wait_ext_(double timeout,
/* @} */
SG_END_DECL()
-#endif /* GRAS_MSG_H */
+#endif /* GRAS_MSG_H */
/* Functions module implementor should use */
XBT_PUBLIC(void) gras_module_add(const char *name, unsigned int data_size,
int *ID, void_f_void_t init_f,
- void_f_void_t exit_f, void_f_pvoid_t join_f,
+ void_f_void_t exit_f,
+ void_f_pvoid_t join_f,
void_f_pvoid_t leave_f);
XBT_PUBLIC(void *) gras_moddata_by_id(unsigned int ID);
-#endif /* GRAS_MODULE_H */
+#endif /* GRAS_MODULE_H */
SG_BEGIN_DECL()
- void gras_agent_spawn(const char *name, void *data, xbt_main_func_t code,
- int argc, char *argv[], xbt_dict_t properties);
+void gras_agent_spawn(const char *name, void *data, xbt_main_func_t code,
+ int argc, char *argv[], xbt_dict_t properties);
/****************************************************************************/
/* @} */
SG_END_DECL()
-#endif /* GRAS_PROCESS_H */
+#endif /* GRAS_PROCESS_H */
/** @} */
SG_END_DECL()
-#endif /* GRAS_TIMER_H */
+#endif /* GRAS_TIMER_H */
unsigned long int bufSize,
int measurement);
XBT_PUBLIC(gras_socket_t)
- gras_socket_server_range(unsigned short minport, unsigned short maxport,
+ gras_socket_server_range(unsigned short minport, unsigned short maxport,
unsigned long int buf_size, int measurement);
/* @}*/
/* @} */
-#endif /* GRAS_TRANSPORT_H */
+#endif /* GRAS_TRANSPORT_H */
/* Initialization of the simulation world. Do not call them in RL.
Indeed, do not call them at all. Let gras_stub_generator do it for you. */
- void gras_global_init(int *argc, char **argv);
- void gras_create_environment(const char *file);
- void gras_function_register(const char *name, xbt_main_func_t code);
- void gras_function_register_default(xbt_main_func_t code);
- void gras_launch_application(const char *file);
- void gras_load_environment_script(const char *file);
- void gras_clean(void);
- void gras_main(void);
+void gras_global_init(int *argc, char **argv);
+void gras_create_environment(const char *file);
+void gras_function_register(const char *name, xbt_main_func_t code);
+void gras_function_register_default(xbt_main_func_t code);
+void gras_launch_application(const char *file);
+void gras_load_environment_script(const char *file);
+void gras_clean(void);
+void gras_main(void);
/** @addtogroup GRAS_virtu
/** @} */
SG_END_DECL()
-#endif /* GRAS_VIRTU_H */
+#endif /* GRAS_VIRTU_H */
#define TRACE_ERROR_FILE_OPEN 401
#define TRACE_ERROR_START 500
-XBT_PUBLIC(int) TRACE_start (void);
-XBT_PUBLIC(int) TRACE_end (void);
-XBT_PUBLIC(int) TRACE_category (const char *category);
-XBT_PUBLIC(void) TRACE_define_type (const char *type, const char *parent_type, int final);
-XBT_PUBLIC(int) TRACE_create_category (const char *category, const char *type, const char *parent_category);
-XBT_PUBLIC(void) TRACE_msg_set_task_category (m_task_t task, const char *category);
-XBT_PUBLIC(void) TRACE_msg_set_process_category (m_process_t process, const char *category);
-XBT_PUBLIC(void) TRACE_set_mask (int mask);
-XBT_PUBLIC(void) TRACE_user_host_variable (double time, const char *variable, double value, const char *what);
-XBT_PUBLIC(void) TRACE_user_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what);
-XBT_PUBLIC(void) TRACE_declare_mark (const char *mark_type);
-XBT_PUBLIC(void) TRACE_mark (const char *mark_type, const char *mark_value);
-XBT_PUBLIC(int) TRACE_smpi_set_category (const char *category);
-XBT_PUBLIC(void) TRACE_sd_set_task_category(SD_task_t task, const char *category);
+XBT_PUBLIC(int) TRACE_start(void);
+XBT_PUBLIC(int) TRACE_end(void);
+XBT_PUBLIC(int) TRACE_category(const char *category);
+XBT_PUBLIC(void) TRACE_define_type(const char *type,
+ const char *parent_type, int final);
+XBT_PUBLIC(int) TRACE_create_category(const char *category,
+ const char *type,
+ const char *parent_category);
+XBT_PUBLIC(void) TRACE_msg_set_task_category(m_task_t task,
+ const char *category);
+XBT_PUBLIC(void) TRACE_msg_set_process_category(m_process_t process,
+ const char *category);
+XBT_PUBLIC(void) TRACE_set_mask(int mask);
+XBT_PUBLIC(void) TRACE_user_host_variable(double time,
+ const char *variable,
+ double value, const char *what);
+XBT_PUBLIC(void) TRACE_user_link_variable(double time, const char *src,
+ const char *dst,
+ const char *variable,
+ double value, const char *what);
+XBT_PUBLIC(void) TRACE_declare_mark(const char *mark_type);
+XBT_PUBLIC(void) TRACE_mark(const char *mark_type, const char *mark_value);
+XBT_PUBLIC(int) TRACE_smpi_set_category(const char *category);
+XBT_PUBLIC(void) TRACE_sd_set_task_category(SD_task_t task,
+ const char *category);
#define TRACE_host_variable_declare(var) \
TRACE_user_host_variable(0,var,0,"declare");
#define TRACE_link_variable_sub(src,dst,var,value) \
TRACE_user_link_variable(MSG_get_clock(),src,dst,var,value,"sub");
-#else /* HAVE_TRACING */
+#else /* HAVE_TRACING */
#define TRACE_start()
#define TRACE_end()
#define TRACE_smpi_set_category(cat)
#define TRACE_sd_set_task_category(task,cat)
-#endif /* HAVE_TRACING */
+#endif /* HAVE_TRACING */
-#endif /* INSTR_H_ */
+#endif /* INSTR_H_ */
#include "xbt.h"
XBT_PUBLIC(void) MC_assert(int);
-XBT_PUBLIC(int) MC_random(int min, int max);
\ No newline at end of file
+XBT_PUBLIC(int) MC_random(int min, int max);
#ifndef MSG_DATATYPE_H
#define MSG_DATATYPE_H
#include "xbt/misc.h"
-#include "simgrid_config.h" // for HAVE_TRACING
+#include "simgrid_config.h" // for HAVE_TRACING
SG_BEGIN_DECL()
/* ******************************** Host ************************************ */
/** @defgroup m_datatypes_management_details Details on MSG datatypes
@ingroup m_datatypes_management*/
- typedef struct simdata_host *simdata_host_t;
+typedef struct simdata_host *simdata_host_t;
/** @brief Host datatype
@ingroup m_datatypes_management_details */
- typedef struct m_host {
- char *name; /**< @brief host name if any */
- simdata_host_t simdata; /**< @brief simulator data */
- void *data; /**< @brief user data */
- } s_m_host_t;
+typedef struct m_host {
+ char *name; /**< @brief host name if any */
+ simdata_host_t simdata; /**< @brief simulator data */
+ void *data; /**< @brief user data */
+} s_m_host_t;
/** @brief Host datatype
@ingroup m_datatypes_management
\see m_host_management
@{ */
- typedef struct m_host *m_host_t;
+typedef struct m_host *m_host_t;
/** @} */
/* ******************************** Task ************************************ */
- typedef struct simdata_task *simdata_task_t;
+typedef struct simdata_task *simdata_task_t;
/** @brief Task datatype
@ingroup m_datatypes_management_details */
- typedef struct m_task {
- char *name; /**< @brief task name if any */
- simdata_task_t simdata; /**< @brief simulator data */
- void *data; /**< @brief user data */
+typedef struct m_task {
+ char *name; /**< @brief task name if any */
+ simdata_task_t simdata; /**< @brief simulator data */
+ void *data; /**< @brief user data */
#ifdef HAVE_TRACING
- long long int counter; /* task unique identifier for instrumentation */
- char *category; /* task category for instrumentation */
+ long long int counter; /* task unique identifier for instrumentation */
+ char *category; /* task category for instrumentation */
#endif
- } s_m_task_t;
+} s_m_task_t;
/** @brief Task datatype
@ingroup m_datatypes_management
data</em>.
\see m_task_management
@{ */
- typedef struct m_task *m_task_t;
+typedef struct m_task *m_task_t;
/** \brief Default value for an uninitialized #m_task_t.
\ingroup m_datatypes_management
*/
#define MSG_TASK_UNINITIALIZED NULL
- typedef struct s_smx_comm *msg_comm_t;
+typedef struct s_smx_comm *msg_comm_t;
/** @} */
/* ****************************** Process *********************************** */
- typedef struct simdata_process *simdata_process_t;
+typedef struct simdata_process *simdata_process_t;
/** @brief Process datatype
@ingroup m_datatypes_management_details @{ */
- typedef struct m_process {
- char *name; /**< @brief process name if any */
- simdata_process_t simdata;
+typedef struct m_process {
+ char *name; /**< @brief process name if any */
+ simdata_process_t simdata;
/**< @brief simulator data */
- void *data; /**< @brief user data */
- char *category; /* process category for instrumentation */
- } s_m_process_t;
+ void *data; /**< @brief user data */
+ char *category; /* process category for instrumentation */
+} s_m_process_t;
/** @} */
/** @brief Agent datatype
@ingroup m_datatypes_management
data</em>, executing in a <em>location</em>.
\see m_process_management
@{ */
- typedef struct m_process *m_process_t;
+typedef struct m_process *m_process_t;
/** @} */
/* ********************************* Channel ******************************** */
port number does).
\see m_channel_management
@{ */
- typedef int m_channel_t;
+typedef int m_channel_t;
/** @} */
/* ******************************** Mailbox ************************************ */
- typedef struct s_msg_mailbox *msg_mailbox_t;
+typedef struct s_msg_mailbox *msg_mailbox_t;
/** @brief Mailbox datatype
@ingroup m_datatypes_management_details @{ */
- msg_mailbox_t MSG_mailbox_create(const char *alias);
- void MSG_mailbox_free(void *mailbox);
+msg_mailbox_t MSG_mailbox_create(const char *alias);
+void MSG_mailbox_free(void *mailbox);
/** @} */
/* ***************************** Error handling ***************************** */
/** @brief Error handling
@ingroup m_datatypes_management
- @{
-*/ /* Keep these code as binary values: java bindings manipulate | of these values */
- typedef enum {
- MSG_OK = 0, /**< @brief Everything is right. Keep on going this way ! */
- MSG_TIMEOUT=1, /**< @brief nothing good happened before the timer you provided elapsed */
- MSG_TRANSFER_FAILURE=2,/**< @brief There has been a problem during you task
+ @{
+*//* Keep these code as binary values: java bindings manipulate | of these values */
+typedef enum {
+ MSG_OK = 0, /**< @brief Everything is right. Keep on going this way ! */
+ MSG_TIMEOUT = 1, /**< @brief nothing good happened before the timer you provided elapsed */
+ MSG_TRANSFER_FAILURE = 2, /**< @brief There has been a problem during you task
transfer. Either the network is down or the remote host has been
shutdown. */
- MSG_HOST_FAILURE=4, /**< @brief System shutdown. The host on which you are
+ MSG_HOST_FAILURE = 4, /**< @brief System shutdown. The host on which you are
running has just been rebooted. Free your datastructures and
return now !*/
- MSG_TASK_CANCELLED=8, /**< @brief Canceled task. This task has been canceled by somebody!*/
- } MSG_error_t;
+ MSG_TASK_CANCELLED = 8, /**< @brief Canceled task. This task has been canceled by somebody!*/
+} MSG_error_t;
/** @} */
SG_END_DECL()
XBT_PUBLIC(xbt_main_func_t) MSG_get_registered_function(const char *name);
XBT_PUBLIC(void) MSG_launch_application(const char *file);
/*Bypass the parser */
-XBT_PUBLIC(void) MSG_set_function(const char* host_id,const char *function_name,xbt_dynar_t arguments);
+XBT_PUBLIC(void) MSG_set_function(const char *host_id,
+ const char *function_name,
+ xbt_dynar_t arguments);
XBT_PUBLIC(double) MSG_get_clock(void);
XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
/************************** Process handling *********************************/
XBT_PUBLIC(m_process_t) MSG_process_create(const char *name,
- xbt_main_func_t code, void *data,
- m_host_t host);
+ xbt_main_func_t code,
+ void *data, m_host_t host);
XBT_PUBLIC(m_process_t) MSG_process_create_with_arguments(const char *name,
xbt_main_func_t
code, void *data,
m_host_t host,
int argc,
char **argv);
-XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char *name,
+XBT_PUBLIC(m_process_t) MSG_process_create_with_environment(const char
+ *name,
xbt_main_func_t
- code, void *data,
+ code,
+ void *data,
m_host_t host,
int argc,
char **argv,
XBT_PUBLIC(MSG_error_t) MSG_process_change_host(m_host_t host);
XBT_PUBLIC(void *) MSG_process_get_data(m_process_t process);
-XBT_PUBLIC(MSG_error_t) MSG_process_set_data(m_process_t process, void *data);
+XBT_PUBLIC(MSG_error_t) MSG_process_set_data(m_process_t process,
+ void *data);
XBT_PUBLIC(m_host_t) MSG_process_get_host(m_process_t process);
XBT_PUBLIC(m_process_t) MSG_process_from_PID(int PID);
XBT_PUBLIC(int) MSG_process_get_PID(m_process_t process);
/*property handlers*/
XBT_PUBLIC(xbt_dict_t) MSG_process_get_properties(m_process_t process);
-XBT_PUBLIC(const char *) MSG_process_get_property_value(m_process_t process,
+XBT_PUBLIC(const char *) MSG_process_get_property_value(m_process_t
+ process,
const char *name);
XBT_PUBLIC(MSG_error_t) MSG_process_suspend(m_process_t process);
XBT_PUBLIC(m_task_t) MSG_task_create(const char *name,
double compute_duration,
double message_size, void *data);
-XBT_PUBLIC(m_task_t) MSG_parallel_task_create(const char *name, int host_nb,
+XBT_PUBLIC(m_task_t) MSG_parallel_task_create(const char *name,
+ int host_nb,
const m_host_t * host_list,
double *computation_amount,
double *communication_amount,
void *data);
XBT_PUBLIC(void *) MSG_task_get_data(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_data(m_task_t task,void*data);
+XBT_PUBLIC(void) MSG_task_set_data(m_task_t task, void *data);
XBT_PUBLIC(m_process_t) MSG_task_get_sender(m_task_t task);
XBT_PUBLIC(m_host_t) MSG_task_get_source(m_task_t task);
XBT_PUBLIC(const char *) MSG_task_get_name(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_name(m_task_t task,const char*name);
+XBT_PUBLIC(void) MSG_task_set_name(m_task_t task, const char *name);
XBT_PUBLIC(MSG_error_t) MSG_task_cancel(m_task_t task);
XBT_PUBLIC(MSG_error_t) MSG_task_destroy(m_task_t task);
XBT_PUBLIC(void) MSG_task_refcount_dec(m_task_t task);
XBT_PUBLIC(MSG_error_t) MSG_task_get_with_timeout(m_task_t * task,
m_channel_t channel,
double max_duration);
-XBT_PUBLIC(MSG_error_t) MSG_task_get_from_host(m_task_t * task, int channel,
- m_host_t host);
- MSG_error_t MSG_task_receive_from_host(m_task_t * task,
- const char *alias, m_host_t host);
+XBT_PUBLIC(MSG_error_t) MSG_task_get_from_host(m_task_t * task,
+ int channel, m_host_t host);
+MSG_error_t MSG_task_receive_from_host(m_task_t * task, const char *alias,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t) MSG_task_get_ext(m_task_t * task, int channel,
- double max_duration, m_host_t host);
+ double max_duration,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t) MSG_task_put(m_task_t task, m_host_t dest,
XBT_PUBLIC(MSG_error_t) MSG_get_errno(void);
XBT_PUBLIC(double) MSG_task_get_compute_duration(m_task_t task);
-XBT_PUBLIC(void) MSG_task_set_compute_duration(m_task_t task,double compute_duration);
+XBT_PUBLIC(void) MSG_task_set_compute_duration(m_task_t task,
+ double compute_duration);
XBT_PUBLIC(double) MSG_task_get_remaining_computation(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_remaining_communication(m_task_t task);
-XBT_PUBLIC(int) MSG_task_is_latency_bounded(m_task_t task);
+XBT_PUBLIC(int) MSG_task_is_latency_bounded(m_task_t task);
XBT_PUBLIC(double) MSG_task_get_data_size(m_task_t task);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout,
+ MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout,
m_host_t host);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive_with_timeout(m_task_t * task, const char *alias,
+ MSG_task_receive_with_timeout(m_task_t * task, const char *alias,
double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_task_receive(m_task_t * task, const char *alias);
-
-XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias);
-XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias);
-XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
-XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
-XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm,double timeout);
-XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t *comm,int nb_elem, double timeout);
+ MSG_task_receive(m_task_t * task, const char *alias);
+
+XBT_PUBLIC(msg_comm_t) MSG_task_isend(m_task_t task, const char *alias);
+XBT_PUBLIC(msg_comm_t) MSG_task_irecv(m_task_t * task, const char *alias);
+XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
+XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
+XBT_PUBLIC(MSG_error_t) MSG_comm_wait(msg_comm_t comm, double timeout);
+XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t * comm, int nb_elem,
+ double timeout);
XBT_PUBLIC(int) MSG_comm_waitany(xbt_dynar_t comms);
XBT_PUBLIC(m_task_t) MSG_comm_get_task(msg_comm_t comm);
XBT_PUBLIC(int) MSG_task_listen(const char *alias);
-XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias, m_host_t host);
+XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias,
+ m_host_t host);
XBT_PUBLIC(MSG_error_t)
- MSG_alias_select_from(const char *alias, double timeout, int *PID);
+ MSG_alias_select_from(const char *alias, double timeout, int *PID);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send_with_timeout(m_task_t task, const char *alias, double timeout);
+ MSG_task_send_with_timeout(m_task_t task, const char *alias,
+ double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send(m_task_t task, const char *alias);
+ MSG_task_send(m_task_t task, const char *alias);
XBT_PUBLIC(MSG_error_t)
- MSG_task_send_bounded(m_task_t task, const char *alias, double rate);
+ MSG_task_send_bounded(m_task_t task, const char *alias, double rate);
XBT_PUBLIC(int) MSG_task_listen_from(const char *alias);
/************************** Task handling ************************************/
XBT_PUBLIC(MSG_error_t)
- MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
+ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
m_host_t host, double timeout);
XBT_PUBLIC(MSG_error_t)
- MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
+ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
double timeout);
/************************** Action handling **********************************/
- typedef void (*msg_action_fun) (xbt_dynar_t args);
+typedef void (*msg_action_fun) (xbt_dynar_t args);
XBT_PUBLIC(void) MSG_action_register(const char *action_name,
msg_action_fun function);
XBT_PUBLIC(void) MSG_action_unregister(const char *action_name);
- MSG_error_t MSG_action_trace_run(char *path);
+MSG_error_t MSG_action_trace_run(char *path);
#ifdef MSG_USE_DEPRECATED
@see SD_task_management */
typedef enum {
SD_NOT_SCHEDULED = 0, /**< @brief Initial state (not valid for SD_watch and SD_unwatch). */
- SD_SCHEDULABLE = 0x0001, /**< @brief A task becomes SD_READY as soon as its dependencies are satisfied */
+ SD_SCHEDULABLE = 0x0001, /**< @brief A task becomes SD_READY as soon as its dependencies are satisfied */
SD_SCHEDULED = 0x0002, /**< @brief A task becomes SD_SCHEDULED when you call function
SD_task_schedule. SD_simulate will execute it when it becomes SD_RUNNABLE. */
SD_RUNNABLE = 0x0004, /**< @brief A scheduled task becomes runnable is SD_simulate as soon as its dependencies are satisfied. */
@see SD_task_management */
typedef enum {
SD_TASK_NOT_TYPED = 0, /**< @no specified type */
- SD_TASK_COMM_E2E = 1, /**< @brief end to end communication */
- SD_TASK_COMP_SEQ = 2, /**< @brief sequential computation */
+ SD_TASK_COMM_E2E = 1, /**< @brief end to end communication */
+ SD_TASK_COMP_SEQ = 2, /**< @brief sequential computation */
} e_SD_task_kind_t;
workstation);
XBT_PUBLIC(const char *) SD_workstation_get_property_value(SD_workstation_t
workstation,
- const char *name);
+ const char
+ *name);
XBT_PUBLIC(const SD_link_t *) SD_route_get_list(SD_workstation_t src,
SD_workstation_t dst);
-XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src, SD_workstation_t dst);
+XBT_PUBLIC(int) SD_route_get_size(SD_workstation_t src,
+ SD_workstation_t dst);
XBT_PUBLIC(double) SD_workstation_get_power(SD_workstation_t workstation);
XBT_PUBLIC(double) SD_workstation_get_available_power(SD_workstation_t
workstation);
XBT_PUBLIC(e_SD_workstation_access_mode_t)
- SD_workstation_get_access_mode(SD_workstation_t workstation);
-XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t workstation,
+ SD_workstation_get_access_mode(SD_workstation_t workstation);
+XBT_PUBLIC(void) SD_workstation_set_access_mode(SD_workstation_t
+ workstation,
e_SD_workstation_access_mode_t
access_mode);
double
communication_amount);
-XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task (SD_workstation_t workstation);
+XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task(SD_workstation_t
+ workstation);
/** @} */
/************************** Task handling ************************************/
XBT_PUBLIC(double) SD_task_get_execution_time(SD_task_t task,
int workstation_nb,
const SD_workstation_t *
- workstation_list, const double
+ workstation_list,
+ const double
*computation_amount, const double
*communication_amount);
XBT_PUBLIC(int) SD_task_get_kind(SD_task_t task);
XBT_PUBLIC(void) SD_task_schedule(SD_task_t task, int workstation_nb,
- const SD_workstation_t * workstation_list,
+ const SD_workstation_t *
+ workstation_list,
const double *computation_amount,
const double *communication_amount,
double rate);
XBT_PUBLIC(xbt_dynar_t) SD_task_get_parents(SD_task_t task);
XBT_PUBLIC(xbt_dynar_t) SD_task_get_children(SD_task_t task);
XBT_PUBLIC(int) SD_task_get_workstation_count(SD_task_t task);
-XBT_PUBLIC(SD_workstation_t*) SD_task_get_workstation_list(SD_task_t task);
+XBT_PUBLIC(SD_workstation_t *) SD_task_get_workstation_list(SD_task_t
+ task);
XBT_PUBLIC(void) SD_task_destroy(SD_task_t task);
XBT_PUBLIC(void) SD_task_dump(SD_task_t task);
-XBT_PUBLIC(void) SD_task_dotty(SD_task_t task,void* out_FILE);
-
-XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char*name,void *data,double amount);
-XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char*name,void *data,double amount);
-XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list);
+XBT_PUBLIC(void) SD_task_dotty(SD_task_t task, void *out_FILE);
+
+XBT_PUBLIC(SD_task_t) SD_task_create_comp_seq(const char *name, void *data,
+ double amount);
+XBT_PUBLIC(SD_task_t) SD_task_create_comm_e2e(const char *name, void *data,
+ double amount);
+XBT_PUBLIC(void) SD_task_schedulev(SD_task_t task, int count,
+ const SD_workstation_t * list);
XBT_PUBLIC(void) SD_task_schedulel(SD_task_t task, int count, ...);
/** @brief A constant to use in SD_task_schedule to mean that there is no cost.
XBT_PUBLIC(void) SD_task_dependency_add(const char *name, void *data,
SD_task_t src, SD_task_t dst);
XBT_PUBLIC(void) SD_task_dependency_remove(SD_task_t src, SD_task_t dst);
-XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src, SD_task_t dst);
+XBT_PUBLIC(void *) SD_task_dependency_get_data(SD_task_t src,
+ SD_task_t dst);
XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
/** @} */
XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
XBT_PUBLIC(double) SD_get_clock(void);
XBT_PUBLIC(void) SD_exit(void);
-XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char*filename);
-XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char*filename);
+XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char *filename);
+XBT_PUBLIC(xbt_dynar_t) SD_dotload(const char *filename);
XBT_PUBLIC(void) uniq_transfer_task_name(SD_task_t task);
/** @} */
#define MPI_THREAD_FUNNELED 1
#define MPI_THREAD_SERIALIZED 2
#define MPI_THREAD_MULTIPLE 3
-
//FIXME: check values
#define MPI_MAX_PROCESSOR_NAME 100
#define MPI_MAX_ERROR_STRING 100
#define MPI_MAX_INFO_VAL 100
#define MPI_MAX_OBJECT_NAME 100
#define MPI_MAX_PORT_NAME 100
-
#define SMPI_RAND_SEED 5
#define MPI_ANY_SOURCE -1
#define MPI_PROC_NULL -2
#define MPI_ANY_TAG -1
#define MPI_UNDEFINED -1
-
// errorcodes
#define MPI_SUCCESS 0
#define MPI_ERR_COMM 1
#define MPI_ERR_TRUNCATE 9
#define MPI_ERR_GROUP 10
#define MPI_ERR_OP 11
-
#define MPI_IDENT 0
#define MPI_SIMILAR 1
#define MPI_UNEQUAL 2
#define MPI_CONGRUENT 3
-
#define MPI_WTIME_IS_GLOBAL 1
-
typedef ptrdiff_t MPI_Aint;
typedef long long MPI_Offset;
struct s_smpi_mpi_datatype;
-typedef struct s_smpi_mpi_datatype* MPI_Datatype;
+typedef struct s_smpi_mpi_datatype *MPI_Datatype;
typedef struct {
int MPI_SOURCE;
extern MPI_Datatype MPI_LONG_DOUBLE_INT;
-typedef void MPI_User_function(void* invec, void* inoutvec, int* len, MPI_Datatype* datatype);
+typedef void MPI_User_function(void *invec, void *inoutvec, int *len,
+ MPI_Datatype * datatype);
struct s_smpi_mpi_op;
-typedef struct s_smpi_mpi_op* MPI_Op;
+typedef struct s_smpi_mpi_op *MPI_Op;
#define MPI_OP_NULL NULL
extern MPI_Op MPI_MAX;
extern MPI_Op MPI_BXOR;
struct s_smpi_mpi_group;
-typedef struct s_smpi_mpi_group* MPI_Group;
+typedef struct s_smpi_mpi_group *MPI_Group;
#define MPI_GROUP_NULL NULL
extern MPI_Group MPI_GROUP_EMPTY;
struct s_smpi_mpi_communicator;
-typedef struct s_smpi_mpi_communicator* MPI_Comm;
+typedef struct s_smpi_mpi_communicator *MPI_Comm;
#define MPI_COMM_NULL NULL
extern MPI_Comm MPI_COMM_WORLD;
#define MPI_COMM_SELF smpi_process_comm_self()
struct s_smpi_mpi_request;
-typedef struct s_smpi_mpi_request* MPI_Request;
+typedef struct s_smpi_mpi_request *MPI_Request;
#define MPI_REQUEST_NULL NULL
-XBT_PUBLIC(int) MPI_Init(int* argc, char*** argv);
+XBT_PUBLIC(int) MPI_Init(int *argc, char ***argv);
XBT_PUBLIC(int) MPI_Finalize(void);
-XBT_PUBLIC(int) MPI_Init_thread(int* argc, char*** argv, int required, int* provided);
-XBT_PUBLIC(int) MPI_Query_thread(int* provided);
-XBT_PUBLIC(int) MPI_Is_thread_main(int* flag);
+XBT_PUBLIC(int) MPI_Init_thread(int *argc, char ***argv, int required,
+ int *provided);
+XBT_PUBLIC(int) MPI_Query_thread(int *provided);
+XBT_PUBLIC(int) MPI_Is_thread_main(int *flag);
XBT_PUBLIC(int) MPI_Abort(MPI_Comm comm, int errorcode);
XBT_PUBLIC(double) MPI_Wtime(void);
-XBT_PUBLIC(int) MPI_Address(void *location, MPI_Aint *address);
-
-XBT_PUBLIC(int) MPI_Type_free(MPI_Datatype* datatype);
-XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, int* size);
-XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent);
-XBT_PUBLIC(int) MPI_Type_extent(MPI_Datatype datatype, MPI_Aint* extent);
-XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp);
-XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp);
-
-XBT_PUBLIC(int) MPI_Op_create(MPI_User_function* function, int commute, MPI_Op* op);
-XBT_PUBLIC(int) MPI_Op_free(MPI_Op* op);
-
-XBT_PUBLIC(int) MPI_Group_free(MPI_Group *group);
-XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int* size);
-XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int* rank);
-XBT_PUBLIC(int) MPI_Group_translate_ranks (MPI_Group group1, int n, int* ranks1, MPI_Group group2, int* ranks2);
-XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2, int* result);
-XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
-XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
-
-XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int* rank);
-XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int* size);
+XBT_PUBLIC(int) MPI_Address(void *location, MPI_Aint * address);
+
+XBT_PUBLIC(int) MPI_Type_free(MPI_Datatype * datatype);
+XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, int *size);
+XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb,
+ MPI_Aint * extent);
+XBT_PUBLIC(int) MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent);
+XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp);
+XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp);
+
+XBT_PUBLIC(int) MPI_Op_create(MPI_User_function * function, int commute,
+ MPI_Op * op);
+XBT_PUBLIC(int) MPI_Op_free(MPI_Op * op);
+
+XBT_PUBLIC(int) MPI_Group_free(MPI_Group * group);
+XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int *size);
+XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int *rank);
+XBT_PUBLIC(int) MPI_Group_translate_ranks(MPI_Group group1, int n,
+ int *ranks1, MPI_Group group2,
+ int *ranks2);
+XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2,
+ int *result);
+XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n,
+ int ranges[][3],
+ MPI_Group * newgroup);
+XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n,
+ int ranges[][3],
+ MPI_Group * newgroup);
+
+XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int *rank);
+XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int *size);
XBT_PUBLIC(int) MPI_Get_processor_name(char *name, int *resultlen);
-XBT_PUBLIC(int) MPI_Get_count(MPI_Status* status, MPI_Datatype datatype, int* count);
-
-XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group* group);
-XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result);
-XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm);
-XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm);
-XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm* comm);
-
-XBT_PUBLIC(int) MPI_Send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Start(MPI_Request* request);
-XBT_PUBLIC(int) MPI_Startall(int count, MPI_Request* requests);
-XBT_PUBLIC(int) MPI_Request_free(MPI_Request* request);
-XBT_PUBLIC(int) MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request);
-XBT_PUBLIC(int) MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
-
-
-XBT_PUBLIC(int) MPI_Test(MPI_Request* request, int* flag, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Wait(MPI_Request* request, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status);
-XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]);
-XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[]);
-
-XBT_PUBLIC(int) MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Get_count(MPI_Status * status, MPI_Datatype datatype,
+ int *count);
+
+XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group * group);
+XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2,
+ int *result);
+XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm);
+XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group,
+ MPI_Comm * newcomm);
+XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm * comm);
+
+XBT_PUBLIC(int) MPI_Send_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Recv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Start(MPI_Request * request);
+XBT_PUBLIC(int) MPI_Startall(int count, MPI_Request * requests);
+XBT_PUBLIC(int) MPI_Request_free(MPI_Request * request);
+XBT_PUBLIC(int) MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Isend(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm,
+ MPI_Request * request);
+XBT_PUBLIC(int) MPI_Recv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Send(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Sendrecv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, int dst, int sendtag,
+ void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Sendrecv_replace(void *buf, int count,
+ MPI_Datatype datatype, int dst,
+ int sendtag, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status);
+
+
+XBT_PUBLIC(int) MPI_Test(MPI_Request * request, int *flag,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int *index,
+ int *flag, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Wait(MPI_Request * request, MPI_Status * status);
+XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int *index,
+ MPI_Status * status);
+XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[],
+ MPI_Status status[]);
+XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[],
+ int *outcount, int *indices,
+ MPI_Status status[]);
+
+XBT_PUBLIC(int) MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm);
XBT_PUBLIC(int) MPI_Barrier(MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-XBT_PUBLIC(int) MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Gather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Gatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allgather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allgatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scatter(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Reduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Scan(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Reduce_scatter(void *sendbuf, void *recvbuf,
+ int *recvcounts, MPI_Datatype datatype,
+ MPI_Op op, MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Alltoall(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+XBT_PUBLIC(int) MPI_Alltoallv(void *sendbuf, int *sendcounts,
+ int *senddisps, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts,
+ int *recvdisps, MPI_Datatype recvtype,
+ MPI_Comm comm);
/*
TODO
MPI_Comm* comm_out);
*/
// smpi functions
-XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char** argv);
+XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
/*
XBT_PUBLIC(void) smpi_exit(int);
*/
XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
-XBT_PUBLIC(int) smpi_gettimeofday(struct timeval* tv, struct timezone* tz);
-XBT_PUBLIC(void) smpi_sample_1(int global, const char* file, int line, int max);
-XBT_PUBLIC(int) smpi_sample_2(int global, const char* file, int line);
-XBT_PUBLIC(void) smpi_sample_3(int global, const char* file, int line);
+XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
+XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line,
+ int max);
+XBT_PUBLIC(int) smpi_sample_2(int global, const char *file, int line);
+XBT_PUBLIC(void) smpi_sample_3(int global, const char *file, int line);
XBT_PUBLIC(void) smpi_sample_flops(double flops);
#define SMPI_SAMPLE_LOCAL(num) for(smpi_sample_1(0, __FILE__, __LINE__, num); \
#define SMPI_SAMPLE_DELAY(flops) for(smpi_sample_flops(flops); 0; )
-XBT_PUBLIC(void*) smpi_shared_malloc(size_t size, const char* file, int line);
+XBT_PUBLIC(void *) smpi_shared_malloc(size_t size, const char *file,
+ int line);
#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
-XBT_PUBLIC(void) smpi_shared_free(void* data);
+XBT_PUBLIC(void) smpi_shared_free(void *data);
#define SMPI_SHARED_FREE(data) smpi_shared_free(data)
SG_END_DECL()
/* XML processor/application API for src/surf/simgrid.dtd.
- * Generated 2010/10/06 15:20:08.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
SG_BEGIN_DECL()
/* Hook for the different tags. All the functions which pointer to are push into here are run when the tag is encountered */
-XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
+ XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_platform_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_host_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_host_cb_list;
XBT_PUBLIC(void) surf_parse_get_int(int *value, const char *string);
/* Prototypes of the functions offered by flex */
-XBT_PUBLIC(int) surf_parse_lex(void);
-XBT_PUBLIC(int) surf_parse_get_lineno(void);
+XBT_PUBLIC(int) surf_parse_lex(void);
+XBT_PUBLIC(int) surf_parse_get_lineno(void);
XBT_PUBLIC(FILE *) surf_parse_get_in(void);
XBT_PUBLIC(FILE *) surf_parse_get_out(void);
-XBT_PUBLIC(int) surf_parse_get_leng(void);
+XBT_PUBLIC(int) surf_parse_get_leng(void);
XBT_PUBLIC(char *) surf_parse_get_text(void);
-XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
-XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
-XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
-XBT_PUBLIC(int) surf_parse_get_debug(void);
-XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
-XBT_PUBLIC(int) surf_parse_lex_destroy(void);
+XBT_PUBLIC(void) surf_parse_set_lineno(int line_number);
+XBT_PUBLIC(void) surf_parse_set_in(FILE * in_str);
+XBT_PUBLIC(void) surf_parse_set_out(FILE * out_str);
+XBT_PUBLIC(int) surf_parse_get_debug(void);
+XBT_PUBLIC(void) surf_parse_set_debug(int bdebug);
+XBT_PUBLIC(int) surf_parse_lex_destroy(void);
/* What is needed to bypass the parser. */
ETag_surfxml_##tag();\
} while(0)
-XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function);
-XBT_PUBLIC(void) surfxml_del_callback(xbt_dynar_t* cb_list, void_f_void_t function);
+XBT_PUBLIC(void) surfxml_add_callback(xbt_dynar_t cb_list,
+ void_f_void_t function);
+XBT_PUBLIC(void) surfxml_del_callback(xbt_dynar_t * cb_list,
+ void_f_void_t function);
SG_END_DECL()
#endif
/* pimple to display the message sizes */
XBT_PUBLIC(void) SIMIX_message_sizes_output(const char *filename);
-#endif /* xbt_H */
+#endif /* xbt_H */
#define xbt_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) THROW6(0,0,msg,a,b,c,d,e,f)
#endif
/** @} */
- SG_END_DECL()
-#endif /* _XBT_ASSERTS_H */
+ SG_END_DECL()
+#endif /* _XBT_ASSERTS_H */
* @{
*/
/** @brief Configuration set are only special dynars. But don't rely on it, it may change. */
- typedef xbt_dynar_t xbt_cfg_t;
+typedef xbt_dynar_t xbt_cfg_t;
XBT_PUBLIC(void) xbt_cfg_set(xbt_cfg_t cfg, const char *name, ...);
XBT_PUBLIC(void) xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name,
Set the default value of the cell \a name in \a cfg with the provided value.
If it was already set to something (possibly from the command line), do nothing.
*/
-XBT_PUBLIC(void) xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char* val);
-XBT_PUBLIC(void) xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name, const char* host, int port);
+XBT_PUBLIC(void) xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name,
+ int val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name,
+ double val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name,
+ const char *val);
+XBT_PUBLIC(void) xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name,
+ const char *host, int port);
/*
*/
/** @brief possible content of each configuration cell */
- typedef enum {
- xbt_cfgelm_int = 0,
+typedef enum {
+ xbt_cfgelm_int = 0,
/**< int */
- xbt_cfgelm_double,
+ xbt_cfgelm_double,
/**< double */
- xbt_cfgelm_string,
+ xbt_cfgelm_string,
/**< char* */
- xbt_cfgelm_peer,/**< both a char* (representing the peername) and an integer (representing the port) */
+ xbt_cfgelm_peer, /**< both a char* (representing the peername) and an integer (representing the port) */
- xbt_cfgelm_any, /* not shown to users to prevent errors */
- xbt_cfgelm_type_count
- } e_xbt_cfgelm_type_t;
+ xbt_cfgelm_any, /* not shown to users to prevent errors */
+ xbt_cfgelm_type_count
+} e_xbt_cfgelm_type_t;
/** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
- typedef void (*xbt_cfg_cb_t) (const char *, int);
+typedef void (*xbt_cfg_cb_t) (const char *, int);
XBT_PUBLIC(xbt_cfg_t) xbt_cfg_new(void);
-XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */ xbt_cfg_t * whereto);
+XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */
+ xbt_cfg_t * whereto);
XBT_PUBLIC(void) xbt_cfg_free(xbt_cfg_t * cfg);
XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent,
xbt_cfg_t cfg);
* @{
*/
XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t * cfg,
- const char *name, const char *description,
+ const char *name,
+ const char *description,
e_xbt_cfgelm_type_t type,
void *default_value, int min, int max,
xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm);
char **peer, int *port);
XBT_PUBLIC(xbt_dynar_t) xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name);
-XBT_PUBLIC(int) xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name, int pos);
+XBT_PUBLIC(int) xbt_cfg_get_int_at(xbt_cfg_t cfg, const char *name,
+ int pos);
XBT_PUBLIC(double) xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name,
int pos);
XBT_PUBLIC(char *) xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name,
int pos);
-XBT_PUBLIC(void) xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name, int pos,
- char **peer, int *port);
+XBT_PUBLIC(void) xbt_cfg_get_peer_at(xbt_cfg_t cfg, const char *name,
+ int pos, char **peer, int *port);
/** @} */
SG_END_DECL()
-#endif /* _XBT_CONFIG_H_ */
+#endif /* _XBT_CONFIG_H_ */
SG_BEGIN_DECL()
/* test suite object type */
- typedef struct s_xbt_test_suite *xbt_test_suite_t;
+typedef struct s_xbt_test_suite *xbt_test_suite_t;
/* test object type */
- typedef struct s_xbt_test_unit *xbt_test_unit_t;
+typedef struct s_xbt_test_unit *xbt_test_unit_t;
/* test callback function type */
- typedef void (*ts_test_cb_t) (void);
+typedef void (*ts_test_cb_t) (void);
/* test suite operations */
XBT_PUBLIC(xbt_test_suite_t) xbt_test_suite_new(const char *name,
XBT_PUBLIC(xbt_test_suite_t) xbt_test_suite_by_name(const char *name,
const char *fmt, ...);
XBT_PUBLIC(void) xbt_test_suite_dump(xbt_test_suite_t suite);
-XBT_PUBLIC(void) xbt_test_suite_push(xbt_test_suite_t suite, const char *name,
- ts_test_cb_t func, const char *fmt, ...);
+XBT_PUBLIC(void) xbt_test_suite_push(xbt_test_suite_t suite,
+ const char *name, ts_test_cb_t func,
+ const char *fmt, ...);
/* Run all the specified tests. what_to_do allows to disable some tests.
* It is a coma (,) separated list of directives. They are applied from left to right.
#define xbt_test_add4(fmt,a,b,c,d) _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d)
#define xbt_test_add5(fmt,a,b,c,d,e) _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d,e)
-XBT_PUBLIC(void) _xbt_test_fail(const char *file, int line, const char *fmt,
- ...) _XBT_GNUC_PRINTF(3, 4);
+XBT_PUBLIC(void) _xbt_test_fail(const char *file, int line,
+ const char *fmt, ...) _XBT_GNUC_PRINTF(3,
+ 4);
#define xbt_test_fail0(fmt) _xbt_test_fail(__FILE__, __LINE__, fmt)
#define xbt_test_fail1(fmt,a) _xbt_test_fail(__FILE__, __LINE__, fmt,a)
#define xbt_test_fail2(fmt,a,b) _xbt_test_fail(__FILE__, __LINE__, fmt,a,b)
void func(void)
SG_END_DECL()
-#endif /* _TS_H_ */
+#endif /* _TS_H_ */
#include "xbt/misc.h" /* SG_BEGIN_DECL */
#include "xbt/dynar.h" /* void_f_pvoid_t */
-#include <stdint.h> /* uintptr_t */
+#include <stdint.h> /* uintptr_t */
SG_BEGIN_DECL();
void_f_pvoid_t free_ctn);
XBT_PUBLIC(void *) xbt_dict_get(xbt_dict_t dict, const char *key);
XBT_PUBLIC(void *) xbt_dict_get_or_null(xbt_dict_t dict, const char *key);
-XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void*data);
+XBT_PUBLIC(char *) xbt_dict_get_key(xbt_dict_t dict, const void *data);
XBT_PUBLIC(void) xbt_dict_remove(xbt_dict_t dict, const char *key);
XBT_PUBLIC(void) xbt_dict_reset(xbt_dict_t dict);
void *data, void_f_pvoid_t free_ctn);
XBT_PUBLIC(void *) xbt_dict_get_ext(xbt_dict_t dict, const char *key,
int key_len);
-XBT_PUBLIC(void *) xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key,
- int key_len);
+XBT_PUBLIC(void *) xbt_dict_get_or_null_ext(xbt_dict_t dict,
+ const char *key, int key_len);
XBT_PUBLIC(void) xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
int key_len);
-XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key, uintptr_t data);
+XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key,
+ uintptr_t data);
XBT_PUBLIC(uintptr_t) xbt_dicti_get(xbt_dict_t dict, uintptr_t key);
XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key);
* @{ */
/** @brief Cursor on dictionaries (opaque type) */
- typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
+typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
XBT_PUBLIC(xbt_dict_cursor_t) xbt_dict_cursor_new(const xbt_dict_t dict);
XBT_PUBLIC(void) xbt_dict_cursor_free(xbt_dict_cursor_t * cursor);
-XBT_INLINE XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
+XBT_INLINE XBT_PUBLIC(void) xbt_dict_cursor_rewind(xbt_dict_cursor_t
+ cursor);
XBT_PUBLIC(char *) xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor);
XBT_PUBLIC(void *) xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor);
XBT_PUBLIC(void) xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor,
- void *data, void_f_pvoid_t free_ctn);
+ void *data,
+ void_f_pvoid_t free_ctn);
XBT_PUBLIC(void) xbt_dict_cursor_first(const xbt_dict_t dict,
xbt_dict_cursor_t * cursor);
/*----[ xbt_multidict_get ]--------------------------------------------------*/
XBT_PUBLIC(void *) xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict, xbt_dynar_t keys,
+XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict,
+ xbt_dynar_t keys,
xbt_dynar_t lens);
/*----[ xbt_multidict_remove ]-----------------------------------------------*/
/*---------------------------------------------------------------------------*/
XBT_PUBLIC(void) xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys);
-XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys,
+XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict,
+ xbt_dynar_t keys,
xbt_dynar_t lens);
/** @} */
SG_END_DECL()
-#endif /* _XBT_DICT_H */
+#endif /* _XBT_DICT_H */
#ifndef _XBT_DYNAR_H
#define _XBT_DYNAR_H
-#include <string.h> /* memcpy */
+#include <string.h> /* memcpy */
#include "xbt/misc.h" /* SG_BEGIN_DECL */
#include "xbt/function_types.h"
* @{
*/
/** \brief Dynar data type (opaque type) */
- typedef struct xbt_dynar_s *xbt_dynar_t;
+typedef struct xbt_dynar_s *xbt_dynar_t;
XBT_PUBLIC(xbt_dynar_t) xbt_dynar_new(const unsigned long elm_size,
XBT_PUBLIC(void) xbt_dynar_free_voidp(void *dynar);
XBT_PUBLIC(void) xbt_dynar_free_container(xbt_dynar_t * dynar);
-XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t dynar);
-XBT_INLINE XBT_PUBLIC (int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
+XBT_INLINE XBT_PUBLIC(unsigned long) xbt_dynar_length(const xbt_dynar_t
+ dynar);
+XBT_INLINE XBT_PUBLIC(int) xbt_dynar_is_empty(const xbt_dynar_t dynar);
XBT_PUBLIC(void) xbt_dynar_reset(xbt_dynar_t const dynar);
XBT_PUBLIC(void) xbt_dynar_shrink(xbt_dynar_t dynar, int empty_slots);
*/
XBT_PUBLIC(void) xbt_dynar_get_cpy(const xbt_dynar_t dynar,
- const unsigned long idx, void *const dst);
+ const unsigned long idx,
+ void *const dst);
XBT_PUBLIC(void) xbt_dynar_set(xbt_dynar_t dynar, const int idx,
const void *src);
-XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar, const unsigned long idx,
+XBT_PUBLIC(void) xbt_dynar_replace(xbt_dynar_t dynar,
+ const unsigned long idx,
const void *object);
-XBT_PUBLIC(void) xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx,
- const void *src);
-XBT_PUBLIC(void) xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx,
- void *const dst);
+XBT_PUBLIC(void) xbt_dynar_insert_at(xbt_dynar_t const dynar,
+ const int idx, const void *src);
+XBT_PUBLIC(void) xbt_dynar_remove_at(xbt_dynar_t const dynar,
+ const int idx, void *const dst);
-XBT_PUBLIC(unsigned int) xbt_dynar_search(xbt_dynar_t const dynar, void *elem);
+XBT_PUBLIC(unsigned int) xbt_dynar_search(xbt_dynar_t const dynar,
+ void *elem);
XBT_PUBLIC(int) xbt_dynar_member(xbt_dynar_t const dynar, void *elem);
-XBT_PUBLIC(void) xbt_dynar_sort(xbt_dynar_t const dynar, int_f_cpvoid_cpvoid_t compar_fn);
+XBT_PUBLIC(void) xbt_dynar_sort(xbt_dynar_t const dynar,
+ int_f_cpvoid_cpvoid_t compar_fn);
/** @} */
/** @defgroup XBT_dynar_perl Perl-like use of dynars
* @{
*/
-XBT_INLINE XBT_PUBLIC(void) xbt_dynar_push(xbt_dynar_t const dynar, const void *src);
-XBT_INLINE XBT_PUBLIC(void) xbt_dynar_pop(xbt_dynar_t const dynar, void *const dst);
-XBT_PUBLIC(void) xbt_dynar_unshift(xbt_dynar_t const dynar, const void *src);
+XBT_INLINE XBT_PUBLIC(void) xbt_dynar_push(xbt_dynar_t const dynar,
+ const void *src);
+XBT_INLINE XBT_PUBLIC(void) xbt_dynar_pop(xbt_dynar_t const dynar,
+ void *const dst);
+XBT_PUBLIC(void) xbt_dynar_unshift(xbt_dynar_t const dynar,
+ const void *src);
XBT_PUBLIC(void) xbt_dynar_shift(xbt_dynar_t const dynar, void *const dst);
XBT_PUBLIC(void) xbt_dynar_map(const xbt_dynar_t dynar,
void_f_pvoid_t const op);
*/
XBT_INLINE XBT_PUBLIC(void *) xbt_dynar_get_ptr(const xbt_dynar_t dynar,
- const unsigned long idx);
+ const unsigned long idx);
XBT_PUBLIC(void *) xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar,
const int idx);
XBT_PUBLIC(void *) xbt_dynar_push_ptr(xbt_dynar_t const dynar);
*/
XBT_INLINE XBT_PUBLIC(void) xbt_dynar_cursor_rm(xbt_dynar_t dynar,
- unsigned int *const cursor);
+ unsigned int *const
+ cursor);
XBT_PUBLIC(void) xbt_dynar_cursor_unlock(xbt_dynar_t dynar);
/* do not use this structure internals directly, but use the public interface
} s_xbt_dynar_t;
static XBT_INLINE void
-_xbt_dynar_cursor_first(const xbt_dynar_t dynar, unsigned int *const cursor)
+_xbt_dynar_cursor_first(const xbt_dynar_t dynar,
+ unsigned int *const cursor)
{
/* don't test for dynar!=NULL. The segfault would tell us */
- if (dynar->mutex) /* ie _dynar_lock(dynar) but not public */
+ if (dynar->mutex) /* ie _dynar_lock(dynar) but not public */
xbt_mutex_acquire(dynar->mutex);
//DEBUG1("Set cursor on %p to the first position", (void *) dynar);
if (idx >= dynar->used) {
//DEBUG1("Cursor on %p already on last elem", (void *) dynar);
- if (dynar->mutex) /* unlock */
+ if (dynar->mutex) /* unlock */
xbt_mutex_release(dynar->mutex);
return FALSE;
}
// DEBUG2("Cash out cursor on %p at %u", (void *) dynar, *idx);
- memcpy(dst, ((char*)dynar->data) + idx * dynar->elmsize, dynar->elmsize);
+ memcpy(dst, ((char *) dynar->data) + idx * dynar->elmsize,
+ dynar->elmsize);
return TRUE;
}
/** @} */
SG_END_DECL()
-#endif /* _XBT_DYNAR_H */
+#endif /* _XBT_DYNAR_H */
/*-*-* Emergency debuging: define this when the exceptions get crazy *-*-*/
#undef __EX_MAYDAY
-
#ifdef __EX_MAYDAY
# include <stdio.h>
#include <errno.h>
-
# define MAYDAY_SAVE(m) printf("%d %s:%d save %p\n", \
(*xbt_getpid)(),__FILE__,__LINE__, \
(m)->jb \
# define MAYDAY_RESTORE(m)
# define MAYDAY_CATCH(e)
#endif
-
/*-*-* end of debugging stuff *-*-*/
-
#if defined(__EX_MCTX_MCSC__)
#include <ucontext.h> /* POSIX.1 ucontext(3) */
#define __ex_mctx_struct ucontext_t uc;
#define __ex_mctx_save(mctx) (getcontext(&(mctx)->uc) == 0)
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) (void)setcontext(&(mctx)->uc)
-
#elif defined(__EX_MCTX_SSJLJ__)
#include <setjmp.h> /* POSIX.1 sigjmp_buf(3) */
#define __ex_mctx_struct sigjmp_buf jb;
#define __ex_mctx_save(mctx) (sigsetjmp((mctx)->jb, 1) == 0)
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) (void)siglongjmp((mctx)->jb, 1)
-
#elif defined(__EX_MCTX_SJLJ__) || !defined(__EX_MCTX_CUSTOM__) || defined(__EX_MAYDAY)
#include <setjmp.h> /* ISO-C jmp_buf(3) */
#define __ex_mctx_struct jmp_buf jb;
#define __ex_mctx_restored(mctx) /* noop */
#define __ex_mctx_restore(mctx) ( MAYDAY_RESTORE(mctx) (void)longjmp((mctx)->jb, 1))
#endif
-
/* declare the machine context type */
typedef struct {
__ex_mctx_struct} __ex_mctx_t;
XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat);
/** @brief Structure describing an exception */
- typedef struct {
- char *msg; /**< human readable message */
- xbt_errcat_t category;
+typedef struct {
+ char *msg; /**< human readable message */
+ xbt_errcat_t category;
/**< category like HTTP (what went wrong) */
- int value; /**< like errno (why did it went wrong) */
- /* throw point */
- short int remote;
+ int value; /**< like errno (why did it went wrong) */
+ /* throw point */
+ short int remote;
/**< whether it was raised remotely */
- char *host;/**< NULL locally thrown exceptions; full hostname if remote ones */
- /* FIXME: host should be hostname:port[#thread] */
- char *procname;
+ char *host; /**< NULL locally thrown exceptions; full hostname if remote ones */
+ /* FIXME: host should be hostname:port[#thread] */
+ char *procname;
/**< Name of the process who thrown this */
- int pid; /**< PID of the process who thrown this */
- char *file;/**< Thrown point */
- int line; /**< Thrown point */
- char *func;/**< Thrown point */
- /* Backtrace */
- int used;
- char **bt_strings; /* only filed on display (or before the network propagation) */
- void *bt[XBT_BACKTRACE_SIZE];
- } xbt_ex_t;
+ int pid; /**< PID of the process who thrown this */
+ char *file; /**< Thrown point */
+ int line; /**< Thrown point */
+ char *func; /**< Thrown point */
+ /* Backtrace */
+ int used;
+ char **bt_strings; /* only filed on display (or before the network propagation) */
+ void *bt[XBT_BACKTRACE_SIZE];
+} xbt_ex_t;
/* declare the context type (private) */
- typedef struct {
- __ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */
- volatile int ctx_caught; /* temporary flag whether exception was caught */
- volatile xbt_ex_t ctx_ex; /* temporary exception storage */
- } ex_ctx_t;
+typedef struct {
+ __ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */
+ volatile int ctx_caught; /* temporary flag whether exception was caught */
+ volatile xbt_ex_t ctx_ex; /* temporary exception storage */
+} ex_ctx_t;
/* the static and dynamic initializers for a context structure */
#define XBT_CTX_INITIALIZER \
} while (0)
/* the exception context */
- typedef ex_ctx_t *(*ex_ctx_cb_t) (void);
+typedef ex_ctx_t *(*ex_ctx_cb_t) (void);
XBT_PUBLIC_DATA(ex_ctx_cb_t) __xbt_ex_ctx;
- extern ex_ctx_t *__xbt_ex_ctx_default(void);
+extern ex_ctx_t *__xbt_ex_ctx_default(void);
/* the termination handler */
- typedef void (*ex_term_cb_t) (xbt_ex_t *);
+typedef void (*ex_term_cb_t) (xbt_ex_t *);
XBT_PUBLIC_DATA(ex_term_cb_t) __xbt_ex_terminate;
- extern void __xbt_ex_terminate_default(xbt_ex_t * e);
+extern void __xbt_ex_terminate_default(xbt_ex_t * e);
/** @brief Introduce a block where exception may be dealed with
* @hideinitializer
SG_END_DECL()
/** @}Â */
-#endif /* __XBT_EX_H__ */
+#endif /* __XBT_EX_H__ */
*/
/** \brief Bucket structure
*/
- typedef struct xbt_fifo_item *xbt_fifo_item_t;
+typedef struct xbt_fifo_item *xbt_fifo_item_t;
/** \brief FIFO structure
*/
- typedef struct xbt_fifo *xbt_fifo_t;
+typedef struct xbt_fifo *xbt_fifo_t;
XBT_PUBLIC(xbt_fifo_t) xbt_fifo_new(void);
XBT_PUBLIC(void) xbt_fifo_free(xbt_fifo_t);
XBT_PUBLIC(int) xbt_fifo_remove_all(xbt_fifo_t, void *);
XBT_PUBLIC(void) xbt_fifo_remove_item(xbt_fifo_t, xbt_fifo_item_t);
-XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_first_item(xbt_fifo_t l);
-XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_last_item(xbt_fifo_t l);
+XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_first_item(xbt_fifo_t
+ l);
+XBT_INLINE XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_last_item(xbt_fifo_t
+ l);
XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_next_item(xbt_fifo_item_t i);
XBT_PUBLIC(xbt_fifo_item_t) xbt_fifo_get_prev_item(xbt_fifo_item_t i);
SG_END_DECL()
-#endif /* _XBT_FIFO_H */
+#endif /* _XBT_FIFO_H */
typedef void (*void_f_ppvoid_t) (void **);
typedef void (*void_f_pvoid_t) (void *);
-typedef void (*void_f_int_pvoid_t) (int,void *);
- typedef void *(*pvoid_f_void_t) (void);
- typedef void *(*pvoid_f_pvoid_t) (void *);
- typedef void (*void_f_void_t) (void);
+typedef void (*void_f_int_pvoid_t) (int, void *);
+typedef void *(*pvoid_f_void_t) (void);
+typedef void *(*pvoid_f_pvoid_t) (void *);
+typedef void (*void_f_void_t) (void);
- typedef int (*int_f_void_t) (void);
+typedef int (*int_f_void_t) (void);
- typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
- typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
+typedef int (*int_f_pvoid_pvoid_t) (void *, void *);
+typedef int (*int_f_cpvoid_cpvoid_t) (const void *, const void *);
- typedef int (*xbt_main_func_t) (int argc, char *argv[]);
+typedef int (*xbt_main_func_t) (int argc, char *argv[]);
SG_END_DECL()
-#endif /* XBT_FUNCTION_TYPE_H */
+#endif /* XBT_FUNCTION_TYPE_H */
*
* @{
*/
- typedef struct xbt_node *xbt_node_t;
- typedef struct xbt_edge *xbt_edge_t;
- typedef struct xbt_graph *xbt_graph_t;
+typedef struct xbt_node *xbt_node_t;
+typedef struct xbt_edge *xbt_edge_t;
+typedef struct xbt_graph *xbt_graph_t;
/* API */
XBT_PUBLIC(xbt_graph_t) xbt_graph_new_graph(unsigned short int directed,
XBT_PUBLIC(xbt_node_t) xbt_graph_edge_get_source(xbt_edge_t e);
XBT_PUBLIC(xbt_node_t) xbt_graph_edge_get_target(xbt_edge_t e);
XBT_PUBLIC(xbt_graph_t) xbt_graph_read(const char *filename, void
- * (node_label_and_data) (xbt_node_t,
- const char *,
- const char *),
- void
- * (edge_label_and_data) (xbt_edge_t,
- const char *,
- const char *)
- );
+ *(node_label_and_data) (xbt_node_t,
+ const char
+ *,
+ const char
+ *), void
+ *(edge_label_and_data) (xbt_edge_t,
+ const char
+ *,
+ const char
+ *)
+ );
XBT_PUBLIC(void) xbt_graph_export_graphviz(xbt_graph_t g,
const char *filename, const char
- * (node_name) (xbt_node_t), const char
- * (edge_name) (xbt_edge_t));
+ *(node_name) (xbt_node_t), const char
+ *(edge_name) (xbt_edge_t));
XBT_PUBLIC(void) xbt_graph_export_graphxml(xbt_graph_t g,
const char *filename, const char
- * (node_name) (xbt_node_t), const char
- * (edge_name) (xbt_edge_t),
- const char *(node_data_print) (void
- *),
- const char *(edge_data_print) (void
- *));
+ *(node_name) (xbt_node_t), const char
+ *(edge_name) (xbt_edge_t), const char
+ *(node_data_print) (void *), const char
+ *(edge_data_print) (void *));
/* Not implemented yet ! */
/* void *xbt_graph_to_array(xbt_graph_t g); */
SG_END_DECL()
-#endif /* _XBT_GRAPH_H */
+#endif /* _XBT_GRAPH_H */
/** @} */
/* XML processor/application API for src/xbt/graphxml.dtd.
- * Generated 2010/10/01 22:34:15.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
#ifndef _XBT_GRAPHXML_PARSE_H
#define _XBT_GRAPHXML_PARSE_H
-#include <stdio.h> /* to have FILE */
+#include <stdio.h> /* to have FILE */
#include "xbt/misc.h"
#include "xbt/graphxml.h"
#include "simgrid_config.h"
XBT_PUBLIC(void) xbt_sha(const char *data, char *hash);
-#endif /* XBT_HASH_H */
+#endif /* XBT_HASH_H */
/* @brief heap datatype */
typedef struct xbt_heap *xbt_heap_t;
-XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int num, void_f_pvoid_t const free_func);
+XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int num,
+ void_f_pvoid_t const free_func);
XBT_PUBLIC(void) xbt_heap_free(xbt_heap_t H);
XBT_PUBLIC(int) xbt_heap_size(xbt_heap_t H);
XBT_PUBLIC(double) xbt_heap_maxkey(xbt_heap_t H);
XBT_PUBLIC(void *) xbt_heap_maxcontent(xbt_heap_t H);
-XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H, void (*update_callback)(void*, int));
-XBT_PUBLIC(void*) xbt_heap_remove(xbt_heap_t H, int i);
+XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H,
+ void (*update_callback) (void
+ *,
+ int));
+XBT_PUBLIC(void *) xbt_heap_remove(xbt_heap_t H, int i);
/* @} */
-#endif /* _XBT_HEAP_H */
+#endif /* _XBT_HEAP_H */
*
* The different existing priorities.
*/
- typedef enum {
- xbt_log_priority_none = 0, /* used internally (don't poke with) */
- xbt_log_priority_trace = 1, /**< enter and return of some functions */
- xbt_log_priority_debug = 2, /**< crufty output */
- xbt_log_priority_verbose = 3, /**< verbose output for the user wanting more */
- xbt_log_priority_info = 4, /**< output about the regular functionning */
- xbt_log_priority_warning = 5, /**< minor issue encountered */
- xbt_log_priority_error = 6, /**< issue encountered */
- xbt_log_priority_critical = 7, /**< major issue encountered */
+typedef enum {
+ xbt_log_priority_none = 0, /* used internally (don't poke with) */
+ xbt_log_priority_trace = 1, /**< enter and return of some functions */
+ xbt_log_priority_debug = 2, /**< crufty output */
+ xbt_log_priority_verbose = 3, /**< verbose output for the user wanting more */
+ xbt_log_priority_info = 4, /**< output about the regular functionning */
+ xbt_log_priority_warning = 5, /**< minor issue encountered */
+ xbt_log_priority_error = 6, /**< issue encountered */
+ xbt_log_priority_critical = 7, /**< major issue encountered */
- xbt_log_priority_infinite = 8, /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
+ xbt_log_priority_infinite = 8, /**< value for XBT_LOG_STATIC_THRESHOLD to not log */
- xbt_log_priority_uninitialized = -1 /* used internally (don't poke with) */
- } e_xbt_log_priority_t;
+ xbt_log_priority_uninitialized = -1 /* used internally (don't poke with) */
+} e_xbt_log_priority_t;
/*
# ifdef NDEBUG
# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_verbose
-# else /* !NLOG && !NDEBUG */
+# else /* !NLOG && !NDEBUG */
# ifndef XBT_LOG_STATIC_THRESHOLD
# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_none
-# endif /* !XBT_LOG_STATIC_THRESHOLD */
-# endif /* NDEBUG */
-#endif /* !defined(NLOG) */
+# endif /* !XBT_LOG_STATIC_THRESHOLD */
+# endif /* NDEBUG */
+#endif /* !defined(NLOG) */
/* Transforms a category name to a global variable name. */
#define _XBT_LOGV(cat) _XBT_LOG_CONCAT(_simgrid_log_category__, cat)
* Indicates which category is the default one.
*/
-#if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
+#if defined(XBT_LOG_MAYDAY) || defined(SUPERNOVAE_MODE) /*|| defined (NLOG) * turning logging off */
# define XBT_LOG_DEFAULT_CATEGORY(cname)
#else
# define XBT_LOG_DEFAULT_CATEGORY(cname) \
XBT_PUBLIC(void) xbt_log_control_set(const char *cs);
/* Forward declarations */
- typedef struct xbt_log_appender_s s_xbt_log_appender_t,
- *xbt_log_appender_t;
- typedef struct xbt_log_layout_s s_xbt_log_layout_t, *xbt_log_layout_t;
- typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
- typedef struct xbt_log_category_s s_xbt_log_category_t,
- *xbt_log_category_t;
+typedef struct xbt_log_appender_s s_xbt_log_appender_t,
+ *xbt_log_appender_t;
+typedef struct xbt_log_layout_s s_xbt_log_layout_t, *xbt_log_layout_t;
+typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
+typedef struct xbt_log_category_s s_xbt_log_category_t,
+ *xbt_log_category_t;
/*
* Do NOT access any members of this structure directly. FIXME: move to private?
#else
#define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */
#endif
- struct xbt_log_category_s {
- xbt_log_category_t parent;
- xbt_log_category_t firstChild;
- xbt_log_category_t nextSibling;
- const char *name;
- int threshold;
- int isThreshInherited;
- xbt_log_appender_t appender;
- xbt_log_layout_t layout;
- int additivity;
- };
-
- struct xbt_log_event_s {
- xbt_log_category_t cat;
- e_xbt_log_priority_t priority;
- const char *fileName;
- const char *functionName;
- int lineNum;
- va_list ap;
- va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
+struct xbt_log_category_s {
+ xbt_log_category_t parent;
+ xbt_log_category_t firstChild;
+ xbt_log_category_t nextSibling;
+ const char *name;
+ int threshold;
+ int isThreshInherited;
+ xbt_log_appender_t appender;
+ xbt_log_layout_t layout;
+ int additivity;
+};
+
+struct xbt_log_event_s {
+ xbt_log_category_t cat;
+ e_xbt_log_priority_t priority;
+ const char *fileName;
+ const char *functionName;
+ int lineNum;
+ va_list ap;
+ va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
#ifdef _XBT_WIN32
- char *buffer;
+ char *buffer;
#else
- char buffer[XBT_LOG_BUFF_SIZE];
+ char buffer[XBT_LOG_BUFF_SIZE];
#endif
- };
+};
/**
* \ingroup XBT_log_implem
XBT_PUBLIC_DATA(s_xbt_log_category_t) _XBT_LOGV(XBT_LOG_ROOT_CAT);
- extern xbt_log_appender_t xbt_log_default_appender;
- extern xbt_log_layout_t xbt_log_default_layout;
+extern xbt_log_appender_t xbt_log_default_appender;
+extern xbt_log_layout_t xbt_log_default_layout;
/* ********************** */
/* Public functions again */
* Setting the LogEvent's valist member is done inside _log_logEvent.
*/
#ifdef _XBT_WIN32
-#include <stdlib.h> /* calloc */
+#include <stdlib.h> /* calloc */
#define _XBT_LOG_PRE(catv, prio) do { \
if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
s_xbt_log_event_t _log_ev; \
_log_ev.buffer = (char*) calloc(XBT_LOG_BUFF_SIZE + 1, sizeof(char)); \
_xbt_log_event_log(&_log_ev
#else
-#include <string.h> /* memset */
+#include <string.h> /* memset */
#define _XBT_LOG_PRE(catv, prio) do { \
if (_XBT_LOG_ISENABLEDV(catv, prio)) { \
s_xbt_log_event_t _log_ev; \
SG_END_DECL()
-#endif /* ! _XBT_LOG_H_ */
+#endif /* ! _XBT_LOG_H_ */
* @{
*/
/** \brief Mallocator data type (opaque structure) */
- typedef struct s_xbt_mallocator *xbt_mallocator_t;
+typedef struct s_xbt_mallocator *xbt_mallocator_t;
XBT_PUBLIC(xbt_mallocator_t) xbt_mallocator_new(int size,
pvoid_f_void_t new_f,
void_f_pvoid_t free_f,
/** @} */
SG_END_DECL()
-#endif /* _XBT_MALLOCATOR_H */
+#endif /* _XBT_MALLOCATOR_H */
SG_BEGIN_DECL()
- typedef struct {
- unsigned int lines, rows;
- unsigned long elmsize;
+typedef struct {
+ unsigned int lines, rows;
+ unsigned long elmsize;
- char *data;
- void_f_pvoid_t free_f;
- } s_xbt_matrix_t, *xbt_matrix_t;
+ char *data;
+ void_f_pvoid_t free_f;
+} s_xbt_matrix_t, *xbt_matrix_t;
/** @brief Retrieve the address of a cell (not its content)
XBT_PUBLIC(void) xbt_matrix_free(xbt_matrix_t matrix);
XBT_PUBLIC(void) xbt_matrix_free_voidp(void *d);
-XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest, xbt_matrix_t src,
+XBT_PUBLIC(void) xbt_matrix_copy_values(xbt_matrix_t dest,
+ xbt_matrix_t src,
unsigned int lsize,
unsigned int rsize,
unsigned int lpos_dst,
XBT_PUBLIC(void) xbt_matrix_double_addmult(xbt_matrix_t A, xbt_matrix_t B,
/*OUT*/ xbt_matrix_t C);
SG_END_DECL()
-#endif /* XBT_MATRIX_H */
+#endif /* XBT_MATRIX_H */
# define _XBT_GNUC_DESTRUCTOR __attribute__((__destructor__))
# undef _XBT_NEED_INIT_PRAGMA
-#else /* !__GNUC__ */
+#else /* !__GNUC__ */
# define _XBT_GNUC_PRINTF( format_idx, arg_idx )
# define _XBT_GNUC_SCANF( format_idx, arg_idx )
# define _XBT_GNUC_FORMAT( arg_idx )
# define _XBT_GNUC_DESTRUCTOR
# define _XBT_NEED_INIT_PRAGMA 1
-#endif /* !__GNUC__ */
+#endif /* !__GNUC__ */
/* inline and __FUNCTION__ are only in GCC when -ansi is off */
#if defined(__GNUC__) && ! defined(__STRICT_ANSI__)
# define _XBT_FUNCTION __FUNCTION__
#elif (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-# define _XBT_FUNCTION __func__ /* ISO-C99 compliant */
+# define _XBT_FUNCTION __func__ /* ISO-C99 compliant */
#else
# define _XBT_FUNCTION "function"
#endif
#define XBT_BACKTRACE_SIZE 10 /* FIXME: better place? Do document */
SG_END_DECL()
-#endif /* XBT_MISC_H */
+#endif /* XBT_MISC_H */
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#else
-# include <sys/types.h> /* for size_t */
-# include <stdio.h> /* for NULL */
+# include <sys/types.h> /* for size_t */
+# include <stdio.h> /* for NULL */
#endif
//#include "./include/ansidecl.h"
/* Allocate SIZE bytes of memory. */
-extern void* mmalloc(void* md, size_t size);
+extern void *mmalloc(void *md, size_t size);
/* Re-allocate the previously allocated block in void*, making the new block
SIZE bytes long. */
-extern void* mrealloc(void* md, void* ptr, size_t size);
+extern void *mrealloc(void *md, void *ptr, size_t size);
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
-extern void* mcalloc (void* md, size_t nmemb, size_t size);
+extern void *mcalloc(void *md, size_t nmemb, size_t size);
/* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'. */
-extern void mfree (void* md, void* ptr);
+extern void mfree(void *md, void *ptr);
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
-extern void* mmemalign (void* md, size_t alignment, size_t size);
+extern void *mmemalign(void *md, size_t alignment, size_t size);
/* Allocate SIZE bytes on a page boundary. */
-extern void* mvalloc (void* md, size_t size);
+extern void *mvalloc(void *md, size_t size);
/* Activate a standard collection of debugging hooks. */
-extern int mmcheck (void* md, void (*func) (void));
+extern int mmcheck(void *md, void (*func) (void));
-extern int mmcheckf (void* md, void (*func) (void), int force);
+extern int mmcheckf(void *md, void (*func) (void), int force);
/* Pick up the current statistics. (see FIXME elsewhere) */
-extern struct mstats mmstats (void* md);
+extern struct mstats mmstats(void *md);
-extern void* mmalloc_attach (int fd, void* baseaddr);
+extern void *mmalloc_attach(int fd, void *baseaddr);
-extern void* mmalloc_detach (void* md);
+extern void *mmalloc_detach(void *md);
-extern int mmalloc_setkey (void* md, int keynum, void* key);
+extern int mmalloc_setkey(void *md, int keynum, void *key);
-extern void* mmalloc_getkey (void* md, int keynum);
+extern void *mmalloc_getkey(void *md, int keynum);
// FIXME: this function is not implemented anymore?
//extern int mmalloc_errno (void* md);
extern int mmtrace(void);
-extern void* mmalloc_findbase(int size);
+extern void *mmalloc_findbase(int size);
/* To change the heap used when using the legacy version malloc/free/realloc and such */
void mmalloc_set_current_heap(void *new_heap);
-void* mmalloc_get_current_heap(void);
+void *mmalloc_get_current_heap(void);
-#endif /* MMALLOC_H */
+#endif /* MMALLOC_H */
XBT_PUBLIC(void) xbt_init(int *argc, char **argv);
XBT_PUBLIC(void) xbt_exit(void);
-#endif /* _XBT_MODULE_H */
+#endif /* _XBT_MODULE_H */
SG_BEGIN_DECL()
- typedef struct {
- char *name;
- int port;
- } s_xbt_peer_t, *xbt_peer_t;
+typedef struct {
+ char *name;
+ int port;
+} s_xbt_peer_t, *xbt_peer_t;
XBT_PUBLIC(xbt_peer_t) xbt_peer_new(const char *name, int port);
XBT_PUBLIC(xbt_peer_t) xbt_peer_from_string(const char *peerport);
XBT_PUBLIC(void) xbt_peer_free_voidp(void *d);
SG_END_DECL()
-#endif /* XBT_PEER_H */
+#endif /* XBT_PEER_H */
* @{
*/
/** \brief Queue data type (opaque type) */
- typedef struct s_xbt_queue_ *xbt_queue_t;
+typedef struct s_xbt_queue_ *xbt_queue_t;
-XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity, unsigned long elm_size);
+XBT_PUBLIC(xbt_queue_t) xbt_queue_new(int capacity,
+ unsigned long elm_size);
XBT_PUBLIC(void) xbt_queue_free(xbt_queue_t * queue);
XBT_PUBLIC(unsigned long) xbt_queue_length(const xbt_queue_t queue);
XBT_PUBLIC(void) xbt_queue_push_timed(xbt_queue_t queue, const void *src,
double delay);
-XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,
- double delay);
+XBT_PUBLIC(void) xbt_queue_unshift_timed(xbt_queue_t queue,
+ const void *src, double delay);
XBT_PUBLIC(void) xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
double delay);
XBT_PUBLIC(void) xbt_queue_pop_timed(xbt_queue_t queue, void *const dst,
/** @} */
SG_END_DECL()
-#endif /* _XBT_QUEUE_H */
+#endif /* _XBT_QUEUE_H */
* @{
*/
/** \brief Opaque type representing a set */
- typedef struct xbt_set_ *xbt_set_t;
+typedef struct xbt_set_ *xbt_set_t;
#define XBT_SET_HEADERS \
unsigned int ID; \
unsigned int name_len
/** \brief It must be possible to cast set elements to this type */
- typedef struct xbt_set_elm_ {
- unsigned int ID; /**< Identificator (system assigned) */
- char *name; /**< Name (user assigned) */
- unsigned int name_len;
+typedef struct xbt_set_elm_ {
+ unsigned int ID; /**< Identificator (system assigned) */
+ char *name; /**< Name (user assigned) */
+ unsigned int name_len;
/**< Length of the name */
- } s_xbt_set_elm_t, *xbt_set_elm_t;
+} s_xbt_set_elm_t, *xbt_set_elm_t;
/*####[ Functions ]##########################################################*/
XBT_PUBLIC(xbt_set_t) xbt_set_new(void);
int key_len);
XBT_PUBLIC(void) xbt_set_remove_by_id(xbt_set_t set, int id);
-XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name(xbt_set_t set, const char *key);
+XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name(xbt_set_t set,
+ const char *key);
XBT_PUBLIC(xbt_set_elm_t) xbt_set_get_by_name_ext(xbt_set_t set,
const char *key,
int key_len);
*/
/** @brief Cursor type */
- typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
+typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
XBT_PUBLIC(void) xbt_set_cursor_first(xbt_set_t set,
xbt_set_cursor_t * cursor);
/* @} */
SG_END_DECL()
-#endif /* _XBT_SET_H */
+#endif /* _XBT_SET_H */
void xbt_setset_elm_add(xbt_setset_t setset, void *obj);
/* Remove an object from the setset */
-void xbt_setset_elm_remove(xbt_setset_t setset, void * obj);
+void xbt_setset_elm_remove(xbt_setset_t setset, void *obj);
/* Create a new set in the setset */
xbt_setset_set_t xbt_setset_new_set(xbt_setset_t setset);
void xbt_setset_destroy_set(xbt_setset_set_t);
/* Insert an element into a set */
-void xbt_setset_set_insert(xbt_setset_set_t set, void* obj);
+void xbt_setset_set_insert(xbt_setset_set_t set, void *obj);
/* Remove an element from a set */
-void xbt_setset_set_remove(xbt_setset_set_t set, void* obj);
+void xbt_setset_set_remove(xbt_setset_set_t set, void *obj);
/* Remove all the elements of a set */
void xbt_setset_set_reset(xbt_setset_set_t set);
void *xbt_setset_set_extract(xbt_setset_set_t set);
/* Test if an element belongs to a set */
-int xbt_setset_set_belongs(xbt_setset_set_t set, void* obj);
+int xbt_setset_set_belongs(xbt_setset_set_t set, void *obj);
/* Get the number of elements in a set */
int xbt_setset_set_size(xbt_setset_set_t set);
void xbt_setset_intersect(xbt_setset_set_t set1, xbt_setset_set_t set2);
/* Get the cursor to point to the first element of a set */
-void xbt_setset_cursor_first(xbt_setset_set_t set, xbt_setset_cursor_t *cursor);
+void xbt_setset_cursor_first(xbt_setset_set_t set,
+ xbt_setset_cursor_t * cursor);
/* Get the data pointed by a cursor */
int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data);
#define xbt_setset_foreach(set, cursor, data) \
for(xbt_setset_cursor_first(set, &cursor); \
xbt_setset_cursor_get_data(cursor, (void **)&data); \
- xbt_setset_cursor_next(cursor))
+ xbt_setset_cursor_next(cursor))
#endif
* asprintf()), while some other are a bit more exotic.
* @{
*/
-
-
/* Trim related functions */
XBT_PUBLIC(void) xbt_str_rtrim(char *s, const char *char_list);
XBT_PUBLIC(void) xbt_str_ltrim(char *s, const char *char_list);
XBT_PUBLIC(void) xbt_str_strip_spaces(char *);
XBT_PUBLIC(char *) xbt_str_diff(char *a, char *b);
-XBT_PUBLIC(char*)xbt_str_from_file(FILE *file);
+XBT_PUBLIC(char *) xbt_str_from_file(FILE * file);
/**Â @brief Classical alias to (char*)
*
* This of almost no use, beside cosmetics and the GRAS parsing macro (see \ref GRAS_dd_auto).
*/
- typedef char *xbt_string_t;
+typedef char *xbt_string_t;
/**@}*/
SG_END_DECL()
-#endif /* XBT_STR_H */
+#endif /* XBT_STR_H */
XBT_PUBLIC(void) xbt_strbuff_append(xbt_strbuff_t b, const char *toadd);
XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b);
XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns);
+XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b,
+ xbt_dict_t patterns);
#endif
those structs directly. Use them as an abstract datatype.
*/
/* @{ */
- typedef struct xbt_swag_hookup {
- void *next;
- void *prev;
- } s_xbt_swag_hookup_t;
+typedef struct xbt_swag_hookup {
+ void *next;
+ void *prev;
+} s_xbt_swag_hookup_t;
/**< This type should be added to a type that is to be used in a swag.
*
* Whenever a new object with this struct is created, all fields have
}
\endcode
*/
- typedef s_xbt_swag_hookup_t *xbt_swag_hookup_t;
+typedef s_xbt_swag_hookup_t *xbt_swag_hookup_t;
- typedef struct xbt_swag {
- void *head;
- void *tail;
- size_t offset;
- int count;
- } s_xbt_swag_t, *xbt_swag_t;
+typedef struct xbt_swag {
+ void *head;
+ void *tail;
+ size_t offset;
+ int count;
+} s_xbt_swag_t, *xbt_swag_t;
/**< A typical swag */
/* @} */
#define xbt_swag_getNext(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->prev)
#define xbt_swag_getPrev(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->next)
-static XBT_INLINE int xbt_swag_belongs(void *obj, xbt_swag_t swag) {
- return ((xbt_swag_getNext(obj, swag->offset)) || (xbt_swag_getPrev(obj, swag->offset))
- || (swag->head == obj));
+static XBT_INLINE int xbt_swag_belongs(void *obj, xbt_swag_t swag)
+{
+ return ((xbt_swag_getNext(obj, swag->offset))
+ || (xbt_swag_getPrev(obj, swag->offset))
+ || (swag->head == obj));
}
static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag)
/* @} */
SG_END_DECL()
-#endif /* _XBT_SWAG_H */
+#endif /* _XBT_SWAG_H */
#include "xbt/dynar.h"
SG_BEGIN_DECL()
-XBT_PUBLIC(void) xbt_dynar_dopar(xbt_dynar_t datas, void_f_int_pvoid_t function);
+XBT_PUBLIC(void) xbt_dynar_dopar(xbt_dynar_t datas,
+ void_f_int_pvoid_t function);
SG_END_DECL()
-
-#endif /* SYNCHRO_H_ */
+#endif /* SYNCHRO_H_ */
* @{
*/
/** \brief Thread data type (opaque structure) */
- typedef struct s_xbt_thread_ *xbt_thread_t;
+typedef struct s_xbt_thread_ *xbt_thread_t;
XBT_PUBLIC(xbt_thread_t) xbt_thread_create(const char *name,
void_f_pvoid_t start_routine,
- void *param,int joinable);
+ void *param, int joinable);
XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
XBT_PUBLIC(const char *) xbt_thread_name(xbt_thread_t t);
XBT_PUBLIC(const char *) xbt_thread_self_name(void);
/** \brief Thread mutex data type (opaque structure) */
- typedef struct s_xbt_mutex_ *xbt_mutex_t;
+typedef struct s_xbt_mutex_ *xbt_mutex_t;
XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
XBT_PUBLIC(void) xbt_mutex_acquire(xbt_mutex_t mutex);
/** \brief Thread condition data type (opaque structure) */
- typedef struct s_xbt_cond_ *xbt_cond_t;
+typedef struct s_xbt_cond_ *xbt_cond_t;
XBT_PUBLIC(xbt_cond_t) xbt_cond_init(void);
XBT_PUBLIC(void) xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex);
/** @} */
SG_END_DECL()
-#endif /* _XBT_THREAD_H */
+#endif /* _XBT_THREAD_H */
#if defined(__GNUC__) || defined(DOXYGEN)
/** @brief Like strdup, but xbt_die() on error */
-static inline __attribute__((always_inline)) char *xbt_strdup(const char *s)
+static inline __attribute__ ((always_inline))
+char *xbt_strdup(const char *s)
{
char *res = NULL;
if (s) {
/** @brief Like malloc, but xbt_die() on error
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_malloc(unsigned int n)
+static inline __attribute__ ((always_inline))
+void *xbt_malloc(unsigned int n)
{
void *res;
/* if (n==0) {
/** @brief like malloc, but xbt_die() on error and memset data to 0
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_malloc0(unsigned int n)
+static inline __attribute__ ((always_inline))
+void *xbt_malloc0(unsigned int n)
{
void *res;
//if (n==0) xbt_die("calloc(0) is not portable");
/** @brief like realloc, but xbt_die() on error
@hideinitializer */
-static inline __attribute__((always_inline)) void *xbt_realloc(void *p, unsigned int s)
+static inline __attribute__ ((always_inline))
+void *xbt_realloc(void *p, unsigned int s)
{
void *res = res;
//if (s==0) xbt_die("realloc(0) is not portable");
}
return res;
}
-#else /* non __GNUC__ */
+#else /* non __GNUC__ */
# define xbt_strdup(s) strdup(s)
# define xbt_malloc(n) malloc(n)
# define xbt_malloc0(n) calloc(n,1)
# define xbt_realloc(p,s) realloc(p,s)
-#endif /* __GNUC__ ? */
+#endif /* __GNUC__ ? */
/** @brief like free
@hideinitializer */
SG_END_DECL()
-#endif /* _XBT_SYSDEP_H */
+#endif /* _XBT_SYSDEP_H */
SG_BEGIN_DECL()
- /* Get the PID of the current process */
- XBT_PUBLIC_DATA(int_f_void_t) xbt_getpid;
+ /* Get the PID of the current process */
+ XBT_PUBLIC_DATA(int_f_void_t) xbt_getpid;
SG_END_DECL()
-#endif /* __XBT_VIRTU_H__ */
+#endif /* __XBT_VIRTU_H__ */
* License along with QueueUserAPCEx in the file COPYING.LIB;\r
* if not, write to the Free Software Foundation, Inc.,\r
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\r
- */\r
-\r
+ */ \r
+ \r
#ifndef UCONTEXT_H\r
#define UCONTEXT_H\r
-\r
+ \r
#include <windows.h>\r
-\r
-typedef struct __stack {\r
- void *ss_sp;\r
- size_t ss_size;\r
- int ss_flags;\r
-} stack_t;\r
-\r
-typedef CONTEXT mcontext_t;\r
-typedef unsigned long __sigset_t;\r
-\r
-typedef struct __ucontext {\r
- unsigned long int uc_flags;\r
- struct __ucontext *uc_link;\r
- stack_t uc_stack;\r
- mcontext_t uc_mcontext;\r
- __sigset_t uc_sigmask;\r
-} ucontext_t;\r
-\r
-\r
-int getcontext(ucontext_t *ucp);\r
-int setcontext(const ucontext_t *ucp);\r
-int makecontext(ucontext_t *, void (*)(), int, ...);\r
-int swapcontext(ucontext_t *, const ucontext_t *);\r
-\r
-#endif /* UCONTEXT_H */\r
+ \rtypedef struct __stack {
+ \rvoid *ss_sp;
+ \rsize_t ss_size;
+ \rint ss_flags;
+\r} stack_t;
+\r\rtypedef CONTEXT mcontext_t;
+\rtypedef unsigned long __sigset_t;
+\r\rtypedef struct __ucontext {
+ \runsigned long int uc_flags;
+ \rstruct __ucontext *uc_link;
+ \rstack_t uc_stack;
+ \rmcontext_t uc_mcontext;
+ \r__sigset_t uc_sigmask;
+\r} ucontext_t;
+\r\r\rint getcontext(ucontext_t * ucp);
+\rint setcontext(const ucontext_t * ucp);
+\rint makecontext(ucontext_t *, void (*)(), int, ...);
+\rint swapcontext(ucontext_t *, const ucontext_t *);
+\r\r
+#endif /* UCONTEXT_H */\r
gras_datadesc_struct_close(bw_res_desc);
bw_res_desc = gras_datadesc_ref("bw_res_t", bw_res_desc);
- gras_msgtype_declare_rpc("BW handshake", bw_request_desc, bw_request_desc);
+ gras_msgtype_declare_rpc("BW handshake", bw_request_desc,
+ bw_request_desc);
gras_msgtype_declare_rpc("BW reask", bw_request_desc, NULL);
gras_msgtype_declare("BW stop", NULL);
request->peer.name = NULL;
request->peer.port = gras_socket_my_port(measMasterIn);
DEBUG6
- ("Handshaking with %s:%d to connect it back on my %d (bufsize=%ld, msg_size=%ld, msg_amount=%ld)",
- gras_socket_peer_name(peer), gras_socket_peer_port(peer),
- request->peer.port, request->buf_size, request->msg_size,
- request->msg_amount);
+ ("Handshaking with %s:%d to connect it back on my %d (bufsize=%ld, msg_size=%ld, msg_amount=%ld)",
+ gras_socket_peer_name(peer), gras_socket_peer_port(peer),
+ request->peer.port, request->buf_size, request->msg_size,
+ request->msg_amount);
TRY {
gras_msg_rpccall(peer, 15, "BW handshake", &request, &request_ack);
}
CATCH(e) {
RETHROW2
- ("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
- gras_socket_peer_name(peer), request_ack->peer.port);
+ ("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
+ gras_socket_peer_name(peer), request_ack->peer.port);
}
- DEBUG2("Got ACK; conduct the experiment (msg_size = %ld, msg_amount=%ld)",
- request->msg_size, request->msg_amount);
+ DEBUG2
+ ("Got ACK; conduct the experiment (msg_size = %ld, msg_amount=%ld)",
+ request->msg_size, request->msg_amount);
*sec = 0;
first_pass = 1;
And then increase the number of messages to compensate (check for overflow there, too) */
if (request->msg_size > 64 * 1024 * 1024) {
unsigned long int new_amount =
- ((request->msg_size / ((double) 64 * 1024 * 1024))
- * request->msg_amount) + 1;
+ ((request->msg_size / ((double) 64 * 1024 * 1024))
+ * request->msg_amount) + 1;
xbt_assert0(new_amount > request->msg_amount,
"Overflow on the number of messages! You must have a *really* fat pipe. Please fix your platform");
}
VERB5
- ("The experiment was too short (%f sec<%f sec). Redo it with msg_size=%lu (nb_messages=%lu) (got %fMb/s)",
- meas_duration, min_duration, request->msg_size, request->msg_amount,
- ((double) request->msg_size) * ((double) request->msg_amount /
- (*sec) / 1024.0 / 1024.0));
+ ("The experiment was too short (%f sec<%f sec). Redo it with msg_size=%lu (nb_messages=%lu) (got %fMb/s)",
+ meas_duration, min_duration, request->msg_size,
+ request->msg_amount,
+ ((double) request->msg_size) * ((double) request->msg_amount /
+ (*sec) / 1024.0 / 1024.0));
gras_msg_rpccall(peer, 60, "BW reask", &request, NULL);
}
*sec = gras_os_time() - *sec;
if (*sec != 0.0) {
*bw =
- ((double) request->msg_size) * ((double) request->msg_amount) /
- (*sec);
+ ((double) request->msg_size) * ((double) request->msg_amount) /
+ (*sec);
}
DEBUG1("Experiment done ; it took %f sec", *sec);
if (*sec <= 0) {
} while (*sec < min_duration);
- DEBUG2("This measurement was long enough (%f sec; found %f b/s). Stop peer",
- *sec, *bw);
+ DEBUG2
+ ("This measurement was long enough (%f sec; found %f b/s). Stop peer",
+ *sec, *bw);
gras_msg_send(peer, "BW stop", NULL);
free(request_ack);
static xbt_dynar_t msgtwaited = NULL;
DEBUG5
- ("Handshaked to connect to %s:%d (sizes: buf=%lu msg=%lu msg_amount=%lu)",
- gras_socket_peer_name(expeditor), request->peer.port, request->buf_size,
- request->msg_size, request->msg_amount);
+ ("Handshaked to connect to %s:%d (sizes: buf=%lu msg=%lu msg_amount=%lu)",
+ gras_socket_peer_name(expeditor), request->peer.port,
+ request->buf_size, request->msg_size, request->msg_amount);
/* Build our answer */
answer = xbt_new0(s_bw_request_t, 1);
else
/* FIXME: tell error to remote */
RETHROW0
- ("Error encountered while opening a measurement server socket: %s");
+ ("Error encountered while opening a measurement server socket: %s");
}
}
}
CATCH(e) {
RETHROW2
- ("Error encountered while opening a measurement socket back to %s:%d : %s",
- gras_socket_peer_name(expeditor), request->peer.port);
+ ("Error encountered while opening a measurement socket back to %s:%d : %s",
+ gras_socket_peer_name(expeditor), request->peer.port);
/* FIXME: tell error to remote */
}
TRY {
measIn = gras_socket_meas_accept(measMasterIn);
DEBUG4
- ("BW handshake answered. buf_size=%lu msg_size=%lu msg_amount=%lu port=%d",
- answer->buf_size, answer->msg_size, answer->msg_amount,
- answer->peer.port);
+ ("BW handshake answered. buf_size=%lu msg_size=%lu msg_amount=%lu port=%d",
+ answer->buf_size, answer->msg_size, answer->msg_amount,
+ answer->peer.port);
}
CATCH(e) {
gras_socket_close(measMasterIn);
if (i != j) {
/* Mesurements of Bandwidth */
amok_bw_request(p1->name, p1->port, p2->name, p2->port,
- buf_size_bw, msg_size_bw, msg_amount_bw, min_duration,
- &sec, &matrix_res[i * len + j]);
+ buf_size_bw, msg_size_bw, msg_amount_bw,
+ min_duration, &sec, &matrix_res[i * len + j]);
}
}
}
const char *to_name, unsigned int to_port,
unsigned int msg_size, unsigned int duration);
-#endif /* AMOK_BANDWIDTH_PRIVATE_H */
+#endif /* AMOK_BANDWIDTH_PRIVATE_H */
/* Launch the saturation */
- ctx = gras_msg_rpc_async_call(peer_cmd, 60, "amok_bw_sat begin", &request);
+ ctx =
+ gras_msg_rpc_async_call(peer_cmd, 60, "amok_bw_sat begin", &request);
free(request);
gras_msg_rpc_async_wait(ctx, &request);
meas = gras_socket_client_ext(to_name, request->peer.port,
free(answer);
} else {
INFO6
- ("Saturation from %s:%d to %s:%d elapsed after %f sec (achieving %f kb/s)",
- gras_os_myname(), gras_os_myport(), to_name, to_port, elapsed,
- bw / 1024.0);
+ ("Saturation from %s:%d to %s:%d elapsed after %f sec (achieving %f kb/s)",
+ gras_os_myname(), gras_os_myport(), to_name, to_port, elapsed,
+ bw / 1024.0);
}
gras_socket_close(meas);
xbt_ex_free(e);
else
RETHROW0
- ("Error encountered while opening a measurement server socket: %s");
+ ("Error encountered while opening a measurement server socket: %s");
}
if (measMaster == NULL)
port++; /* prepare for a new loop */
TRY {
gras_msg_rpccall(sock, 60, "amok_bw_sat stop", NULL, &answer);
} CATCH(e) {
- RETHROW2("Cannot ask %s:%d to stop saturation: %s", from_name, from_port);
+ RETHROW2("Cannot ask %s:%d to stop saturation: %s", from_name,
+ from_port);
}
gras_socket_close(sock);
if (time)
static int amok_pm_cb_join(gras_msg_cb_ctx_t ctx, void *payload)
{
amok_pm_moddata_t g = gras_moddata_by_id(amok_pm_moddata_id);
- char* group_name = *(char* *) payload;
+ char *group_name = *(char **) payload;
xbt_dynar_t group = xbt_dict_get(g->groups, group_name);
int rank;
rank = xbt_dynar_length(group);
xbt_dynar_push(group, &dude);
- VERB3("Contacted by %s:%d. Give it rank #%d", dude->name, dude->port,rank);
+ VERB3("Contacted by %s:%d. Give it rank #%d", dude->name, dude->port,
+ rank);
gras_msg_rpcreturn(10, ctx, &rank);
free(group_name);
gras_msg_rpccall(master, 30, "amok_pm_join", &group_name, &rank);
VERB4("Joined group '%s' on %s:%d. Got rank %d",
group_name, gras_socket_peer_name(master),
- gras_socket_peer_port(master),
- rank);
+ gras_socket_peer_port(master), rank);
return rank;
}
/* no world-wide globals */
/* Datatype and message declarations */
gras_datadesc_type_t pm_group_type =
- gras_datadesc_dynar(gras_datadesc_by_name("xbt_peer_t"),
- xbt_peer_free_voidp);
+ gras_datadesc_dynar(gras_datadesc_by_name("xbt_peer_t"),
+ xbt_peer_free_voidp);
gras_msgtype_declare("amok_pm_kill", NULL);
gras_msgtype_declare_rpc("amok_pm_killrpc", NULL, NULL);
gras_msgtype_declare_rpc("amok_pm_get",
gras_datadesc_by_name("string"), pm_group_type);
- gras_msgtype_declare_rpc("amok_pm_join", gras_datadesc_by_name("string"), gras_datadesc_by_name("int"));
+ gras_msgtype_declare_rpc("amok_pm_join", gras_datadesc_by_name("string"),
+ gras_datadesc_by_name("int"));
gras_msgtype_declare_rpc("amok_pm_leave",
gras_datadesc_by_name("string"), NULL);
void amok_pm_modulecreate()
{
- gras_module_add("amok_pm", sizeof(s_amok_pm_moddata_t), &amok_pm_moddata_id,
- _amok_pm_init, _amok_pm_exit, _amok_pm_join,
- _amok_pm_leave);
+ gras_module_add("amok_pm", sizeof(s_amok_pm_moddata_t),
+ &amok_pm_moddata_id, _amok_pm_init, _amok_pm_exit,
+ _amok_pm_join, _amok_pm_leave);
}
/* module creation functions */
void amok_pm_modulecreate(void);
-#endif /* AMOK_BASE_H */
+#endif /* AMOK_BASE_H */
/**********************************************/
const char *SIM_PREEMBULE =
- "/* specific to Borland Compiler */\n"
- "#ifdef __BORLANDC__\n"
- "#pragma hdrstop\n"
- "#endif\n\n"
- "#include <stdlib.h>\n"
- "#include <stdio.h>\n"
- "#include \"msg/msg.h\"\n"
- "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
+ "/* specific to Borland Compiler */\n"
+ "#ifdef __BORLANDC__\n"
+ "#pragma hdrstop\n"
+ "#endif\n\n"
+ "#include <stdlib.h>\n"
+ "#include <stdio.h>\n"
+ "#include \"msg/msg.h\"\n"
+ "#include <gras.h>\n" "\n" "char *gras_log=NULL;\n";
#define SIM_LAUNCH_FUNC \
"}\n"
const char *SIM_MAIN_POSTEMBULE = "\n"
- "\n"
- " gras_load_environment_script(argv[1]);\n"
- "\n"
- " /* Run the simulation */\n"
- " gras_main();\n"
- "\n"
- " /* cleanup the place */\n"
- " gras_clean();\n"
- " if (gras_log)\n" " free(gras_log);\n" " return 0;\n" "}\n";
+ "\n"
+ " gras_load_environment_script(argv[1]);\n"
+ "\n"
+ " /* Run the simulation */\n"
+ " gras_main();\n"
+ "\n"
+ " /* cleanup the place */\n"
+ " gras_clean();\n"
+ " if (gras_log)\n" " free(gras_log);\n" " return 0;\n" "}\n";
/***************************************
" if (argc != 2) {\n"
" fprintf(stderr, \"Usage: lua platform_script.lua [--log=...]\\n\");\n"
" exit(1);\n" " }\n" "\n");
- fprintf(OUT,
- "\n" " /* Application deployment */\n");
+ fprintf(OUT, "\n" " /* Application deployment */\n");
xbt_dict_foreach(process_function_set, cursor, key, data) {
- fprintf(OUT, " gras_function_register(\"%s\", launch_%s);\n", key, key);
+ fprintf(OUT, " gras_function_register(\"%s\", launch_%s);\n", key,
+ key);
}
fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
fclose(OUT);
xbt_dict_foreach(process_function_set, cursor, key, data) {
filename =
- xbt_new(char, strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
+ xbt_new(char,
+ strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
sprintf(filename, RL_SOURCENAME, project, key);
char *filename = NULL;
FILE *OUT = NULL;
- filename = xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
+ filename =
+ xbt_new(char, strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
sprintf(filename, MAKEFILE_FILENAME_LOCAL, project);
OUT = fopen(filename, "w");
#include "xbt.h"
#include "lua_stub_generator.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua,bindings,"Lua Bindings");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
#define TASK_MODULE_NAME "simgrid.Task"
#define HOST_MODULE_NAME "simgrid.Host"
/* ********************************************************************************* */
/* helper functions */
/* ********************************************************************************* */
-static void stackDump (const char *msg, lua_State *L) {
+static void stackDump(const char *msg, lua_State * L)
+{
char buff[2048];
- char *p=buff;
+ char *p = buff;
int i;
int top = lua_gettop(L);
fflush(stdout);
- p+=sprintf(p,"STACK(top=%d): ",top);
+ p += sprintf(p, "STACK(top=%d): ", top);
for (i = 1; i <= top; i++) { /* repeat for each level */
int t = lua_type(L, i);
switch (t) {
- case LUA_TSTRING: /* strings */
- p+=sprintf(p,"`%s'", lua_tostring(L, i));
+ case LUA_TSTRING: /* strings */
+ p += sprintf(p, "`%s'", lua_tostring(L, i));
break;
- case LUA_TBOOLEAN: /* booleans */
- p+=sprintf(p,lua_toboolean(L, i) ? "true" : "false");
+ case LUA_TBOOLEAN: /* booleans */
+ p += sprintf(p, lua_toboolean(L, i) ? "true" : "false");
break;
- case LUA_TNUMBER: /* numbers */
- p+=sprintf(p,"%g", lua_tonumber(L, i));
+ case LUA_TNUMBER: /* numbers */
+ p += sprintf(p, "%g", lua_tonumber(L, i));
break;
case LUA_TTABLE:
- p+=sprintf(p, "Table");
+ p += sprintf(p, "Table");
break;
- default: /* other values */
- p+=sprintf(p, "???");
+ default: /* other values */
+ p += sprintf(p, "???");
/* if ((ptr = luaL_checkudata(L,i,TASK_MODULE_NAME))) {
p+=sprintf(p,"task");
} else {
break;
}
- p+=sprintf(p," "); /* put a separator */
+ p += sprintf(p, " "); /* put a separator */
}
- INFO2("%s%s",msg,buff);
+ INFO2("%s%s", msg, buff);
}
/** @brief ensures that a userdata on the stack is a task and returns the pointer inside the userdata */
-static m_task_t checkTask (lua_State *L,int index) {
- m_task_t *pi,tk;
- luaL_checktype(L,index,LUA_TTABLE);
- lua_getfield(L,index,"__simgrid_task");
- pi = (m_task_t*)luaL_checkudata(L,-1,TASK_MODULE_NAME);
- if(pi == NULL)
- luaL_typerror(L,index,TASK_MODULE_NAME);
+static m_task_t checkTask(lua_State * L, int index)
+{
+ m_task_t *pi, tk;
+ luaL_checktype(L, index, LUA_TTABLE);
+ lua_getfield(L, index, "__simgrid_task");
+ pi = (m_task_t *) luaL_checkudata(L, -1, TASK_MODULE_NAME);
+ if (pi == NULL)
+ luaL_typerror(L, index, TASK_MODULE_NAME);
tk = *pi;
- if(!tk)
- luaL_error(L,"null Task");
- lua_pop(L,1);
- return tk;
+ if (!tk)
+ luaL_error(L, "null Task");
+ lua_pop(L, 1);
+ return tk;
}
+
/* ********************************************************************************* */
/* wrapper functions */
/* ********************************************************************************* */
* If 0, then it cannot be transfered with the get() and put() methods.
* This value has to be >= 0.
*/
-static int Task_new(lua_State* L) {
- const char *name=luaL_checkstring(L,1);
- int comp_size = luaL_checkint(L,2);
- int msg_size = luaL_checkint(L,3);
- m_task_t msg_task = MSG_task_create(name,comp_size,msg_size,NULL);
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_task_t *lua_task = (m_task_t*)lua_newuserdata(L,sizeof(m_task_t));
- *lua_task = msg_task;
- luaL_getmetatable(L,TASK_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_task"); /* put the userdata as field of the table */
- /* remove the args from the stack */
- lua_remove(L,1);
- lua_remove(L,1);
- lua_remove(L,1);
- return 1;
+static int Task_new(lua_State * L)
+{
+ const char *name = luaL_checkstring(L, 1);
+ int comp_size = luaL_checkint(L, 2);
+ int msg_size = luaL_checkint(L, 3);
+ m_task_t msg_task = MSG_task_create(name, comp_size, msg_size, NULL);
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_task_t *lua_task = (m_task_t *) lua_newuserdata(L, sizeof(m_task_t));
+ *lua_task = msg_task;
+ luaL_getmetatable(L, TASK_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_task"); /* put the userdata as field of the table */
+ /* remove the args from the stack */
+ lua_remove(L, 1);
+ lua_remove(L, 1);
+ lua_remove(L, 1);
+ return 1;
}
-static int Task_get_name(lua_State *L) {
- m_task_t tk = checkTask(L,-1);
- lua_pushstring(L,MSG_task_get_name(tk));
+static int Task_get_name(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ lua_pushstring(L, MSG_task_get_name(tk));
return 1;
}
-static int Task_computation_duration(lua_State *L){
- m_task_t tk = checkTask(L,-1);
- lua_pushnumber(L,MSG_task_get_compute_duration (tk));
+static int Task_computation_duration(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ lua_pushnumber(L, MSG_task_get_compute_duration(tk));
return 1;
}
-static int Task_execute(lua_State *L){
- m_task_t tk = checkTask(L,-1);
+static int Task_execute(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
int res = MSG_task_execute(tk);
- lua_pushnumber(L,res);
+ lua_pushnumber(L, res);
return 1;
}
-static int Task_destroy(lua_State *L) {
- m_task_t tk = checkTask(L,-1);
+static int Task_destroy(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
int res = MSG_task_destroy(tk);
- lua_pushnumber(L,res);
+ lua_pushnumber(L, res);
return 1;
}
-static int Task_send(lua_State *L) {
+static int Task_send(lua_State * L)
+{
//stackDump("send ",L);
- m_task_t tk = checkTask(L,-2);
- const char *mailbox = luaL_checkstring(L,-1);
- lua_pop(L,1); // remove the string so that the task is on top of it
- MSG_task_set_data(tk,L); // Copy my stack into the task, so that the receiver can copy the lua task directly
- MSG_error_t res = MSG_task_send(tk,mailbox);
- while (MSG_task_get_data(tk)!=NULL) // Don't mess up with my stack: the receiver didn't copy the data yet
- MSG_process_sleep(0); // yield
-
- if (res != MSG_OK) switch(res) {
- case MSG_TIMEOUT :
+ m_task_t tk = checkTask(L, -2);
+ const char *mailbox = luaL_checkstring(L, -1);
+ lua_pop(L, 1); // remove the string so that the task is on top of it
+ MSG_task_set_data(tk, L); // Copy my stack into the task, so that the receiver can copy the lua task directly
+ MSG_error_t res = MSG_task_send(tk, mailbox);
+ while (MSG_task_get_data(tk) != NULL) // Don't mess up with my stack: the receiver didn't copy the data yet
+ MSG_process_sleep(0); // yield
+
+ if (res != MSG_OK)
+ switch (res) {
+ case MSG_TIMEOUT:
ERROR0("MSG_task_send failed : Timeout");
break;
- case MSG_TRANSFER_FAILURE :
+ case MSG_TRANSFER_FAILURE:
ERROR0("MSG_task_send failed : Transfer Failure");
break;
- case MSG_HOST_FAILURE :
+ case MSG_HOST_FAILURE:
ERROR0("MSG_task_send failed : Host Failure ");
break;
- default :
- ERROR0("MSG_task_send failed : Unexpected error , please report this bug");
+ default:
+ ERROR0
+ ("MSG_task_send failed : Unexpected error , please report this bug");
break;
}
return 0;
}
-static int Task_recv(lua_State *L) {
+static int Task_recv(lua_State * L)
+{
m_task_t tk = NULL;
- const char *mailbox = luaL_checkstring(L,-1);
- MSG_error_t res = MSG_task_receive(&tk,mailbox);
+ const char *mailbox = luaL_checkstring(L, -1);
+ MSG_error_t res = MSG_task_receive(&tk, mailbox);
lua_State *sender_stack = MSG_task_get_data(tk);
- lua_xmove(sender_stack,L,1); // copy the data directly from sender's stack
- MSG_task_set_data(tk,NULL);
-
- if(res != MSG_OK) switch(res){
- case MSG_TIMEOUT :
- ERROR0("MSG_task_receive failed : Timeout");
- break;
- case MSG_TRANSFER_FAILURE :
- ERROR0("MSG_task_receive failed : Transfer Failure");
- break;
- case MSG_HOST_FAILURE :
- ERROR0("MSG_task_receive failed : Host Failure ");
- break;
- default :
- ERROR0("MSG_task_receive failed : Unexpected error , please report this bug");
- break;
- }
+ lua_xmove(sender_stack, L, 1); // copy the data directly from sender's stack
+ MSG_task_set_data(tk, NULL);
+
+ if (res != MSG_OK)
+ switch (res) {
+ case MSG_TIMEOUT:
+ ERROR0("MSG_task_receive failed : Timeout");
+ break;
+ case MSG_TRANSFER_FAILURE:
+ ERROR0("MSG_task_receive failed : Transfer Failure");
+ break;
+ case MSG_HOST_FAILURE:
+ ERROR0("MSG_task_receive failed : Host Failure ");
+ break;
+ default:
+ ERROR0
+ ("MSG_task_receive failed : Unexpected error , please report this bug");
+ break;
+ }
return 1;
}
static const luaL_reg Task_methods[] = {
- {"new", Task_new},
- {"name", Task_get_name},
- {"computation_duration", Task_computation_duration},
- {"execute", Task_execute},
- {"destroy", Task_destroy},
- {"send", Task_send},
- {"recv", Task_recv},
- {0,0}
+ {"new", Task_new},
+ {"name", Task_get_name},
+ {"computation_duration", Task_computation_duration},
+ {"execute", Task_execute},
+ {"destroy", Task_destroy},
+ {"send", Task_send},
+ {"recv", Task_recv},
+ {0, 0}
};
-static int Task_gc(lua_State *L) {
- m_task_t tk=checkTask(L,-1);
- if (tk) MSG_task_destroy(tk);
+
+static int Task_gc(lua_State * L)
+{
+ m_task_t tk = checkTask(L, -1);
+ if (tk)
+ MSG_task_destroy(tk);
return 0;
}
-static int Task_tostring(lua_State *L) {
- lua_pushfstring(L, "Task :%p",lua_touserdata(L,1));
+static int Task_tostring(lua_State * L)
+{
+ lua_pushfstring(L, "Task :%p", lua_touserdata(L, 1));
return 1;
}
static const luaL_reg Task_meta[] = {
- {"__gc", Task_gc},
- {"__tostring", Task_tostring},
- {0,0}
+ {"__gc", Task_gc},
+ {"__tostring", Task_tostring},
+ {0, 0}
};
/**
* Host
*/
-static m_host_t checkHost (lua_State *L,int index) {
- m_host_t *pi,ht;
- luaL_checktype(L,index,LUA_TTABLE);
- lua_getfield(L,index,"__simgrid_host");
- pi = (m_host_t*)luaL_checkudata(L,-1,HOST_MODULE_NAME);
- if(pi == NULL)
- luaL_typerror(L,index,HOST_MODULE_NAME);
+static m_host_t checkHost(lua_State * L, int index)
+{
+ m_host_t *pi, ht;
+ luaL_checktype(L, index, LUA_TTABLE);
+ lua_getfield(L, index, "__simgrid_host");
+ pi = (m_host_t *) luaL_checkudata(L, -1, HOST_MODULE_NAME);
+ if (pi == NULL)
+ luaL_typerror(L, index, HOST_MODULE_NAME);
ht = *pi;
- if(!ht)
- luaL_error(L,"null Host");
- lua_pop(L,1);
- return ht;
+ if (!ht)
+ luaL_error(L, "null Host");
+ lua_pop(L, 1);
+ return ht;
}
-static int Host_get_by_name(lua_State *L)
+static int Host_get_by_name(lua_State * L)
{
- const char *name=luaL_checkstring(L,1);
- DEBUG0("Getting Host from name...");
- m_host_t msg_host = MSG_get_host_by_name(name);
- if (!msg_host)
- {
- luaL_error(L,"null Host : MSG_get_host_by_name failled");
- }
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_host_t *lua_host = (m_host_t*)lua_newuserdata(L,sizeof(m_host_t));
- *lua_host = msg_host;
- luaL_getmetatable(L,HOST_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_host"); /* put the userdata as field of the table */
- /* remove the args from the stack */
- lua_remove(L,1);
- return 1;
+ const char *name = luaL_checkstring(L, 1);
+ DEBUG0("Getting Host from name...");
+ m_host_t msg_host = MSG_get_host_by_name(name);
+ if (!msg_host) {
+ luaL_error(L, "null Host : MSG_get_host_by_name failled");
+ }
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_host_t *lua_host = (m_host_t *) lua_newuserdata(L, sizeof(m_host_t));
+ *lua_host = msg_host;
+ luaL_getmetatable(L, HOST_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_host"); /* put the userdata as field of the table */
+ /* remove the args from the stack */
+ lua_remove(L, 1);
+ return 1;
}
-static int Host_get_name(lua_State *L) {
- m_host_t ht = checkHost(L,-1);
- lua_pushstring(L,MSG_host_get_name(ht));
+static int Host_get_name(lua_State * L)
+{
+ m_host_t ht = checkHost(L, -1);
+ lua_pushstring(L, MSG_host_get_name(ht));
return 1;
}
-static int Host_number(lua_State *L) {
- lua_pushnumber(L,MSG_get_host_number());
+static int Host_number(lua_State * L)
+{
+ lua_pushnumber(L, MSG_get_host_number());
return 1;
}
-static int Host_at(lua_State *L)
+static int Host_at(lua_State * L)
{
- int index = luaL_checkinteger(L,1);
- m_host_t host = MSG_get_host_table()[index-1]; // lua indexing start by 1 (lua[1] <=> C[0])
- lua_newtable (L); /* create a table, put the userdata on top of it */
- m_host_t *lua_host = (m_host_t*)lua_newuserdata(L,sizeof(m_host_t));
- *lua_host = host;
- luaL_getmetatable(L,HOST_MODULE_NAME);
- lua_setmetatable(L,-2);
- lua_setfield (L, -2, "__simgrid_host"); /* put the userdata as field of the table */
- return 1;
+ int index = luaL_checkinteger(L, 1);
+ m_host_t host = MSG_get_host_table()[index - 1]; // lua indexing start by 1 (lua[1] <=> C[0])
+ lua_newtable(L); /* create a table, put the userdata on top of it */
+ m_host_t *lua_host = (m_host_t *) lua_newuserdata(L, sizeof(m_host_t));
+ *lua_host = host;
+ luaL_getmetatable(L, HOST_MODULE_NAME);
+ lua_setmetatable(L, -2);
+ lua_setfield(L, -2, "__simgrid_host"); /* put the userdata as field of the table */
+ return 1;
}
#include "surf/surfxml_parse.h" /* to override surf_parse and bypass the parser */
#include "surf/surf_private.h"
-typedef struct t_AS_attr
-{
- const char* id;
- const char *mode;
-}AS_attr,*p_AS_attr;
-
-typedef struct t_host_attr
-{
- //platform attribute
- // Mandatory attributes
- const char* id;
- double power_peak;
- // Optional attributes
- double power_scale;
- const char *power_trace;
- int state_initial;
- const char *state_trace;
- //deployment attribute
- const char* function;
- xbt_dynar_t args_list;
-}host_attr,*p_host_attr;
-
-typedef struct t_link_attr
-{
- //mandatory attributes
- const char* id;
- double bandwidth;
- double latency;
- // Optional attributes
- const char* bandwidth_trace;
- const char* latency_trace;
- const char* state_trace;
- int state_initial;
- int policy;
-}link_attr,*p_link_attr;
-
-typedef struct t_route_attr
-{
- const char *src_id;
- const char *dest_id;
- xbt_dynar_t links_id;
-
-}route_attr,*p_route_attr;
+typedef struct t_AS_attr {
+ const char *id;
+ const char *mode;
+} AS_attr, *p_AS_attr;
+
+typedef struct t_host_attr {
+ //platform attribute
+ // Mandatory attributes
+ const char *id;
+ double power_peak;
+ // Optional attributes
+ double power_scale;
+ const char *power_trace;
+ int state_initial;
+ const char *state_trace;
+ //deployment attribute
+ const char *function;
+ xbt_dynar_t args_list;
+} host_attr, *p_host_attr;
+
+typedef struct t_link_attr {
+ //mandatory attributes
+ const char *id;
+ double bandwidth;
+ double latency;
+ // Optional attributes
+ const char *bandwidth_trace;
+ const char *latency_trace;
+ const char *state_trace;
+ int state_initial;
+ int policy;
+} link_attr, *p_link_attr;
+
+typedef struct t_route_attr {
+ const char *src_id;
+ const char *dest_id;
+ xbt_dynar_t links_id;
+
+} route_attr, *p_route_attr;
//AS : One struct needed
static p_AS_attr AS;
//using xbt_dynar_t :
-static xbt_dynar_t host_list_d ;
-static xbt_dynar_t link_list_d ;
-static xbt_dynar_t route_list_d ;
+static xbt_dynar_t host_list_d;
+static xbt_dynar_t link_list_d;
+static xbt_dynar_t route_list_d;
/*
* Initialize platform model routing
*/
-static void create_AS(const char* id,const char * mode)
+static void create_AS(const char *id, const char *mode)
{
- surf_AS_new(id,mode);
+ surf_AS_new(id, mode);
}
/**
* create host resource via CPU model [for MSG]
*/
-static void create_host(const char* id,double power_peak,double power_sc,
- const char* power_tr,int state_init,
- const char* state_tr)
+static void create_host(const char *id, double power_peak, double power_sc,
+ const char *power_tr, int state_init,
+ const char *state_tr)
{
- double power_scale = 1.0;
- tmgr_trace_t power_trace = NULL;
- e_surf_resource_state_t state_initial;
- tmgr_trace_t state_trace;
- if(power_sc) // !=0
- power_scale = power_sc;
- if (state_init == -1)
- state_initial = SURF_RESOURCE_OFF;
- else
- state_initial = SURF_RESOURCE_ON;
- if(power_tr)
- power_trace = tmgr_trace_new(power_tr);
- else
- power_trace = tmgr_trace_new("");
- if(state_tr)
- state_trace = tmgr_trace_new(state_tr);
- else
- state_trace = tmgr_trace_new("");
- current_property_set = xbt_dict_new();
- surf_host_create_resource(xbt_strdup(id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ double power_scale = 1.0;
+ tmgr_trace_t power_trace = NULL;
+ e_surf_resource_state_t state_initial;
+ tmgr_trace_t state_trace;
+ if (power_sc) // !=0
+ power_scale = power_sc;
+ if (state_init == -1)
+ state_initial = SURF_RESOURCE_OFF;
+ else
+ state_initial = SURF_RESOURCE_ON;
+ if (power_tr)
+ power_trace = tmgr_trace_new(power_tr);
+ else
+ power_trace = tmgr_trace_new("");
+ if (state_tr)
+ state_trace = tmgr_trace_new(state_tr);
+ else
+ state_trace = tmgr_trace_new("");
+ current_property_set = xbt_dict_new();
+ surf_host_create_resource(xbt_strdup(id), power_peak, power_scale,
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
* create link resource via network model
*/
static void create_link(const char *name,
- double bw_initial,const char *trace,double lat_initial,
- const char* latency_trace,int state_init, const char* state_trace,int policy)
+ double bw_initial, const char *trace,
+ double lat_initial, const char *latency_trace,
+ int state_init, const char *state_trace,
+ int policy)
{
- tmgr_trace_t bw_trace;
- tmgr_trace_t lat_trace;
- e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
- e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
- tmgr_trace_t st_trace;
- if(trace)
- bw_trace = tmgr_trace_new(trace);
- else
- bw_trace = tmgr_trace_new("");
-
- if(latency_trace)
- lat_trace = tmgr_trace_new(latency_trace);
- else
- lat_trace = tmgr_trace_new("");
-
- if(state_trace)
- st_trace = tmgr_trace_new(state_trace);
- else
- st_trace = tmgr_trace_new("");
-
- if(state_init == -1)
- state_initial_link = SURF_RESOURCE_OFF;
- if(policy == -1)
- policy_initial_link = SURF_LINK_FATPIPE;
-
- surf_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, st_trace,
- policy_initial_link, xbt_dict_new());
+ tmgr_trace_t bw_trace;
+ tmgr_trace_t lat_trace;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
+ e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
+ tmgr_trace_t st_trace;
+ if (trace)
+ bw_trace = tmgr_trace_new(trace);
+ else
+ bw_trace = tmgr_trace_new("");
+
+ if (latency_trace)
+ lat_trace = tmgr_trace_new(latency_trace);
+ else
+ lat_trace = tmgr_trace_new("");
+
+ if (state_trace)
+ st_trace = tmgr_trace_new(state_trace);
+ else
+ st_trace = tmgr_trace_new("");
+
+ if (state_init == -1)
+ state_initial_link = SURF_RESOURCE_OFF;
+ if (policy == -1)
+ policy_initial_link = SURF_LINK_FATPIPE;
+
+ surf_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
+ lat_initial, lat_trace, state_initial_link,
+ st_trace, policy_initial_link, xbt_dict_new());
}
/*
*create host resource via workstation_ptask_L07 model [for SimDag]
*/
-static void create_host_wsL07(const char* id,double power_peak,double power_sc,
- const char* power_tr,int state_init,
- const char* state_tr)
+static void create_host_wsL07(const char *id, double power_peak,
+ double power_sc, const char *power_tr,
+ int state_init, const char *state_tr)
{
- double power_scale = 1.0;
- tmgr_trace_t power_trace = NULL;
- e_surf_resource_state_t state_initial;
- tmgr_trace_t state_trace;
- if(power_sc) // !=0
- power_scale = power_sc;
- if (state_init == -1)
- state_initial = SURF_RESOURCE_OFF;
- else
- state_initial = SURF_RESOURCE_ON;
- if(power_tr)
- power_trace = tmgr_trace_new(power_tr);
- else
- power_trace = tmgr_trace_new("");
- if(state_tr)
- state_trace = tmgr_trace_new(state_tr);
- else
- state_trace = tmgr_trace_new("");
- current_property_set = xbt_dict_new();
- surf_wsL07_host_create_resource(xbt_strdup(id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ double power_scale = 1.0;
+ tmgr_trace_t power_trace = NULL;
+ e_surf_resource_state_t state_initial;
+ tmgr_trace_t state_trace;
+ if (power_sc) // !=0
+ power_scale = power_sc;
+ if (state_init == -1)
+ state_initial = SURF_RESOURCE_OFF;
+ else
+ state_initial = SURF_RESOURCE_ON;
+ if (power_tr)
+ power_trace = tmgr_trace_new(power_tr);
+ else
+ power_trace = tmgr_trace_new("");
+ if (state_tr)
+ state_trace = tmgr_trace_new(state_tr);
+ else
+ state_trace = tmgr_trace_new("");
+ current_property_set = xbt_dict_new();
+ surf_wsL07_host_create_resource(xbt_strdup(id), power_peak, power_scale,
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
*/
static void create_link_wsL07(const char *name,
- double bw_initial,const char *trace,double lat_initial,
- const char* latency_trace,int state_init, const char* state_trace,int policy)
+ double bw_initial, const char *trace,
+ double lat_initial,
+ const char *latency_trace, int state_init,
+ const char *state_trace, int policy)
{
- tmgr_trace_t bw_trace;
- tmgr_trace_t lat_trace;
- e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
- e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
- tmgr_trace_t st_trace;
- if(trace)
- bw_trace = tmgr_trace_new(trace);
- else
- bw_trace = tmgr_trace_new("");
-
- if(latency_trace)
- lat_trace = tmgr_trace_new(latency_trace);
- else
- lat_trace = tmgr_trace_new("");
-
- if(state_trace)
- st_trace = tmgr_trace_new(state_trace);
- else
- st_trace = tmgr_trace_new("");
-
- if(state_init == -1)
- state_initial_link = SURF_RESOURCE_OFF;
- if(policy == -1)
- policy_initial_link = SURF_LINK_FATPIPE;
-
- surf_wsL07_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, st_trace,
- policy_initial_link, xbt_dict_new());
+ tmgr_trace_t bw_trace;
+ tmgr_trace_t lat_trace;
+ e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
+ e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
+ tmgr_trace_t st_trace;
+ if (trace)
+ bw_trace = tmgr_trace_new(trace);
+ else
+ bw_trace = tmgr_trace_new("");
+
+ if (latency_trace)
+ lat_trace = tmgr_trace_new(latency_trace);
+ else
+ lat_trace = tmgr_trace_new("");
+
+ if (state_trace)
+ st_trace = tmgr_trace_new(state_trace);
+ else
+ st_trace = tmgr_trace_new("");
+
+ if (state_init == -1)
+ state_initial_link = SURF_RESOURCE_OFF;
+ if (policy == -1)
+ policy_initial_link = SURF_LINK_FATPIPE;
+
+ surf_wsL07_link_create_resource(xbt_strdup(name), bw_initial, bw_trace,
+ lat_initial, lat_trace,
+ state_initial_link, st_trace,
+ policy_initial_link, xbt_dict_new());
}
* init AS
*/
-static int AS_new(lua_State *L)
+static int AS_new(lua_State * L)
{
- const char *id;
- const char *mode;
- if(lua_istable(L,1))
- {
- lua_pushstring(L,"id");
- lua_gettable(L,-2);
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- lua_pushstring(L,"mode");
- lua_gettable(L,-2);
- mode = lua_tostring(L,-1);
- lua_pop(L,1);
- }
- else {
- ERROR0("Bad Arguments to AS.new, Should be a table with named arguments");
- return -1;
- }
- AS = malloc(sizeof(AS_attr));
- AS->id = id;
- AS->mode = mode;
-
- return 0;
+ const char *id;
+ const char *mode;
+ if (lua_istable(L, 1)) {
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "mode");
+ lua_gettable(L, -2);
+ mode = lua_tostring(L, -1);
+ lua_pop(L, 1);
+ } else {
+ ERROR0
+ ("Bad Arguments to AS.new, Should be a table with named arguments");
+ return -1;
+ }
+ AS = malloc(sizeof(AS_attr));
+ AS->id = id;
+ AS->mode = mode;
+
+ return 0;
}
/*
* add new host to platform hosts list
*/
-static int Host_new(lua_State *L)
+static int Host_new(lua_State * L)
{
- if(xbt_dynar_is_empty(host_list_d))
- host_list_d = xbt_dynar_new(sizeof(p_host_attr), &xbt_free_ref);
-
- p_host_attr host;
- const char * id;
- const char *power_trace;
- const char *state_trace;
- double power,power_scale;
- int state_initial;
- //get values from the table passed as argument
- if (lua_istable(L,-1)) {
-
- // get Id Value
- lua_pushstring(L,"id");
- lua_gettable(L, -2 );
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- // get power value
- lua_pushstring(L,"power");
- lua_gettable(L, -2 );
- power = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get power_scale
- lua_pushstring(L,"power_scale");
- lua_gettable(L, -2 );
- power_scale = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get power_trace
- lua_pushstring(L,"power_trace");
- lua_gettable(L, -2 );
- power_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state initial
- lua_pushstring(L,"state_initial");
- lua_gettable(L, -2 );
- state_initial = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get trace state
- lua_pushstring(L,"state_trace");
- lua_gettable(L, -2 );
- state_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- } else {
- ERROR0("Bad Arguments to create host, Should be a table with named arguments");
- return -1;
- }
+ if (xbt_dynar_is_empty(host_list_d))
+ host_list_d = xbt_dynar_new(sizeof(p_host_attr), &xbt_free_ref);
+
+ p_host_attr host;
+ const char *id;
+ const char *power_trace;
+ const char *state_trace;
+ double power, power_scale;
+ int state_initial;
+ //get values from the table passed as argument
+ if (lua_istable(L, -1)) {
+
+ // get Id Value
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ // get power value
+ lua_pushstring(L, "power");
+ lua_gettable(L, -2);
+ power = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get power_scale
+ lua_pushstring(L, "power_scale");
+ lua_gettable(L, -2);
+ power_scale = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get power_trace
+ lua_pushstring(L, "power_trace");
+ lua_gettable(L, -2);
+ power_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state initial
+ lua_pushstring(L, "state_initial");
+ lua_gettable(L, -2);
+ state_initial = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get trace state
+ lua_pushstring(L, "state_trace");
+ lua_gettable(L, -2);
+ state_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ } else {
+ ERROR0
+ ("Bad Arguments to create host, Should be a table with named arguments");
+ return -1;
+ }
+
+ host = malloc(sizeof(host_attr));
+ host->id = id;
+ host->power_peak = power;
+ host->power_scale = power_scale;
+ host->power_trace = power_trace;
+ host->state_initial = state_initial;
+ host->state_trace = state_trace;
+ host->function = NULL;
+ xbt_dynar_push(host_list_d, &host);
- host = malloc(sizeof(host_attr));
- host->id = id;
- host->power_peak = power;
- host->power_scale = power_scale;
- host->power_trace = power_trace;
- host->state_initial = state_initial;
- host->state_trace = state_trace;
- host->function = NULL;
- xbt_dynar_push(host_list_d, &host);
-
- return 0;
+ return 0;
}
/**
* add link to platform links list
*/
-static int Link_new(lua_State *L) // (id,bandwidth,latency)
+static int Link_new(lua_State * L) // (id,bandwidth,latency)
{
- if(xbt_dynar_is_empty(link_list_d))
- link_list_d = xbt_dynar_new(sizeof(p_link_attr), &xbt_free_ref);
-
- const char* id;
- double bandwidth,latency;
- const char* bandwidth_trace;
- const char* latency_trace;
- const char* state_trace;
- int state_initial,policy;
-
- //get values from the table passed as argument
- if (lua_istable(L,-1)) {
- // get Id Value
- lua_pushstring(L,"id");
- lua_gettable(L, -2 );
- id = lua_tostring(L,-1);
- lua_pop(L,1);
-
- // get bandwidth value
- lua_pushstring(L,"bandwidth");
- lua_gettable(L, -2 );
- bandwidth = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- //get latency value
- lua_pushstring(L,"latency");
- lua_gettable(L, -2 );
- latency = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- /*Optional Arguments */
-
- //get bandwidth_trace value
- lua_pushstring(L,"bandwidth_trace");
- lua_gettable(L, -2 );
- bandwidth_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get latency_trace value
- lua_pushstring(L,"latency_trace");
- lua_gettable(L, -2 );
- latency_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state_trace value
- lua_pushstring(L,"state_trace");
- lua_gettable(L, -2 );
- state_trace = lua_tostring(L,-1);
- lua_pop(L,1);
-
- //get state_initial value
- lua_pushstring(L,"state_initial");
- lua_gettable(L, -2 );
- state_initial = lua_tonumber(L,-1);
- lua_pop(L,1);
-
-
- //get policy value
- lua_pushstring(L,"policy");
- lua_gettable(L, -2 );
- policy = lua_tonumber(L,-1);
- lua_pop(L,1);
-
- } else {
- ERROR0("Bad Arguments to create link, Should be a table with named arguments");
- return -1;
- }
-
- p_link_attr link = malloc(sizeof(link_attr));
- link->id = id;
- link->bandwidth = bandwidth;
- link->latency = latency;
- link->bandwidth_trace = bandwidth_trace;
- link->latency_trace = latency_trace;
- link->state_trace = state_trace;
- link->state_initial= state_initial;
- link->policy = policy;
- xbt_dynar_push(link_list_d,&link);
- return 0;
+ if (xbt_dynar_is_empty(link_list_d))
+ link_list_d = xbt_dynar_new(sizeof(p_link_attr), &xbt_free_ref);
+
+ const char *id;
+ double bandwidth, latency;
+ const char *bandwidth_trace;
+ const char *latency_trace;
+ const char *state_trace;
+ int state_initial, policy;
+
+ //get values from the table passed as argument
+ if (lua_istable(L, -1)) {
+ // get Id Value
+ lua_pushstring(L, "id");
+ lua_gettable(L, -2);
+ id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ // get bandwidth value
+ lua_pushstring(L, "bandwidth");
+ lua_gettable(L, -2);
+ bandwidth = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ //get latency value
+ lua_pushstring(L, "latency");
+ lua_gettable(L, -2);
+ latency = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ /*Optional Arguments */
+
+ //get bandwidth_trace value
+ lua_pushstring(L, "bandwidth_trace");
+ lua_gettable(L, -2);
+ bandwidth_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get latency_trace value
+ lua_pushstring(L, "latency_trace");
+ lua_gettable(L, -2);
+ latency_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state_trace value
+ lua_pushstring(L, "state_trace");
+ lua_gettable(L, -2);
+ state_trace = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ //get state_initial value
+ lua_pushstring(L, "state_initial");
+ lua_gettable(L, -2);
+ state_initial = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+
+ //get policy value
+ lua_pushstring(L, "policy");
+ lua_gettable(L, -2);
+ policy = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ } else {
+ ERROR0
+ ("Bad Arguments to create link, Should be a table with named arguments");
+ return -1;
+ }
+
+ p_link_attr link = malloc(sizeof(link_attr));
+ link->id = id;
+ link->bandwidth = bandwidth;
+ link->latency = latency;
+ link->bandwidth_trace = bandwidth_trace;
+ link->latency_trace = latency_trace;
+ link->state_trace = state_trace;
+ link->state_initial = state_initial;
+ link->policy = policy;
+ xbt_dynar_push(link_list_d, &link);
+ return 0;
}
/**
* add route to platform routes list
*/
-static int Route_new(lua_State *L) // (src_id,dest_id,links_number,link_table)
+static int Route_new(lua_State * L) // (src_id,dest_id,links_number,link_table)
{
- if(xbt_dynar_is_empty(route_list_d))
- route_list_d = xbt_dynar_new(sizeof(p_route_attr), &xbt_free_ref);
- const char * link_id;
- p_route_attr route = malloc(sizeof(route_attr));
- route->src_id = luaL_checkstring(L,1);
- route->dest_id = luaL_checkstring(L,2);
- route->links_id = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- lua_pushnil(L);
- while (lua_next(L,3) != 0) {
- link_id = lua_tostring(L, -1);
- xbt_dynar_push(route->links_id, &link_id);
- DEBUG2("index = %f , Link_id = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
-
- //add route to platform's route list
- xbt_dynar_push(route_list_d,&route);
- return 0;
+ if (xbt_dynar_is_empty(route_list_d))
+ route_list_d = xbt_dynar_new(sizeof(p_route_attr), &xbt_free_ref);
+ const char *link_id;
+ p_route_attr route = malloc(sizeof(route_attr));
+ route->src_id = luaL_checkstring(L, 1);
+ route->dest_id = luaL_checkstring(L, 2);
+ route->links_id = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+ lua_pushnil(L);
+ while (lua_next(L, 3) != 0) {
+ link_id = lua_tostring(L, -1);
+ xbt_dynar_push(route->links_id, &link_id);
+ DEBUG2("index = %f , Link_id = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+
+ //add route to platform's route list
+ xbt_dynar_push(route_list_d, &route);
+ return 0;
}
/**
* set function to process
*/
-static int Host_set_function(lua_State *L) //(host,function,nb_args,list_args)
+static int Host_set_function(lua_State * L) //(host,function,nb_args,list_args)
{
- // look for the index of host in host_list
- const char *host_id = luaL_checkstring(L,1);
- const char* argument;
- unsigned int i;
- p_host_attr p_host;
-
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- if(p_host->id == host_id)
- {
- p_host->function = luaL_checkstring(L,2);
- if(lua_istable(L,3))
- {
- p_host->args_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- // fill the args list
- lua_pushnil(L);
- int j = 0;
- while (lua_next(L,3) != 0) {
- argument = lua_tostring(L, -1);
- xbt_dynar_push(p_host->args_list, &argument);
- DEBUG2("index = %f , Arg_id = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- j++;
- lua_pop(L, 1);
- }
- }
- lua_pop(L, 1);
- return 0;
- }
- }
- ERROR1("Host : %s Not Found !!",host_id);
- return 1;
+ // look for the index of host in host_list
+ const char *host_id = luaL_checkstring(L, 1);
+ const char *argument;
+ unsigned int i;
+ p_host_attr p_host;
+
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ if (p_host->id == host_id) {
+ p_host->function = luaL_checkstring(L, 2);
+ if (lua_istable(L, 3)) {
+ p_host->args_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+ // fill the args list
+ lua_pushnil(L);
+ int j = 0;
+ while (lua_next(L, 3) != 0) {
+ argument = lua_tostring(L, -1);
+ xbt_dynar_push(p_host->args_list, &argument);
+ DEBUG2("index = %f , Arg_id = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ j++;
+ lua_pop(L, 1);
+ }
+ }
+ lua_pop(L, 1);
+ return 0;
+ }
+ }
+ ERROR1("Host : %s Not Found !!", host_id);
+ return 1;
}
/*
static int surf_parse_bypass_platform()
{
- unsigned int i;
- p_host_attr p_host;
- p_link_attr p_link;
- p_route_attr p_route;
-
- // Init routing mode
- create_AS(AS->id,AS->mode);
-
-
- // Add Hosts
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- create_host(p_host->id,p_host->power_peak,p_host->power_scale,p_host->power_trace,
- p_host->state_initial,p_host->state_trace);
- //add to routing model host list
- surf_route_add_host((char*)p_host->id);
-
- }
-
- //add Links
- xbt_dynar_foreach(link_list_d,i,p_link)
- {
- create_link(p_link->id,p_link->bandwidth,p_link->bandwidth_trace,p_link->latency,
- p_link->latency_trace,p_link->state_initial,p_link->state_trace,p_link->policy);
- }
- // add route
- xbt_dynar_foreach(route_list_d,i,p_route)
- {
- surf_routing_add_route((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id);
- }
- /* </platform> */
-
- // Finalize AS
- surf_AS_finalize(AS->id);
-
- // add traces
- surf_add_host_traces();
- surf_add_link_traces();
-
- return 0; // must return 0 ?!!
+ unsigned int i;
+ p_host_attr p_host;
+ p_link_attr p_link;
+ p_route_attr p_route;
+
+ // Init routing mode
+ create_AS(AS->id, AS->mode);
+
+
+ // Add Hosts
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ create_host(p_host->id, p_host->power_peak, p_host->power_scale,
+ p_host->power_trace, p_host->state_initial,
+ p_host->state_trace);
+ //add to routing model host list
+ surf_route_add_host((char *) p_host->id);
+
+ }
+
+ //add Links
+ xbt_dynar_foreach(link_list_d, i, p_link) {
+ create_link(p_link->id, p_link->bandwidth, p_link->bandwidth_trace,
+ p_link->latency, p_link->latency_trace,
+ p_link->state_initial, p_link->state_trace,
+ p_link->policy);
+ }
+ // add route
+ xbt_dynar_foreach(route_list_d, i, p_route) {
+ surf_routing_add_route((char *) p_route->src_id,
+ (char *) p_route->dest_id, p_route->links_id);
+ }
+ /* </platform> */
+
+ // Finalize AS
+ surf_AS_finalize(AS->id);
+
+ // add traces
+ surf_add_host_traces();
+ surf_add_link_traces();
+
+ return 0; // must return 0 ?!!
}
static int surf_wsL07_parse_bypass_platform()
{
- unsigned int i;
- p_host_attr p_host;
- p_link_attr p_link;
- p_route_attr p_route;
-
- // Init routing mode
- create_AS(AS->id,AS->mode);
-
- // Add Hosts
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- create_host_wsL07(p_host->id,p_host->power_peak,p_host->power_scale,p_host->power_trace,
- p_host->state_initial,p_host->state_trace);
- //add to routing model host list
- surf_route_add_host((char*)p_host->id);
- }
-
- //add Links
- xbt_dynar_foreach(link_list_d,i,p_link)
- {
- create_link_wsL07(p_link->id,p_link->bandwidth,p_link->bandwidth_trace,p_link->latency,
- p_link->latency_trace,p_link->state_initial,p_link->state_trace,p_link->policy);
- }
- // add route
- xbt_dynar_foreach(route_list_d,i,p_route)
- {
- surf_routing_add_route((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id);
- }
- /* </platform> */
-
- // Finalize AS
- surf_AS_finalize(AS->id);
- // add traces
- surf_wsL07_add_traces();
-
- return 0;
+ unsigned int i;
+ p_host_attr p_host;
+ p_link_attr p_link;
+ p_route_attr p_route;
+
+ // Init routing mode
+ create_AS(AS->id, AS->mode);
+
+ // Add Hosts
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ create_host_wsL07(p_host->id, p_host->power_peak, p_host->power_scale,
+ p_host->power_trace, p_host->state_initial,
+ p_host->state_trace);
+ //add to routing model host list
+ surf_route_add_host((char *) p_host->id);
+ }
+
+ //add Links
+ xbt_dynar_foreach(link_list_d, i, p_link) {
+ create_link_wsL07(p_link->id, p_link->bandwidth,
+ p_link->bandwidth_trace, p_link->latency,
+ p_link->latency_trace, p_link->state_initial,
+ p_link->state_trace, p_link->policy);
+ }
+ // add route
+ xbt_dynar_foreach(route_list_d, i, p_route) {
+ surf_routing_add_route((char *) p_route->src_id,
+ (char *) p_route->dest_id, p_route->links_id);
+ }
+ /* </platform> */
+
+ // Finalize AS
+ surf_AS_finalize(AS->id);
+ // add traces
+ surf_wsL07_add_traces();
+
+ return 0;
}
/*
*/
static int surf_parse_bypass_application()
{
- unsigned int i;
- p_host_attr p_host;
- xbt_dynar_foreach(host_list_d,i,p_host)
- {
- if(p_host->function)
- MSG_set_function(p_host->id,p_host->function,p_host->args_list);
- }
- return 0;
+ unsigned int i;
+ p_host_attr p_host;
+ xbt_dynar_foreach(host_list_d, i, p_host) {
+ if (p_host->function)
+ MSG_set_function(p_host->id, p_host->function, p_host->args_list);
+ }
+ return 0;
}
free(p->host);
}
-static int gras_add_process_function(lua_State *L)
+static int gras_add_process_function(lua_State * L)
{
- const char * arg;
- const char* process_host = luaL_checkstring(L,1);
- const char *process_function = luaL_checkstring(L,2);
-
- if(xbt_dict_is_empty(machine_set) || xbt_dict_is_empty(process_function_set)
- || xbt_dynar_is_empty(process_list))
- {
- process_function_set = xbt_dict_new();
- process_list = xbt_dynar_new(sizeof(s_process_t), s_process_free);
- machine_set = xbt_dict_new();
- }
-
- xbt_dict_set(machine_set,process_host, NULL, NULL);
- xbt_dict_set(process_function_set,process_function, NULL, NULL);
-
- process.argc = 1;
- process.argv = xbt_new(char *, 1);
- process.argv[0] = xbt_strdup(process_function);
- process.host = strdup(process_host);
-
- lua_pushnil(L);
- while (lua_next(L,3) != 0) {
- arg = lua_tostring(L, -1);
- process.argc++;
- process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
- process.argv[(process.argc) - 1] = xbt_strdup(arg);
-
- DEBUG2("index = %f , arg = %s \n",lua_tonumber(L, -2),lua_tostring(L, -1));
- lua_pop(L, 1);
- }
- lua_pop(L, 1);
- //add to the process list
- xbt_dynar_push(process_list, &process);
-
- return 0;
+ const char *arg;
+ const char *process_host = luaL_checkstring(L, 1);
+ const char *process_function = luaL_checkstring(L, 2);
+
+ if (xbt_dict_is_empty(machine_set)
+ || xbt_dict_is_empty(process_function_set)
+ || xbt_dynar_is_empty(process_list)) {
+ process_function_set = xbt_dict_new();
+ process_list = xbt_dynar_new(sizeof(s_process_t), s_process_free);
+ machine_set = xbt_dict_new();
+ }
+
+ xbt_dict_set(machine_set, process_host, NULL, NULL);
+ xbt_dict_set(process_function_set, process_function, NULL, NULL);
+
+ process.argc = 1;
+ process.argv = xbt_new(char *, 1);
+ process.argv[0] = xbt_strdup(process_function);
+ process.host = strdup(process_host);
+
+ lua_pushnil(L);
+ while (lua_next(L, 3) != 0) {
+ arg = lua_tostring(L, -1);
+ process.argc++;
+ process.argv =
+ xbt_realloc(process.argv, (process.argc) * sizeof(char *));
+ process.argv[(process.argc) - 1] = xbt_strdup(arg);
+
+ DEBUG2("index = %f , arg = %s \n", lua_tonumber(L, -2),
+ lua_tostring(L, -1));
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+ //add to the process list
+ xbt_dynar_push(process_list, &process);
+
+ return 0;
}
-static int gras_generate(lua_State *L)
+static int gras_generate(lua_State * L)
{
- const char *project_name = luaL_checkstring(L,1);
+ const char *project_name = luaL_checkstring(L, 1);
generate_sim(project_name);
generate_rl(project_name);
generate_makefile_local(project_name);
* Host Methods
*/
static const luaL_reg Host_methods[] = {
- {"getByName", Host_get_by_name},
- {"name", Host_get_name},
- {"number", Host_number},
- {"at", Host_at},
- // Bypass XML Methods
- {"new", Host_new},
- {"setFunction", Host_set_function},
- {0,0}
+ {"getByName", Host_get_by_name},
+ {"name", Host_get_name},
+ {"number", Host_number},
+ {"at", Host_at},
+ // Bypass XML Methods
+ {"new", Host_new},
+ {"setFunction", Host_set_function},
+ {0, 0}
};
-static int Host_gc(lua_State *L)
+static int Host_gc(lua_State * L)
{
- m_host_t ht = checkHost(L,-1);
- if (ht) ht = NULL;
+ m_host_t ht = checkHost(L, -1);
+ if (ht)
+ ht = NULL;
return 0;
}
-static int Host_tostring(lua_State *L)
+static int Host_tostring(lua_State * L)
{
- lua_pushfstring(L,"Host :%p",lua_touserdata(L,1));
+ lua_pushfstring(L, "Host :%p", lua_touserdata(L, 1));
return 1;
}
static const luaL_reg Host_meta[] = {
- {"__gc", Host_gc},
- {"__tostring", Host_tostring},
- {0,0}
+ {"__gc", Host_gc},
+ {"__tostring", Host_tostring},
+ {0, 0}
};
/*
* AS Methods
*/
static const luaL_reg AS_methods[] = {
- {"new",AS_new},
- {0,0}
+ {"new", AS_new},
+ {0, 0}
};
* Link Methods
*/
static const luaL_reg Link_methods[] = {
- {"new",Link_new},
- {0,0}
+ {"new", Link_new},
+ {0, 0}
};
+
/*
* Route Methods
*/
-static const luaL_reg Route_methods[] ={
- {"new",Route_new},
- {0,0}
+static const luaL_reg Route_methods[] = {
+ {"new", Route_new},
+ {0, 0}
};
/*
extern lua_State *simgrid_lua_state;
-static int run_lua_code(int argc,char **argv) {
- DEBUG1("Run lua code %s",argv[0]);
+static int run_lua_code(int argc, char **argv)
+{
+ DEBUG1("Run lua code %s", argv[0]);
lua_State *L = lua_newthread(simgrid_lua_state);
- int ref = luaL_ref(simgrid_lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
+ int ref = luaL_ref(simgrid_lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
int res = 1;
/* Start the co-routine */
- lua_getglobal(L,argv[0]);
- xbt_assert1(lua_isfunction(L,-1),
- "The lua function %s does not seem to exist",argv[0]);
+ lua_getglobal(L, argv[0]);
+ xbt_assert1(lua_isfunction(L, -1),
+ "The lua function %s does not seem to exist", argv[0]);
// push arguments onto the stack
int i;
- for(i=1;i<argc;i++)
- lua_pushstring(L,argv[i]);
+ for (i = 1; i < argc; i++)
+ lua_pushstring(L, argv[i]);
// Call the function (in resume)
- xbt_assert2(lua_pcall(L, argc-1, 1, 0) == 0,
- "error running function `%s': %s",argv[0], lua_tostring(L, -1));
+ xbt_assert2(lua_pcall(L, argc - 1, 1, 0) == 0,
+ "error running function `%s': %s", argv[0], lua_tostring(L,
+ -1));
/* retrieve result */
if (lua_isnumber(L, -1)) {
res = lua_tonumber(L, -1);
- lua_pop(L, 1); /* pop returned value */
+ lua_pop(L, 1); /* pop returned value */
}
// cleanups
- luaL_unref(simgrid_lua_state,LUA_REGISTRYINDEX,ref );
+ luaL_unref(simgrid_lua_state, LUA_REGISTRYINDEX, ref);
DEBUG1("Execution of lua code %s is over", (argv ? argv[0] : "(null)"));
return res;
}
-static int launch_application(lua_State *L) {
- const char * file = luaL_checkstring(L,1);
+
+static int launch_application(lua_State * L)
+{
+ const char *file = luaL_checkstring(L, 1);
MSG_function_register_default(run_lua_code);
MSG_launch_application(file);
return 0;
}
-#include "simix/simix.h" //FIXME: KILLME when debugging on simix internals become useless
-static int create_environment(lua_State *L) {
- const char *file = luaL_checkstring(L,1);
- DEBUG1("Loading environment file %s",file);
+
+#include "simix/simix.h" //FIXME: KILLME when debugging on simix internals become useless
+static int create_environment(lua_State * L)
+{
+ const char *file = luaL_checkstring(L, 1);
+ DEBUG1("Loading environment file %s", file);
MSG_create_environment(file);
smx_host_t *hosts = SIMIX_host_get_table();
int i;
- for (i=0;i<SIMIX_host_get_number();i++) {
+ for (i = 0; i < SIMIX_host_get_number(); i++) {
DEBUG1("We have an host %s", SIMIX_host_get_name(hosts[i]));
}
return 0;
}
-static int debug(lua_State *L) {
- const char *str = luaL_checkstring(L,1);
- DEBUG1("%s",str);
+static int debug(lua_State * L)
+{
+ const char *str = luaL_checkstring(L, 1);
+ DEBUG1("%s", str);
return 0;
}
-static int info(lua_State *L) {
- const char *str = luaL_checkstring(L,1);
- INFO1("%s",str);
+
+static int info(lua_State * L)
+{
+ const char *str = luaL_checkstring(L, 1);
+ INFO1("%s", str);
return 0;
}
-static int run(lua_State *L) {
+
+static int run(lua_State * L)
+{
MSG_main();
return 0;
}
-static int clean(lua_State *L) {
+
+static int clean(lua_State * L)
+{
MSG_clean();
return 0;
}
/*
* Register platform for MSG
*/
-static int msg_register_platform(lua_State *L)
+static int msg_register_platform(lua_State * L)
{
- /* Tell Simgrid we dont wanna use its parser*/
- surf_parse = surf_parse_bypass_platform;
- MSG_create_environment(NULL);
- return 0;
+ /* Tell Simgrid we dont wanna use its parser */
+ surf_parse = surf_parse_bypass_platform;
+ MSG_create_environment(NULL);
+ return 0;
}
/*
* Register platform for Simdag
*/
-static int sd_register_platform(lua_State *L)
+static int sd_register_platform(lua_State * L)
{
- surf_parse = surf_wsL07_parse_bypass_platform;
- SD_create_environment(NULL);
- return 0;
+ surf_parse = surf_wsL07_parse_bypass_platform;
+ SD_create_environment(NULL);
+ return 0;
}
+
/*
* Register platform for gras
*/
-static int gras_register_platform(lua_State *L)
+static int gras_register_platform(lua_State * L)
{
- /* Tell Simgrid we dont wanna use surf parser*/
- surf_parse = surf_parse_bypass_platform;
- gras_create_environment(NULL);
- return 0;
+ /* Tell Simgrid we dont wanna use surf parser */
+ surf_parse = surf_parse_bypass_platform;
+ gras_create_environment(NULL);
+ return 0;
}
/**
* Register applicaiton for MSG
*/
-static int msg_register_application(lua_State *L)
+static int msg_register_application(lua_State * L)
{
- MSG_function_register_default(run_lua_code);
- surf_parse = surf_parse_bypass_application;
- MSG_launch_application(NULL);
- return 0;
+ MSG_function_register_default(run_lua_code);
+ surf_parse = surf_parse_bypass_application;
+ MSG_launch_application(NULL);
+ return 0;
}
/*
* Register application for gras
*/
-static int gras_register_application(lua_State *L)
+static int gras_register_application(lua_State * L)
{
- gras_function_register_default(run_lua_code);
- surf_parse = surf_parse_bypass_application;
- gras_launch_application(NULL);
- return 0;
+ gras_function_register_default(run_lua_code);
+ surf_parse = surf_parse_bypass_application;
+ gras_launch_application(NULL);
+ return 0;
}
+
static const luaL_Reg simgrid_funcs[] = {
- { "create_environment", create_environment},
- { "launch_application", launch_application},
- { "debug", debug},
- { "info", info},
- { "run", run},
- { "clean", clean},
- /* short names */
- { "platform", create_environment},
- { "application", launch_application},
- /* methods to bypass XML parser*/
- { "msg_register_platform",msg_register_platform},
- { "sd_register_platform",sd_register_platform},
- { "msg_register_application",msg_register_application},
- { "gras_register_platform",gras_register_platform},
- { "gras_register_application",gras_register_application},
- /* gras sub generator method*/
- {"gras_set_process_function",gras_add_process_function},
- {"gras_generate",gras_generate},
- { NULL, NULL }
+ {"create_environment", create_environment},
+ {"launch_application", launch_application},
+ {"debug", debug},
+ {"info", info},
+ {"run", run},
+ {"clean", clean},
+ /* short names */
+ {"platform", create_environment},
+ {"application", launch_application},
+ /* methods to bypass XML parser */
+ {"msg_register_platform", msg_register_platform},
+ {"sd_register_platform", sd_register_platform},
+ {"msg_register_application", msg_register_application},
+ {"gras_register_platform", gras_register_platform},
+ {"gras_register_application", gras_register_application},
+ /* gras sub generator method */
+ {"gras_set_process_function", gras_add_process_function},
+ {"gras_generate", gras_generate},
+ {NULL, NULL}
};
/* ********************************************************************************* */
/* module management functions */
/* ********************************************************************************* */
-extern const char*xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
+extern const char *xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
-#define LUA_MAX_ARGS_COUNT 10 /* maximum amount of arguments we can get from lua on command line */
+#define LUA_MAX_ARGS_COUNT 10 /* maximum amount of arguments we can get from lua on command line */
#define TEST
-int luaopen_simgrid(lua_State* L); // Fuck gcc: we don't need that prototype
-int luaopen_simgrid(lua_State* L) {
+int luaopen_simgrid(lua_State * L); // Fuck gcc: we don't need that prototype
+int luaopen_simgrid(lua_State * L)
+{
//xbt_ctx_factory_to_use = "lua";
- char **argv=malloc(sizeof(char*)*LUA_MAX_ARGS_COUNT);
- int argc=1;
- argv[0] = (char*)"/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
+ char **argv = malloc(sizeof(char *) * LUA_MAX_ARGS_COUNT);
+ int argc = 1;
+ argv[0] = (char *) "/usr/bin/lua"; /* Lie on the argv[0] so that the stack dumping facilities find the right binary. FIXME: what if lua is not in that location? */
/* Get the command line arguments from the lua interpreter */
- lua_getglobal(L,"arg");
+ lua_getglobal(L, "arg");
/* if arg is a null value, it means we use lua only as a script to init platform
* else it should be a table and then take arg in consideration
*/
- if(lua_istable(L,-1))
- {
- int done=0;
- while (!done) {
- argc++;
- lua_pushinteger(L,argc-2);
- lua_gettable(L,-2);
- if (lua_isnil(L,-1)) {
- done = 1;
- } else {
- xbt_assert1(lua_isstring(L,-1),"argv[%d] got from lua is no string",argc-1);
- xbt_assert2(argc<LUA_MAX_ARGS_COUNT,
- "Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
- __FILE__,LUA_MAX_ARGS_COUNT-1);
- argv[argc-1] = (char*)luaL_checkstring(L,-1);
- lua_pop(L,1);
- DEBUG1("Got command line argument %s from lua",argv[argc-1]);
- }
- }
- argv[argc--]=NULL;
-
- /* Initialize the MSG core */
- MSG_global_init(&argc,argv);
- DEBUG1("Still %d arguments on command line",argc); // FIXME: update the lua's arg table to reflect the changes from SimGrid
- }
+ if (lua_istable(L, -1)) {
+ int done = 0;
+ while (!done) {
+ argc++;
+ lua_pushinteger(L, argc - 2);
+ lua_gettable(L, -2);
+ if (lua_isnil(L, -1)) {
+ done = 1;
+ } else {
+ xbt_assert1(lua_isstring(L, -1),
+ "argv[%d] got from lua is no string", argc - 1);
+ xbt_assert2(argc < LUA_MAX_ARGS_COUNT,
+ "Too many arguments, please increase LUA_MAX_ARGS_COUNT in %s before recompiling SimGrid if you insist on having more than %d args on command line",
+ __FILE__, LUA_MAX_ARGS_COUNT - 1);
+ argv[argc - 1] = (char *) luaL_checkstring(L, -1);
+ lua_pop(L, 1);
+ DEBUG1("Got command line argument %s from lua", argv[argc - 1]);
+ }
+ }
+ argv[argc--] = NULL;
+
+ /* Initialize the MSG core */
+ MSG_global_init(&argc, argv);
+ DEBUG1("Still %d arguments on command line", argc); // FIXME: update the lua's arg table to reflect the changes from SimGrid
+ }
/* register the core C functions to lua */
luaL_register(L, "simgrid", simgrid_funcs);
/* register the task methods to lua */
- luaL_openlib(L,TASK_MODULE_NAME,Task_methods,0); //create methods table,add it to the globals
- luaL_newmetatable(L,TASK_MODULE_NAME); //create metatable for Task,add it to the Lua registry
- luaL_openlib(L,0,Task_meta,0);// fill metatable
- lua_pushliteral(L,"__index");
- lua_pushvalue(L,-3); //dup methods table
- lua_rawset(L,-3); //matatable.__index = methods
- lua_pushliteral(L,"__metatable");
- lua_pushvalue(L,-3); //dup methods table
- lua_rawset(L,-3); //hide metatable:metatable.__metatable = methods
- lua_pop(L,1); //drop metatable
-
- /* register the hosts methods to lua*/
- luaL_openlib(L,HOST_MODULE_NAME,Host_methods,0);
- luaL_newmetatable(L,HOST_MODULE_NAME);
- luaL_openlib(L,0,Host_meta,0);
- lua_pushliteral(L,"__index");
- lua_pushvalue(L,-3);
- lua_rawset(L,-3);
- lua_pushliteral(L,"__metatable");
- lua_pushvalue(L,-3);
- lua_rawset(L,-3);
- lua_pop(L,1);
-
- /* register the links methods to lua*/
- luaL_openlib(L,AS_MODULE_NAME,AS_methods,0);
- luaL_newmetatable(L,AS_MODULE_NAME);
- lua_pop(L,1);
-
- /* register the links methods to lua*/
- luaL_openlib(L,LINK_MODULE_NAME,Link_methods,0);
- luaL_newmetatable(L,LINK_MODULE_NAME);
- lua_pop(L,1);
-
- /*register the routes methods to lua*/
- luaL_openlib(L,ROUTE_MODULE_NAME,Route_methods,0);
- luaL_newmetatable(L,LINK_MODULE_NAME);
- lua_pop(L,1);
+ luaL_openlib(L, TASK_MODULE_NAME, Task_methods, 0); //create methods table,add it to the globals
+ luaL_newmetatable(L, TASK_MODULE_NAME); //create metatable for Task,add it to the Lua registry
+ luaL_openlib(L, 0, Task_meta, 0); // fill metatable
+ lua_pushliteral(L, "__index");
+ lua_pushvalue(L, -3); //dup methods table
+ lua_rawset(L, -3); //matatable.__index = methods
+ lua_pushliteral(L, "__metatable");
+ lua_pushvalue(L, -3); //dup methods table
+ lua_rawset(L, -3); //hide metatable:metatable.__metatable = methods
+ lua_pop(L, 1); //drop metatable
+
+ /* register the hosts methods to lua */
+ luaL_openlib(L, HOST_MODULE_NAME, Host_methods, 0);
+ luaL_newmetatable(L, HOST_MODULE_NAME);
+ luaL_openlib(L, 0, Host_meta, 0);
+ lua_pushliteral(L, "__index");
+ lua_pushvalue(L, -3);
+ lua_rawset(L, -3);
+ lua_pushliteral(L, "__metatable");
+ lua_pushvalue(L, -3);
+ lua_rawset(L, -3);
+ lua_pop(L, 1);
+
+ /* register the links methods to lua */
+ luaL_openlib(L, AS_MODULE_NAME, AS_methods, 0);
+ luaL_newmetatable(L, AS_MODULE_NAME);
+ lua_pop(L, 1);
+
+ /* register the links methods to lua */
+ luaL_openlib(L, LINK_MODULE_NAME, Link_methods, 0);
+ luaL_newmetatable(L, LINK_MODULE_NAME);
+ lua_pop(L, 1);
+
+ /*register the routes methods to lua */
+ luaL_openlib(L, ROUTE_MODULE_NAME, Route_methods, 0);
+ luaL_newmetatable(L, LINK_MODULE_NAME);
+ lua_pop(L, 1);
/* Keep the context mechanism informed of our lua world today */
simgrid_lua_state = L;
#include "bindings/ruby_bindings.h"
#include "surf/surfxml_parse.h"
-#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */
+#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
// Used to instanciate the Process
-static VALUE args;
-static VALUE prop;
-static VALUE function_name;
-static VALUE host_name;
-
-static VALUE rb_process_instance(VALUE fct_name,VALUE arguments,VALUE properties) {
+static VALUE args;
+static VALUE prop;
+static VALUE function_name;
+static VALUE host_name;
+
+static VALUE rb_process_instance(VALUE fct_name, VALUE arguments,
+ VALUE properties)
+{
ruby_init();
ruby_init_loadpath();
- char * p_className = RSTRING(fct_name)->ptr; // name of process is the one of the class
- return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),rb_intern("new"),3,fct_name,arguments,properties);
+ char *p_className = RSTRING(fct_name)->ptr; // name of process is the one of the class
+ return rb_funcall(rb_const_get(rb_cObject, rb_intern(p_className)),
+ rb_intern("new"), 3, fct_name, arguments, properties);
}
// FIXME: don't mess with MSG internals here, use MSG_process_create_with_arguments()
static void rb_process_create_with_args(VALUE fct_name, VALUE arguments,
- VALUE properties, VALUE ht_name) {
-
- VALUE ruby_process = rb_process_instance(fct_name,arguments,properties);
- m_process_t process; // Native Process to Create
- const char * name ; // Name of C Native Processs
+ VALUE properties, VALUE ht_name)
+{
+
+ VALUE ruby_process =
+ rb_process_instance(fct_name, arguments, properties);
+ m_process_t process; // Native Process to Create
+ const char *name; // Name of C Native Processs
- if(!fct_name)
- rb_raise(rb_eRuntimeError,"Internal error: Process name cannot be NULL");
+ if (!fct_name)
+ rb_raise(rb_eRuntimeError,
+ "Internal error: Process name cannot be NULL");
name = RSTRING(fct_name)->ptr;
- DEBUG1("Create native process %s",name);
+ DEBUG1("Create native process %s", name);
// Allocate the data for the simulation
- process = xbt_new0(s_m_process_t,1);
- process->simdata = xbt_new0(s_simdata_process_t,1);
+ process = xbt_new0(s_m_process_t, 1);
+ process->simdata = xbt_new0(s_simdata_process_t, 1);
// Bind The Ruby Process instance to The Native Process
- rb_process_bind(ruby_process,process);
+ rb_process_bind(ruby_process, process);
process->name = xbt_strdup(name);
// Host
m_host_t host = MSG_get_host_by_name(RSTRING(ht_name)->ptr);
process->simdata->m_host = host;
-
- if(!(process->simdata->m_host)) { // Not Binded
+
+ if (!(process->simdata->m_host)) { // Not Binded
free(process->simdata);
free(process->data);
free(process);
- rb_raise(rb_eRuntimeError,"Host not bound while creating native process");
+ rb_raise(rb_eRuntimeError,
+ "Host not bound while creating native process");
}
- process->simdata->PID = msg_global->PID++;
+ process->simdata->PID = msg_global->PID++;
- DEBUG7("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
- process->name , process->simdata->m_host->name,process->simdata->PID,
- process,process->simdata, process->simdata->m_host,
- process->simdata->m_host->simdata);
+ DEBUG7
+ ("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
+ process->name, process->simdata->m_host->name,
+ process->simdata->PID, process, process->simdata,
+ process->simdata->m_host, process->simdata->m_host->simdata);
/* FIXME: that's mainly for debugging. We could only allocate this if XBT_LOG_ISENABLED(ruby,debug) is true since I guess this leaks */
- char **argv=xbt_new(char*,2);
- argv[0] = bprintf("%s@%s",process->name,process->simdata->m_host->simdata->smx_host->name);
+ char **argv = xbt_new(char *, 2);
+ argv[0] =
+ bprintf("%s@%s", process->name,
+ process->simdata->m_host->simdata->smx_host->name);
argv[1] = NULL;
process->simdata->s_process =
SIMIX_process_create(process->name,
- (xbt_main_func_t)ruby_process,
- (void *) process,
- process->simdata->m_host->simdata->smx_host->name,
- 1,argv,NULL);
+ (xbt_main_func_t) ruby_process,
+ (void *) process,
+ process->simdata->m_host->simdata->
+ smx_host->name, 1, argv, NULL);
- DEBUG1("context created (s_process=%p)",process->simdata->s_process);
+ DEBUG1("context created (s_process=%p)", process->simdata->s_process);
- if (SIMIX_process_self()) { // SomeOne Created Me !!
- process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
+ if (SIMIX_process_self()) { // SomeOne Created Me !!
+ process->simdata->PPID =
+ MSG_process_get_PID(SIMIX_process_self()->data);
} else {
process->simdata->PPID = -1;
}
process->simdata->last_errno = MSG_OK;
// let's Add the Process to the list of the Simulation's Processes
- xbt_fifo_unshift(msg_global->process_list,process);
+ xbt_fifo_unshift(msg_global->process_list, process);
}
-void rb_application_handler_on_start_document(void) {
-
+void rb_application_handler_on_start_document(void)
+{
+
- args = rb_ary_new(); // Max length = 16 !!
- prop = rb_ary_new();
+ args = rb_ary_new(); // Max length = 16 !!
+ prop = rb_ary_new();
}
-void rb_application_handler_on_end_document(void) {
+void rb_application_handler_on_end_document(void)
+{
args = Qnil;
prop = Qnil;
function_name = Qnil;
- host_name = Qnil;
+ host_name = Qnil;
}
-void rb_application_handler_on_begin_process(void) {
-
+void rb_application_handler_on_begin_process(void)
+{
+
host_name = rb_str_new2(A_surfxml_process_host);
function_name = rb_str_new2(A_surfxml_process_function);
- args = rb_ary_new(); // Max length = 16 ?!
+ args = rb_ary_new(); // Max length = 16 ?!
prop = rb_ary_new();
}
-void rb_application_handler_on_process_arg(void) {
-
+void rb_application_handler_on_process_arg(void)
+{
+
VALUE arg = rb_str_new2(A_surfxml_argument_value);
- rb_ary_push(args,arg);
+ rb_ary_push(args, arg);
}
-void rb_application_handler_on_property(void) {
+void rb_application_handler_on_property(void)
+{
VALUE id = rb_str_new2(A_surfxml_prop_id);
- VALUE val = rb_str_new2(A_surfxml_prop_value);
- int i_id = NUM2INT (id);
- rb_ary_store(prop,i_id,val);
+ VALUE val = rb_str_new2(A_surfxml_prop_value);
+ int i_id = NUM2INT(id);
+ rb_ary_store(prop, i_id, val);
}
-void rb_application_handler_on_end_process(void) {
+void rb_application_handler_on_end_process(void)
+{
+
+ rb_process_create_with_args(function_name, args, prop, host_name);
- rb_process_create_with_args(function_name,args,prop,host_name);
-
}
#include "bindings/ruby_bindings.h"
// Free Method
-void rb_host_free(m_host_t ht) {
+void rb_host_free(m_host_t ht)
+{
//Nothing to do !!?
}
// New Method : return a Host
-VALUE rb_host_get_by_name(VALUE class, VALUE name) {
+VALUE rb_host_get_by_name(VALUE class, VALUE name)
+{
- const char * h_name = RSTRING(name)->ptr;
+ const char *h_name = RSTRING(name)->ptr;
m_host_t host = MSG_get_host_by_name(h_name);
- if(!host)
- rb_raise(rb_eRuntimeError,bprintf("No host called '%s' found",h_name));
+ if (!host)
+ rb_raise(rb_eRuntimeError,
+ bprintf("No host called '%s' found", h_name));
- return Data_Wrap_Struct(class,0,rb_host_free,host);
+ return Data_Wrap_Struct(class, 0, rb_host_free, host);
}
//Get Name
-VALUE rb_host_name(VALUE class,VALUE host) {
+VALUE rb_host_name(VALUE class, VALUE host)
+{
// Wrap Ruby Value to m_host_t struct
m_host_t ht;
}
// Get Number
-VALUE rb_host_number(VALUE class) {
+VALUE rb_host_number(VALUE class)
+{
return INT2NUM(MSG_get_host_number());
}
// Host Speed ( Double )
-VALUE rb_host_speed(VALUE class,VALUE host) {
- m_host_t ht ;
- Data_Get_Struct(host,s_m_host_t,ht);
+VALUE rb_host_speed(VALUE class, VALUE host)
+{
+ m_host_t ht;
+ Data_Get_Struct(host, s_m_host_t, ht);
return MSG_get_host_speed(ht);
}
// Host is Avail
-VALUE rb_host_is_avail(VALUE class,VALUE host) {
+VALUE rb_host_is_avail(VALUE class, VALUE host)
+{
m_host_t ht;
- Data_Get_Struct(host,s_m_host_t,ht);
+ Data_Get_Struct(host, s_m_host_t, ht);
if (!ht) {
- rb_raise(rb_eRuntimeError,"Host not Bound");
+ rb_raise(rb_eRuntimeError, "Host not Bound");
return Qnil;
}
- if(MSG_host_is_avail(ht))
+ if (MSG_host_is_avail(ht))
return Qtrue;
return Qfalse;
}
// getHost from process
-VALUE rb_host_process(VALUE class,VALUE ruby_process)
+VALUE rb_host_process(VALUE class, VALUE ruby_process)
{
-
- m_process_t process = rb_process_to_native(ruby_process);
+
+ m_process_t process = rb_process_to_native(ruby_process);
m_host_t host;
-
+
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
- return Qnil; // NULL
+ rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host");
+ return Qnil; // NULL
}
-
+
host = MSG_process_get_host(process);
-
- return Data_Wrap_Struct(class, 0, rb_host_free, host);
+
+ return Data_Wrap_Struct(class, 0, rb_host_free, host);
}
// get all hosts
VALUE rb_host_get_all_hosts(VALUE class)
{
- int nb,index;
- m_host_t *hosts;
- VALUE rb_hosts;
- nb = MSG_get_host_number();
- hosts = MSG_get_host_table();
- rb_hosts = rb_ary_new2(nb);
-
- for(index=0 ; index<nb; index++)
- rb_ary_push(rb_hosts,Data_Wrap_Struct(class, 0, rb_host_free, hosts[index]));
-
- return rb_hosts;
+ int nb, index;
+ m_host_t *hosts;
+ VALUE rb_hosts;
+ nb = MSG_get_host_number();
+ hosts = MSG_get_host_table();
+ rb_hosts = rb_ary_new2(nb);
+
+ for (index = 0; index < nb; index++)
+ rb_ary_push(rb_hosts,
+ Data_Wrap_Struct(class, 0, rb_host_free, hosts[index]));
+
+ return rb_hosts;
}
-
/* 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. */
-#include "msg/private.h" /* s_simdata_process_t */
+#include "msg/private.h" /* s_simdata_process_t */
#include "bindings/ruby_bindings.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby,bindings,"Ruby Bindings");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ruby, bindings, "Ruby Bindings");
/*
* Functions for Ruby Process Management (Up Calls)
*/
// get Ruby Process Name
-VALUE rb_process_getName(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getName"),0);
+VALUE rb_process_getName(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getName"), 0);
}
// Get Process ID
-VALUE rb_process_getID(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getID"),0);
+VALUE rb_process_getID(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getID"), 0);
}
// Get Bind
-VALUE rb_process_getBind(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("getBind"),0);
+VALUE rb_process_getBind(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("getBind"), 0);
}
// Set Bind
-void rb_process_setBind(VALUE ruby_process,long bind) {
+void rb_process_setBind(VALUE ruby_process, long bind)
+{
VALUE r_bind = LONG2FIX(bind);
- rb_funcall(ruby_process,rb_intern("setBind"),1,r_bind);
+ rb_funcall(ruby_process, rb_intern("setBind"), 1, r_bind);
}
// isAlive
-VALUE rb_process_isAlive(VALUE ruby_process) {
- return rb_funcall(ruby_process,rb_intern("alive?"),0);
+VALUE rb_process_isAlive(VALUE ruby_process)
+{
+ return rb_funcall(ruby_process, rb_intern("alive?"), 0);
}
// Kill Process
-void rb_process_kill_up(VALUE ruby_process) {
- rb_funcall(ruby_process,rb_intern("kill"),0);
+void rb_process_kill_up(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("kill"), 0);
}
// join Process
-void rb_process_join( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("join"),0);
+void rb_process_join(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("join"), 0);
}
// FIXME: all this calls must be manually inlined I guess
// unschedule Process
-void rb_process_unschedule( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("unschedule"),0);
+void rb_process_unschedule(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("unschedule"), 0);
}
// schedule Process
-void rb_process_schedule( VALUE ruby_process ) {
- rb_funcall(ruby_process,rb_intern("schedule"),0);
+void rb_process_schedule(VALUE ruby_process)
+{
+ rb_funcall(ruby_process, rb_intern("schedule"), 0);
}
/***************************************************
****************************************************/
// Process To Native
-m_process_t rb_process_to_native(VALUE ruby_process) {
+m_process_t rb_process_to_native(VALUE ruby_process)
+{
VALUE id = rb_process_getBind(ruby_process);
if (!id) {
- rb_raise(rb_eRuntimeError,"Process Not Bound >>> id_Bind Null");
+ rb_raise(rb_eRuntimeError, "Process Not Bound >>> id_Bind Null");
return NULL;
}
- long l_id= FIX2LONG(id);
- return (m_process_t)l_id;
+ long l_id = FIX2LONG(id);
+ return (m_process_t) l_id;
}
// Bind Process
-void rb_process_bind(VALUE ruby_process,m_process_t process) {
- long bind = (long)(process);
- rb_process_setBind(ruby_process,bind);
+void rb_process_bind(VALUE ruby_process, m_process_t process)
+{
+ long bind = (long) (process);
+ rb_process_setBind(ruby_process, bind);
}
// Process Management
-void rb_process_suspend(VALUE class,VALUE ruby_process) {
+void rb_process_suspend(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while suspending process");
- return;
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while suspending process");
+ return;
}
-
// Trying to suspend The Process
- if ( MSG_OK != MSG_process_suspend(process))
- rb_raise(rb_eRuntimeError,"MSG_process_suspend() failed");
+ if (MSG_OK != MSG_process_suspend(process))
+ rb_raise(rb_eRuntimeError, "MSG_process_suspend() failed");
}
-void rb_process_resume(VALUE class,VALUE ruby_process) {
+void rb_process_resume(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise(rb_eRuntimeError,"Process not Bound...while resuming process");
- return ;
+ rb_raise(rb_eRuntimeError,
+ "Process not Bound...while resuming process");
+ return;
}
-
// Trying to resume the process
- if ( MSG_OK != MSG_process_resume(process))
- rb_raise(rb_eRuntimeError,"MSG_process_resume() failed");
+ if (MSG_OK != MSG_process_resume(process))
+ rb_raise(rb_eRuntimeError, "MSG_process_resume() failed");
}
-VALUE rb_process_isSuspended(VALUE class,VALUE ruby_process) {
+VALUE rb_process_isSuspended(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
if (!process) {
- rb_raise (rb_eRuntimeError,"Process not Bound...while testing if suspended");
+ rb_raise(rb_eRuntimeError,
+ "Process not Bound...while testing if suspended");
return Qfalse;
}
- if(MSG_process_is_suspended(process))
+ if (MSG_process_is_suspended(process))
return Qtrue;
return Qfalse;
}
-void rb_process_kill_down(VALUE class,VALUE ruby_process) {
+void rb_process_kill_down(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
- if(!process) {
- rb_raise (rb_eRuntimeError,"Process Not Bound...while killing process");
+ if (!process) {
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while killing process");
return;
}
// Delete The Global Reference / Ruby Process
MSG_process_kill(process);
}
-VALUE rb_process_getHost(VALUE class,VALUE ruby_process) {
+VALUE rb_process_getHost(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
m_host_t host;
-
+
if (!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
- return Qnil; // NULL
+ rb_raise(rb_eRuntimeError, "Process Not Bound...while getting Host");
+ return Qnil; // NULL
}
-
+
host = MSG_process_get_host(process);
-
+
return Data_Wrap_Struct(class, 0, rb_host_free, host);
/*if(host->data) printf("Ok\n");
-
- if(!host->data) {
- rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed");
- return Qnil;
- }
- printf("Houuuuuuuuuuuuuuna3!!\n");
- return Data_Wrap_Struct(class, 0, rb_host_free, host);*/
+
+ if(!host->data) {
+ rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed");
+ return Qnil;
+ }
+ printf("Houuuuuuuuuuuuuuna3!!\n");
+ return Data_Wrap_Struct(class, 0, rb_host_free, host); */
}
-void rb_process_exit(VALUE class,VALUE ruby_process) {
+void rb_process_exit(VALUE class, VALUE ruby_process)
+{
m_process_t process = rb_process_to_native(ruby_process);
- if(!process) {
- rb_raise(rb_eRuntimeError,"Process Not Bound...while exiting process");
+ if (!process) {
+ rb_raise(rb_eRuntimeError,
+ "Process Not Bound...while exiting process");
return;
}
SIMIX_context_stop(SIMIX_process_self()->context);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
// Free Method
-void rb_task_free(m_task_t tk) {
+void rb_task_free(m_task_t tk)
+{
//MSG_task_destroy(tk); ( This cause a bug !! is it really necessary ?!! not really sure !! )
}
// New Method
-VALUE rb_task_new(VALUE class, VALUE name,VALUE comp_size,VALUE comm_size) {
- m_task_t task = MSG_task_create(RSTRING(name)->ptr,NUM2INT(comp_size),NUM2INT(comm_size),NULL);
+VALUE rb_task_new(VALUE class, VALUE name, VALUE comp_size,
+ VALUE comm_size)
+{
+ m_task_t task = MSG_task_create(RSTRING(name)->ptr, NUM2INT(comp_size),
+ NUM2INT(comm_size), NULL);
rb_data_t data = malloc(sizeof(s_ruby_data_t));
data->ruby_task = NULL;
data->user_data = NULL;
- MSG_task_set_data(task,(void*)data);
+ MSG_task_set_data(task, (void *) data);
// Wrap m_task_t to a Ruby Value
return Data_Wrap_Struct(class, 0, rb_task_free, task);
}
//Get Computation Size
-VALUE rb_task_comp(VALUE class,VALUE task) {
+VALUE rb_task_comp(VALUE class, VALUE task)
+{
double size;
m_task_t tk;
// Wrap Ruby Value to m_task_t struct
}
//Get Name
-VALUE rb_task_name(VALUE class,VALUE task) {
+VALUE rb_task_name(VALUE class, VALUE task)
+{
// Wrap Ruby Value to m_task_t struct
- m_task_t tk;
+ m_task_t tk;
Data_Get_Struct(task, s_m_task_t, tk);
return rb_str_new2(MSG_task_get_name(tk));
}
// Execute Task
-VALUE rb_task_execute(VALUE class,VALUE task) {
+VALUE rb_task_execute(VALUE class, VALUE task)
+{
// Wrap Ruby Value to m_task_t struct
m_task_t tk;
}
// Sending Task
-void rb_task_send(VALUE class,VALUE task,VALUE mailbox) {
+void rb_task_send(VALUE class, VALUE task, VALUE mailbox)
+{
MSG_error_t rv;
rb_data_t data;
m_task_t tk;
Data_Get_Struct(task, s_m_task_t, tk);
data = MSG_task_get_data(tk);
- data->ruby_task =(void*)task;
- MSG_task_set_data(tk,(void*)data);
- DEBUG1("Sending task %p",tk);
- rv = MSG_task_send(tk,RSTRING(mailbox)->ptr);
- if(rv != MSG_OK)
- {
- if (rv == MSG_TRANSFER_FAILURE )
- rb_raise(rb_eRuntimeError,"Transfer failure while Sending");
- else if ( rv == MSG_HOST_FAILURE )
- rb_raise(rb_eRuntimeError,"Host failure while Sending");
- else if ( rv == MSG_TIMEOUT )
- rb_raise(rb_eRuntimeError,"Timeout failure while Sending");
- else
- rb_raise(rb_eRuntimeError,"MSG_task_send failed");
+ data->ruby_task = (void *) task;
+ MSG_task_set_data(tk, (void *) data);
+ DEBUG1("Sending task %p", tk);
+ rv = MSG_task_send(tk, RSTRING(mailbox)->ptr);
+ if (rv != MSG_OK) {
+ if (rv == MSG_TRANSFER_FAILURE)
+ rb_raise(rb_eRuntimeError, "Transfer failure while Sending");
+ else if (rv == MSG_HOST_FAILURE)
+ rb_raise(rb_eRuntimeError, "Host failure while Sending");
+ else if (rv == MSG_TIMEOUT)
+ rb_raise(rb_eRuntimeError, "Timeout failure while Sending");
+ else
+ rb_raise(rb_eRuntimeError, "MSG_task_send failed");
}
}
// Receiving Task (returns a Task)
-VALUE rb_task_receive(VALUE class, VALUE mailbox) {
+VALUE rb_task_receive(VALUE class, VALUE mailbox)
+{
// We must put the location where we copy the task
// pointer to on the heap, because the stack may move
// during the context switches (damn ruby internals)
m_task_t *ptask = malloc(sizeof(m_task_t));
m_task_t task;
*ptask = NULL;
- rb_data_t data =NULL;
- DEBUG2("Receiving a task on mailbox '%s', store it into %p",RSTRING(mailbox)->ptr,&task);
- MSG_task_receive(ptask,RSTRING(mailbox)->ptr);
+ rb_data_t data = NULL;
+ DEBUG2("Receiving a task on mailbox '%s', store it into %p",
+ RSTRING(mailbox)->ptr, &task);
+ MSG_task_receive(ptask, RSTRING(mailbox)->ptr);
task = *ptask;
free(ptask);
data = MSG_task_get_data(task);
- if(data==NULL) printf("Empty task while receving");
- return (VALUE)data->ruby_task;
+ if (data == NULL)
+ printf("Empty task while receving");
+ return (VALUE) data->ruby_task;
}
// It Return a Native Process ( m_process_t )
-VALUE rb_task_sender(VALUE class,VALUE task) {
+VALUE rb_task_sender(VALUE class, VALUE task)
+{
m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
THROW_UNIMPLEMENTED;
- return 0;//MSG_task_get_sender(tk);
+ return 0; //MSG_task_get_sender(tk);
}
// it return a Host
-VALUE rb_task_source(VALUE class,VALUE task) {
+VALUE rb_task_source(VALUE class, VALUE task)
+{
m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
m_host_t host = MSG_task_get_source(tk);
- if(!host->data) {
- rb_raise(rb_eRuntimeError,"MSG_task_get_source() failed");
+ if (!host->data) {
+ rb_raise(rb_eRuntimeError, "MSG_task_get_source() failed");
return Qnil;
}
THROW_UNIMPLEMENTED;
- return 0;//host;
+ return 0; //host;
}
// Return Boolean
-VALUE rb_task_listen(VALUE class,VALUE task,VALUE alias) {
+VALUE rb_task_listen(VALUE class, VALUE task, VALUE alias)
+{
m_task_t tk;
const char *p_alias;
int rv;
- Data_Get_Struct(task,s_m_task_t,tk);
+ Data_Get_Struct(task, s_m_task_t, tk);
p_alias = RSTRING(alias)->ptr;
rv = MSG_task_listen(p_alias);
- if(rv) return Qtrue;
+ if (rv)
+ return Qtrue;
return Qfalse;
}
// return Boolean
-VALUE rb_task_listen_host(VALUE class,VALUE task,VALUE alias,VALUE host) {
+VALUE rb_task_listen_host(VALUE class, VALUE task, VALUE alias, VALUE host)
+{
m_task_t tk;
m_host_t ht;
const char *p_alias;
int rv;
- Data_Get_Struct(task,s_m_task_t,tk);
- Data_Get_Struct(host,s_m_host_t,ht);
+ Data_Get_Struct(task, s_m_task_t, tk);
+ Data_Get_Struct(host, s_m_host_t, ht);
p_alias = RSTRING(alias)->ptr;
- rv = MSG_task_listen_from_host(p_alias,ht);
+ rv = MSG_task_listen_from_host(p_alias, ht);
if (rv)
return Qtrue;
return Qfalse;
// Set Priority
-void rb_task_set_priority(VALUE class,VALUE task,VALUE priority)
+void rb_task_set_priority(VALUE class, VALUE task, VALUE priority)
{
-
+
m_task_t tk;
double prt = NUM2DBL(priority);
- Data_Get_Struct(task,s_m_task_t,tk);
- MSG_task_set_priority(tk,prt);
-
+ Data_Get_Struct(task, s_m_task_t, tk);
+ MSG_task_set_priority(tk, prt);
+
}
// Cancel
-void rb_task_cancel(VALUE class,VALUE task)
+void rb_task_cancel(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- MSG_task_cancel(tk);
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ MSG_task_cancel(tk);
}
-void rb_task_set_data(VALUE class,VALUE task,VALUE data)
+void rb_task_set_data(VALUE class, VALUE task, VALUE data)
{
- m_task_t tk;
- rb_data_t rb_data;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data = MSG_task_get_data(tk);
- rb_data->user_data = (void*)data;
- MSG_task_set_data(tk,(void*)rb_data);
+ m_task_t tk;
+ rb_data_t rb_data;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data = MSG_task_get_data(tk);
+ rb_data->user_data = (void *) data;
+ MSG_task_set_data(tk, (void *) rb_data);
}
-VALUE rb_task_get_data(VALUE class,VALUE task)
+VALUE rb_task_get_data(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data_t rb_data = MSG_task_get_data(tk);
- if(!rb_data->user_data)
- ERROR1("the task %s contain no user data",MSG_task_get_name(tk));
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data_t rb_data = MSG_task_get_data(tk);
+ if (!rb_data->user_data)
+ ERROR1("the task %s contain no user data", MSG_task_get_name(tk));
- return (VALUE)rb_data->user_data;
+ return (VALUE) rb_data->user_data;
}
-VALUE rb_task_has_data(VALUE class,VALUE task)
+VALUE rb_task_has_data(VALUE class, VALUE task)
{
- m_task_t tk;
- Data_Get_Struct(task,s_m_task_t,tk);
- rb_data_t rb_data = MSG_task_get_data(tk);
- if(!rb_data->user_data)
- return Qfalse;
- return Qtrue;
+ m_task_t tk;
+ Data_Get_Struct(task, s_m_task_t, tk);
+ rb_data_t rb_data = MSG_task_get_data(tk);
+ if (!rb_data->user_data)
+ return Qfalse;
+ return Qtrue;
}
-
VALUE rb_host;
//Init Msg From Ruby
-static void msg_init(VALUE Class,VALUE args)
+static void msg_init(VALUE Class, VALUE args)
{
- char **argv=NULL;
+ char **argv = NULL;
const char *tmp;
- int argc,type,i;
- VALUE *ptr ;
+ int argc, type, i;
+ VALUE *ptr;
// Testing The Args Type
- type = TYPE(args);
- if (type != T_ARRAY ) {
- rb_raise(rb_eRuntimeError,"Bad arguments to msg_init (expecting an array)");
+ type = TYPE(args);
+ if (type != T_ARRAY) {
+ rb_raise(rb_eRuntimeError,
+ "Bad arguments to msg_init (expecting an array)");
return;
}
- ptr= RARRAY(args)->ptr;
- argc= RARRAY(args)->len;
+ ptr = RARRAY(args)->ptr;
+ argc = RARRAY(args)->len;
// Create C Array to Hold Data_Get_Struct
argc++;
argv = xbt_new0(char *, argc);
argv[0] = strdup("ruby");
- for (i=0;i<argc-1;i++) {
+ for (i = 0; i < argc - 1; i++) {
VALUE value = ptr[i];
type = TYPE(value);
// if (type == T_STRING)
tmp = RSTRING(value)->ptr;
- argv[i+1] = strdup(tmp);
+ argv[i + 1] = strdup(tmp);
}
// Calling C Msg_Init Method
- MSG_global_init(&argc,argv);
+ MSG_global_init(&argc, argv);
// Cleanups
- for (i=0;i<argc;i++)
- free(argv[i]) ;
- free (argv);
+ for (i = 0; i < argc; i++)
+ free(argv[i]);
+ free(argv);
}
+
//Init Msg_Run From Ruby
-static void msg_run(VALUE class) {
+static void msg_run(VALUE class)
+{
DEBUG0("Start Running...");
m_host_t *hosts;
- int cpt,host_count;
+ int cpt, host_count;
VALUE rbHost;
// Let's Run
//printf("msg_run3\n");
- if (MSG_OK != MSG_main()){
- rb_raise(rb_eRuntimeError,"MSG_main() failed");
+ if (MSG_OK != MSG_main()) {
+ rb_raise(rb_eRuntimeError, "MSG_main() failed");
}
DEBUG0
- ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
+ ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
/* Cleanup Ruby hosts */
DEBUG0("Clean Ruby World ");
hosts = MSG_get_host_table();
host_count = MSG_get_host_number();
- for (cpt=0;cpt<host_count;cpt++) {
- rbHost = (VALUE)((hosts[cpt])->data);
+ for (cpt = 0; cpt < host_count; cpt++) {
+ rbHost = (VALUE) ((hosts[cpt])->data);
}
return;
}
static void msg_clean(VALUE class)
{
- if (MSG_OK != MSG_clean())
- rb_raise(rb_eRuntimeError,"MSG_clean() failed");
-
+ if (MSG_OK != MSG_clean())
+ rb_raise(rb_eRuntimeError, "MSG_clean() failed");
+
}
-static void msg_createEnvironment(VALUE class,VALUE plateformFile) {
+
+static void msg_createEnvironment(VALUE class, VALUE plateformFile)
+{
int type = TYPE(plateformFile);
- if ( type != T_STRING )
- rb_raise(rb_eRuntimeError,"Bad Argument's Type");
- const char * platform = RSTRING(plateformFile)->ptr;
+ if (type != T_STRING)
+ rb_raise(rb_eRuntimeError, "Bad Argument's Type");
+ const char *platform = RSTRING(plateformFile)->ptr;
MSG_create_environment(platform);
- DEBUG1("Create Environment (%s)...Done",platform);
+ DEBUG1("Create Environment (%s)...Done", platform);
}
//deploy Application
-static void msg_deployApplication(VALUE class,VALUE deploymentFile ) {
+static void msg_deployApplication(VALUE class, VALUE deploymentFile)
+{
int type = TYPE(deploymentFile);
- if ( type != T_STRING )
- rb_raise(rb_eRuntimeError,"Bad Argument's Type for deployApplication ");
+ if (type != T_STRING)
+ rb_raise(rb_eRuntimeError,
+ "Bad Argument's Type for deployApplication ");
const char *dep_file = RSTRING(deploymentFile)->ptr;
surf_parse_reset_parser();
surfxml_add_callback(STag_surfxml_process_cb_list,
- rb_application_handler_on_begin_process);
+ rb_application_handler_on_begin_process);
surfxml_add_callback(ETag_surfxml_argument_cb_list,
- rb_application_handler_on_process_arg);
+ rb_application_handler_on_process_arg);
surfxml_add_callback(STag_surfxml_prop_cb_list,
- rb_application_handler_on_property);
+ rb_application_handler_on_property);
surfxml_add_callback(ETag_surfxml_process_cb_list,
- rb_application_handler_on_end_process);
+ rb_application_handler_on_end_process);
surf_parse_open(dep_file);
rb_application_handler_on_start_document();
- if(surf_parse())
- rb_raise(rb_eRuntimeError,"surf_parse() failed");
+ if (surf_parse())
+ rb_raise(rb_eRuntimeError, "surf_parse() failed");
surf_parse_close();
-
+
rb_application_handler_on_end_document();
- DEBUG1("Deploy Application(%s)...Done",dep_file);
+ DEBUG1("Deploy Application(%s)...Done", dep_file);
}
// INFO
-static void msg_info(VALUE class,VALUE msg) {
+static void msg_info(VALUE class, VALUE msg)
+{
const char *s = RSTRING(msg)->ptr;
- INFO1("%s",s);
+ INFO1("%s", s);
}
-static void msg_debug(VALUE class,VALUE msg) {
+
+static void msg_debug(VALUE class, VALUE msg)
+{
const char *s = RSTRING(msg)->ptr;
- DEBUG1("%s",s);
+ DEBUG1("%s", s);
}
// get Clock
-static VALUE msg_get_clock(VALUE class) {
+static VALUE msg_get_clock(VALUE class)
+{
return rb_float_new(MSG_get_clock());
}
-extern const char*xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
+extern const char *xbt_ctx_factory_to_use; /*Hack: let msg load directly the right factory */
-typedef VALUE(*rb_meth)(ANYARGS);
-void Init_libsimgrid() {
+typedef VALUE(*rb_meth) (ANYARGS);
+void Init_libsimgrid()
+{
xbt_ctx_factory_to_use = "ruby";
// Modules
rb_msg = rb_define_module("MSG");
//Associated Environment Methods
- rb_define_module_function(rb_msg,"init",(rb_meth)msg_init,1);
- rb_define_module_function(rb_msg,"run",(rb_meth)msg_run,0);
- rb_define_module_function(rb_msg,"createEnvironment",(rb_meth)msg_createEnvironment,1);
- rb_define_module_function(rb_msg,"deployApplication",(rb_meth)msg_deployApplication,1);
- rb_define_module_function(rb_msg,"info",(rb_meth)msg_info,1);
- rb_define_module_function(rb_msg,"debug",(rb_meth)msg_debug,1);
- rb_define_module_function(rb_msg,"getClock",(rb_meth)msg_get_clock,0);
- rb_define_module_function(rb_msg,"exit",(rb_meth)msg_clean,0);
+ rb_define_module_function(rb_msg, "init", (rb_meth) msg_init, 1);
+ rb_define_module_function(rb_msg, "run", (rb_meth) msg_run, 0);
+ rb_define_module_function(rb_msg, "createEnvironment",
+ (rb_meth) msg_createEnvironment, 1);
+ rb_define_module_function(rb_msg, "deployApplication",
+ (rb_meth) msg_deployApplication, 1);
+ rb_define_module_function(rb_msg, "info", (rb_meth) msg_info, 1);
+ rb_define_module_function(rb_msg, "debug", (rb_meth) msg_debug, 1);
+ rb_define_module_function(rb_msg, "getClock", (rb_meth) msg_get_clock,
+ 0);
+ rb_define_module_function(rb_msg, "exit", (rb_meth) msg_clean, 0);
//Associated Process Methods
- rb_define_method(rb_msg,"processSuspend",(rb_meth)rb_process_suspend,1);
- rb_define_method(rb_msg,"processResume",(rb_meth)rb_process_resume,1);
- rb_define_method(rb_msg,"processIsSuspend",(rb_meth)rb_process_isSuspended,1);
- rb_define_method(rb_msg,"processKill",(rb_meth)rb_process_kill_up,1);
- rb_define_method(rb_msg,"processKillDown",(rb_meth)rb_process_kill_down,1);
- rb_define_method(rb_msg,"processGetHost",(rb_meth)rb_process_getHost,1);
- rb_define_method(rb_msg,"processExit",(rb_meth)rb_process_exit,1);
+ rb_define_method(rb_msg, "processSuspend", (rb_meth) rb_process_suspend,
+ 1);
+ rb_define_method(rb_msg, "processResume", (rb_meth) rb_process_resume,
+ 1);
+ rb_define_method(rb_msg, "processIsSuspend",
+ (rb_meth) rb_process_isSuspended, 1);
+ rb_define_method(rb_msg, "processKill", (rb_meth) rb_process_kill_up, 1);
+ rb_define_method(rb_msg, "processKillDown",
+ (rb_meth) rb_process_kill_down, 1);
+ rb_define_method(rb_msg, "processGetHost", (rb_meth) rb_process_getHost,
+ 1);
+ rb_define_method(rb_msg, "processExit", (rb_meth) rb_process_exit, 1);
//Classes
- rb_task = rb_define_class_under(rb_msg,"RbTask",rb_cObject);
- rb_host = rb_define_class_under(rb_msg,"RbHost",rb_cObject);
+ rb_task = rb_define_class_under(rb_msg, "RbTask", rb_cObject);
+ rb_host = rb_define_class_under(rb_msg, "RbHost", rb_cObject);
//Task Methods
- rb_define_module_function(rb_task,"new",(rb_meth)rb_task_new,3);
- rb_define_module_function(rb_task,"compSize",(rb_meth)rb_task_comp,1);
- rb_define_module_function(rb_task,"name",(rb_meth)rb_task_name,1);
- rb_define_module_function(rb_task,"execute",(rb_meth)rb_task_execute,1);
- rb_define_module_function(rb_task,"send",(rb_meth)rb_task_send,2);
- rb_define_module_function(rb_task,"receive",(rb_meth)rb_task_receive,1);
- rb_define_module_function(rb_task,"sender",(rb_meth)rb_task_sender,1);
- rb_define_module_function(rb_task,"source",(rb_meth)rb_task_source,1);
- rb_define_module_function(rb_task,"listen",(rb_meth)rb_task_listen,2);
- rb_define_module_function(rb_task,"listenFromHost",(rb_meth)rb_task_listen_host,3);
- rb_define_module_function(rb_task,"setPriority",(rb_meth)rb_task_set_priority,2);
- rb_define_module_function(rb_task,"cancel",(rb_meth)rb_task_cancel,1);
- rb_define_module_function(rb_task,"hasData",(rb_meth)rb_task_has_data,1);
- rb_define_module_function(rb_task,"setData",(rb_meth)rb_task_set_data,2);
- rb_define_module_function(rb_task,"data",(rb_meth)rb_task_get_data,1);
+ rb_define_module_function(rb_task, "new", (rb_meth) rb_task_new, 3);
+ rb_define_module_function(rb_task, "compSize", (rb_meth) rb_task_comp,
+ 1);
+ rb_define_module_function(rb_task, "name", (rb_meth) rb_task_name, 1);
+ rb_define_module_function(rb_task, "execute", (rb_meth) rb_task_execute,
+ 1);
+ rb_define_module_function(rb_task, "send", (rb_meth) rb_task_send, 2);
+ rb_define_module_function(rb_task, "receive", (rb_meth) rb_task_receive,
+ 1);
+ rb_define_module_function(rb_task, "sender", (rb_meth) rb_task_sender,
+ 1);
+ rb_define_module_function(rb_task, "source", (rb_meth) rb_task_source,
+ 1);
+ rb_define_module_function(rb_task, "listen", (rb_meth) rb_task_listen,
+ 2);
+ rb_define_module_function(rb_task, "listenFromHost",
+ (rb_meth) rb_task_listen_host, 3);
+ rb_define_module_function(rb_task, "setPriority",
+ (rb_meth) rb_task_set_priority, 2);
+ rb_define_module_function(rb_task, "cancel", (rb_meth) rb_task_cancel,
+ 1);
+ rb_define_module_function(rb_task, "hasData", (rb_meth) rb_task_has_data,
+ 1);
+ rb_define_module_function(rb_task, "setData", (rb_meth) rb_task_set_data,
+ 2);
+ rb_define_module_function(rb_task, "data", (rb_meth) rb_task_get_data,
+ 1);
//Host Methods
- rb_define_module_function(rb_host,"getByName",(rb_meth)rb_host_get_by_name,1);
- rb_define_module_function(rb_host,"name",(rb_meth)rb_host_name,1);
- rb_define_module_function(rb_host,"speed",(rb_meth)rb_host_speed,1);
- rb_define_module_function(rb_host,"number",(rb_meth)rb_host_number,0);
- rb_define_module_function(rb_host,"isAvail",(rb_meth)rb_host_is_avail,1);
- rb_define_module_function(rb_host,"getHostProcess",(rb_meth)rb_host_process,1);
- rb_define_module_function(rb_host,"all",(rb_meth)rb_host_get_all_hosts,0);
+ rb_define_module_function(rb_host, "getByName",
+ (rb_meth) rb_host_get_by_name, 1);
+ rb_define_module_function(rb_host, "name", (rb_meth) rb_host_name, 1);
+ rb_define_module_function(rb_host, "speed", (rb_meth) rb_host_speed, 1);
+ rb_define_module_function(rb_host, "number", (rb_meth) rb_host_number,
+ 0);
+ rb_define_module_function(rb_host, "isAvail", (rb_meth) rb_host_is_avail,
+ 1);
+ rb_define_module_function(rb_host, "getHostProcess",
+ (rb_meth) rb_host_process, 1);
+ rb_define_module_function(rb_host, "all",
+ (rb_meth) rb_host_get_all_hosts, 0);
}
#include "rb_SD_task.h"
// Free Method
-static void SD_task_free(SD_task_t tk) {
+static void SD_task_free(SD_task_t tk)
+{
// SD_task_destroy(tk);
}
-static void rb_SD_task_destroy(VALUE class,VALUE task)
+static void rb_SD_task_destroy(VALUE class, VALUE task)
{
- SD_task_t tk ;
- Data_Get_Struct(task, SD_task_t, tk);
- SD_task_destroy(tk);
+ SD_task_t tk;
+ Data_Get_Struct(task, SD_task_t, tk);
+ SD_task_destroy(tk);
}
+
// New Method
-static VALUE rb_SD_task_new(VALUE class, VALUE name,VALUE amount)
+static VALUE rb_SD_task_new(VALUE class, VALUE name, VALUE amount)
{
//data Set to NULL
- SD_task_t task = SD_task_create(RSTRING(name)->ptr,NULL,NUM2DBL(amount));
+ SD_task_t task =
+ SD_task_create(RSTRING(name)->ptr, NULL, NUM2DBL(amount));
// Wrap m_task_t to a Ruby Value
return Data_Wrap_Struct(class, 0, SD_task_free, task);
}
//Get Name
-static VALUE rb_SD_task_name(VALUE class,VALUE task)
+static VALUE rb_SD_task_name(VALUE class, VALUE task)
{
// Wrap Ruby Value to m_task_t struct
SD_task_t tk;
Data_Get_Struct(task, SD_task_t, tk);
return rb_str_new2(SD_task_get_name(tk));
-
+
}
// Schedule Task
-static void rb_SD_task_schedule(VALUE class,VALUE task,VALUE workstation_nb,VALUE workstation_list,VALUE computation_amount,VALUE communication_amount,VALUE rate)
+static void rb_SD_task_schedule(VALUE class, VALUE task,
+ VALUE workstation_nb,
+ VALUE workstation_list,
+ VALUE computation_amount,
+ VALUE communication_amount, VALUE rate)
{
// Wrap Ruby Value to m_task_t struct
- int i,wrk_nb,comp_nb,comm_nb;
- double *comp_amount,*comm_amount;
+ int i, wrk_nb, comp_nb, comm_nb;
+ double *comp_amount, *comm_amount;
double rt;
- VALUE *ptr_wrk,*ptr_comp,*ptr_comm;
+ VALUE *ptr_wrk, *ptr_comp, *ptr_comm;
SD_task_t tk;
Data_Get_Struct(task, SD_task_t, tk);
wrk_nb = NUM2INT(workstation_nb);
comm_nb = RARRAY(communication_amount)->len;
rt = NUM2DBL(rate);
SD_workstation_t *wrk_list;
-
+
ptr_wrk = RARRAY(workstation_list)->ptr;
ptr_comp = RARRAY(computation_amount)->ptr;
ptr_comm = RARRAY(communication_amount)->ptr;
-
- wrk_list = xbt_new0(SD_workstation_t,wrk_nb);
- comp_amount = xbt_new0(double,wrk_nb);
- comm_amount = xbt_new0(double,wrk_nb);
-
+
+ wrk_list = xbt_new0(SD_workstation_t, wrk_nb);
+ comp_amount = xbt_new0(double, wrk_nb);
+ comm_amount = xbt_new0(double, wrk_nb);
+
// wrk_nb == comp_nb == comm_nb ???
- for (i=0;i<wrk_nb;i++)
- {
- Data_Get_Struct(ptr_wrk[i],SD_workstation_t,wrk_list[i]);
+ for (i = 0; i < wrk_nb; i++) {
+ Data_Get_Struct(ptr_wrk[i], SD_workstation_t, wrk_list[i]);
comp_amount[i] = NUM2DBL(ptr_comp[i]);
comm_amount[i] = NUM2DBL(ptr_comm[i]);
}
/*for (i=0;i<comp_nb;i++)
- comp_amount[i] = NUM2DBL(ptr_comp[i]);
-
- for (i=0;i<comm_nb;i++)
- comm_amount[i] = NUM2DBL(ptr_comm[i]);*/
-
- SD_task_schedule(tk,wrk_nb,wrk_list,comp_amount,comm_amount,rt);
-
+ comp_amount[i] = NUM2DBL(ptr_comp[i]);
+
+ for (i=0;i<comm_nb;i++)
+ comm_amount[i] = NUM2DBL(ptr_comm[i]); */
+
+ SD_task_schedule(tk, wrk_nb, wrk_list, comp_amount, comm_amount, rt);
+
xbt_free(wrk_list);
xbt_free(comp_amount);
xbt_free(comm_amount);
-
+
}
//unschedule
-static void rb_SD_task_unschedule(VALUE class,VALUE task)
+static void rb_SD_task_unschedule(VALUE class, VALUE task)
{
SD_task_t tk;
- Data_Get_Struct(task,SD_task_t,tk);
- SD_task_unschedule (tk);
-
+ Data_Get_Struct(task, SD_task_t, tk);
+ SD_task_unschedule(tk);
+
}
// task dependency add
-static void rb_SD_task_add_dependency(VALUE Class,VALUE task_src,VALUE task_dst)
+static void rb_SD_task_add_dependency(VALUE Class, VALUE task_src,
+ VALUE task_dst)
{
- SD_task_t tk_src,tk_dst;
- Data_Get_Struct(task_src, SD_task_t ,tk_src);
- Data_Get_Struct(task_dst, SD_task_t ,tk_dst);
- SD_task_dependency_add(NULL,NULL,tk_src,tk_dst);
-
+ SD_task_t tk_src, tk_dst;
+ Data_Get_Struct(task_src, SD_task_t, tk_src);
+ Data_Get_Struct(task_dst, SD_task_t, tk_dst);
+ SD_task_dependency_add(NULL, NULL, tk_src, tk_dst);
+
}
//task execution time
-static VALUE rb_SD_task_execution_time(VALUE class,VALUE task,VALUE workstation_nb,VALUE workstation_list,VALUE computation_amount,VALUE communication_amount,VALUE rate)
+static VALUE rb_SD_task_execution_time(VALUE class, VALUE task,
+ VALUE workstation_nb,
+ VALUE workstation_list,
+ VALUE computation_amount,
+ VALUE communication_amount,
+ VALUE rate)
{
-
- int i,wrk_nb;
- double *comp_amount,*comm_amount;
+
+ int i, wrk_nb;
+ double *comp_amount, *comm_amount;
double rt;
- VALUE *ptr_wrk,*ptr_comp,*ptr_comm;
+ VALUE *ptr_wrk, *ptr_comp, *ptr_comm;
SD_task_t tk;
Data_Get_Struct(task, SD_task_t, tk);
wrk_nb = NUM2INT(workstation_nb);
rt = NUM2DBL(rate);
SD_workstation_t *wrk_list;
-
+
ptr_wrk = RARRAY(workstation_list)->ptr;
ptr_comp = RARRAY(computation_amount)->ptr;
ptr_comm = RARRAY(communication_amount)->ptr;
-
- wrk_list = xbt_new0(SD_workstation_t,wrk_nb);
- comp_amount = xbt_new0(double,wrk_nb);
- comm_amount = xbt_new0(double,wrk_nb);
-
- for (i=0;i<wrk_nb;i++)
- {
- Data_Get_Struct(ptr_wrk[i],SD_workstation_t,wrk_list[i]);
+
+ wrk_list = xbt_new0(SD_workstation_t, wrk_nb);
+ comp_amount = xbt_new0(double, wrk_nb);
+ comm_amount = xbt_new0(double, wrk_nb);
+
+ for (i = 0; i < wrk_nb; i++) {
+ Data_Get_Struct(ptr_wrk[i], SD_workstation_t, wrk_list[i]);
comp_amount[i] = NUM2DBL(ptr_comp[i]);
comm_amount[i] = NUM2DBL(ptr_comm[i]);
}
-
- return rb_float_new(SD_task_get_execution_time (tk,wrk_nb,wrk_list,comp_amount,comm_amount,rt));
-
+
+ return
+ rb_float_new(SD_task_get_execution_time
+ (tk, wrk_nb, wrk_list, comp_amount, comm_amount, rt));
+
}
//task start time
-static VALUE rb_SD_task_start_time(VALUE class,VALUE task)
+static VALUE rb_SD_task_start_time(VALUE class, VALUE task)
{
SD_task_t tk;
- Data_Get_Struct(task,SD_task_t,tk);
- double time=SD_task_get_start_time(tk);
+ Data_Get_Struct(task, SD_task_t, tk);
+ double time = SD_task_get_start_time(tk);
return rb_float_new(time);
-
+
}
//task fininsh time
-static VALUE rb_SD_task_finish_time(VALUE class,VALUE task)
+static VALUE rb_SD_task_finish_time(VALUE class, VALUE task)
{
SD_task_t tk;
- Data_Get_Struct(task,SD_task_t,tk);
- double time=SD_task_get_finish_time(tk);
+ Data_Get_Struct(task, SD_task_t, tk);
+ double time = SD_task_get_finish_time(tk);
return rb_float_new(time);
-
+
}
// Simulate : return a SD_task
-static VALUE rb_SD_simulate(VALUE class,VALUE how_long)
+static VALUE rb_SD_simulate(VALUE class, VALUE how_long)
{
int i;
- SD_task_t task ;
+ SD_task_t task;
double hl = NUM2DBL(how_long);
- xbt_dynar_t simulated_tasks = SD_simulate(hl) ;
-
+ xbt_dynar_t simulated_tasks = SD_simulate(hl);
+
VALUE rb_tasks = rb_ary_new();
- xbt_dynar_foreach(simulated_tasks, i, task){
+ xbt_dynar_foreach(simulated_tasks, i, task) {
VALUE tk = Qnil;
tk = Data_Wrap_Struct(class, 0, SD_task_free, task);
- rb_ary_push(rb_tasks,tk);
+ rb_ary_push(rb_tasks, tk);
}
-
- return rb_tasks;
-
+
+ return rb_tasks;
+
}
#include <ruby.h>
#include <simdag/simdag.h>
-#include "xbt/sysdep.h"
+#include "xbt/sysdep.h"
// Free Method
static void SD_task_free(SD_task_t tk); // needed by ruby while wrapping
//destroy
-static void rb_SD_task_destory(VALUE Class,VALUE task);
+static void rb_SD_task_destory(VALUE Class, VALUE task);
// New Method
-static VALUE rb_SD_task_new(VALUE Class, VALUE name,VALUE amount); //data set to NULL
+static VALUE rb_SD_task_new(VALUE Class, VALUE name, VALUE amount); //data set to NULL
//Get Name
-static VALUE rb_SD_task_name(VALUE Class,VALUE task);
+static VALUE rb_SD_task_name(VALUE Class, VALUE task);
// Schedule Task
-static void rb_SD_task_schedule(VALUE Class,VALUE task,VALUE workstation_nb,VALUE workstation_list,VALUE comp_amount,VALUE comm_amount,VALUE rate);
+static void rb_SD_task_schedule(VALUE Class, VALUE task,
+ VALUE workstation_nb,
+ VALUE workstation_list, VALUE comp_amount,
+ VALUE comm_amount, VALUE rate);
// unschedule Task
-static void rb_SD_task_unschedule(VALUE Class,VALUE task);
+static void rb_SD_task_unschedule(VALUE Class, VALUE task);
// task dependency Add ( name & data set to NULL)
-static void rb_SD_task_add_dependency(VALUE Class,VALUE task_src,VALUE task_dst);
+static void rb_SD_task_add_dependency(VALUE Class, VALUE task_src,
+ VALUE task_dst);
// task execution time
-static VALUE rb_SD_task_execution_time(VALUE Class,VALUE task,VALUE workstation_nb,VALUE workstation_list,VALUE comp_amount,VALUE comm_amount,VALUE rate);
+static VALUE rb_SD_task_execution_time(VALUE Class, VALUE task,
+ VALUE workstation_nb,
+ VALUE workstation_list,
+ VALUE comp_amount,
+ VALUE comm_amount, VALUE rate);
// task start time
-static VALUE rb_SD_task_start_time(VALUE Class,VALUE task);
+static VALUE rb_SD_task_start_time(VALUE Class, VALUE task);
// task finish time
-static VALUE rb_SD_task_finish_time(VALUE Class,VALUE task);
+static VALUE rb_SD_task_finish_time(VALUE Class, VALUE task);
// simulation
-static VALUE rb_SD_simulate(VALUE Class,VALUE how_long);
+static VALUE rb_SD_simulate(VALUE Class, VALUE how_long);
-#endif
\ No newline at end of file
+#endif
{
//NOTHING TO DO
}
+
// Workstation list
static VALUE rb_SD_workstation_list(VALUE class)
{
-
- int i,nb;
+
+ int i, nb;
nb = SD_workstation_get_number();
VALUE workstation_list = rb_ary_new2(nb);
- for (i=0;i<nb;i++)
- {
- VALUE wrk = Qnil;
- wrk = Data_Wrap_Struct(class, 0, SD_workstation_free, SD_workstation_get_list()[i]);
- rb_ary_push(workstation_list,wrk);
-
+ for (i = 0; i < nb; i++) {
+ VALUE wrk = Qnil;
+ wrk =
+ Data_Wrap_Struct(class, 0, SD_workstation_free,
+ SD_workstation_get_list()[i]);
+ rb_ary_push(workstation_list, wrk);
+
}
return workstation_list;
}
}
// Workstation name
-static VALUE rb_SD_workstation_name(VALUE class,VALUE workstation)
+static VALUE rb_SD_workstation_name(VALUE class, VALUE workstation)
{
- SD_workstation_t wk;
- Data_Get_Struct(workstation, SD_workstation_t, wk);
- return rb_str_new2(SD_workstation_get_name(wk));
-
-}
\ No newline at end of file
+ SD_workstation_t wk;
+ Data_Get_Struct(workstation, SD_workstation_t, wk);
+ return rb_str_new2(SD_workstation_get_name(wk));
+
+}
static VALUE rb_SD_workstation_number(VALUE Class);
// Workstation name
-static VALUE rb_SD_workstation_name(VALUE Class,VALUE workstation);
+static VALUE rb_SD_workstation_name(VALUE Class, VALUE workstation);
-#endif
\ No newline at end of file
+#endif
* 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.
- */
+ */
//FIXME #include "ruby_simdag.h"
#include "rb_SD_task.c"
VALUE rb_workstation;
//Init Msg_Init From Ruby
-static void sd_init(VALUE Class,VALUE args)
-{
- char **argv=NULL;
+static void sd_init(VALUE Class, VALUE args)
+{
+ char **argv = NULL;
const char *tmp;
- int argc,type,i;
+ int argc, type, i;
VALUE *ptr;
type = TYPE(args);
- if ( type != T_ARRAY )
- {
- rb_raise(rb_eRuntimeError,"Bad Argument to SD_init");
- return;
+ if (type != T_ARRAY) {
+ rb_raise(rb_eRuntimeError, "Bad Argument to SD_init");
+ return;
}
ptr = RARRAY(args)->ptr;
- argc= RARRAY(args)->len;
+ argc = RARRAY(args)->len;
argc++;
- argv= xbt_new0(char*,argc);
+ argv = xbt_new0(char *, argc);
argv[0] = strdup("ruby");
- for (i=0;i<argc-1;i++)
- {
- VALUE value = ptr[i];
- type = TYPE(value);
- tmp = RSTRING(value)->ptr;
- argv[i+1] = strdup(tmp);
+ for (i = 0; i < argc - 1; i++) {
+ VALUE value = ptr[i];
+ type = TYPE(value);
+ tmp = RSTRING(value)->ptr;
+ argv[i + 1] = strdup(tmp);
}
- SD_init(&argc,argv);
+ SD_init(&argc, argv);
free(argv);
// INFO0("SD Init...Done");
printf("SD Init...Done\n");
return;
-
+
}
//Init Msg_Run From Ruby
{
SD_application_reinit();
}
-
+
//deploy Application
-static void sd_createEnvironment(VALUE class,VALUE plateformFile )
-{
- int type = TYPE(plateformFile);
- if ( type != T_STRING )
- rb_raise(rb_eRuntimeError,"Bad Argument's Type");
- const char * platform = RSTRING(plateformFile)->ptr;
- SD_create_environment(platform);
- printf("Create Environment...Done\n");
-
- return;
+static void sd_createEnvironment(VALUE class, VALUE plateformFile)
+{
+ int type = TYPE(plateformFile);
+ if (type != T_STRING)
+ rb_raise(rb_eRuntimeError, "Bad Argument's Type");
+ const char *platform = RSTRING(plateformFile)->ptr;
+ SD_create_environment(platform);
+ printf("Create Environment...Done\n");
+
+ return;
}
-
+
// INFO
-static void sd_info(VALUE class,VALUE msg)
+static void sd_info(VALUE class, VALUE msg)
{
- const char *s = RSTRING(msg)->ptr;
+ const char *s = RSTRING(msg)->ptr;
// INFO1("%s",s);
- printf("%s\n",s);
+ printf("%s\n", s);
}
// Get Clock
static VALUE sd_get_clock(VALUE class)
{
return rb_float_new(SD_get_clock());
-}
+}
void Init_dag()
{
- // Modules
- rb_dag = rb_define_module("DAG");
-
- // Classes
- //Associated Environment Methods!
- rb_define_method(rb_dag,"init",sd_init,1);
- rb_define_method(rb_dag,"reinit",sd_reinit,0);
- rb_define_method(rb_dag,"createEnvironment",sd_createEnvironment,1);
- rb_define_method(rb_dag,"info",sd_info,1);
- rb_define_method(rb_dag,"getClock",sd_get_clock,0);
-
- //Classes
- rb_task = rb_define_class_under(rb_dag,"SdTask",rb_cObject);
- rb_workstation = rb_define_class_under(rb_dag,"SdWorkstation",rb_cObject);
+ // Modules
+ rb_dag = rb_define_module("DAG");
+
+ // Classes
+ //Associated Environment Methods!
+ rb_define_method(rb_dag, "init", sd_init, 1);
+ rb_define_method(rb_dag, "reinit", sd_reinit, 0);
+ rb_define_method(rb_dag, "createEnvironment", sd_createEnvironment, 1);
+ rb_define_method(rb_dag, "info", sd_info, 1);
+ rb_define_method(rb_dag, "getClock", sd_get_clock, 0);
+
+ //Classes
+ rb_task = rb_define_class_under(rb_dag, "SdTask", rb_cObject);
+ rb_workstation =
+ rb_define_class_under(rb_dag, "SdWorkstation", rb_cObject);
// TODO Link Class
-
- //Task Methods
- rb_define_module_function(rb_task,"new",rb_SD_task_new,2);
+
+ //Task Methods
+ rb_define_module_function(rb_task, "new", rb_SD_task_new, 2);
// rb_define_module_function(rb_task,"free",rb_SD_task_destroy,1);
- rb_define_module_function(rb_task,"name",rb_SD_task_name,1);
- rb_define_module_function(rb_task,"schedule",rb_SD_task_schedule,6);
- rb_define_module_function(rb_task,"unschedule",rb_SD_task_unschedule,1);
- rb_define_module_function(rb_task,"addDependency",rb_SD_task_add_dependency,2);
- rb_define_module_function(rb_task,"executionTime",rb_SD_task_execution_time,6);
- rb_define_module_function(rb_task,"startTime",rb_SD_task_start_time,1);
- rb_define_module_function(rb_task,"finishTime",rb_SD_task_finish_time,1);
- rb_define_module_function(rb_task,"simulate",rb_SD_simulate,1);
-
- //Worstation Methods
- rb_define_module_function(rb_workstation,"getList",rb_SD_workstation_list,0);
- rb_define_module_function(rb_workstation,"getNumber",rb_SD_workstation_number,0);
- rb_define_module_function(rb_workstation,"name",rb_SD_workstation_name,1);
-}
+ rb_define_module_function(rb_task, "name", rb_SD_task_name, 1);
+ rb_define_module_function(rb_task, "schedule", rb_SD_task_schedule, 6);
+ rb_define_module_function(rb_task, "unschedule", rb_SD_task_unschedule,
+ 1);
+ rb_define_module_function(rb_task, "addDependency",
+ rb_SD_task_add_dependency, 2);
+ rb_define_module_function(rb_task, "executionTime",
+ rb_SD_task_execution_time, 6);
+ rb_define_module_function(rb_task, "startTime", rb_SD_task_start_time,
+ 1);
+ rb_define_module_function(rb_task, "finishTime", rb_SD_task_finish_time,
+ 1);
+ rb_define_module_function(rb_task, "simulate", rb_SD_simulate, 1);
+
+ //Worstation Methods
+ rb_define_module_function(rb_workstation, "getList",
+ rb_SD_workstation_list, 0);
+ rb_define_module_function(rb_workstation, "getNumber",
+ rb_SD_workstation_number, 0);
+ rb_define_module_function(rb_workstation, "name", rb_SD_workstation_name,
+ 1);
+}
* Context related stuff *
* ********************* */
typedef struct s_smx_ctx_ruby {
- s_smx_ctx_base_t super; /* Fields of super implementation */
- VALUE process; // The Ruby Process Instance
+ s_smx_ctx_base_t super; /* Fields of super implementation */
+ VALUE process; // The Ruby Process Instance
//...
-}s_smx_ctx_ruby_t,*smx_ctx_ruby_t;
-void SIMIX_ctx_ruby_factory_init(smx_context_factory_t *factory);
+} s_smx_ctx_ruby_t, *smx_ctx_ruby_t;
+void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory);
-void Init_libsimgrid(void); /* Load the bindings */
-void initRuby(void); // Mandatory to call Ruby methods from C
+void Init_libsimgrid(void); /* Load the bindings */
+void initRuby(void); // Mandatory to call Ruby methods from C
/* *********************************************** *
* Functions for Ruby Process Management (Up Call) *
* Independent Methods *
* *********************************************** */
-VALUE rb_process_getName( VALUE ruby_process );
+VALUE rb_process_getName(VALUE ruby_process);
VALUE rb_process_getID(VALUE ruby_process);
VALUE rb_process_getBind(VALUE ruby_class);
-void rb_process_setBind(VALUE ruby_class,long bind);
+void rb_process_setBind(VALUE ruby_class, long bind);
VALUE rb_process_isAlive(VALUE ruby_process);
-void rb_process_kill_up(VALUE ruby_process);
-void rb_process_join( VALUE ruby_process );
-void rb_process_unschedule( VALUE ruby_process );
-void rb_process_schedule( VALUE ruby_process );
+void rb_process_kill_up(VALUE ruby_process);
+void rb_process_join(VALUE ruby_process);
+void rb_process_unschedule(VALUE ruby_process);
+void rb_process_schedule(VALUE ruby_process);
/* ********************************************** *
* Function for Native Process (Bound) Management *
//friend Method // Not belong to the Class but Called within !!
m_process_t rb_process_to_native(VALUE ruby_process);
// Binding Process >> Friend Method
-void rb_process_bind(VALUE ruby_class,m_process_t process);
-void rb_process_create(VALUE Class,VALUE rb_process,VALUE host);
-void rb_process_suspend(VALUE Class,VALUE ruby_process);
-void rb_process_resume(VALUE Class,VALUE ruby_process);
+void rb_process_bind(VALUE ruby_class, m_process_t process);
+void rb_process_create(VALUE Class, VALUE rb_process, VALUE host);
+void rb_process_suspend(VALUE Class, VALUE ruby_process);
+void rb_process_resume(VALUE Class, VALUE ruby_process);
// Returns Boolean ( Qtrue / Qfalse )
-VALUE rb_process_isSuspended(VALUE Class,VALUE ruby_process);
-void rb_process_kill_down(VALUE Class,VALUE ruby_process);
-VALUE rb_process_getHost(VALUE Class,VALUE ruby_process);
-void rb_process_exit(VALUE Class,VALUE ruby_process);
+VALUE rb_process_isSuspended(VALUE Class, VALUE ruby_process);
+void rb_process_kill_down(VALUE Class, VALUE ruby_process);
+VALUE rb_process_getHost(VALUE Class, VALUE ruby_process);
+void rb_process_exit(VALUE Class, VALUE ruby_process);
/* Functions related to hosts */
-void rb_host_free(m_host_t ht);
+void rb_host_free(m_host_t ht);
VALUE rb_host_get_by_name(VALUE Class, VALUE name);
-VALUE rb_host_name(VALUE Class,VALUE host);
+VALUE rb_host_name(VALUE Class, VALUE host);
VALUE rb_host_number(VALUE Class);
-VALUE rb_host_speed(VALUE Class,VALUE host);
-void rb_host_set_data(VALUE Class,VALUE host,VALUE data);
-VALUE rb_host_get_data(VALUE Class,VALUE host);
-VALUE rb_host_is_avail(VALUE Class,VALUE host);
-VALUE rb_host_process(VALUE Class,VALUE process);
+VALUE rb_host_speed(VALUE Class, VALUE host);
+void rb_host_set_data(VALUE Class, VALUE host, VALUE data);
+VALUE rb_host_get_data(VALUE Class, VALUE host);
+VALUE rb_host_is_avail(VALUE Class, VALUE host);
+VALUE rb_host_process(VALUE Class, VALUE process);
VALUE rb_host_get_all_hosts(VALUE Class);
/* Functions related to tasks */
typedef struct ruby_data {
- void *ruby_task; // Pointer to send the ruby_task
- void *user_data; // Pointer on the user data
-}s_ruby_data_t,*rb_data_t;
+ void *ruby_task; // Pointer to send the ruby_task
+ void *user_data; // Pointer on the user data
+} s_ruby_data_t, *rb_data_t;
void rb_task_free(m_task_t tk);
-VALUE rb_task_new(VALUE Class, VALUE name,VALUE comp_size,VALUE comm_size);
-VALUE rb_task_comp(VALUE Class,VALUE task); // Get Computation Size
-VALUE rb_task_name(VALUE Class,VALUE task);
-VALUE rb_task_execute(VALUE Class,VALUE task);
-void rb_task_send(VALUE Class,VALUE task,VALUE mailbox);
-VALUE rb_task_receive(VALUE Class,VALUE mailbox);// Receive : return a task
-void rb_task_receive2(VALUE Class,VALUE task,VALUE mailbox);// Receive Task 2 << Not Appreciated
-VALUE rb_task_sender(VALUE Class,VALUE task);
-VALUE rb_task_source(VALUE Class,VALUE task);
-VALUE rb_task_listen(VALUE Class,VALUE task,VALUE alias); //Listen From Alias (=mailbox)
-VALUE rb_task_listen_host(VALUE Class,VALUE task,VALUE alias,VALUE host); //Listen from Host
-void rb_task_set_priority(VALUE Class,VALUE task,VALUE priority); // Set Priority
-void rb_task_cancel(VALUE Class,VALUE task); // Cancel
-VALUE rb_task_has_data(VALUE Class,VALUE task); // check if the task contains a data
-VALUE rb_task_get_data(VALUE Class,VALUE task); // get data
-void rb_task_set_data(VALUE Class,VALUE task,VALUE data); // set data
+VALUE rb_task_new(VALUE Class, VALUE name, VALUE comp_size,
+ VALUE comm_size);
+VALUE rb_task_comp(VALUE Class, VALUE task); // Get Computation Size
+VALUE rb_task_name(VALUE Class, VALUE task);
+VALUE rb_task_execute(VALUE Class, VALUE task);
+void rb_task_send(VALUE Class, VALUE task, VALUE mailbox);
+VALUE rb_task_receive(VALUE Class, VALUE mailbox); // Receive : return a task
+void rb_task_receive2(VALUE Class, VALUE task, VALUE mailbox); // Receive Task 2 << Not Appreciated
+VALUE rb_task_sender(VALUE Class, VALUE task);
+VALUE rb_task_source(VALUE Class, VALUE task);
+VALUE rb_task_listen(VALUE Class, VALUE task, VALUE alias); //Listen From Alias (=mailbox)
+VALUE rb_task_listen_host(VALUE Class, VALUE task, VALUE alias, VALUE host); //Listen from Host
+void rb_task_set_priority(VALUE Class, VALUE task, VALUE priority); // Set Priority
+void rb_task_cancel(VALUE Class, VALUE task); // Cancel
+VALUE rb_task_has_data(VALUE Class, VALUE task); // check if the task contains a data
+VALUE rb_task_get_data(VALUE Class, VALUE task); // get data
+void rb_task_set_data(VALUE Class, VALUE task, VALUE data); // set data
/* Upcalls for the application handler */
void rb_application_handler_on_start_document(void);
void rb_application_handler_on_property(void);
void rb_application_handler_on_end_process(void);
-#endif /* RB_SG_BINDINGS */
+#endif /* RB_SG_BINDINGS */
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 1295 "xbt/config.c"
+#line 1325 "xbt/config.c"
#include "xbt.h"
#include "xbt/ex.h"
xbt_dynar_t dyn;
xbt_cfg_t myset = make_set();
- xbt_cfg_set_parse(myset, "peername:veloce user:foo\nuser:bar\tuser:toto");
+ xbt_cfg_set_parse(myset,
+ "peername:veloce user:foo\nuser:bar\tuser:toto");
xbt_cfg_set_parse(myset, "speed:42");
xbt_cfg_check(myset);
dyn = xbt_cfg_get_dynar(myset, "user");
xbt_dynar_length(dyn));
if (strcmp(xbt_dynar_get_as(dyn, 0, char *), "foo"))
- xbt_test_fail1("Dynar[0] = %s, I expected foo",
- xbt_dynar_get_as(dyn, 0, char *));
+ xbt_test_fail1("Dynar[0] = %s, I expected foo",
+ xbt_dynar_get_as(dyn, 0, char *));
if (strcmp(xbt_dynar_get_as(dyn, 1, char *), "bar"))
- xbt_test_fail1("Dynar[1] = %s, I expected bar",
- xbt_dynar_get_as(dyn, 1, char *));
+ xbt_test_fail1("Dynar[1] = %s, I expected bar",
+ xbt_dynar_get_as(dyn, 1, char *));
if (strcmp(xbt_dynar_get_as(dyn, 2, char *), "toto"))
- xbt_test_fail1("Dynar[2] = %s, I expected toto",
- xbt_dynar_get_as(dyn, 2, char *));
+ xbt_test_fail1("Dynar[2] = %s, I expected toto",
+ xbt_dynar_get_as(dyn, 2, char *));
xbt_cfg_free(&myset);
}
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 823 "xbt/cunit.c"
+#line 835 "xbt/cunit.c"
XBT_TEST_UNIT("expect", test_expected_failure, "expected failures")
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 816 "xbt/dict.c"
+#line 835 "xbt/dict.c"
#include "xbt.h"
#include "xbt/ex.h"
#include "portable.h"
{
char *data = xbt_strdup(data_to_fill);
- xbt_test_log2("Add %s under %s", PRINTF_STR(data_to_fill), PRINTF_STR(key));
+ xbt_test_log2("Add %s under %s", PRINTF_STR(data_to_fill),
+ PRINTF_STR(key));
xbt_dict_set(head, key, data, &free);
if (XBT_LOG_ISENABLED(xbt_dict, xbt_log_priority_debug)) {
TRY {
data = xbt_dict_get(head, data);
- THROW1(unknown_error, 0, "Found something which shouldn't be there (%s)",
- data);
+ THROW1(unknown_error, 0,
+ "Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
length);
xbt_dict_foreach(dict, cursor, key, data)
- effective++;
+ effective++;
xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
effective, length);
static void count_check_get_key(xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
- char *key,*key2;
+ char *key, *key2;
void *data;
int effective = 0;
- xbt_test_add1("Count elements (expecting %d), and test the getkey function", length);
+ xbt_test_add1
+ ("Count elements (expecting %d), and test the getkey function",
+ length);
xbt_test_assert2(xbt_dict_length(dict) == length,
"Announced length(%d) != %d.", xbt_dict_length(dict),
length);
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
- key2 = xbt_dict_get_key(dict,data);
- xbt_assert2(!strcmp(key,key2),
- "The data was registered under %s instead of %s as expected",key2,key);
+ key2 = xbt_dict_get_key(dict, data);
+ xbt_assert2(!strcmp(key, key2),
+ "The data was registered under %s instead of %s as expected",
+ key2, key);
}
xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
char *data;
-XBT_TEST_UNIT("basic", test_dict_basic,"Basic usage: change, retrieve, traverse")
+XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve, traverse")
{
xbt_test_add0("Traversal the null dictionary");
traverse(head);
xbt_dict_free(&head);
xbt_test_add0
- ("Remove each data manually (traversing the resulting dictionary each time)");
+ ("Remove each data manually (traversing the resulting dictionary each time)");
fill(&head);
debuged_remove(head, "12a");
traverse(head);
}
traverse(head);
- xbt_test_add0("Free dict, create new fresh one, and then reset the dict");
+ xbt_test_add0
+ ("Free dict, create new fresh one, and then reset the dict");
xbt_dict_free(&head);
fill(&head);
xbt_dict_reset(head);
xbt_dict_free(&head);
}
-static void debuged_addi(xbt_dict_t head, uintptr_t key, uintptr_t data) {
- uintptr_t stored_data = 0;
+static void debuged_addi(xbt_dict_t head, uintptr_t key, uintptr_t data)
+{
+ uintptr_t stored_data = 0;
xbt_test_log2("Add %zu under %zu", data, key);
xbt_dicti_set(head, key, data);
fflush(stdout);
}
stored_data = xbt_dicti_get(head, key);
- xbt_test_assert3(stored_data==data,
- "Retrieved data (%zu) is not what I just stored (%zu) under key %zu",stored_data,data,key);
+ xbt_test_assert3(stored_data == data,
+ "Retrieved data (%zu) is not what I just stored (%zu) under key %zu",
+ stored_data, data, key);
}
XBT_TEST_UNIT("dicti", test_dict_scalar, "Scalar data and key management")
for (i = 0; i < 10; i++) {
xbt_test_add2("CRASH test number %d (%d to go)", i + 1, 10 - i - 1);
- xbt_test_log0("Fill the struct, count its elems and frees the structure");
- xbt_test_log1("using 1000 elements with %d chars long randomized keys.",
- SIZEOFKEY);
+ xbt_test_log0
+ ("Fill the struct, count its elems and frees the structure");
+ xbt_test_log1
+ ("using 1000 elements with %d chars long randomized keys.",
+ SIZEOFKEY);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
nb = 0;
}
/*xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0("Count the elements (retrieving the key and data for each)");
+ xbt_test_add0
+ ("Count the elements (retrieving the key and data for each)");
i = countelems(head);
xbt_test_log1("There is %d elements", i);
"with get, key=%s != data=%s", key, (char *) data);
data = xbt_dict_get_ext(head, key, strlen(key));
xbt_test_assert2(!strcmp(key, (char *) data),
- "with get_ext, key=%s != data=%s", key, (char *) data);
+ "with get_ext, key=%s != data=%s", key,
+ (char *) data);
}
}
free(key);
xbt_test_add0("Generic multicache CRASH test");
- xbt_test_log4(" Fill the struct and frees it %d times, using %d elements, "
- "depth of multicache=%d, key size=%d",
- NB_TEST, NB_ELM, DEPTH, KEY_SIZE);
+ xbt_test_log4
+ (" Fill the struct and frees it %d times, using %d elements, "
+ "depth of multicache=%d, key size=%d", NB_TEST, NB_ELM, DEPTH,
+ KEY_SIZE);
for (l = 0; l < DEPTH; l++) {
key = xbt_malloc(KEY_SIZE);
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 716 "xbt/dynar.c"
+#line 730 "xbt/dynar.c"
#define NB_ELEM 5000
xbt_dynar_foreach(d, cursor, i) {
xbt_assert0(0, "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1
- ("==== Push %d int, set them again 3 times, traverse them, shift them",
- NB_ELEM);
+ ("==== Push %d int, set them again 3 times, traverse them, shift them",
+ NB_ELEM);
/* Populate_ints [doxygen cruft] */
/* 1. Populate the dynar */
d = xbt_dynar_new(sizeof(int), NULL);
}
/* 5. Free the resources */
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Unshift/pop %d int", NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
i, cpt);
xbt_test_log2("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1
- ("==== Push %d int, insert 1000 int in the middle, shift everything",
- NB_ELEM);
+ ("==== Push %d int, insert 1000 int in the middle, shift everything",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt);
"The retrieved value is not the same than the injected one at the end (%d!=%d)",
i, cpt);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest", NB_ELEM);
+ xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++)
xbt_dynar_push_as(d, int, cpt);
"Remove a bad value. Got %d, expected %d", i, cpt);
DEBUG2("remove %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
}
/*******************************************************************************/
xbt_test_add0("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(int), NULL);
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert0(FALSE, "Damnit, there is something in the empty dynar");
+ xbt_test_assert0(FALSE,
+ "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Push/shift 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Unshift/pop 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0
- ("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
+ ("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
"The retrieved value is not the same than the injected one at the end (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Push 5000 double, remove 2000-4000. free the rest");
xbt_test_assert2(d1 == d2,
"Remove a bad value. Got %f, expected %f", d2, d1);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
}
xbt_test_add0("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
xbt_dynar_foreach(d, iter, s1) {
- xbt_test_assert0(FALSE, "Damnit, there is something in the empty dynar");
+ xbt_test_assert0(FALSE,
+ "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",
NB_ELEM);
buf, s2);
free(s2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Unshift, traverse and pop %d strings", NB_ELEM);
d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
free(s2);
}
/* 4. Free the resources */
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add2
- ("==== Push %d strings, insert %d strings in the middle, shift everything",
- NB_ELEM, NB_ELEM / 5);
+ ("==== Push %d strings, insert %d strings in the middle, shift everything",
+ NB_ELEM, NB_ELEM / 5);
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
buf, s2);
free(s2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
- xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest", NB_ELEM,
- 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
+ xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",
+ NB_ELEM, 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
}
-XBT_TEST_UNIT("synchronized int", test_dynar_sync_int,"Synchronized dynars of integers")
+XBT_TEST_UNIT("synchronized int", test_dynar_sync_int, "Synchronized dynars of integers")
{
/* Vars_decl [doxygen cruft] */
xbt_dynar_t d;
xbt_test_add0("==== Have a pusher and a popper on the dynar");
d = xbt_dynar_new_sync(sizeof(int), NULL);
- pusher = xbt_thread_create("pusher", pusher_f, d,0/*not joinable*/);
- poper = xbt_thread_create("poper", poper_f, d,0/*not joinable*/);
+ pusher = xbt_thread_create("pusher", pusher_f, d, 0 /*not joinable */ );
+ poper = xbt_thread_create("poper", poper_f, d, 0 /*not joinable */ );
xbt_thread_join(pusher);
xbt_thread_join(poper);
xbt_dynar_free(&d);
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
- } TRY_CLEANUP { /*04 */
+ } TRY_CLEANUP { /*04 */
printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
if (cp3 != NULL)
free(cp3);
gras_cbps_v_pop(gras_cbps_t ps,
const char *name, gras_datadesc_type_t * ddt, void **res)
{
- xbt_dynar_t varstack=NULL, frame=NULL;
+ xbt_dynar_t varstack = NULL, frame = NULL;
gras_cbps_elm_t var = NULL;
void *data = NULL;
xbt_ex_t e;
/* ************************* */
/** \brief Cb to push an integer. Must be attached to the field you want to push */
-void gras_datadesc_cb_push_int(gras_datadesc_type_t ignored, gras_cbps_t vars,
- void *data)
+void gras_datadesc_cb_push_int(gras_datadesc_type_t ignored,
+ gras_cbps_t vars, void *data)
{
int *i = (int *) data;
gras_cbps_i_push(vars, (int) *i);
/* specific datatype: the exception type (for RPC) */
ddt = gras_datadesc_struct("ex_t");
gras_datadesc_struct_append(ddt, "msg", gras_datadesc_by_name("string"));
- gras_datadesc_struct_append(ddt, "category", gras_datadesc_by_name("int"));
+ gras_datadesc_struct_append(ddt, "category",
+ gras_datadesc_by_name("int"));
gras_datadesc_struct_append(ddt, "value", gras_datadesc_by_name("int"));
gras_datadesc_struct_append(ddt, "remote",
gras_datadesc_by_name("short int"));
- gras_datadesc_struct_append(ddt, "host", gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt, "host",
+ gras_datadesc_by_name("string"));
gras_datadesc_struct_append(ddt, "procname",
gras_datadesc_by_name("string"));
- gras_datadesc_struct_append(ddt, "pid", gras_datadesc_by_name("long int"));
- gras_datadesc_struct_append(ddt, "file", gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt, "pid",
+ gras_datadesc_by_name("long int"));
+ gras_datadesc_struct_append(ddt, "file",
+ gras_datadesc_by_name("string"));
gras_datadesc_struct_append(ddt, "line", gras_datadesc_by_name("int"));
- gras_datadesc_struct_append(ddt, "func", gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt, "func",
+ gras_datadesc_by_name("string"));
gras_datadesc_struct_append(ddt, "used", gras_datadesc_by_name("int"));
gras_datadesc_cb_field_push(ddt, "used");
gras_datadesc_struct_append(ddt, "bt_strings",
- gras_datadesc_ref_pop_arr(gras_datadesc_by_name
- ("string")));
+ gras_datadesc_ref_pop_arr
+ (gras_datadesc_by_name("string")));
gras_datadesc_struct_close(ddt);
/* specific datatype: xbt_peer_t */
ddt = gras_datadesc_struct("s_xbt_peer_t");
- gras_datadesc_struct_append(ddt, "name", gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt, "name",
+ gras_datadesc_by_name("string"));
gras_datadesc_struct_append(ddt, "port", gras_datadesc_by_name("int"));
gras_datadesc_struct_close(ddt);
void *dst);
/* Described data exchanges: IDL compilation FIXME: not implemented*/
- void gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src,
- void **dst);
- void gras_datadesc_gen_send(gras_socket_t sock,
- gras_datadesc_type_t type, void *src);
- void gras_datadesc_gen_recv(gras_socket_t sock,
- gras_datadesc_type_t type, int r_arch,
- void *dst);
+void gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src,
+ void **dst);
+void gras_datadesc_gen_send(gras_socket_t sock,
+ gras_datadesc_type_t type, void *src);
+void gras_datadesc_gen_recv(gras_socket_t sock,
+ gras_datadesc_type_t type, int r_arch,
+ void *dst);
-#endif /* GRAS_DATADESC_INTERFACE_H */
+#endif /* GRAS_DATADESC_INTERFACE_H */
********************************************************************/
extern xbt_dict_t gras_dd_constants; /* lives in ddt_parse.c of course */
-#endif /* GRAS_DATADESC_PRIVATE_H */
+#endif /* GRAS_DATADESC_PRIVATE_H */
/**
* Local function doing the grunt work
*/
-static void gras_dd_reverse_bytes(void *to, const void *from, size_t length);
+static void gras_dd_reverse_bytes(void *to, const void *from,
+ size_t length);
/**
* gras_dd_convert_elm:
r_size = type->size[r_arch];
l_size = type->size[GRAS_THISARCH];
- DEBUG4("r_size=%lu l_size=%lu, src=%p dst=%p", r_size, l_size, src, dst);
+ DEBUG4("r_size=%lu l_size=%lu, src=%p dst=%p", r_size, l_size, src,
+ dst);
DEBUG2("remote=%c local=%c", gras_arches[r_arch].endian ? 'B' : 'l',
gras_arches[GRAS_THISARCH].endian ? 'B' : 'l');
int padding;
int sizeChange = l_size - r_size;
int lowOrderFirst = !gras_arches[r_arch].endian ||
- gras_arches[r_arch].endian == gras_arches[GRAS_THISARCH].endian;
+ gras_arches[r_arch].endian == gras_arches[GRAS_THISARCH].endian;
DEBUG5("Resize integer %d from %lu @%p to %lu @%p",
cpt, r_size, r_data, l_size, l_data);
DEBUG0("This is signed");
/* Make sure the high order bit of r_data and l_data are the same */
l_sign = gras_arches[GRAS_THISARCH].endian
- ? ((unsigned char *) l_data + l_size - 1)
- : (unsigned char *) l_data;
+ ? ((unsigned char *) l_data + l_size - 1)
+ : (unsigned char *) l_data;
r_sign = gras_arches[r_arch].endian
- ? ((unsigned char *) r_data + r_size - 1)
- : (unsigned char *) r_data;
+ ? ((unsigned char *) r_data + r_size - 1)
+ : (unsigned char *) r_data;
DEBUG2("This is signed (r_sign=%c l_sign=%c", *r_sign, *l_sign);
if ((*r_sign > 127) != (*l_sign > 127)) {
} else {
/* extend sign */
r_sign =
- gras_arches[r_arch].endian ? ((unsigned char *) r_data + r_size -
- 1)
- : (unsigned char *) r_data;
+ gras_arches[r_arch].endian ? ((unsigned char *) r_data +
+ r_size - 1)
+ : (unsigned char *) r_data;
padding = (*r_sign > 127) ? 0xff : 0;
}
}
-static void gras_dd_reverse_bytes(void *to, const void *from, size_t length)
+static void gras_dd_reverse_bytes(void *to, const void *from,
+ size_t length)
{
char charBegin;
res->name_len = strlen(name);
res->cycle = 0;
- xbt_set_add(gras_datadesc_set_local, (xbt_set_elm_t) res, gras_ddt_freev);
+ xbt_set_add(gras_datadesc_set_local, (xbt_set_elm_t) res,
+ gras_ddt_freev);
XBT_OUT;
return res;
}
volatile int found = 0;
TRY {
res =
- (gras_datadesc_type_t) xbt_set_get_by_name(gras_datadesc_set_local,
- name);
+ (gras_datadesc_type_t) xbt_set_get_by_name(gras_datadesc_set_local,
+ name);
found = 1;
} CATCH(e) {
if (e.category != not_found_error)
gras_datadesc_type_t res = NULL;
TRY {
res =
- (gras_datadesc_type_t) xbt_set_get_by_id(gras_datadesc_set_local, code);
+ (gras_datadesc_type_t) xbt_set_get_by_id(gras_datadesc_set_local,
+ code);
} CATCH(e) {
if (e.category != not_found_error)
RETHROW;
res->size[arch] = gras_arches[arch].sizeofs[type];
res->alignment[arch] = gras_arches[arch].boundaries[type];
res->aligned_size[arch] =
- ddt_aligned(res->size[arch], res->alignment[arch]);
+ ddt_aligned(res->size[arch], res->alignment[arch]);
}
res->category_code = e_gras_datadesc_type_cat_scalar;
}
res->category_code = e_gras_datadesc_type_cat_struct;
res->category.struct_data.fields =
- xbt_dynar_new(sizeof(gras_dd_cat_field_t), gras_dd_cat_field_free);
+ xbt_dynar_new(sizeof(gras_dd_cat_field_t), gras_dd_cat_field_free);
XBT_OUT;
return res;
/** \brief Append a new field to a structure description */
void
gras_datadesc_struct_append(gras_datadesc_type_t struct_type,
- const char *name, gras_datadesc_type_t field_type)
+ const char *name,
+ gras_datadesc_type_t field_type)
{
gras_dd_cat_field_t field;
XBT_IN3("(%s %s.%s;)", field_type->name, struct_type->name, name);
if (struct_type->category.struct_data.closed) {
VERB1
- ("Ignoring request to add field to struct %s (closed. Redefinition?)",
- struct_type->name);
+ ("Ignoring request to add field to struct %s (closed. Redefinition?)",
+ struct_type->name);
return;
}
xbt_dynar_push(struct_type->category.struct_data.fields, &field);
DEBUG3("Push a %s into %s at offset %ld.",
- field_type->name, struct_type->name, field->offset[GRAS_THISARCH]);
+ field_type->name, struct_type->name,
+ field->offset[GRAS_THISARCH]);
DEBUG3(" f={size=%ld,align=%ld,asize=%ld}",
field_type->size[GRAS_THISARCH],
field_type->alignment[GRAS_THISARCH],
res->category_code = e_gras_datadesc_type_cat_union;
res->category.union_data.fields =
- xbt_dynar_new(sizeof(gras_dd_cat_field_t *), gras_dd_cat_field_free);
+ xbt_dynar_new(sizeof(gras_dd_cat_field_t *), gras_dd_cat_field_free);
res->category.union_data.selector = selector;
return res;
union_type->alignment[arch] = max(union_type->alignment[arch],
field_type->alignment[arch]);
union_type->aligned_size[arch] = ddt_aligned(union_type->size[arch],
- union_type->alignment[arch]);
+ union_type->alignment
+ [arch]);
}
}
{
gras_datadesc_type_t res;
- gras_datadesc_type_t pointer_type = gras_datadesc_by_name("data pointer");
+ gras_datadesc_type_t pointer_type =
+ gras_datadesc_by_name("data pointer");
int arch;
XBT_IN1("(%s)", name);
* callback and expects it to return the type description to use.
*/
gras_datadesc_type_t
-gras_datadesc_ref_generic(const char *name, gras_datadesc_selector_t selector)
+gras_datadesc_ref_generic(const char *name,
+ gras_datadesc_selector_t selector)
{
gras_datadesc_type_t res;
- gras_datadesc_type_t pointer_type = gras_datadesc_by_name("data pointer");
+ gras_datadesc_type_t pointer_type =
+ gras_datadesc_by_name("data pointer");
int arch;
XBT_IN1("(%s)", name);
"Redefinition of type %s does not match", name);
if (res->category.array_data.type != element_type) {
- ERROR1("Redefinition of type %s does not match: array elements differ",
- name);
+ ERROR1
+ ("Redefinition of type %s does not match: array elements differ",
+ name);
gras_datadesc_type_dump(res->category.array_data.type);
gras_datadesc_type_dump(element_type);
}
gras_datadesc_type_t
gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type)
{
- int cpt=0;
- gras_datadesc_type_t res,ddt2;
+ int cpt = 0;
+ gras_datadesc_type_t res, ddt2;
char *name = (char *) xbt_malloc(strlen(element_type->name) + 4);
sprintf(name, "%s[]", element_type->name);
while (ddt2) {
free(name);
- name=bprintf("%s[]_%d",element_type->name,cpt++);
- ddt2=gras_datadesc_by_name_or_null(name);
+ name = bprintf("%s[]_%d", element_type->name, cpt++);
+ ddt2 = gras_datadesc_by_name_or_null(name);
}
res = gras_datadesc_array_dyn(name, element_type, gras_datadesc_cb_pop);
sprintf(name, "%s[]*", element_type->name);
- cpt=0;
+ cpt = 0;
ddt2 = gras_datadesc_by_name_or_null(name);
while (ddt2) {
free(name);
- name=bprintf("%s[]*_%d",element_type->name,cpt++);
- ddt2=gras_datadesc_by_name_or_null(name);
+ name = bprintf("%s[]*_%d", element_type->name, cpt++);
+ ddt2 = gras_datadesc_by_name_or_null(name);
}
res = gras_datadesc_ref(name, res);
gras_datadesc_struct_append(res, "elmsize",
gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_struct_append(res, "data", gras_datadesc_ref_pop_arr(elm_t));
+ gras_datadesc_struct_append(res, "data",
+ gras_datadesc_ref_pop_arr(elm_t));
gras_datadesc_struct_append(res, "free_f",
gras_datadesc_by_name("function pointer"));
}
gras_datadesc_type_t
-gras_datadesc_matrix(gras_datadesc_type_t elm_t, void_f_pvoid_t const free_f)
+gras_datadesc_matrix(gras_datadesc_type_t elm_t,
+ void_f_pvoid_t const free_f)
{
char *buffname;
gras_datadesc_type_t res;
gras_datadesc_struct_append(res, "elmsize",
gras_datadesc_by_name("unsigned long int"));
- gras_datadesc_struct_append(res, "data", gras_datadesc_ref_pop_arr(elm_t));
+ gras_datadesc_struct_append(res, "data",
+ gras_datadesc_ref_pop_arr(elm_t));
gras_datadesc_struct_append(res, "free_f",
gras_datadesc_by_name("function pointer"));
gras_datadesc_struct_close(res);
gras_datadesc_type_t
gras_datadesc_import_nws(const char *name,
- const DataDescriptor * desc, unsigned long howmany)
+ const DataDescriptor * desc,
+ unsigned long howmany)
{
THROW_UNIMPLEMENTED;
}
field->send = gras_datadesc_cb_push_ulint;
} else {
ERROR1
- ("Field %s is not an int, unsigned int, long int neither unsigned long int",
- sub_type->name);
+ ("Field %s is not an int, unsigned int, long int neither unsigned long int",
+ sub_type->name);
xbt_abort();
}
}
field->send = gras_datadesc_cb_push_ulint_mult;
} else {
ERROR1
- ("Field %s is not an int, unsigned int, long int neither unsigned long int",
- sub_type->name);
+ ("Field %s is not an int, unsigned int, long int neither unsigned long int",
+ sub_type->name);
xbt_abort();
}
}
if (d1->aligned_size[cpt] != d2->aligned_size[cpt]) {
DEBUG5
- ("ddt_cmp: %s->aligned_size=%ld != %s->aligned_size=%ld (on %s)",
- d1->name, d1->aligned_size[cpt], d2->name, d2->aligned_size[cpt],
- gras_arches[cpt].name);
+ ("ddt_cmp: %s->aligned_size=%ld != %s->aligned_size=%ld (on %s)",
+ d1->name, d1->aligned_size[cpt], d2->name,
+ d2->aligned_size[cpt], gras_arches[cpt].name);
return d1->aligned_size[cpt] > d2->aligned_size[cpt] ? 1 : -1;
}
}
if (d1->category.scalar_data.encoding !=
d2->category.scalar_data.encoding)
return d1->category.scalar_data.encoding >
- d2->category.scalar_data.encoding ? 1 : -1;
+ d2->category.scalar_data.encoding ? 1 : -1;
break;
case e_gras_datadesc_type_cat_struct:
d2->name, xbt_dynar_length(d2->category.struct_data.fields));
return xbt_dynar_length(d1->category.struct_data.fields) >
- xbt_dynar_length(d2->category.struct_data.fields) ? 1 : -1;
+ xbt_dynar_length(d2->category.struct_data.fields) ? 1 : -1;
}
xbt_dynar_foreach(d1->category.struct_data.fields, cpt, field1) {
field2 =
- xbt_dynar_get_as(d2->category.struct_data.fields, cpt,
- gras_dd_cat_field_t);
+ xbt_dynar_get_as(d2->category.struct_data.fields, cpt,
+ gras_dd_cat_field_t);
field_desc_1 = field1->type;
field_desc_2 = field2->type;
ret = gras_datadesc_type_cmp(field_desc_1, field_desc_2);
break;
case e_gras_datadesc_type_cat_union:
- if (d1->category.union_data.selector != d2->category.union_data.selector)
+ if (d1->category.union_data.selector !=
+ d2->category.union_data.selector)
return 1; /* ISO C forbids ordered comparisons of pointers to functions */
if (xbt_dynar_length(d1->category.union_data.fields) !=
xbt_dynar_length(d2->category.union_data.fields))
return xbt_dynar_length(d1->category.union_data.fields) >
- xbt_dynar_length(d2->category.union_data.fields) ? 1 : -1;
+ xbt_dynar_length(d2->category.union_data.fields) ? 1 : -1;
xbt_dynar_foreach(d1->category.union_data.fields, cpt, field1) {
field2 =
- xbt_dynar_get_as(d2->category.union_data.fields, cpt,
- gras_dd_cat_field_t);
+ xbt_dynar_get_as(d2->category.union_data.fields, cpt,
+ gras_dd_cat_field_t);
field_desc_1 = field1->type;
field_desc_2 = field2->type;
ret = gras_datadesc_type_cmp(field_desc_1, field_desc_2);
return 1; /* ISO C forbids ordered comparisons of pointers to functions */
if (d1->category.ref_data.type != d2->category.ref_data.type)
- return d1->category.ref_data.type > d2->category.ref_data.type ? 1 : -1;
+ return d1->category.ref_data.type >
+ d2->category.ref_data.type ? 1 : -1;
break;
case e_gras_datadesc_type_cat_array:
if (d1->category.array_data.type != d2->category.array_data.type)
return d1->category.array_data.type >
- d2->category.array_data.type ? 1 : -1;
+ d2->category.array_data.type ? 1 : -1;
if (d1->category.array_data.fixed_size !=
d2->category.array_data.fixed_size)
return d1->category.array_data.fixed_size >
- d2->category.array_data.fixed_size ? 1 : -1;
+ d2->category.array_data.fixed_size ? 1 : -1;
if (d1->category.array_data.dynamic_size !=
d2->category.array_data.dynamic_size)
l_data = xbt_malloc((size_t) size);
*l_ref = l_data;
- DEBUG5("alloc_ref: l_data=%p, &l_data=%p; r_ref=%p; *r_ref=%p, r_len=%ld",
- (void *) l_data, (void *) &l_data,
- (void *) r_ref, (void *) (r_ref ? *r_ref : NULL), r_len);
+ DEBUG5
+ ("alloc_ref: l_data=%p, &l_data=%p; r_ref=%p; *r_ref=%p, r_len=%ld",
+ (void *) l_data, (void *) &l_data, (void *) r_ref,
+ (void *) (r_ref ? *r_ref : NULL), r_len);
if (detect_cycle && r_ref && !gras_dd_is_r_null(r_ref, r_len)) {
void *ptr = xbt_malloc(sizeof(void *));
gras_datadesc_memcpy_rec(gras_cbps_t state,
xbt_dict_t refs,
gras_datadesc_type_t type,
- char *src, char *dst, int subsize, int detect_cycle)
+ char *src, char *dst, int subsize,
+ int detect_cycle)
{
DEBUG1("Copy field %s", field->name);
count +=
- gras_datadesc_memcpy_rec(state, refs, sub_type, field_src,
- field_dst, 0, detect_cycle
- || sub_type->cycle);
+ gras_datadesc_memcpy_rec(state, refs, sub_type, field_src,
+ field_dst, 0, detect_cycle
+ || sub_type->cycle);
if (XBT_LOG_ISENABLED(gras_ddt_exchange, xbt_log_priority_verbose)) {
if (sub_type == gras_datadesc_by_name("unsigned int")) {
VERB2("Copied value for field '%s': %d (type: unsigned int)",
field->name, *(unsigned int *) field_dst);
} else if (sub_type == gras_datadesc_by_name("int")) {
- VERB2("Copied value for field '%s': %d (type: int)", field->name,
- *(int *) field_dst);
+ VERB2("Copied value for field '%s': %d (type: int)",
+ field->name, *(int *) field_dst);
- } else if (sub_type == gras_datadesc_by_name("unsigned long int")) {
+ } else if (sub_type ==
+ gras_datadesc_by_name("unsigned long int")) {
VERB2
- ("Copied value for field '%s': %ld (type: unsigned long int)",
- field->name, *(unsigned long int *) field_dst);
+ ("Copied value for field '%s': %ld (type: unsigned long int)",
+ field->name, *(unsigned long int *) field_dst);
} else if (sub_type == gras_datadesc_by_name("long int")) {
VERB2("Copied value for field '%s': %ld (type: long int)",
field->name, *(long int *) field_dst);
xbt_assert3(field_num < xbt_dynar_length(union_data.fields),
"union field selector of %s returned %d but there is only %lu fields",
- type->name, field_num, xbt_dynar_length(union_data.fields));
+ type->name, field_num,
+ xbt_dynar_length(union_data.fields));
/* Copy the content */
field =
- xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
+ xbt_dynar_get_as(union_data.fields, field_num,
+ gras_dd_cat_field_t);
sub_type = field->type;
if (field->send)
reference_is_to_cpy = 1;
if (detect_cycle &&
- (n_ref=xbt_dict_get_or_null_ext(refs, (char *) o_ref, sizeof(char *)))) {
+ (n_ref =
+ xbt_dict_get_or_null_ext(refs, (char *) o_ref,
+ sizeof(char *)))) {
/* already known, no need to copy it */
//INFO0("Cycle detected");
reference_is_to_cpy = 0;
subsub_type = array_data.type;
subsubcount = array_data.fixed_size;
if (subsubcount == -1)
- subsubcount = array_data.dynamic_size(subsub_type, state, *o_ref);
+ subsubcount =
+ array_data.dynamic_size(subsub_type, state, *o_ref);
if (subsubcount != 0)
gras_dd_alloc_ref(refs,
- subsub_type->size[GRAS_THISARCH] * subsubcount,
- o_ref, pointer_type->size[GRAS_THISARCH],
+ subsub_type->size[GRAS_THISARCH] *
+ subsubcount, o_ref,
+ pointer_type->size[GRAS_THISARCH],
(char **) &l_referenced, detect_cycle);
} else {
gras_dd_alloc_ref(refs, sub_type->size[GRAS_THISARCH],
} else {
VERB2
- ("NOT copying data previously referenced @%p (already done, @%p now)",
- *(void **) o_ref, *(void **) n_ref);
+ ("NOT copying data previously referenced @%p (already done, @%p now)",
+ *(void **) o_ref, *(void **) n_ref);
*(void **) dst = *n_ref;
if (array_count == -1) {
array_count = array_data.dynamic_size(type, state, src);
xbt_assert1(array_count >= 0,
- "Invalid (negative) array size for type %s", type->name);
+ "Invalid (negative) array size for type %s",
+ type->name);
}
/* send the content */
elm_size = sub_type->aligned_size[GRAS_THISARCH];
if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) {
VERB1("Array of %ld scalars, copy it in one shot", array_count);
- memcpy(dst, src, sub_type->aligned_size[GRAS_THISARCH] * array_count);
+ memcpy(dst, src,
+ sub_type->aligned_size[GRAS_THISARCH] * array_count);
count += sub_type->aligned_size[GRAS_THISARCH] * array_count;
- } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
- sub_type->category.array_data.fixed_size > 0 &&
- sub_type->category.array_data.type->category_code ==
+ } else if (sub_type->category_code == e_gras_datadesc_type_cat_array
+ && sub_type->category.array_data.fixed_size > 0
+ && sub_type->category.array_data.type->category_code ==
e_gras_datadesc_type_cat_scalar) {
VERB1("Array of %ld fixed array of scalars, copy it in one shot",
array_count);
memcpy(dst, src,
- sub_type->category.array_data.type->aligned_size[GRAS_THISARCH]
+ sub_type->category.array_data.
+ type->aligned_size[GRAS_THISARCH]
* array_count * sub_type->category.array_data.fixed_size);
count +=
- sub_type->category.array_data.type->aligned_size[GRAS_THISARCH]
- * array_count * sub_type->category.array_data.fixed_size;
+ sub_type->category.array_data.type->aligned_size[GRAS_THISARCH]
+ * array_count * sub_type->category.array_data.fixed_size;
} else {
VERB1("Array of %ld stuff, copy it in one after the other",
for (cpt = 0; cpt < array_count; cpt++) {
VERB2("Copy the %dth stuff out of %ld", cpt, array_count);
count +=
- gras_datadesc_memcpy_rec(state, refs, sub_type, src_ptr, dst_ptr,
- 0, detect_cycle || sub_type->cycle);
+ gras_datadesc_memcpy_rec(state, refs, sub_type, src_ptr,
+ dst_ptr, 0, detect_cycle
+ || sub_type->cycle);
src_ptr += elm_size;
dst_ptr += elm_size;
}
}
TRY {
- size = gras_datadesc_memcpy_rec(state, refs, type, (char *) src, (char *) dst,0, type->cycle);
+ size =
+ gras_datadesc_memcpy_rec(state, refs, type, (char *) src,
+ (char *) dst, 0, type->cycle);
} TRY_CLEANUP {
xbt_dict_reset(refs);
gras_cbps_reset(state);
xbt_assert3(field_num < xbt_dynar_length(union_data.fields),
"union field selector of %s returned %d but there is only %lu fields",
- type->name, field_num, xbt_dynar_length(union_data.fields));
+ type->name, field_num,
+ xbt_dynar_length(union_data.fields));
/* Send the field number */
gras_dd_send_int(sock, &field_num, 0 /* not stable */ );
/* Send the content */
field =
- xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
+ xbt_dynar_get_as(union_data.fields, field_num,
+ gras_dd_cat_field_t);
sub_type = field->type;
if (field->send)
reference_is_to_send = 1;
/* return ignored. Just checking whether it's known or not */
- if (detect_cycle && xbt_dict_get_or_null_ext(refs, (char *) ref, sizeof(char *))) {
+ if (detect_cycle
+ && xbt_dict_get_or_null_ext(refs, (char *) ref,
+ sizeof(char *))) {
//INFO0("Cycle detected");
reference_is_to_send = 0;
}
if (count == -1) {
count = array_data.dynamic_size(type, state, data);
xbt_assert1(count >= 0,
- "Invalid (negative) array size for type %s", type->name);
+ "Invalid (negative) array size for type %s",
+ type->name);
gras_dd_send_int(sock, &count, 0 /*non-stable */ );
}
gras_trp_send(sock, data,
sub_type->aligned_size[GRAS_THISARCH] * count,
0 /* not stable */ );
- } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
- sub_type->category.array_data.fixed_size > 0 &&
- sub_type->category.array_data.type->category_code ==
+ } else if (sub_type->category_code == e_gras_datadesc_type_cat_array
+ && sub_type->category.array_data.fixed_size > 0
+ && sub_type->category.array_data.type->category_code ==
e_gras_datadesc_type_cat_scalar) {
VERB1("Array of %d fixed array of scalars, send it in one shot",
/* Recv the content */
field =
- xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
+ xbt_dynar_get_as(union_data.fields, field_num,
+ gras_dd_cat_field_t);
sub_type = field->type;
gras_datadesc_recv_rec(sock, state, refs, sub_type,
reference_is_to_recv = 1;
if (detect_cycle && (l_ref =
- xbt_dict_get_or_null_ext(refs, (char *) r_ref,
- pointer_type->size[r_arch]))) {
+ xbt_dict_get_or_null_ext(refs, (char *) r_ref,
+ pointer_type->size
+ [r_arch]))) {
reference_is_to_recv = 0;
//INFO0("Cycle detected");
}
if (subsubcount != 0)
gras_dd_alloc_ref(refs,
- subsub_type->size[GRAS_THISARCH] * subsubcount,
- r_ref, pointer_type->size[r_arch],
+ subsub_type->size[GRAS_THISARCH] *
+ subsubcount, r_ref,
+ pointer_type->size[r_arch],
(char **) &l_referenced, detect_cycle);
else
l_referenced = NULL;
} else {
VERB2
- ("NOT receiving data remotely referenced @%p (already done, @%p here)",
- *(void **) r_ref, *(void **) l_ref);
+ ("NOT receiving data remotely referenced @%p (already done, @%p here)",
+ *(void **) r_ref, *(void **) l_ref);
*(void **) l_data = *l_ref;
} else {
ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
- gras_trp_recv(sock, (char *) ptr, sub_type->size[r_arch] * count);
+ gras_trp_recv(sock, (char *) ptr,
+ sub_type->size[r_arch] * count);
if (r_arch != GRAS_THISARCH)
gras_dd_convert_elm(sub_type, count, r_arch, ptr, l_data);
free(ptr);
}
- } else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
- sub_type->category.array_data.fixed_size >= 0 &&
- sub_type->category.array_data.type->category_code ==
+ } else if (sub_type->category_code == e_gras_datadesc_type_cat_array
+ && sub_type->category.array_data.fixed_size >= 0
+ && sub_type->category.array_data.type->category_code ==
e_gras_datadesc_type_cat_scalar) {
gras_datadesc_type_t subsub_type;
array_data = sub_type->category.array_data;
r_arch, l_data, l_data);
} else {
ptr =
- xbt_malloc(subsub_type->aligned_size[r_arch] * count *
- array_data.fixed_size);
+ xbt_malloc(subsub_type->aligned_size[r_arch] * count *
+ array_data.fixed_size);
gras_trp_recv(sock, (char *) ptr,
subsub_type->size[r_arch] * count *
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1
- ("Unparsable symbol: found a typeless statement (got '%s' instead)",
- gras_ddt_parse_text);
+ ("Unparsable symbol: found a typeless statement (got '%s' instead)",
+ gras_ddt_parse_text);
/**** get the type modifier of this statement ****/
parse_type_modifier(&identifier.tm);
if (identifier.tm.is_union || identifier.tm.is_enum
|| identifier.tm.is_struct)
PARSE_ERROR0
- ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle recursive type definition yet");
+ ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle recursive type definition yet");
/**** get the base type, giving "short a" the needed love ****/
if (!identifier.tm.is_union &&
/**** build the base type for latter use ****/
if (identifier.tm.is_union) {
PARSE_ERROR0
- ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle union yet (get callback from annotation?)");
+ ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle union yet (get callback from annotation?)");
} else if (identifier.tm.is_enum) {
PARSE_ERROR0
- ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle enum yet");
+ ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle enum yet");
} else if (identifier.tm.is_struct) {
sprintf(buffname, "struct %s", identifier.type_name);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RB) {
PARSE_ERROR0
- ("Unimplemented feature: GRAS_DEFINE_TYPE cannot deal with [] constructs (yet)");
+ ("Unimplemented feature: GRAS_DEFINE_TYPE cannot deal with [] constructs (yet)");
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
char *end;
if (end == gras_ddt_parse_text || *end != '\0') {
/* Not a number. Get the constant value, if any */
- int *storage =
- xbt_dict_get_or_null(gras_dd_constants, gras_ddt_parse_text);
+ int *storage = xbt_dict_get_or_null(gras_dd_constants,
+ gras_ddt_parse_text);
if (storage) {
size = *storage;
} else {
PARSE_ERROR1
- ("Unparsable size of array. Found '%s', expected number or known constant. Need to use gras_datadesc_set_const(), huh?",
- gras_ddt_parse_text);
+ ("Unparsable size of array. Found '%s', expected number or known constant. Need to use gras_datadesc_set_const(), huh?",
+ gras_ddt_parse_text);
}
}
char *keyval = NULL;
memset(&array, 0, sizeof(array));
if (strcmp(gras_ddt_parse_text, "GRAS_ANNOTE"))
- PARSE_ERROR1("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",
- gras_ddt_parse_text);
+ PARSE_ERROR1
+ ("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",
+ gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP)
PARSE_ERROR1
- ("Unparsable annotation: Expected parenthesis, got '%s'",
- gras_ddt_parse_text);
+ ("Unparsable annotation: Expected parenthesis, got '%s'",
+ gras_ddt_parse_text);
while ((gras_ddt_parse_tok_num =
- gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+ gras_ddt_parse_lex_n_dump()) ==
+ GRAS_DDT_PARSE_TOKEN_EMPTY);
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
- PARSE_ERROR1("Unparsable annotation: Expected key name, got '%s'",
- gras_ddt_parse_text);
+ PARSE_ERROR1
+ ("Unparsable annotation: Expected key name, got '%s'",
+ gras_ddt_parse_text);
keyname = (char *) strdup(gras_ddt_parse_text);
while ((gras_ddt_parse_tok_num =
- gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+ gras_ddt_parse_lex_n_dump()) ==
+ GRAS_DDT_PARSE_TOKEN_EMPTY);
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_COLON)
PARSE_ERROR1
- ("Unparsable annotation: expected ',' after the key name, got '%s'",
- gras_ddt_parse_text);
+ ("Unparsable annotation: expected ',' after the key name, got '%s'",
+ gras_ddt_parse_text);
while ((gras_ddt_parse_tok_num =
- gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+ gras_ddt_parse_lex_n_dump()) ==
+ GRAS_DDT_PARSE_TOKEN_EMPTY);
/* get the value */
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
- PARSE_ERROR1("Unparsable annotation: Expected key value, got '%s'",
- gras_ddt_parse_text);
+ PARSE_ERROR1
+ ("Unparsable annotation: Expected key value, got '%s'",
+ gras_ddt_parse_text);
keyval = (char *) strdup(gras_ddt_parse_text);
while ((gras_ddt_parse_tok_num =
- gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY);
+ gras_ddt_parse_lex_n_dump()) ==
+ GRAS_DDT_PARSE_TOKEN_EMPTY);
/* Done with parsing the annotation. Now deal with it by replacing previously pushed type with the right one */
if (!strcmp(keyname, "size")) {
free(keyname);
if (!identifier.tm.is_ref)
- PARSE_ERROR0("Size annotation for a field not being a reference");
+ PARSE_ERROR0
+ ("Size annotation for a field not being a reference");
identifier.tm.is_ref--;
if (!strcmp(keyval, "1")) {
identifier.tm.is_dynar = -1;
} else {
PARSE_ERROR1
- ("subtype annotation only accepted for dynars and matrices, but passed to '%s'",
- identifier.type_name);
+ ("subtype annotation only accepted for dynars and matrices, but passed to '%s'",
+ identifier.type_name);
}
free(keyval);
} else if (!strcmp(keyname, "free_f")) {
int *storage = xbt_dict_get_or_null(gras_dd_constants, keyval);
if (!storage)
PARSE_ERROR1
- ("value for free_f annotation of field %s is not a known constant",
- identifier.name);
+ ("value for free_f annotation of field %s is not a known constant",
+ identifier.name);
if (identifier.tm.is_matrix == -1) {
add_free_f(identifiers, *(void_f_pvoid_t *) storage);
identifier.tm.is_matrix = 0;
identifier.tm.is_dynar = 0;
} else {
PARSE_ERROR1
- ("free_f annotation only accepted for dynars and matrices which subtype is already declared (field %s)",
- identifier.name);
+ ("free_f annotation only accepted for dynars and matrices which subtype is already declared (field %s)",
+ identifier.name);
}
free(keyval);
} else {
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1
- ("Unparsable annotation: Expected field name after '*', got '%s'",
- gras_ddt_parse_text);
+ ("Unparsable annotation: Expected field name after '*', got '%s'",
+ gras_ddt_parse_text);
keyval = xbt_malloc(strlen(gras_ddt_parse_text) + 2);
sprintf(keyval, "*%s", gras_ddt_parse_text);
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RP)
PARSE_ERROR1
- ("Unparsable annotation: Expected parenthesis, got '%s'",
- gras_ddt_parse_text);
+ ("Unparsable annotation: Expected parenthesis, got '%s'",
+ gras_ddt_parse_text);
continue;
/* End of annotation handling */
} else {
PARSE_ERROR1
- ("Unparsable symbol: Got '%s' instead of expected comma (',')",
- gras_ddt_parse_text);
+ ("Unparsable symbol: Got '%s' instead of expected comma (',')",
+ gras_ddt_parse_text);
}
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_COLON) {
PARSE_ERROR0("Unparsable symbol: Unexpected comma (',')");
}
PARSE_ERROR0
- ("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
+ ("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
if (identifier.tm.is_matrix > 0)
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LA)
PARSE_ERROR1
- ("Unparasable symbol: Expecting struct definition, but got %s instead of '{'",
- gras_ddt_parse_text);
+ ("Unparasable symbol: Expecting struct definition, but got %s instead of '{'",
+ gras_ddt_parse_text);
/* Parse the identifiers */
done = 0;
xbt_dynar_foreach(identifiers, iter, field) {
if (field.tm.is_ref)
PARSE_ERROR2
- ("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
- field.name, field.tm.is_ref);
+ ("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
+ field.name, field.tm.is_ref);
VERB2("Append field '%s' to %p", field.name, (void *) struct_type);
gras_datadesc_struct_append(struct_type, field.name, field.type);
/* terminates */
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RA)
PARSE_ERROR1
- ("Unparasable symbol: Expected '}' at the end of struct definition, got '%s'",
- gras_ddt_parse_text);
+ ("Unparasable symbol: Expected '}' at the end of struct definition, got '%s'",
+ gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (tm.is_ref)
PARSE_ERROR0
- ("GRAS_DEFINE_TYPE cannot handle reference without annotation");
+ ("GRAS_DEFINE_TYPE cannot handle reference without annotation");
/* get the aliasing name */
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
- PARSE_ERROR1("Unparsable typedef: Expected the alias name, and got '%s'",
- gras_ddt_parse_text);
+ PARSE_ERROR1
+ ("Unparsable typedef: Expected the alias name, and got '%s'",
+ gras_ddt_parse_text);
/* (FIXME: should) build the alias */
PARSE_ERROR0
- ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle typedef yet");
+ ("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle typedef yet");
XBT_OUT;
return typedef_desc;
} else {
ERROR1
- ("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",
- definition);
+ ("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",
+ definition);
xbt_abort();
}
/* register it under the name provided as symbol */
if (strcmp(res->name, name)) {
ERROR2
- ("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
- name, res->name);
+ ("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
+ name, res->name);
xbt_abort();
}
gras_ddt_parse_lex_destroy();
char _GRAS_header[6];
const char *e_gras_msg_kind_names[e_gras_msg_kind_count] =
- { "UNKNOWN", "ONEWAY", "RPC call", "RPC answer", "RPC error" };
+ { "UNKNOWN", "ONEWAY", "RPC call", "RPC answer", "RPC error" };
/** \brief Waits for a message to come in over a given socket.
s_gras_msg_t msg;
double start, now;
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cpt;
xbt_assert0(msg_got, "msg_got is an output parameter");
*/
void gras_msg_wait_or(double timeout,
xbt_dynar_t msgt_want,
- gras_msg_cb_ctx_t * ctx, int *msgt_got, void *payload)
+ gras_msg_cb_ctx_t * ctx, int *msgt_got,
+ void *payload)
{
s_gras_msg_t msg;
/** \brief Send the data pointed by \a payload as a message of type
* \a msgtype to the peer \a sock */
-void gras_msg_send_(gras_socket_t sock, gras_msgtype_t msgtype, void *payload)
+void gras_msg_send_(gras_socket_t sock, gras_msgtype_t msgtype,
+ void *payload)
{
if (msgtype->ctn_type) {
s_gras_msg_t msg;
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
gras_cblist_t *list = NULL;
gras_msg_cb_t cb;
s_gras_msg_cb_ctx_t ctx;
xbt_assert1(untiltimer > 0, "Negative timer (%f). I'm 'puzzeled'",
untiltimer);
WARN1
- ("No timer elapsed, in contrary to expectations (next in %f sec)",
- untiltimer);
+ ("No timer elapsed, in contrary to expectations (next in %f sec)",
+ untiltimer);
THROW1(timeout_error, 0,
"No timer elapsed, in contrary to expectations (next in %f sec)",
untiltimer);
}
if (!list) {
INFO4
- ("No callback for message '%s' (type:%s) from %s:%d. Queue it for later gras_msg_wait() use.",
- msg.type->name, e_gras_msg_kind_names[msg.kind],
- gras_socket_peer_name(msg.expe), gras_socket_peer_port(msg.expe));
+ ("No callback for message '%s' (type:%s) from %s:%d. Queue it for later gras_msg_wait() use.",
+ msg.type->name, e_gras_msg_kind_names[msg.kind],
+ gras_socket_peer_name(msg.expe), gras_socket_peer_port(msg.expe));
xbt_dynar_push(pd->msg_waitqueue, &msg);
return; /* FIXME: maybe we should call ourselves again until the end of the timer or a proper msg is got */
}
xbt_dynar_foreach(list->cbs, cpt, cb) {
if (!ran_ok) {
DEBUG4
- ("Use the callback #%d (@%p) for incomming msg '%s' (payload_size=%d)",
- cpt + 1, cb, msg.type->name, msg.payl_size);
+ ("Use the callback #%d (@%p) for incomming msg '%s' (payload_size=%d)",
+ cpt + 1, cb, msg.type->name, msg.payl_size);
if (!(*cb) (&ctx, msg.payl)) {
/* cb handled the message */
free(msg.payl);
e.host = (char *) gras_os_myname();
xbt_ex_setup_backtrace(&e);
}
- INFO5("Propagate %s exception ('%s') from '%s' RPC cb back to %s:%d",
- (e.remote ? "remote" : "local"),
- e.msg,
- msg.type->name,
- gras_socket_peer_name(msg.expe),
- gras_socket_peer_port(msg.expe));
+ INFO5
+ ("Propagate %s exception ('%s') from '%s' RPC cb back to %s:%d",
+ (e.remote ? "remote" : "local"), e.msg, msg.type->name,
+ gras_socket_peer_name(msg.expe),
+ gras_socket_peer_port(msg.expe));
if (XBT_LOG_ISENABLED(gras_msg, xbt_log_priority_verbose))
xbt_ex_display(&e);
gras_msg_send_ext(msg.expe, e_gras_msg_kind_rpcerror,
ran_ok = 1;
} else {
RETHROW4
- ("Callback #%d (@%p) to message '%s' (payload size: %d) raised an exception: %s",
- cpt + 1, cb, msg.type->name, msg.payl_size);
+ ("Callback #%d (@%p) to message '%s' (payload size: %d) raised an exception: %s",
+ cpt + 1, cb, msg.type->name, msg.payl_size);
}
}
msg.type->name);
if (ctx.answer_due)
CRITICAL1
- ("BUGS BOTH IN USER CODE (RPC callback to message '%s' didn't call gras_msg_rpcreturn) "
- "AND IN SIMGRID (process wasn't killed by an assert)",
- msg.type->name);
+ ("BUGS BOTH IN USER CODE (RPC callback to message '%s' didn't call gras_msg_rpcreturn) "
+ "AND IN SIMGRID (process wasn't killed by an assert)",
+ msg.type->name);
if (!ran_ok)
THROW1(mismatch_error, 0,
"Message '%s' refused by all registered callbacks (maybe your callback misses a 'return 0' at the end)",
INFO3("Unexpected RPC answer discarded (type: %s; from:%s:%d)",
msg.type->name, gras_socket_peer_name(msg.expe),
gras_socket_peer_port(msg.expe));
- WARN0("FIXME: gras_datadesc_free not implemented => leaking the payload");
+ WARN0
+ ("FIXME: gras_datadesc_free not implemented => leaking the payload");
return;
case e_gras_msg_kind_rpcerror:
INFO3("Unexpected RPC error discarded (type: %s; from:%s:%d)",
msg.type->name, gras_socket_peer_name(msg.expe),
gras_socket_peer_port(msg.expe));
- WARN0("FIXME: gras_datadesc_free not implemented => leaking the payload");
+ WARN0
+ ("FIXME: gras_datadesc_free not implemented => leaking the payload");
return;
default:
#include "gras/Transport/transport_interface.h" /* gras_select */
typedef struct s_gras_msg_listener_ {
- xbt_queue_t incomming_messages; /* messages received from the wire and still to be used by master */
+ xbt_queue_t incomming_messages; /* messages received from the wire and still to be used by master */
xbt_queue_t socks_to_close; /* let the listener close the sockets, since it may be selecting on them. Darwin don't like this trick */
gras_socket_t wakeup_sock_listener_side;
gras_socket_t wakeup_sock_master_side;
- xbt_mutex_t init_mutex; /* both this mutex and condition are used at initialization to make sure that*/
- xbt_cond_t init_cond; /* the main thread speaks to the listener only once it is started (FIXME: It would be easier using a semaphore, if only semaphores were in xbt_synchro) */
+ xbt_mutex_t init_mutex; /* both this mutex and condition are used at initialization to make sure that */
+ xbt_cond_t init_cond; /* the main thread speaks to the listener only once it is started (FIXME: It would be easier using a semaphore, if only semaphores were in xbt_synchro) */
xbt_thread_t listener;
} s_gras_msg_listener_t;
gras_msg_t msg;
xbt_ex_t e;
gras_msgtype_t msg_wakeup_listener_t =
- gras_msgtype_by_name("_wakeup_listener");
+ gras_msgtype_by_name("_wakeup_listener");
DEBUG0("I'm the listener");
/* get a free socket for the receiving part of the listener */
- me->wakeup_sock_listener_side = gras_socket_server_range(5000, 6000, -1, 0);
+ me->wakeup_sock_listener_side =
+ gras_socket_server_range(5000, 6000, -1, 0);
/* wake up the launcher */
xbt_mutex_acquire(me->init_mutex);
msg = gras_msg_recv_any();
if (msg->type != msg_wakeup_listener_t) {
VERB1("Got a '%s' message. Queue it for handling by main thread",
- gras_msgtype_get_name(msg->type));
+ gras_msgtype_get_name(msg->type));
xbt_queue_push(me->incomming_messages, msg);
} else {
char got = *(char *) msg->payl;
xbt_queue_shift_timed(me->socks_to_close, &sock, 0);
if (tcp_close(sock) < 0) {
#ifdef _XBT_WIN32
- WARN2("error while closing tcp socket %d: %d\n", sock, sock_errno);
+ WARN2("error while closing tcp socket %d: %d\n", sock,
+ sock_errno);
#else
WARN3("error while closing tcp socket %d: %d (%s)\n",
sock, sock_errno, sock_errstr(sock_errno));
/* actually start the thread, and */
/* wait for the listener to initialize before we connect to its socket */
xbt_mutex_acquire(arg->init_mutex);
- arg->listener = xbt_thread_create("listener", listener_function, arg,1/*joinable*/);
+ arg->listener =
+ xbt_thread_create("listener", listener_function, arg,
+ 1 /*joinable */ );
xbt_cond_wait(arg->init_cond, arg->init_mutex);
xbt_mutex_release(arg->init_mutex);
xbt_cond_destroy(arg->init_cond);
/* Connect the other part of the socket */
arg->wakeup_sock_master_side =
- gras_socket_client(gras_os_myname(),
- gras_socket_my_port(arg->wakeup_sock_listener_side));
+ gras_socket_client(gras_os_myname(),
+ gras_socket_my_port
+ (arg->wakeup_sock_listener_side));
return arg;
}
DEBUG0("Listener quit");
if (pd->listener)
- gras_msg_send(pd->listener->wakeup_sock_master_side, "_wakeup_listener",
- &kill);
+ gras_msg_send(pd->listener->wakeup_sock_master_side,
+ "_wakeup_listener", &kill);
xbt_thread_join(pd->listener->listener);
DEBUG0("Awaking the listener");
pd = gras_procdata_get();
if (pd->listener) {
- gras_msg_send(pd->listener->wakeup_sock_master_side, "_wakeup_listener",
- &c);
+ gras_msg_send(pd->listener->wakeup_sock_master_side,
+ "_wakeup_listener", &c);
}
}
void gras_msg_register()
{
gras_msg_libdata_id =
- gras_procdata_add("gras_msg", gras_msg_procdata_new,
- gras_msg_procdata_free);
+ gras_procdata_add("gras_msg", gras_msg_procdata_new,
+ gras_msg_procdata_free);
}
/*
_GRAS_header[5] = (char) GRAS_THISARCH;
gras_msg_ctx_mallocator =
- xbt_mallocator_new(1000,
- gras_msg_ctx_mallocator_new_f,
- gras_msg_ctx_mallocator_free_f,
- gras_msg_ctx_mallocator_reset_f);
+ xbt_mallocator_new(1000,
+ gras_msg_ctx_mallocator_new_f,
+ gras_msg_ctx_mallocator_free_f,
+ gras_msg_ctx_mallocator_reset_f);
}
/*
xbt_ex_t e;
TRY {
- msgtype = (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev);
+ msgtype =
+ (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev);
found = 1;
} CATCH(e) {
if (e.category != not_found_error) {
if (found) {
VERB2
- ("Re-register version %d of message '%s' (same kind & payload, ignored).",
- version, name);
+ ("Re-register version %d of message '%s' (same kind & payload, ignored).",
+ version, name);
xbt_assert3(msgtype->kind == kind,
"Message %s re-registered as a %s (it was known as a %s)",
namev, e_gras_msg_kind_names[kind],
e_gras_msg_kind_names[msgtype->kind]);
- xbt_assert3(!gras_datadesc_type_cmp(msgtype->ctn_type, payload_request),
+ xbt_assert3(!gras_datadesc_type_cmp
+ (msgtype->ctn_type, payload_request),
"Message %s re-registred with another payload (%s was %s)",
namev, gras_datadesc_get_name(payload_request),
gras_datadesc_get_name(msgtype->ctn_type));
- xbt_assert3(!gras_datadesc_type_cmp(msgtype->answer_type, payload_answer),
+ xbt_assert3(!gras_datadesc_type_cmp
+ (msgtype->answer_type, payload_answer),
"Message %s re-registred with another answer payload (%s was %s)",
namev, gras_datadesc_get_name(payload_answer),
gras_datadesc_get_name(msgtype->answer_type));
msgtype->ctn_type = payload_request;
msgtype->answer_type = payload_answer;
- xbt_set_add(_gras_msgtype_set, (xbt_set_elm_t) msgtype, &gras_msgtype_free);
+ xbt_set_add(_gras_msgtype_set, (xbt_set_elm_t) msgtype,
+ &gras_msgtype_free);
}
xbt_ex_free(e);
}
if (!found)
- THROW1(not_found_error, 0, "No registred message of that name: %s", name);
+ THROW1(not_found_error, 0, "No registred message of that name: %s",
+ name);
free(namev);
/* GETTERS */
/* ******************************************************************** */
-XBT_INLINE const char* gras_msgtype_get_name(gras_msgtype_t type) {
+XBT_INLINE const char *gras_msgtype_get_name(gras_msgtype_t type)
+{
return type->name;
}
void gras_cb_register_(gras_msgtype_t msgtype, gras_msg_cb_t cb)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
gras_cblist_t *list = NULL;
unsigned int cpt;
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
gras_cblist_t *list;
gras_msg_cb_t cb_cpt;
unsigned int cpt;
#define GRAS_PROTOCOL_VERSION '\1';
-#endif /* GRAS_MSG_INTERFACE_H */
+#endif /* GRAS_MSG_INTERFACE_H */
/* functions to extract msg from socket or put it on wire (depend RL vs SG) */
-gras_msg_t gras_msg_recv_any(void); /* Get first message arriving */
+gras_msg_t gras_msg_recv_any(void); /* Get first message arriving */
void gras_msg_recv(gras_socket_t sock, gras_msg_t msg /*OUT*/);
void gras_msg_send_ext(gras_socket_t sock,
e_gras_msg_kind_t kind,
void gras_msg_ctx_mallocator_reset_f(void *dict);
-#endif /* GRAS_MESSAGE_PRIVATE_H */
+#endif /* GRAS_MESSAGE_PRIVATE_H */
void gras_msg_recv(gras_socket_t sock, gras_msg_t msg);
-gras_msg_t gras_msg_recv_any(void) {
- gras_msg_t msg = xbt_new0(s_gras_msg_t,1);
+gras_msg_t gras_msg_recv_any(void)
+{
+ gras_msg_t msg = xbt_new0(s_gras_msg_t, 1);
msg->expe = gras_trp_select(-1);
DEBUG0("Select returned something");
gras_msg_recv(msg->expe, msg);
msg->kind = (e_gras_msg_kind_t) c_kind;
}
CATCH(e) {
- RETHROW0("Exception caught while trying to get the message header: %s");
+ RETHROW0
+ ("Exception caught while trying to get the message header: %s");
}
for (cpt = 0; cpt < 4; cpt++)
gras_datadesc_recv(sock, string_type, r_arch, &msg_name);
DEBUG4
- ("Handle an incoming message '%s' (%s) using protocol %d (remote is %s)",
- msg_name, e_gras_msg_kind_names[msg->kind], (int) header[4],
- gras_datadesc_arch_name(r_arch));
+ ("Handle an incoming message '%s' (%s) using protocol %d (remote is %s)",
+ msg_name, e_gras_msg_kind_names[msg->kind], (int) header[4],
+ gras_datadesc_arch_name(r_arch));
TRY {
msg->type =
- (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, msg_name);
+ (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, msg_name);
} CATCH(e) {
/* FIXME: Survive unknown messages */
if (e.category == not_found_error) {
msg_name);
} else
RETHROW1
- ("Exception caught while retrieving the type associated to messages '%s' : %s",
- msg_name);
+ ("Exception caught while retrieving the type associated to messages '%s' : %s",
+ msg_name);
}
free(msg_name);
{
unsigned long int ID = *(unsigned long int *) ctx;
int res = msg->ID == ID &&
- (msg->kind == e_gras_msg_kind_rpcanswer
- || msg->kind == e_gras_msg_kind_rpcerror);
+ (msg->kind == e_gras_msg_kind_rpcanswer
+ || msg->kind == e_gras_msg_kind_rpcerror);
unsigned int cursor;
gras_msg_cb_ctx_t rpc_ctx;
DEBUG5
- ("Filter a message of ID %lu, type '%s' and kind '%s'. Waiting for ID=%lu. %s",
- msg->ID, msg->type->name, e_gras_msg_kind_names[msg->kind], ID,
- res ? "take it" : "reject");
+ ("Filter a message of ID %lu, type '%s' and kind '%s'. Waiting for ID=%lu. %s",
+ msg->ID, msg->type->name, e_gras_msg_kind_names[msg->kind], ID,
+ res ? "take it" : "reject");
if (res && !_gras_rpc_cancelled)
return res;
xbt_dynar_foreach(_gras_rpc_cancelled, cursor, rpc_ctx) {
if (msg->ID == rpc_ctx->ID && msg->kind == e_gras_msg_kind_rpcanswer) {
VERB1
- ("Got an answer to the already canceled (timeouted?) RPC %ld. Ignore it (leaking the payload!).",
- msg->ID);
+ ("Got an answer to the already canceled (timeouted?) RPC %ld. Ignore it (leaking the payload!).",
+ msg->ID);
xbt_dynar_cursor_rm(_gras_rpc_cancelled, &cursor);
return 1;
}
msgtype->name);
} else {
xbt_assert1(!request,
- "No payload was declared for RPC type '%s'", msgtype->name);
+ "No payload was declared for RPC type '%s'",
+ msgtype->name);
}
ctx->ID = last_msg_ID++;
if (!_gras_rpc_cancelled)
_gras_rpc_cancelled = xbt_dynar_new(sizeof(ctx), NULL);
xbt_dynar_push(_gras_rpc_cancelled, &ctx);
- INFO5("canceled RPC %ld pushed onto the stack (%s from %s:%d) Reason: %s",
- ctx->ID, ctx->msgtype->name,
- gras_socket_peer_name(ctx->expeditor),
- gras_socket_peer_port(ctx->expeditor), e.msg);
+ INFO5
+ ("canceled RPC %ld pushed onto the stack (%s from %s:%d) Reason: %s",
+ ctx->ID, ctx->msgtype->name,
+ gras_socket_peer_name(ctx->expeditor),
+ gras_socket_peer_port(ctx->expeditor), e.msg);
RETHROW;
}
__xbt_ex_ctx()->ctx_ex.func = e.func;
__xbt_ex_ctx()->ctx_ex.used = e.used;
__xbt_ex_ctx()->ctx_ex.bt_strings = e.bt_strings;
- memset(&__xbt_ex_ctx()->ctx_ex.bt, 0, sizeof(__xbt_ex_ctx()->ctx_ex.bt));
+ memset(&__xbt_ex_ctx()->ctx_ex.bt, 0,
+ sizeof(__xbt_ex_ctx()->ctx_ex.bt));
DO_THROW(__xbt_ex_ctx()->ctx_ex);
}
memcpy(answer, received.payl, received.payl_size);
* some cleanups before leaving.
*/
-void gras_msg_rpcreturn(double timeOut, gras_msg_cb_ctx_t ctx, void *answer)
+void gras_msg_rpcreturn(double timeOut, gras_msg_cb_ctx_t ctx,
+ void *answer)
{
xbt_assert0(ctx->answer_due,
"RPC return not allowed here. Either not a RPC message or already returned a result");
typedef void *gras_trp_bufdata_;
-gras_msg_t gras_msg_recv_any(void) {
+gras_msg_t gras_msg_recv_any(void)
+{
gras_trp_procdata_t trp_proc =
(gras_trp_procdata_t) gras_libdata_by_name("gras_trp");
gras_msg_t msg;
/* Build a dynar of all communications I could get something from */
- xbt_dynar_t comms = xbt_dynar_new(sizeof(smx_comm_t),NULL);
+ xbt_dynar_t comms = xbt_dynar_new(sizeof(smx_comm_t), NULL);
unsigned int cursor = 0;
int got = 0;
smx_comm_t comm = NULL;
gras_socket_t sock = NULL;
gras_trp_sg_sock_data_t sock_data;
- xbt_dynar_foreach(trp_proc->sockets,cursor,sock) {
+ xbt_dynar_foreach(trp_proc->sockets, cursor, sock) {
sock_data = (gras_trp_sg_sock_data_t) sock->data;
- DEBUG5("Consider socket %p (data:%p; Here rdv: %p; Remote rdv: %p; Comm %p) to get a message",
- sock,sock_data,
- (sock_data->server==SIMIX_process_self())?sock_data->rdv_server:sock_data->rdv_client,
- (sock_data->server==SIMIX_process_self())?sock_data->rdv_client:sock_data->rdv_server,
- sock_data->comm_recv);
+ DEBUG5
+ ("Consider socket %p (data:%p; Here rdv: %p; Remote rdv: %p; Comm %p) to get a message",
+ sock, sock_data,
+ (sock_data->server ==
+ SIMIX_process_self())? sock_data->
+ rdv_server : sock_data->rdv_client,
+ (sock_data->server ==
+ SIMIX_process_self())? sock_data->
+ rdv_client : sock_data->rdv_server, sock_data->comm_recv);
/* The following assert fails in some valid conditions, we need to
* when that iterator is equal to "got", the result of waitany. Not needed if B holds.
*/
xbt_assert1(sock_data->comm_recv,
- "Comm_recv of socket %p is empty; please report that nasty bug",sock);
+ "Comm_recv of socket %p is empty; please report that nasty bug",
+ sock);
/* End of paranoia */
VERB3("Copy comm_recv %p rdv:%p (other rdv:%p)",
- sock_data->comm_recv,
- (sock_data->server==SIMIX_process_self())?sock_data->rdv_server:sock_data->rdv_client,
- (sock_data->server==SIMIX_process_self())?sock_data->rdv_client:sock_data->rdv_server);
- xbt_dynar_push(comms,&(sock_data->comm_recv));
+ sock_data->comm_recv,
+ (sock_data->server ==
+ SIMIX_process_self())? sock_data->
+ rdv_server : sock_data->rdv_client,
+ (sock_data->server ==
+ SIMIX_process_self())? sock_data->
+ rdv_client : sock_data->rdv_server);
+ xbt_dynar_push(comms, &(sock_data->comm_recv));
}
- VERB1("Wait on %ld 'sockets'",xbt_dynar_length(comms));
+ VERB1("Wait on %ld 'sockets'", xbt_dynar_length(comms));
/* Wait for the end of any of these communications */
got = SIMIX_network_waitany(comms);
/* retrieve the message sent in that communication */
- xbt_dynar_get_cpy(comms,got,&(comm));
- msg=SIMIX_communication_get_data(comm);
- VERB1("Got something. Communication %p's over",comm);
+ xbt_dynar_get_cpy(comms, got, &(comm));
+ msg = SIMIX_communication_get_data(comm);
+ VERB1("Got something. Communication %p's over", comm);
/* Reinstall a waiting communication on that rdv */
/* Get the sock again
* For that, we use the fact that */
- sock=xbt_dynar_get_as(trp_proc->sockets,got,gras_socket_t);
+ sock = xbt_dynar_get_as(trp_proc->sockets, got, gras_socket_t);
/* xbt_dynar_foreach(trp_proc->sockets,cursor,sock) {
sock_data = (gras_trp_sg_sock_data_t) sock->data;
if (sock_data->comm_recv && sock_data->comm_recv == comm)
}
*/
sock_data = (gras_trp_sg_sock_data_t) sock->data;
- sock_data->comm_recv = SIMIX_network_irecv(
- sock_data->rdv_server!=NULL?
- //(sock_data->server==SIMIX_process_self())?
- sock_data->rdv_server
- :sock_data->rdv_client,
- NULL,0);
+ sock_data->comm_recv =
+ SIMIX_network_irecv(sock_data->rdv_server != NULL ?
+ //(sock_data->server==SIMIX_process_self())?
+ sock_data->rdv_server
+ : sock_data->rdv_client, NULL, 0);
return msg;
}
smx_comm_t comm;
gras_trp_sg_sock_data_t sock_data = (gras_trp_sg_sock_data_t) sock->data;
- smx_rdv_t target_rdv = (sock_data->server==SIMIX_process_self())?sock_data->rdv_client
- :sock_data->rdv_server;
+ smx_rdv_t target_rdv =
+ (sock_data->server ==
+ SIMIX_process_self())? sock_data->
+ rdv_client : sock_data->rdv_server;
/*initialize gras message */
msg = xbt_new(s_gras_msg_t, 1);
msg->type = msgtype;
msg->ID = ID;
- VERB2("Send msg %s to rdv %p", msgtype->name,target_rdv);
+ VERB2("Send msg %s to rdv %p", msgtype->name, target_rdv);
if (kind == e_gras_msg_kind_rpcerror) {
/* error on remote host, careful, payload is an exception */
msg->payl_size = gras_datadesc_size(gras_datadesc_by_name("ex_t"));
msg->payl = xbt_malloc(msg->payl_size);
- whole_payload_size = gras_datadesc_memcpy(gras_datadesc_by_name("ex_t"),
- payload, msg->payl);
+ whole_payload_size =
+ gras_datadesc_memcpy(gras_datadesc_by_name("ex_t"), payload,
+ msg->payl);
} else if (kind == e_gras_msg_kind_rpcanswer) {
msg->payl_size = gras_datadesc_size(msgtype->answer_type);
if (msg->payl_size)
payload, msg->payl);
}
- SIMIX_network_send(target_rdv, whole_payload_size,-1,-1,&msg,sizeof(void*),&comm,msg);
+ SIMIX_network_send(target_rdv, whole_payload_size, -1, -1, &msg,
+ sizeof(void *), &comm, msg);
VERB0("Message sent");
}
-
void gras_timer_delay(double delay, void_f_void_t action)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
gras_timer_t timer = xbt_dynar_push_ptr(pd->timers);
void gras_timer_repeat(double interval, void_f_void_t action)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
gras_timer_t timer = xbt_dynar_push_ptr(pd->timers);
void gras_timer_cancel_delay(double interval, void_f_void_t action)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cursor;
int found;
s_gras_timer_t timer;
void gras_timer_cancel_repeat(double interval, void_f_void_t action)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cursor;
int found;
s_gras_timer_t timer;
void gras_timer_cancel_delay_all(void)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cursor;
int found;
s_gras_timer_t timer;
void gras_timer_cancel_repeat_all(void)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cursor;
int found;
s_gras_timer_t timer;
void gras_timer_cancel_all(void)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
xbt_dynar_reset(pd->timers);
}
double gras_msg_timer_handle(void)
{
gras_msg_procdata_t pd =
- (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
+ (gras_msg_procdata_t) gras_libdata_by_id(gras_msg_libdata_id);
unsigned int cursor;
gras_timer_t timer;
double now = gras_os_time();
if (timer->repeat) {
timer->expiry = now + timer->period;
DEBUG4("[%.0f] Re-arm repetitive action %p for %f (period=%f)",
- gras_os_time(), timer->action, timer->expiry, timer->period);
+ gras_os_time(), timer->action, timer->expiry,
+ timer->period);
} else {
DEBUG2("[%.0f] Remove %p now that it's done", gras_os_time(),
timer->action);
gras_socket_t gras_trp_select(double timeout)
{
xbt_dynar_t sockets =
- ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->sockets;
+ ((gras_trp_procdata_t)
+ gras_libdata_by_id(gras_trp_libdata_id))->sockets;
int done = -1;
double wakeup = gras_os_time() + timeout;
double now = 0;
/* Check whether there is more data to read from the socket we selected last time.
This can happen with tcp buffered sockets since we try to get as much data as we can for them */
- if (_gras_lastly_selected_socket && _gras_lastly_selected_socket->moredata) {
+ if (_gras_lastly_selected_socket
+ && _gras_lastly_selected_socket->moredata) {
VERB0
- ("Returning _gras_lastly_selected_socket since there is more data on it");
+ ("Returning _gras_lastly_selected_socket since there is more data on it");
return _gras_lastly_selected_socket;
}
fd_setsize = getdtablesize();
# else
fd_setsize = FD_SETSIZE;
-# endif /* !USE_SYSCONF */
+# endif /* !USE_SYSCONF */
#endif
}
/* set the timeout */
tout.tv_sec = (unsigned long) (wakeup - now);
tout.tv_usec =
- ((wakeup - now) - ((unsigned long) (wakeup - now))) * 1000000;
+ ((wakeup - now) - ((unsigned long) (wakeup - now))) * 1000000;
p_tout = &tout;
} else if (timeout == 0) {
/* polling only */
p_tout = NULL;
}
- DEBUG2("Selecting over %d socket(s); timeout=%f", max_fds - 1, timeout);
+ DEBUG2("Selecting over %d socket(s); timeout=%f", max_fds - 1,
+ timeout);
ready = select(max_fds, &FDS, NULL, NULL, p_tout);
DEBUG1("select returned %d", ready);
if (ready == -1) {
{
gras_socket_t res;
gras_trp_procdata_t pd =
- (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
+ (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
gras_trp_sg_sock_data_t *sockdata;
gras_trp_plugin_t trp;
gras_socket_t active_socket = NULL;
res->peer_port = ((gras_trp_procdata_t)
gras_libdata_by_name_from_remote("gras_trp",
sockdata->to_process))->
- myport;
+ myport;
sockdata->to_socket = active_socket;
/*update the peer to_socket variable */
active_socket_data->to_socket = res;
sockdata->mutex = SIMIX_mutex_init();
sockdata->to_host =
- SIMIX_process_get_host(active_socket_data->from_process);
+ SIMIX_process_get_host(active_socket_data->from_process);
res->data = sockdata;
res->peer_name = strdup(SIMIX_host_get_name(sockdata->to_host));
}
if (!measurement)
- ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->myport =
- port;
+ ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->myport
+ = port;
xbt_dynar_push(((gras_trp_procdata_t)
- gras_libdata_by_id(gras_trp_libdata_id))->sockets, &sock);
+ gras_libdata_by_id(gras_trp_libdata_id))->sockets,
+ &sock);
gras_msg_listener_awake();
return sock;
trp = gras_trp_plugin_get_by_name(gras_if_SG()? "sg" : "tcp");
- DEBUG1("Create a client socket from plugin %s", gras_if_RL()? "tcp" : "sg");
+ DEBUG1("Create a client socket from plugin %s",
+ gras_if_RL()? "tcp" : "sg");
/* defaults settings */
gras_trp_socket_new(0, &sock);
sock->plugin = trp;
RETHROW;
}
xbt_dynar_push(((gras_trp_procdata_t)
- gras_libdata_by_id(gras_trp_libdata_id))->sockets, &sock);
+ gras_libdata_by_id(gras_trp_libdata_id))->sockets,
+ &sock);
gras_msg_listener_awake();
return sock;
}
return res;
}
-void gras_socket_close_voidp(void *sock) {
- gras_socket_close((gras_socket_t)sock);
+void gras_socket_close_voidp(void *sock)
+{
+ gras_socket_close((gras_socket_t) sock);
}
/** \brief Close socket */
void gras_socket_close(gras_socket_t sock)
{
xbt_dynar_t sockets =
- ((gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id))->sockets;
+ ((gras_trp_procdata_t)
+ gras_libdata_by_id(gras_trp_libdata_id))->sockets;
gras_socket_t sock_iter = NULL;
unsigned int cursor;
if (sock->moredata)
CRITICAL0
- ("Closing a socket having more data in buffer. Option nomoredata_on_close disabled, so continuing.");
+ ("Closing a socket having more data in buffer. Option nomoredata_on_close disabled, so continuing.");
_gras_lastly_selected_socket = NULL;
}
return;
}
}
- WARN1("Ignoring request to free an unknown socket (%p). Execution stack:",
- sock);
+ WARN1
+ ("Ignoring request to free an unknown socket (%p). Execution stack:",
+ sock);
xbt_backtrace_display_current();
}
XBT_OUT;
for (sent_sofar = 0; sent_sofar < msg_amount; sent_sofar++) {
CDEBUG5(gras_trp_meas,
- "Sent %lu msgs of %lu (size of each: %ld) to %s:%d", sent_sofar,
- msg_amount, msg_size, gras_socket_peer_name(peer),
+ "Sent %lu msgs of %lu (size of each: %ld) to %s:%d",
+ sent_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
(*peer->plugin->raw_send) (peer, chunk, msg_size);
}
- CDEBUG5(gras_trp_meas, "Sent %lu msgs of %lu (size of each: %ld) to %s:%d",
- sent_sofar, msg_amount, msg_size,
- gras_socket_peer_name(peer), gras_socket_peer_port(peer));
+ CDEBUG5(gras_trp_meas,
+ "Sent %lu msgs of %lu (size of each: %ld) to %s:%d", sent_sofar,
+ msg_amount, msg_size, gras_socket_peer_name(peer),
+ gras_socket_peer_port(peer));
if (gras_if_RL())
free(chunk);
for (got_sofar = 0; got_sofar < msg_amount; got_sofar++) {
CDEBUG5(gras_trp_meas,
- "Recvd %ld msgs of %lu (size of each: %ld) from %s:%d", got_sofar,
- msg_amount, msg_size, gras_socket_peer_name(peer),
+ "Recvd %ld msgs of %lu (size of each: %ld) from %s:%d",
+ got_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
(peer->plugin->raw_recv) (peer, chunk, msg_size);
}
CDEBUG5(gras_trp_meas,
- "Recvd %ld msgs of %lu (size of each: %ld) from %s:%d", got_sofar,
- msg_amount, msg_size, gras_socket_peer_name(peer),
+ "Recvd %ld msgs of %lu (size of each: %ld) from %s:%d",
+ got_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
if (gras_if_RL())
void gras_trp_socketset_dump(const char *name)
{
gras_trp_procdata_t procdata =
- (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
+ (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
unsigned int it;
gras_socket_t s;
void gras_trp_register()
{
gras_trp_libdata_id =
- gras_procdata_add("gras_trp", gras_trp_procdata_new,
- gras_trp_procdata_free);
+ gras_procdata_add("gras_trp", gras_trp_procdata_new,
+ gras_trp_procdata_free);
}
int gras_os_myport(void)
/* stable if we know the storage will keep as is until the next trp_flush */
XBT_PUBLIC(void) gras_trp_send(gras_socket_t sd, char *data, long int size,
int stable);
-XBT_PUBLIC(void) gras_trp_recv(gras_socket_t sd, char *data, long int size);
+XBT_PUBLIC(void) gras_trp_recv(gras_socket_t sd, char *data,
+ long int size);
XBT_PUBLIC(void) gras_trp_flush(gras_socket_t sd);
/* Find which socket needs to be read next */
***/
/* A plugin type */
- typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t;
+typedef struct gras_trp_plugin_ s_gras_trp_plugin_t, *gras_trp_plugin_t;
/* A plugin type */
- struct gras_trp_plugin_ {
- char *name;
+struct gras_trp_plugin_ {
+ char *name;
- /* dst pointers are created and initialized with default values
- before call to socket_client/server.
- Retrive the info you need from there. */
- void (*socket_client) (gras_trp_plugin_t self, gras_socket_t dst);
- void (*socket_server) (gras_trp_plugin_t self, gras_socket_t dst);
+ /* dst pointers are created and initialized with default values
+ before call to socket_client/server.
+ Retrive the info you need from there. */
+ void (*socket_client) (gras_trp_plugin_t self, gras_socket_t dst);
+ void (*socket_server) (gras_trp_plugin_t self, gras_socket_t dst);
- gras_socket_t(*socket_accept) (gras_socket_t from);
+ gras_socket_t(*socket_accept) (gras_socket_t from);
- /* socket_close() is responsible of telling the OS that the socket is over,
- but should not free the socket itself (beside the specific part) */
- void (*socket_close) (gras_socket_t sd);
+ /* socket_close() is responsible of telling the OS that the socket is over,
+ but should not free the socket itself (beside the specific part) */
+ void (*socket_close) (gras_socket_t sd);
- /* send/recv may be buffered */
- void (*send) (gras_socket_t sd,
- const char *data,
- unsigned long int size,
- int stable /* storage will survive until flush */ );
- int (*recv) (gras_socket_t sd, char *data, unsigned long int size);
- /* raw_send/raw_recv is never buffered (use it for measurement stuff) */
- void (*raw_send) (gras_socket_t sd,
- const char *data, unsigned long int size);
- int (*raw_recv) (gras_socket_t sd, char *data, unsigned long int size);
+ /* send/recv may be buffered */
+ void (*send) (gras_socket_t sd,
+ const char *data,
+ unsigned long int size,
+ int stable /* storage will survive until flush */ );
+ int (*recv) (gras_socket_t sd, char *data, unsigned long int size);
+ /* raw_send/raw_recv is never buffered (use it for measurement stuff) */
+ void (*raw_send) (gras_socket_t sd,
+ const char *data, unsigned long int size);
+ int (*raw_recv) (gras_socket_t sd, char *data, unsigned long int size);
- /* flush has to make sure that the pending communications are achieved */
- void (*flush) (gras_socket_t sd);
+ /* flush has to make sure that the pending communications are achieved */
+ void (*flush) (gras_socket_t sd);
- void *data; /* plugin-specific data */
+ void *data; /* plugin-specific data */
- /* exit is responsible for freeing data and telling to the OS that
- this plugin is gone */
- /* exit=NULL, data gets brutally free()d by the generic interface.
- (ie exit function needed only when data contains pointers) */
- void (*exit) (gras_trp_plugin_t);
- };
+ /* exit is responsible for freeing data and telling to the OS that
+ this plugin is gone */
+ /* exit=NULL, data gets brutally free()d by the generic interface.
+ (ie exit function needed only when data contains pointers) */
+ void (*exit) (gras_trp_plugin_t);
+};
XBT_PUBLIC(gras_trp_plugin_t)
- gras_trp_plugin_get_by_name(const char *name);
+ gras_trp_plugin_get_by_name(const char *name);
/* Data of this module specific to each process
* (used by sg_process.c to cleanup the SG channel cruft)
*/
- typedef struct {
- /* set headers */
- unsigned int ID;
- char *name;
- unsigned int name_len;
+typedef struct {
+ /* set headers */
+ unsigned int ID;
+ char *name;
+ unsigned int name_len;
- int myport; /* Port on which I listen myself */
+ int myport; /* Port on which I listen myself */
- xbt_dynar_t sockets; /* all sockets known to this process */
+ xbt_dynar_t sockets; /* all sockets known to this process */
- /* SG only elements. In RL, they are part of the OS ;) */
+ /* SG only elements. In RL, they are part of the OS ;) */
- /* List of sockets ready to be select()ed */
- xbt_queue_t msg_selectable_sockets; /* regular sockets */
- xbt_queue_t meas_selectable_sockets; /* measurement ones */
+ /* List of sockets ready to be select()ed */
+ xbt_queue_t msg_selectable_sockets; /* regular sockets */
+ xbt_queue_t meas_selectable_sockets; /* measurement ones */
- } s_gras_trp_procdata_t, *gras_trp_procdata_t;
+} s_gras_trp_procdata_t, *gras_trp_procdata_t;
/* Display the content of our socket set (debugging purpose) */
XBT_PUBLIC(void) gras_trp_socketset_dump(const char *name);
-#endif /* GRAS_TRP_INTERFACE_H */
+#endif /* GRAS_TRP_INTERFACE_H */
void gras_trp_file_close(gras_socket_t sd);
void gras_trp_file_chunk_send_raw(gras_socket_t sd,
- const char *data, unsigned long int size);
-void gras_trp_file_chunk_send(gras_socket_t sd,
- const char *data,
+ const char *data,
+ unsigned long int size);
+void gras_trp_file_chunk_send(gras_socket_t sd, const char *data,
unsigned long int size, int stable_ignored);
int gras_trp_file_chunk_recv(gras_socket_t sd,
if (strcmp("-", path)) {
res->sd =
- open(path, O_TRUNC | O_WRONLY | O_CREAT | O_BINARY,
- S_IRUSR | S_IWUSR | S_IRGRP);
+ open(path, O_TRUNC | O_WRONLY | O_CREAT | O_BINARY,
+ S_IRUSR | S_IWUSR | S_IRGRP);
if (res->sd < 0) {
THROW2(system_error, 0,
}
void gras_trp_sg_socket_client(gras_trp_plugin_t self,
- /* OUT */ gras_socket_t sock) {
+ /* OUT */ gras_socket_t sock)
+{
smx_host_t peer;
gras_hostdata_t *hd;
if (!(hd = (gras_hostdata_t *) SIMIX_host_get_data(peer)))
THROW1(mismatch_error, 0,
- "can't connect to %s: no process on this host", sock->peer_name);
+ "can't connect to %s: no process on this host",
+ sock->peer_name);
pr = find_port(hd, sock->peer_port);
if (pr == NULL) {
THROW2(mismatch_error, 0,
- "can't connect to %s:%d, no process listen on this port",
- sock->peer_name, sock->peer_port);
+ "can't connect to %s:%d, no process listen on this port",
+ sock->peer_name, sock->peer_port);
}
/* Ensure that the listener is expecting the kind of stuff we want to send */
if (!pr->meas && sock->meas) {
THROW2(mismatch_error, 0,
"can't connect to %s:%d in measurement mode, the process listen "
- "in regular mode on this port", sock->peer_name, sock->peer_port);
+ "in regular mode on this port", sock->peer_name,
+ sock->peer_port);
}
/* create simulation data of the socket */
/* initialize synchronization stuff on the socket */
data->rdv_server = pr->rdv;
data->rdv_client = SIMIX_rdv_create(NULL);
- data->comm_recv = SIMIX_network_irecv(data->rdv_client,NULL,0);
+ data->comm_recv = SIMIX_network_irecv(data->rdv_client, NULL, 0);
/* connect that simulation data to the socket */
sock->data = data;
DEBUG5("%s (PID %d) connects in %s mode to %s:%d",
SIMIX_process_get_name(SIMIX_process_self()), gras_os_getpid(),
- sock->meas ? "meas" : "regular", sock->peer_name, sock->peer_port);
+ sock->meas ? "meas" : "regular", sock->peer_name,
+ sock->peer_port);
}
void gras_trp_sg_socket_server(gras_trp_plugin_t self, gras_socket_t sock)
{
gras_hostdata_t *hd =
- (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
+ (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
gras_sg_portrec_t pr;
gras_trp_sg_sock_data_t data;
SIMIX_host_get_name(SIMIX_host_self()), sock->port);
/* This port is free, let's take it */
- pr = xbt_new(s_gras_sg_portrec_t,1);
+ pr = xbt_new(s_gras_sg_portrec_t, 1);
pr->port = sock->port;
pr->meas = sock->meas;
pr->server = SIMIX_process_self();
data->client = NULL;
data->rdv_server = pr->rdv;
data->rdv_client = NULL;
- data->comm_recv = SIMIX_network_irecv(pr->rdv,NULL,0);
+ data->comm_recv = SIMIX_network_irecv(pr->rdv, NULL, 0);
sock->data = data;
- VERB10("'%s' (%d) ears on %s:%d%s (%p; data:%p); Here rdv: %p; Remote rdv: %p; Comm %p",
- SIMIX_process_get_name(SIMIX_process_self()), gras_os_getpid(),
- SIMIX_host_get_name(SIMIX_host_self()), sock->port,
- sock->meas ? " (mode meas)" : "", sock,data,
- (data->server==SIMIX_process_self())?data->rdv_server:data->rdv_client,
- (data->server==SIMIX_process_self())?data->rdv_client:data->rdv_server,
- data->comm_recv);
+ VERB10
+ ("'%s' (%d) ears on %s:%d%s (%p; data:%p); Here rdv: %p; Remote rdv: %p; Comm %p",
+ SIMIX_process_get_name(SIMIX_process_self()), gras_os_getpid(),
+ SIMIX_host_get_name(SIMIX_host_self()), sock->port,
+ sock->meas ? " (mode meas)" : "", sock, data,
+ (data->server ==
+ SIMIX_process_self())? data->rdv_server : data->rdv_client,
+ (data->server ==
+ SIMIX_process_self())? data->rdv_client : data->rdv_server,
+ data->comm_recv);
}
void gras_trp_sg_socket_close(gras_socket_t sock)
{
gras_hostdata_t *hd =
- (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
+ (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
unsigned int cpt;
gras_sg_portrec_t pr;
return;
}
}
- WARN2("socket_close called on the unknown incoming socket %p (port=%d)",
- sock, sock->port);
+ WARN2
+ ("socket_close called on the unknown incoming socket %p (port=%d)",
+ sock, sock->port);
}
XBT_OUT;
}
/* creates simix action and waits its ends, waits in the sender host
condition */
- if (XBT_LOG_ISENABLED(gras_trp_sg,xbt_log_priority_debug)) {
- smx_process_t remote_dude = (sock_data->server==SIMIX_process_self())?(sock_data->client):(sock_data->server);
+ if (XBT_LOG_ISENABLED(gras_trp_sg, xbt_log_priority_debug)) {
+ smx_process_t remote_dude =
+ (sock_data->server ==
+ SIMIX_process_self())? (sock_data->client) : (sock_data->server);
smx_host_t remote_host = SIMIX_process_get_host(remote_dude);
DEBUG4("send chunk from %s to %s:%d (size=%ld)",
- SIMIX_host_get_name(SIMIX_host_self()),
- SIMIX_host_get_name(remote_host),
- sock->peer_port, size);
+ SIMIX_host_get_name(SIMIX_host_self()),
+ SIMIX_host_get_name(remote_host), sock->peer_port, size);
}
//SIMIX_network_send(sock_data->rdv,size,1,-1,NULL,0,NULL,NULL);
THROW_UNIMPLEMENTED;
gras_socket_t remote_socket = NULL;
gras_msg_t msg_got;
gras_msg_procdata_t msg_procdata =
- (gras_msg_procdata_t) gras_libdata_by_name("gras_msg");
+ (gras_msg_procdata_t) gras_libdata_by_name("gras_msg");
gras_trp_procdata_t trp_proc =
- (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
+ (gras_trp_procdata_t) gras_libdata_by_id(gras_trp_libdata_id);
xbt_assert0(sock->meas,
"SG chunk exchange shouldn't be used on non-measurement sockets");
/*****************************/
/* we exchange port number on client side on socket creation,
so we need to be able to talk right now. */
-static XBT_INLINE void gras_trp_tcp_send(gras_socket_t sock, const char *data,
+static XBT_INLINE void gras_trp_tcp_send(gras_socket_t sock,
+ const char *data,
unsigned long int size);
static int gras_trp_tcp_recv(gras_socket_t sock, char *data,
unsigned long int size);
static int _gras_tcp_proto_number(void);
-static XBT_INLINE void gras_trp_sock_socket_client(gras_trp_plugin_t ignored,
+static XBT_INLINE void gras_trp_sock_socket_client(gras_trp_plugin_t
+ ignored,
gras_socket_t sock)
{
struct in_addr *haddr;
int size = sock->buf_size;
uint32_t myport = htonl(((gras_trp_procdata_t)
- gras_libdata_by_id(gras_trp_libdata_id))->myport);
+ gras_libdata_by_id
+ (gras_trp_libdata_id))->myport);
sock->incoming = 1; /* TCP sockets are duplex'ed */
*
* Open a socket used to receive messages.
*/
-static XBT_INLINE void gras_trp_sock_socket_server(gras_trp_plugin_t ignored,
+static XBT_INLINE void gras_trp_sock_socket_server(gras_trp_plugin_t
+ ignored,
gras_socket_t sock)
{
int size = sock->buf_size;
if (bind(sock->sd, (struct sockaddr *) &server, sizeof(server)) == -1) {
tcp_close(sock->sd);
THROW2(system_error, 0,
- "Cannot bind to port %d: %s", sock->port, sock_errstr(sock_errno));
+ "Cannot bind to port %d: %s", sock->port,
+ sock_errstr(sock_errno));
}
DEBUG2("Listen on port %d (sd=%d)", sock->port, sock->sd);
sock->port, sock_errstr(sock_errno));
}
- VERB2("Openned a server socket on port %d (sd=%d)", sock->port, sock->sd);
+ VERB2("Openned a server socket on port %d (sd=%d)", sock->port,
+ sock->sd);
}
static gras_socket_t gras_trp_sock_socket_accept(gras_socket_t sock)
res->buf_size = sock->buf_size;
size = sock->buf_size;
if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size))
- || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *) &size, sizeof(size)))
+ || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *) &size,
+ sizeof(size)))
VERB1("setsockopt failed, cannot set buffer size: %s",
sock_errstr(tmp_errno));
if (status < 0) {
THROW7(system_error, 0,
- "read(%d,%p,%d) from %s:%d failed: %s; got %d so far", sock->sd,
- data + got, (int) size, gras_socket_peer_name(sock),
+ "read(%d,%p,%d) from %s:%d failed: %s; got %d so far",
+ sock->sd, data + got, (int) size, gras_socket_peer_name(sock),
gras_socket_peer_port(sock), sock_errstr(sock_errno), got);
}
DEBUG2("Got %d more bytes (%s)", status,
got += status;
} else {
THROW1(system_error, errno,
- "Socket closed by remote side (got %d bytes before this)", got);
+ "Socket closed by remote side (got %d bytes before this)",
+ got);
}
}
while (chunk_pos < size) {
/* size of the chunk to receive in that shot */
long int thissize =
- min(size - chunk_pos, data->buffsize - data->out_buf.size);
+ min(size - chunk_pos, data->buffsize - data->out_buf.size);
DEBUG4("Set the chars %d..%ld into the buffer; size=%ld, ctn=(%s)",
(int) data->out_buf.size,
((int) data->out_buf.size) + thissize - 1, size,
data->in_buf.size =
- gras_trp_tcp_recv_withbuffer(sock, data->in_buf.data,
- MIN(size - chunk_pos, data->buffsize),
- data->buffsize);
+ gras_trp_tcp_recv_withbuffer(sock, data->in_buf.data,
+ MIN(size - chunk_pos,
+ data->buffsize),
+ data->buffsize);
data->in_buf.pos = 0;
}
thissize = min(size - chunk_pos, data->in_buf.size - data->in_buf.pos);
- memcpy(chunk + chunk_pos, data->in_buf.data + data->in_buf.pos, thissize);
+ memcpy(chunk + chunk_pos, data->in_buf.data + data->in_buf.pos,
+ thissize);
data->in_buf.pos += thissize;
chunk_pos += thissize;
*** Prototypes of BUFFERED
***/
-void gras_trp_buf_socket_client(gras_trp_plugin_t self, gras_socket_t sock);
-void gras_trp_buf_socket_server(gras_trp_plugin_t self, gras_socket_t sock);
+void gras_trp_buf_socket_client(gras_trp_plugin_t self,
+ gras_socket_t sock);
+void gras_trp_buf_socket_server(gras_trp_plugin_t self,
+ gras_socket_t sock);
gras_socket_t gras_trp_buf_socket_accept(gras_socket_t sock);
void gras_trp_buf_socket_close(gras_socket_t sd);
RETSTR(WSA_E_NO_MORE);
RETSTR(WSA_E_CANCELLED);
RETSTR(WSAEREFUSED);
-#endif /* HAVE_WINSOCK2 */
+#endif /* HAVE_WINSOCK2 */
RETSTR(WSAHOST_NOT_FOUND);
RETSTR(WSATRY_AGAIN);
}
return "unknown WSA error";
}
-#endif /* HAVE_WINSOCK_H */
+#endif /* HAVE_WINSOCK_H */
/***********************************/
/****[ end of HELPER FUNCTIONS ]****/
gras_socket_t gras_trp_buf_init_sock(gras_socket_t sock);
-#endif /* GRAS_TRP_PRIVATE_H */
+#endif /* GRAS_TRP_PRIVATE_H */
xbt_assert1(mod->datasize == datasize,
"Module %s reregistered with a different datasize!", name);
xbt_assert1(mod->p_id == ID,
- "Module %s reregistered with a different p_id field!", name);
+ "Module %s reregistered with a different p_id field!",
+ name);
DEBUG1("Module %s already registered. Ignoring re-registration", name);
return;
gras_procdata_t *pd;
void *moddata;
gras_module_t mod =
- (gras_module_t) xbt_set_get_by_name(_gras_modules, name);
+ (gras_module_t) xbt_set_get_by_name(_gras_modules, name);
VERB2("Join to module %s (%p)", name, mod);
{
void *moddata;
gras_module_t mod =
- (gras_module_t) xbt_set_get_by_name(_gras_modules, name);
+ (gras_module_t) xbt_set_get_by_name(_gras_modules, name);
VERB1("Leave module %s", name);
if (!_gras_procdata_fabrics) {
/* create the dynar if needed */
- _gras_procdata_fabrics = xbt_dynar_new(sizeof(s_gras_procdata_fabric_t),
- gras_procdata_fabric_free);
+ _gras_procdata_fabrics =
+ xbt_dynar_new(sizeof(s_gras_procdata_fabric_t),
+ gras_procdata_fabric_free);
}
fab = xbt_dynar_push_ptr(_gras_procdata_fabrics);
{
void *res = NULL;
xbt_ex_t e;
- if (xbt_set_length(pd->libdata) < xbt_dynar_length(_gras_procdata_fabrics)) {
+ if (xbt_set_length(pd->libdata) <
+ xbt_dynar_length(_gras_procdata_fabrics)) {
/* Damn, some new modules were added since procdata_init(). Amok? */
/* Get 'em all */
gras_procdata_init();
void *gras_libdata_by_id(int id)
{
gras_procdata_t *pd = gras_procdata_get();
- if (xbt_set_length(pd->libdata) < xbt_dynar_length(_gras_procdata_fabrics)) {
+ if (xbt_set_length(pd->libdata) <
+ xbt_dynar_length(_gras_procdata_fabrics)) {
/* Damn, some new modules were added since procdata_init(). Amok? */
/* Get 'em all */
gras_procdata_init();
found = 0;
}
if (found)
- THROW1(unknown_error, 0, "MayDay: two modules use '%s' as libdata name",
- fab.name);
+ THROW1(unknown_error, 0,
+ "MayDay: two modules use '%s' as libdata name", fab.name);
/* Add the data in place, after some more sanity checking */
elem = (*(fab.constructor)) ();
if (elem->name_len && elem->name_len != strlen(elem->name)) {
elem->name_len = strlen(elem->name);
WARN1
- ("Module '%s' constructor is borken: it does not set elem->name_len",
- fab.name);
+ ("Module '%s' constructor is borken: it does not set elem->name_len",
+ fab.name);
}
xbt_set_add(pd->libdata, elem, fab.destructor);
}
XBT_LOG_NEW_SUBCATEGORY(gras_virtu_emul, gras_virtu, "Emulation support");
/*** CPU burning */
-void gras_cpu_burn(double flops) {
- while (flops>0) {
- flops-=2;
+void gras_cpu_burn(double flops)
+{
+ while (flops > 0) {
+ flops -= 2;
}
}
/* globals */
static gras_procdata_t *_gras_procdata = NULL;
XBT_EXPORT_NO_IMPORT(char const *) _gras_procname = NULL;
- static xbt_dict_t _process_properties = NULL;
- static xbt_dict_t _host_properties = NULL;
+static xbt_dict_t _process_properties = NULL;
+static xbt_dict_t _host_properties = NULL;
# ifdef __APPLE__
- /* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */
- # include <crt_externs.h>
- # define environ (*_NSGetEnviron())
+ /* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron())
# else
- #ifdef _XBT_WIN32
- /* the environment, as specified by the opengroup, used to initialize the process properties */
- extern char **wenviron;
- #else
- extern char **environ;
- #endif
+#ifdef _XBT_WIN32
+ /* the environment, as specified by the opengroup, used to initialize the process properties */
+extern char **wenviron;
+#else
+extern char **environ;
+#endif
# endif
- void gras_process_init()
+void gras_process_init()
{
char **env_iter;
_gras_procdata = xbt_new0(gras_procdata_t, 1);
equal = strchr(buf, '=');
if (!equal) {
WARN1
- ("The environment contains an entry without '=' char: %s (ignore it)",
- *env_iter);
+ ("The environment contains an entry without '=' char: %s (ignore it)",
+ *env_iter);
continue;
}
*equal = '\0';
- xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1), xbt_free_f);
+ xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1),
+ xbt_free_f);
free(buf);
env_iter++;
}
smx_process_t process = SIMIX_process_self();
/*HACK: maestro used not have a simix process, now it does so
- SIMIX_process_self will return something different to NULL. This breaks
- the old xbt_log logic that assumed that NULL was equivalent to maestro,
- thus when printing it searches for maestro host name (which doesn't exists)
- and breaks the logging.
- As a hack we check for maestro by looking to the assigned host, if it is
- NULL then we are sure is maestro
- */
+ SIMIX_process_self will return something different to NULL. This breaks
+ the old xbt_log logic that assumed that NULL was equivalent to maestro,
+ thus when printing it searches for maestro host name (which doesn't exists)
+ and breaks the logging.
+ As a hack we check for maestro by looking to the assigned host, if it is
+ NULL then we are sure is maestro
+ */
if (process != NULL && (host = SIMIX_host_self()) != NULL)
- return SIMIX_host_get_name(host);
-
- return "";
+ return SIMIX_host_get_name(host);
+
+ return "";
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_virtu_emul, gras_virtu,
"Emulation support");
/*** CPU burning */
-void gras_cpu_burn(double flops) {
+void gras_cpu_burn(double flops)
+{
smx_action_t act;
smx_cond_t cond;
smx_mutex_t mutex;
- if (flops>0) {
+ if (flops > 0) {
cond = SIMIX_cond_init();
mutex = SIMIX_mutex_init();
SIMIX_mutex_lock(mutex);
- act =
- SIMIX_action_execute(SIMIX_host_self(), "task", flops);
+ act = SIMIX_action_execute(SIMIX_host_self(), "task", flops);
SIMIX_register_action_to_condition(act, cond);
SIMIX_cond_wait(cond, mutex);
SIMIX_mutex_destroy(mutex);
}
}
+
/*** Timing macros ***/
static xbt_os_timer_t timer;
static int benchmarking = 0;
return 0;
}
-int gras_bench_always_end(void) {
+int gras_bench_always_end(void)
+{
xbt_assert0(benchmarking, "Not benchmarking yet");
benchmarking = 0;
xbt_os_timer_stop(timer);
duration = xbt_os_timer_elapsed(timer);
- gras_cpu_burn(duration/reference);
+ gras_cpu_burn(duration / reference);
return 0;
}
}
}
-int gras_bench_once_end(void) {
+int gras_bench_once_end(void)
+{
xbt_assert0(benchmarking, "Not benchmarking yet");
benchmarking = 0;
if (duration > 0) {
duration = get_from_dict(benchmark_set, locbuf);
}
DEBUG2("Simulate the run of a task of %f sec for %s", duration, locbuf);
- gras_cpu_burn(duration/reference);
+ gras_cpu_burn(duration / reference);
return 0;
}
void gras_process_init()
{
gras_hostdata_t *hd =
- (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
+ (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
gras_procdata_t *pd = xbt_new0(gras_procdata_t, 1);
gras_trp_procdata_t trp_pd;
trp_pd->msg_selectable_sockets = xbt_queue_new(0, sizeof(gras_socket_t));
- trp_pd->meas_selectable_sockets = xbt_queue_new(0, sizeof(gras_socket_t));
+ trp_pd->meas_selectable_sockets =
+ xbt_queue_new(0, sizeof(gras_socket_t));
VERB2("Creating process '%s' (%d)",
SIMIX_process_get_name(SIMIX_process_self()), gras_os_getpid());
void gras_process_exit()
{
xbt_dynar_t sockets =
- ((gras_trp_procdata_t) gras_libdata_by_name("gras_trp"))->sockets;
+ ((gras_trp_procdata_t) gras_libdata_by_name("gras_trp"))->sockets;
gras_socket_t sock_iter;
unsigned int cursor;
gras_hostdata_t *hd =
- (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
+ (gras_hostdata_t *) SIMIX_host_get_data(SIMIX_host_self());
gras_procdata_t *pd =
- (gras_procdata_t *) SIMIX_process_get_data(SIMIX_process_self());
+ (gras_procdata_t *) SIMIX_process_get_data(SIMIX_process_self());
gras_msg_procdata_t msg_pd =
- (gras_msg_procdata_t) gras_libdata_by_name("gras_msg");
+ (gras_msg_procdata_t) gras_libdata_by_name("gras_msg");
gras_trp_procdata_t trp_pd =
- (gras_trp_procdata_t) gras_libdata_by_name("gras_trp");
+ (gras_trp_procdata_t) gras_libdata_by_name("gras_trp");
xbt_queue_free(&trp_pd->msg_selectable_sockets);
if (xbt_dynar_length(msg_pd->msg_queue)) {
unsigned int cpt;
s_gras_msg_t msg;
- WARN2("process %d terminated, but %ld messages are still queued. Message list:",
- gras_os_getpid(),xbt_dynar_length(msg_pd->msg_queue));
- xbt_dynar_foreach(msg_pd->msg_queue,cpt, msg) {
- WARN5(" Message %s (%s) from %s@%s:%d",msg.type->name,e_gras_msg_kind_names[msg.kind],
- gras_socket_peer_proc(msg.expe),gras_socket_peer_name(msg.expe),gras_socket_peer_port(msg.expe));
+ WARN2
+ ("process %d terminated, but %ld messages are still queued. Message list:",
+ gras_os_getpid(), xbt_dynar_length(msg_pd->msg_queue));
+ xbt_dynar_foreach(msg_pd->msg_queue, cpt, msg) {
+ WARN5(" Message %s (%s) from %s@%s:%d", msg.type->name,
+ e_gras_msg_kind_names[msg.kind],
+ gras_socket_peer_proc(msg.expe),
+ gras_socket_peer_name(msg.expe),
+ gras_socket_peer_port(msg.expe));
}
}
gras_procdata_t *gras_procdata_get(void)
{
gras_procdata_t *pd =
- (gras_procdata_t *) SIMIX_process_get_data(SIMIX_process_self());
+ (gras_procdata_t *) SIMIX_process_get_data(SIMIX_process_self());
xbt_assert0(pd, "Run gras_process_init! (ie, gras_init)");
const char *gras_process_property_value(const char *name)
{
return
- xbt_dict_get_or_null(SIMIX_process_get_properties(SIMIX_process_self()),
- name);
+ xbt_dict_get_or_null(SIMIX_process_get_properties
+ (SIMIX_process_self()), name);
}
/** @brief retrieve the process properties dictionnary
{
smx_process_t process = SIMIX_process_self();
/*FIXME: maestro used not have a simix process, now it does so
- SIMIX_process_self will return something different to NULL. This breaks
- the old xbt_log logic that assumed that NULL was equivalent to maestro,
- thus when printing it searches for maestro host name (which doesn't exists)
- and breaks the logging.
- As a hack we check for maestro by looking to the assigned host, if it is
- NULL then we are sure is maestro
- */
+ SIMIX_process_self will return something different to NULL. This breaks
+ the old xbt_log logic that assumed that NULL was equivalent to maestro,
+ thus when printing it searches for maestro host name (which doesn't exists)
+ and breaks the logging.
+ As a hack we check for maestro by looking to the assigned host, if it is
+ NULL then we are sure is maestro
+ */
if (process != NULL && SIMIX_process_get_host(process))
return SIMIX_process_get_name(process);
{
gras_procdata_t *data;
smx_process_t process = SIMIX_process_self();
-
- if (process != NULL){
- data = (gras_procdata_t *)SIMIX_process_get_data(process);
- if(data != NULL)
+
+ if (process != NULL) {
+ data = (gras_procdata_t *) SIMIX_process_get_data(process);
+ if (data != NULL)
return data->pid;
}
-
+
return 0;
}
const char *gras_os_host_property_value(const char *name)
{
return
- xbt_dict_get_or_null(SIMIX_host_get_properties
- (SIMIX_process_get_host(SIMIX_process_self())),
- name);
+ xbt_dict_get_or_null(SIMIX_host_get_properties
+ (SIMIX_process_get_host(SIMIX_process_self())),
+ name);
}
/** @brief retrieve the host properties dictionnary
xbt_dict_t gras_os_host_properties(void)
{
return
- SIMIX_host_get_properties(SIMIX_process_get_host(SIMIX_process_self()));
+ SIMIX_host_get_properties(SIMIX_process_get_host
+ (SIMIX_process_self()));
}
/* **************************************************************************
SIMIX_init();
while (SIMIX_solve(NULL, NULL) != -1.0);
-
+
return;
}
SIMIX_launch_application(file);
}
-void gras_load_environment_script(const char* script_file)
+void gras_load_environment_script(const char *script_file)
{
#ifdef HAVE_LUA
- lua_State *L = lua_open();
- luaL_openlibs(L);
+ lua_State *L = lua_open();
+ luaL_openlibs(L);
- if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
- printf("error: %s\n", lua_tostring(L, -1));
- return;
- }
+ if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
+ printf("error: %s\n", lua_tostring(L, -1));
+ return;
+ }
#else
- xbt_die("Lua is not available!! to call gras_load_environment_script, lua should be available...");
+ xbt_die
+ ("Lua is not available!! to call gras_load_environment_script, lua should be available...");
#endif
- return;
+ return;
}
void gras_clean()
SG_BEGIN_DECL()
/* shutdown the module mechanism (world-wide cleanups) */
- void gras_moddata_exit(void);
+void gras_moddata_exit(void);
/* shutdown this process wrt module mecanism (process-wide cleanups) */
- void gras_moddata_leave(void);
+void gras_moddata_leave(void);
/* Perform the various intialisations needed by gras. Each process must run it */
/* declare a new process specific data
(used by gras_<module>_register to make sure that gras_process_init will create it) */
- int gras_procdata_add(const char *name, pvoid_f_void_t creator,
- void_f_pvoid_t destructor);
+int gras_procdata_add(const char *name, pvoid_f_void_t creator,
+ void_f_pvoid_t destructor);
- void *gras_libdata_by_name(const char *name);
- void *gras_libdata_by_id(int id);
+void *gras_libdata_by_name(const char *name);
+void *gras_libdata_by_id(int id);
SG_END_DECL()
-#endif /* GRAS_VIRTU_INTERFACE_H */
+#endif /* GRAS_VIRTU_INTERFACE_H */
void *gras_libdata_by_name_from_procdata(const char *name,
gras_procdata_t * pd);
-#endif /* GRAS_VIRTU_PRIVATE_H */
+#endif /* GRAS_VIRTU_PRIVATE_H */
#include "gras/Virtu/virtu_private.h"
-#endif /* VIRTU_RL_H */
+#endif /* VIRTU_RL_H */
smx_process_t server;
smx_process_t client;
- smx_rdv_t rdv_server; /* The rendez-vous point to use */
- smx_rdv_t rdv_client; /* The rendez-vous point to use */
- smx_comm_t comm_recv; /* The comm of irecv on receiver side */
-} s_gras_trp_sg_sock_data_t,*gras_trp_sg_sock_data_t;
+ smx_rdv_t rdv_server; /* The rendez-vous point to use */
+ smx_rdv_t rdv_client; /* The rendez-vous point to use */
+ smx_comm_t comm_recv; /* The comm of irecv on receiver side */
+} s_gras_trp_sg_sock_data_t, *gras_trp_sg_sock_data_t;
void *gras_libdata_by_name_from_remote(const char *name, smx_process_t p);
* order.
*/
-#endif /* VIRTU_SG_H */
+#endif /* VIRTU_SG_H */
void gras_procdata_init(void);
void gras_procdata_exit(void);
-#endif /* GRAS_MODINTER_H */
+#endif /* GRAS_MODINTER_H */
typedef struct s_mc_transition *mc_transition_t;
SG_END_DECL()
-
-#endif /* _MC_MC_H */
+#endif /* _MC_MC_H */
XBT_PUBLIC(void) MC_exit(int);
XBT_PUBLIC(void) MC_assert(int);
XBT_PUBLIC(void) MC_modelcheck(int);
-XBT_PUBLIC(int) MC_random(int,int);
+XBT_PUBLIC(int) MC_random(int, int);
/******************************* Transitions **********************************/
XBT_PUBLIC(void) MC_trans_intercept_isend(smx_rdv_t);
XBT_PUBLIC(void) MC_trans_intercept_wait(smx_comm_t);
XBT_PUBLIC(void) MC_trans_intercept_test(smx_comm_t);
XBT_PUBLIC(void) MC_trans_intercept_waitany(xbt_dynar_t);
-XBT_PUBLIC(void) MC_trans_intercept_random(int,int);
+XBT_PUBLIC(void) MC_trans_intercept_random(int, int);
/********************************* Memory *************************************/
-XBT_PUBLIC(void) MC_memory_init(void); /* Initialize the memory subsystem */
+XBT_PUBLIC(void) MC_memory_init(void); /* Initialize the memory subsystem */
XBT_PUBLIC(void) MC_memory_exit(void);
/*
SG_END_DECL()
-
#endif /* _MC_MC_H */
#ifndef XBT_CONTEXT_H
#define XBT_CONTEXT_H
-#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 */
-
-SG_BEGIN_DECL()
-
+#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 */
+
+SG_BEGIN_DECL()
+
typedef struct s_xbt_context *xbt_context_t;
-XBT_PUBLIC(xbt_context_t) xbt_context_new(const char *name, xbt_main_func_t code,
- void_f_pvoid_t startup_func, void *startup_arg,
- void_f_pvoid_t cleanup_func, void *cleanup_arg, int argc, char *argv[]);
+XBT_PUBLIC(xbt_context_t) xbt_context_new(const char *name,
+ xbt_main_func_t code,
+ void_f_pvoid_t startup_func,
+ void *startup_arg,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg, int argc,
+ char *argv[]);
XBT_PUBLIC(void) xbt_context_kill(xbt_context_t context);
XBT_PUBLIC(void) xbt_context_yield(void);
XBT_PUBLIC(void) xbt_context_schedule(xbt_context_t context);
-
+
void xbt_context_empty_trash(void);
void xbt_context_stop(int exit_code);
-
+
void xbt_context_free(xbt_context_t context);
-SG_END_DECL()
-
-#endif /* !XBT_CONTEXT_H */
+SG_END_DECL()
+#endif /* !XBT_CONTEXT_H */
\see m_host_management
@{ */
- typedef struct s_smx_host *smx_host_t;
+typedef struct s_smx_host *smx_host_t;
/** @} */
/* ******************************** Syncro ************************************ */
- typedef struct s_smx_mutex {
- xbt_swag_t sleeping; /* list of sleeping process */
- int refcount;
- } s_smx_mutex_t;
- typedef s_smx_mutex_t *smx_mutex_t;
-
- typedef struct s_smx_cond {
- xbt_swag_t sleeping; /* list of sleeping process */
- smx_mutex_t mutex;
- xbt_fifo_t actions; /* list of actions */
- } s_smx_cond_t;
- typedef s_smx_cond_t *smx_cond_t;
-
- typedef struct s_smx_sem {
- xbt_fifo_t sleeping; /* list of sleeping process */
- int capacity;
- xbt_fifo_t actions; /* list of actions */
- } s_smx_sem_t;
- typedef s_smx_sem_t *smx_sem_t;
+typedef struct s_smx_mutex {
+ xbt_swag_t sleeping; /* list of sleeping process */
+ int refcount;
+} s_smx_mutex_t;
+typedef s_smx_mutex_t *smx_mutex_t;
+
+typedef struct s_smx_cond {
+ xbt_swag_t sleeping; /* list of sleeping process */
+ smx_mutex_t mutex;
+ xbt_fifo_t actions; /* list of actions */
+} s_smx_cond_t;
+typedef s_smx_cond_t *smx_cond_t;
+
+typedef struct s_smx_sem {
+ xbt_fifo_t sleeping; /* list of sleeping process */
+ int capacity;
+ xbt_fifo_t actions; /* list of actions */
+} s_smx_sem_t;
+typedef s_smx_sem_t *smx_sem_t;
/********************************** Action *************************************/
- typedef struct s_smx_action *smx_action_t;
+typedef struct s_smx_action *smx_action_t;
/* ****************************** Process *********************************** */
/** @brief Agent datatype
data</em>, executing in a <em>location</em>.
\see m_process_management
@{ */
- typedef struct s_smx_process *smx_process_t;
+typedef struct s_smx_process *smx_process_t;
/** @} */
- typedef struct s_smx_context *smx_context_t;
+typedef struct s_smx_context *smx_context_t;
/******************************* Networking ***********************************/
- typedef struct s_smx_rvpoint *smx_rdv_t;
- typedef struct s_smx_comm *smx_comm_t;
- typedef enum {comm_send,
- comm_recv
- } smx_comm_type_t;
+typedef struct s_smx_rvpoint *smx_rdv_t;
+typedef struct s_smx_comm *smx_comm_t;
+typedef enum { comm_send,
+ comm_recv
+} smx_comm_type_t;
XBT_PUBLIC(void) SIMIX_function_register(const char *name,
xbt_main_func_t code);
XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
-XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
+XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char
+ *name);
XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
/*
* Deployment (Bypass the parser)
*/
-XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,const char *process_function,xbt_dynar_t arguments,double process_start_time,double process_kill_time);
+XBT_PUBLIC(void) SIMIX_process_set_function(const char *process_host,
+ const char *process_function,
+ xbt_dynar_t arguments,
+ double process_start_time,
+ double process_kill_time);
XBT_PUBLIC(double) SIMIX_get_clock(void);
* int argc, char **argv: parameters passed to code
*
* */
- typedef void *(*smx_creation_func_t) ( /*name */ const char *,
- /*code */ xbt_main_func_t,
- /*userdata */ void *,
- /*hostname */ char *,
- /* argc */ int,
- /* argv */ char **,
- /* props */ xbt_dict_t);
+typedef void *(*smx_creation_func_t) ( /*name */ const char *,
+ /*code */ xbt_main_func_t,
+ /*userdata */ void *,
+ /*hostname */ char *,
+ /* argc */ int,
+ /* argv */ char **,
+ /* props */ xbt_dict_t);
XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t
function);
XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_f_pvoid_t
XBT_PUBLIC(smx_process_t) SIMIX_process_create(const char *name,
xbt_main_func_t code,
void *data,
- const char *hostname, int argc,
- char **argv,
+ const char *hostname,
+ int argc, char **argv,
xbt_dict_t properties);
XBT_PUBLIC(void) SIMIX_process_kill(smx_process_t process);
XBT_PUBLIC(void *) SIMIX_process_get_data(smx_process_t process);
XBT_PUBLIC(void) SIMIX_process_set_data(smx_process_t process, void *data);
-XBT_INLINE XBT_PUBLIC(smx_host_t) SIMIX_process_get_host(smx_process_t process);
+XBT_INLINE XBT_PUBLIC(smx_host_t) SIMIX_process_get_host(smx_process_t
+ process);
XBT_PUBLIC(const char *) SIMIX_process_get_name(smx_process_t process);
XBT_INLINE XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
XBT_PUBLIC(smx_cond_t) SIMIX_cond_init(void);
XBT_PUBLIC(void) SIMIX_cond_signal(smx_cond_t cond);
XBT_PUBLIC(void) SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
-XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex,
+XBT_PUBLIC(void) SIMIX_cond_wait_timeout(smx_cond_t cond,
+ smx_mutex_t mutex,
double max_duration);
XBT_PUBLIC(void) SIMIX_cond_broadcast(smx_cond_t cond);
XBT_PUBLIC(void) SIMIX_cond_destroy(smx_cond_t cond);
XBT_PUBLIC(int) SIMIX_sem_would_block(smx_sem_t sem);
XBT_PUBLIC(void) SIMIX_sem_block_onto(smx_sem_t sem);
XBT_PUBLIC(void) SIMIX_sem_acquire(smx_sem_t sem);
-XBT_PUBLIC(void) SIMIX_sem_acquire_timeout(smx_sem_t sem, double max_duration);
+XBT_PUBLIC(void) SIMIX_sem_acquire_timeout(smx_sem_t sem,
+ double max_duration);
XBT_PUBLIC(unsigned int) SIMIX_sem_acquire_any(xbt_dynar_t sems);
XBT_PUBLIC(int) SIMIX_sem_get_capacity(smx_sem_t sem);
XBT_PUBLIC(smx_action_t) SIMIX_action_communicate(smx_host_t sender,
smx_host_t receiver,
const char *name,
- double size, double rate);
+ double size,
+ double rate);
XBT_PUBLIC(smx_action_t) SIMIX_action_execute(smx_host_t host,
const char *name,
double amount);
-XBT_PUBLIC(smx_action_t) SIMIX_action_sleep(smx_host_t host, double amount);
+XBT_PUBLIC(smx_action_t) SIMIX_action_sleep(smx_host_t host,
+ double amount);
XBT_PUBLIC(void) SIMIX_action_cancel(smx_action_t action);
XBT_PUBLIC(void) SIMIX_action_set_priority(smx_action_t action,
double priority);
smx_cond_t cond);
XBT_PUBLIC(void) SIMIX_unregister_action_to_condition(smx_action_t action,
smx_cond_t cond);
-XBT_PUBLIC(void) SIMIX_register_action_to_semaphore(smx_action_t action, smx_sem_t sem);
-XBT_INLINE XBT_PUBLIC(void) SIMIX_unregister_action_to_semaphore(smx_action_t action, smx_sem_t sem);
+XBT_PUBLIC(void) SIMIX_register_action_to_semaphore(smx_action_t action,
+ smx_sem_t sem);
+XBT_INLINE XBT_PUBLIC(void)
+SIMIX_unregister_action_to_semaphore(smx_action_t action, smx_sem_t sem);
XBT_PUBLIC(double) SIMIX_action_get_remains(smx_action_t action);
XBT_PUBLIC(int) SIMIX_action_is_latency_bounded(smx_action_t action);
#endif
-XBT_PUBLIC(e_surf_action_state_t) SIMIX_action_get_state(smx_action_t action);
+XBT_PUBLIC(e_surf_action_state_t) SIMIX_action_get_state(smx_action_t
+ action);
XBT_PUBLIC(smx_action_t) SIMIX_action_parallel_execute(char *name,
int host_nb,
- smx_host_t * host_list,
- double
+ smx_host_t *
+ host_list, double
*computation_amount, double
*communication_amount,
double amount,
double rate);
XBT_PUBLIC(char *) SIMIX_action_get_name(smx_action_t action);
-XBT_PUBLIC(void) SIMIX_action_set_name(smx_action_t action,char *name);
+XBT_PUBLIC(void) SIMIX_action_set_name(smx_action_t action, char *name);
XBT_PUBLIC(void) SIMIX_action_signal_all(smx_action_t action);
XBT_PUBLIC(void) SIMIX_display_process_status(void);
/************************** Comunication Handling *****************************/
/*****Rendez-vous points*****/
XBT_PUBLIC(smx_rdv_t) SIMIX_rdv_create(const char *name);
XBT_PUBLIC(void) SIMIX_rdv_destroy(smx_rdv_t rvp);
-XBT_PUBLIC(int) SIMIX_rdv_get_count_waiting_comm(smx_rdv_t rdv, smx_host_t host);
+XBT_PUBLIC(int) SIMIX_rdv_get_count_waiting_comm(smx_rdv_t rdv,
+ smx_host_t host);
XBT_PUBLIC(smx_comm_t) SIMIX_rdv_get_head(smx_rdv_t rdv);
-XBT_PUBLIC(smx_comm_t) SIMIX_rdv_get_request(smx_rdv_t rdv, smx_comm_type_t type);
-XBT_PUBLIC(void) SIMIX_rdv_set_data(smx_rdv_t rdv,void *data);
-XBT_PUBLIC(void*) SIMIX_rdv_get_data(smx_rdv_t rdv);
+XBT_PUBLIC(smx_comm_t) SIMIX_rdv_get_request(smx_rdv_t rdv,
+ smx_comm_type_t type);
+XBT_PUBLIC(void) SIMIX_rdv_set_data(smx_rdv_t rdv, void *data);
+XBT_PUBLIC(void *) SIMIX_rdv_get_data(smx_rdv_t rdv);
/*****Communication Requests*****/
XBT_INLINE XBT_PUBLIC(void) SIMIX_communication_cancel(smx_comm_t comm);
XBT_PUBLIC(void) SIMIX_communication_destroy(smx_comm_t comm);
XBT_PUBLIC(double) SIMIX_communication_get_remains(smx_comm_t comm);
#ifdef HAVE_LATENCY_BOUND_TRACKING
-XBT_PUBLIC(int) SIMIX_communication_is_latency_bounded(smx_comm_t comm);
+XBT_PUBLIC(int) SIMIX_communication_is_latency_bounded(smx_comm_t comm);
#endif
XBT_PUBLIC(void *) SIMIX_communication_get_data(smx_comm_t comm);
XBT_PUBLIC(size_t) SIMIX_communication_get_dst_buf_size(smx_comm_t comm);
/*****Networking*****/
-XBT_PUBLIC(void) SIMIX_network_set_copy_data_callback(void (*callback)(smx_comm_t, size_t));
-XBT_PUBLIC(void) SIMIX_network_copy_pointer_callback(smx_comm_t comm, size_t buff_size);
-XBT_PUBLIC(void) SIMIX_network_copy_buffer_callback(smx_comm_t comm, size_t buff_size);
-XBT_PUBLIC(void) SIMIX_network_send(smx_rdv_t rdv, double task_size, double rate,
- double timeout, void *src_buff,
- size_t src_buff_size, smx_comm_t *comm, void *data);
-XBT_PUBLIC(void) SIMIX_network_recv(smx_rdv_t rdv, double timeout, void *dst_buff,
- size_t *dst_buff_size, smx_comm_t *comm);
-XBT_PUBLIC(smx_comm_t) SIMIX_network_isend(smx_rdv_t rdv, double task_size, double rate,
- void *src_buff, size_t src_buff_size, void *data);
-XBT_PUBLIC(smx_comm_t) SIMIX_network_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size);
+XBT_PUBLIC(void) SIMIX_network_set_copy_data_callback(void (*callback)
+ (smx_comm_t,
+ size_t));
+XBT_PUBLIC(void) SIMIX_network_copy_pointer_callback(smx_comm_t comm,
+ size_t buff_size);
+XBT_PUBLIC(void) SIMIX_network_copy_buffer_callback(smx_comm_t comm,
+ size_t buff_size);
+XBT_PUBLIC(void) SIMIX_network_send(smx_rdv_t rdv, double task_size,
+ double rate, double timeout,
+ void *src_buff, size_t src_buff_size,
+ smx_comm_t * comm, void *data);
+XBT_PUBLIC(void) SIMIX_network_recv(smx_rdv_t rdv, double timeout,
+ void *dst_buff, size_t * dst_buff_size,
+ smx_comm_t * comm);
+XBT_PUBLIC(smx_comm_t) SIMIX_network_isend(smx_rdv_t rdv, double task_size,
+ double rate, void *src_buff,
+ size_t src_buff_size,
+ void *data);
+XBT_PUBLIC(smx_comm_t) SIMIX_network_irecv(smx_rdv_t rdv, void *dst_buff,
+ size_t * dst_buff_size);
XBT_PUBLIC(unsigned int) SIMIX_network_waitany(xbt_dynar_t comms);
-XBT_INLINE XBT_PUBLIC(void) SIMIX_network_wait(smx_comm_t comm, double timeout);
+XBT_INLINE XBT_PUBLIC(void) SIMIX_network_wait(smx_comm_t comm,
+ double timeout);
XBT_PUBLIC(int) SIMIX_network_test(smx_comm_t comm);
SG_END_DECL()
-#endif /* _SIMIX_SIMIX_H */
+#endif /* _SIMIX_SIMIX_H */
typedef struct tmgr_trace_event *tmgr_trace_event_t;
-#endif /* MAXMIN_DATATYPES_H */
+#endif /* MAXMIN_DATATYPES_H */
XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
- void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
+void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
double bound_value);
- void lmm_constraint_shared(lmm_constraint_t cnst);
- int lmm_constraint_is_shared(lmm_constraint_t cnst);
+void lmm_constraint_shared(lmm_constraint_t cnst);
+int lmm_constraint_is_shared(lmm_constraint_t cnst);
- void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
+void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
double weight_value,
double bound,
int number_of_constraints);
- void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
+void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
lmm_variable_t var, double value);
- void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
- lmm_variable_t var, double value);
- void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
- lmm_variable_t var, double value);
-
- lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
- lmm_variable_t var, int num);
- int lmm_get_number_of_cnst_from_var(lmm_system_t sys,
- lmm_variable_t var);
- lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
- lmm_constraint_t cnst,
- lmm_element_t * elem);
-
- lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
- lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
- lmm_constraint_t cnst);
+void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
+ lmm_variable_t var, double value);
+void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
+ lmm_variable_t var, double value);
+
+lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
+ lmm_variable_t var, int num);
+int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
+lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
+ lmm_constraint_t cnst,
+ lmm_element_t * elem);
+
+lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
+lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
+ lmm_constraint_t cnst);
#ifdef HAVE_LATENCY_BOUND_TRACKING
- XBT_PUBLIC(int) lmm_is_variable_limited_by_latency(lmm_variable_t var);
+XBT_PUBLIC(int) lmm_is_variable_limited_by_latency(lmm_variable_t var);
#endif
- void *lmm_constraint_id(lmm_constraint_t cnst);
- void *lmm_variable_id(lmm_variable_t var);
+void *lmm_constraint_id(lmm_constraint_t cnst);
+void *lmm_variable_id(lmm_variable_t var);
- void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
- lmm_variable_t var, double value);
- void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
- double bound);
+void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
+ lmm_variable_t var, double value);
+void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
+ double bound);
XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys,
lmm_variable_t var,
double weight);
- double lmm_get_variable_weight(lmm_variable_t var);
+double lmm_get_variable_weight(lmm_variable_t var);
XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys,
lmm_constraint_t cnst,
double bound);
- int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
+int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
*/
XBT_PUBLIC(void) lmm_set_default_protocol_function(double (*func_f)
- (lmm_variable_t var, double x),
+ (lmm_variable_t var,
+ double x),
double (*func_fp)
- (lmm_variable_t var, double x),
+ (lmm_variable_t var,
+ double x),
double (*func_fpi)
- (lmm_variable_t var, double x));
+ (lmm_variable_t var,
+ double x));
XBT_PUBLIC(double func_reno_f) (lmm_variable_t var, double x);
XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
XBT_PUBLIC(double func_vegas_fpi) (lmm_variable_t var, double x);
-#endif /* _SURF_MAXMIN_H */
+#endif /* _SURF_MAXMIN_H */
SG_BEGIN_DECL()
- typedef enum { NONE, DRAND48, RAND } Generator;
+typedef enum { NONE, DRAND48, RAND } Generator;
- typedef struct random_data_desc {
- long int seed;
- double max, min;
- double mean, std; /* note: mean and standard deviation are normalized */
- Generator generator;
- } s_random_data_t, *random_data_t;
+typedef struct random_data_desc {
+ long int seed;
+ double max, min;
+ double mean, std; /* note: mean and standard deviation are normalized */
+ Generator generator;
+} s_random_data_t, *random_data_t;
XBT_PUBLIC_DATA(xbt_dict_t) random_data_list;
double stdDeviation);
SG_END_DECL()
-#endif /* _SURF_RMGR_H */
+#endif /* _SURF_RMGR_H */
SG_BEGIN_DECL()
/* Actions and models are highly connected structures... */
- typedef enum {
- SURF_RESOURCE_ON = 1, /**< Up & ready */
- SURF_RESOURCE_OFF = 0 /**< Down & broken */
- } e_surf_resource_state_t;
+typedef enum {
+ SURF_RESOURCE_ON = 1, /**< Up & ready */
+ SURF_RESOURCE_OFF = 0 /**< Down & broken */
+} e_surf_resource_state_t;
- typedef enum {
- SURF_LINK_SHARED = 1,
- SURF_LINK_FATPIPE = 0
- } e_surf_link_sharing_policy_t;
+typedef enum {
+ SURF_LINK_SHARED = 1,
+ SURF_LINK_FATPIPE = 0
+} e_surf_link_sharing_policy_t;
/** @Brief Specify that we use that action */
XBT_PUBLIC(void) surf_action_ref(surf_action_t action);
/** \brief Resource model description
*/
- typedef struct surf_model_description {
- const char *name;
- const char *description;
- surf_model_t model;
- void (*model_init_preparse) (const char *filename);
- void (*model_init_postparse) (void);
- } s_surf_model_description_t, *surf_model_description_t;
+typedef struct surf_model_description {
+ const char *name;
+ const char *description;
+ surf_model_t model;
+ void (*model_init_preparse) (const char *filename);
+ void (*model_init_postparse) (void);
+} s_surf_model_description_t, *surf_model_description_t;
-XBT_PUBLIC(void) update_model_description(s_surf_model_description_t * table,
- const char *name,
+XBT_PUBLIC(void) update_model_description(s_surf_model_description_t *
+ table, const char *name,
surf_model_t model);
XBT_PUBLIC(int) find_model_description(s_surf_model_description_t * table,
const char *name);
-XBT_PUBLIC(void) model_help(const char* category, s_surf_model_description_t * table);
+XBT_PUBLIC(void) model_help(const char *category,
+ s_surf_model_description_t * table);
/** \brief Action structure
* \ingroup SURF_actions
*
* \see e_surf_action_state_t
*/
- typedef struct surf_action {
- s_xbt_swag_hookup_t state_hookup;
- xbt_swag_t state_set;
- double cost; /**< cost */
- double priority; /**< priority (1.0 by default) */
- double max_duration; /**< max_duration (may fluctuate until
+typedef struct surf_action {
+ s_xbt_swag_hookup_t state_hookup;
+ xbt_swag_t state_set;
+ double cost; /**< cost */
+ double priority; /**< priority (1.0 by default) */
+ double max_duration; /**< max_duration (may fluctuate until
the task is completed) */
- double remains; /**< How much of that cost remains to
+ double remains; /**< How much of that cost remains to
* be done in the currently running task */
#ifdef HAVE_LATENCY_BOUND_TRACKING
- int latency_limited; /**< Set to 1 if is limited by latency, 0 otherwise */
+ int latency_limited; /**< Set to 1 if is limited by latency, 0 otherwise */
#endif
- double start; /**< start time */
- double finish; /**< finish time : this is modified during the run
+ double start; /**< start time */
+ double finish; /**< finish time : this is modified during the run
* and fluctuates until the task is completed */
- void *data; /**< for your convenience */
- int refcount;
- surf_model_t model_type;
+ void *data; /**< for your convenience */
+ int refcount;
+ surf_model_t model_type;
#ifdef HAVE_TRACING
- char *category; /**< tracing category for categorized resource utilization monitoring */
+ char *category; /**< tracing category for categorized resource utilization monitoring */
#endif
- } s_surf_action_t;
+} s_surf_action_t;
- typedef struct surf_action_lmm {
- s_surf_action_t generic_action;
- lmm_variable_t variable;
- int suspended;
- } s_surf_action_lmm_t, *surf_action_lmm_t;
+typedef struct surf_action_lmm {
+ s_surf_action_t generic_action;
+ lmm_variable_t variable;
+ int suspended;
+} s_surf_action_lmm_t, *surf_action_lmm_t;
/** \brief Action states
* \ingroup SURF_actions
*
* \see surf_action_t, surf_action_state_t
*/
- typedef enum {
- SURF_ACTION_READY = 0, /**< Ready */
- SURF_ACTION_RUNNING, /**< Running */
- SURF_ACTION_FAILED, /**< Task Failure */
- SURF_ACTION_DONE, /**< Completed */
- SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */
- SURF_ACTION_NOT_IN_THE_SYSTEM
+typedef enum {
+ SURF_ACTION_READY = 0, /**< Ready */
+ SURF_ACTION_RUNNING, /**< Running */
+ SURF_ACTION_FAILED, /**< Task Failure */
+ SURF_ACTION_DONE, /**< Completed */
+ SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */
+ SURF_ACTION_NOT_IN_THE_SYSTEM
/**< Not in the system anymore. Why did you ask ? */
- } e_surf_action_state_t;
+} e_surf_action_state_t;
/** \brief Action state sets
* \ingroup SURF_actions
*
* \see surf_action_t, e_surf_action_state_t
*/
- typedef struct surf_action_state {
- xbt_swag_t ready_action_set;
+typedef struct surf_action_state {
+ xbt_swag_t ready_action_set;
/**< Actions in state SURF_ACTION_READY */
- xbt_swag_t running_action_set;
+ xbt_swag_t running_action_set;
/**< Actions in state SURF_ACTION_RUNNING */
- xbt_swag_t failed_action_set;
+ xbt_swag_t failed_action_set;
/**< Actions in state SURF_ACTION_FAILED */
- xbt_swag_t done_action_set;
+ xbt_swag_t done_action_set;
/**< Actions in state SURF_ACTION_DONE */
- } s_surf_action_state_t, *surf_action_state_t;
+} s_surf_action_state_t, *surf_action_state_t;
/***************************/
/* Generic model object */
/***************************/
- typedef struct s_routing_global s_routing_global_t, *routing_global_t;
+typedef struct s_routing_global s_routing_global_t, *routing_global_t;
XBT_PUBLIC_DATA(routing_global_t) global_routing;
/** \brief Private data available on all models
* \ingroup SURF_models
*/
- typedef struct surf_model_private *surf_model_private_t;
+typedef struct surf_model_private *surf_model_private_t;
/** \brief Timer model extension public
* \ingroup SURF_model
*
* Additionnal functions specific to the timer model
*/
- typedef struct surf_timer_model_extension_public {
- void (*set) (double date, void *function, void *arg);
- int (*get) (void **function, void **arg);
- } s_surf_model_extension_timer_t;
+typedef struct surf_timer_model_extension_public {
+ void (*set) (double date, void *function, void *arg);
+ int (*get) (void **function, void **arg);
+} s_surf_model_extension_timer_t;
/* Cpu model */
*
* Public functions specific to the CPU model.
*/
- typedef struct surf_cpu_model_extension_public {
- surf_action_t(*execute) (void *cpu, double size);
- surf_action_t(*sleep) (void *cpu, double duration);
- e_surf_resource_state_t(*get_state) (void *cpu);
- double (*get_speed) (void *cpu, double load);
- double (*get_available_speed) (void *cpu);
- void (*create_resource)(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties);
- void (*add_traces)(void);
- } s_surf_model_extension_cpu_t;
+typedef struct surf_cpu_model_extension_public {
+ surf_action_t(*execute) (void *cpu, double size);
+ surf_action_t(*sleep) (void *cpu, double duration);
+ e_surf_resource_state_t(*get_state) (void *cpu);
+ double (*get_speed) (void *cpu, double load);
+ double (*get_available_speed) (void *cpu);
+ void (*create_resource) (char *name, double power_peak,
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties);
+ void (*add_traces) (void);
+} s_surf_model_extension_cpu_t;
/* Network model */
*
* Public functions specific to the network model
*/
- typedef struct surf_network_model_extension_public {
- surf_action_t(*communicate) (const char *src_name,
- const char *dst_name,
- double size, double rate);
- xbt_dynar_t(*get_route) (const char *src_name, const char *dst_name);
- double (*get_link_bandwidth) (const void *link);
- double (*get_link_latency) (const void *link);
- int (*link_shared) (const void *link);
- void (*add_traces)(void);
- void (*create_resource)(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties);
- } s_surf_model_extension_network_t;
+typedef struct surf_network_model_extension_public {
+ surf_action_t(*communicate) (const char *src_name,
+ const char *dst_name,
+ double size, double rate);
+ xbt_dynar_t(*get_route) (const char *src_name, const char *dst_name);
+ double (*get_link_bandwidth) (const void *link);
+ double (*get_link_latency) (const void *link);
+ int (*link_shared) (const void *link);
+ void (*add_traces) (void);
+ void (*create_resource) (char *name,
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties);
+} s_surf_model_extension_network_t;
/** \brief Workstation model extension public
* \ingroup SURF_models
*
* Public functions specific to the workstation model.
*/
- typedef struct surf_workstation_model_extension_public {
- surf_action_t(*execute) (void *workstation, double size); /**< Execute a computation amount on a workstation
+typedef struct surf_workstation_model_extension_public {
+ surf_action_t(*execute) (void *workstation, double size); /**< Execute a computation amount on a workstation
and create the corresponding action */
- surf_action_t(*sleep) (void *workstation, double duration); /**< Make a workstation sleep during a given duration */
- e_surf_resource_state_t(*get_state) (void *workstation); /**< Return the CPU state of a workstation */
- double (*get_speed) (void *workstation, double load); /**< Return the speed of a workstation */
- double (*get_available_speed) (void *workstation); /**< Return tha available speed of a workstation */
- surf_action_t(*communicate) (void *workstation_src, /**< Execute a communication amount between two workstations */
- void *workstation_dst, double size,
- double max_rate);
- xbt_dynar_t(*get_route) (void *workstation_src, void *workstation_dst); /**< Get the list of links between two ws */
-
- surf_action_t(*execute_parallel_task) (int workstation_nb, /**< Execute a parallel task on several workstations */
- void **workstation_list,
- double *computation_amount,
- double *communication_amount,
- double amount, double rate);
- double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
- double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
- int (*link_shared) (const void *link);
- xbt_dict_t(*get_properties) (const void *resource);
- void (*link_create_resource) (char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties);
- void (*cpu_create_resource) (char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties);
- void (*add_traces) (void);
-
- } s_surf_model_extension_workstation_t;
+ surf_action_t(*sleep) (void *workstation, double duration); /**< Make a workstation sleep during a given duration */
+ e_surf_resource_state_t(*get_state) (void *workstation); /**< Return the CPU state of a workstation */
+ double (*get_speed) (void *workstation, double load); /**< Return the speed of a workstation */
+ double (*get_available_speed) (void *workstation); /**< Return tha available speed of a workstation */
+ surf_action_t(*communicate) (void *workstation_src, /**< Execute a communication amount between two workstations */
+ void *workstation_dst, double size,
+ double max_rate);
+ xbt_dynar_t(*get_route) (void *workstation_src, void *workstation_dst); /**< Get the list of links between two ws */
+
+ surf_action_t(*execute_parallel_task) (int workstation_nb, /**< Execute a parallel task on several workstations */
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double amount, double rate);
+ double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
+ double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
+ int (*link_shared) (const void *link);
+ xbt_dict_t(*get_properties) (const void *resource);
+ void (*link_create_resource) (char *name,
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties);
+ void (*cpu_create_resource) (char *name, double power_peak,
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties);
+ void (*add_traces) (void);
+
+} s_surf_model_extension_workstation_t;
* Generic data structure for a model. The workstations,
* the CPUs and the network links are examples of models.
*/
- typedef struct surf_model {
- const char *name;/**< Name of this model */
- s_surf_action_state_t states; /**< Any living action on this model */
+typedef struct surf_model {
+ const char *name; /**< Name of this model */
+ s_surf_action_state_t states; /**< Any living action on this model */
- e_surf_action_state_t(*action_state_get) (surf_action_t action);
+ e_surf_action_state_t(*action_state_get) (surf_action_t action);
/**< Return the state of an action */
- void (*action_state_set) (surf_action_t action,
- e_surf_action_state_t state);
+ void (*action_state_set) (surf_action_t action,
+ e_surf_action_state_t state);
/**< Change an action state*/
- double (*action_get_start_time) (surf_action_t action);/**< Return the start time of an action */
- double (*action_get_finish_time) (surf_action_t action);/**< Return the finish time of an action */
- int (*action_unref) (surf_action_t action);/**< Specify that we don't use that action anymore */
- void (*action_cancel) (surf_action_t action);/**< Cancel a running action */
- void (*action_recycle) (surf_action_t action);/**< Recycle an action */
- void (*action_data_set) (surf_action_t action, void *data);/**< Set the user data of an action */
- void (*suspend) (surf_action_t action);/**< Suspend an action */
- void (*resume) (surf_action_t action);/**< Resume a suspended action */
- int (*is_suspended) (surf_action_t action);/**< Return whether an action is suspended */
- void (*set_max_duration) (surf_action_t action, double duration);/**< Set the max duration of an action*/
- void (*set_priority) (surf_action_t action, double priority);/**< Set the priority of an action */
- double (*get_remains) (surf_action_t action);/**< Get the remains of an action */
+ double (*action_get_start_time) (surf_action_t action); /**< Return the start time of an action */
+ double (*action_get_finish_time) (surf_action_t action); /**< Return the finish time of an action */
+ int (*action_unref) (surf_action_t action); /**< Specify that we don't use that action anymore */
+ void (*action_cancel) (surf_action_t action); /**< Cancel a running action */
+ void (*action_recycle) (surf_action_t action); /**< Recycle an action */
+ void (*action_data_set) (surf_action_t action, void *data); /**< Set the user data of an action */
+ void (*suspend) (surf_action_t action); /**< Suspend an action */
+ void (*resume) (surf_action_t action); /**< Resume a suspended action */
+ int (*is_suspended) (surf_action_t action); /**< Return whether an action is suspended */
+ void (*set_max_duration) (surf_action_t action, double duration); /**< Set the max duration of an action*/
+ void (*set_priority) (surf_action_t action, double priority); /**< Set the priority of an action */
+ double (*get_remains) (surf_action_t action); /**< Get the remains of an action */
#ifdef HAVE_LATENCY_BOUND_TRACKING
- int (*get_latency_limited) (surf_action_t action);/**< Return 1 if action is limited by latency, 0 otherwise */
+ int (*get_latency_limited) (surf_action_t action); /**< Return 1 if action is limited by latency, 0 otherwise */
#endif
- xbt_dict_t resource_set;
+ xbt_dict_t resource_set;
- surf_model_private_t model_private;
+ surf_model_private_t model_private;
- union extension {
- s_surf_model_extension_timer_t timer;
- s_surf_model_extension_cpu_t cpu;
- s_surf_model_extension_network_t network;
- s_surf_model_extension_workstation_t workstation;
- } extension;
- } s_surf_model_t;
+ union extension {
+ s_surf_model_extension_timer_t timer;
+ s_surf_model_extension_cpu_t cpu;
+ s_surf_model_extension_network_t network;
+ s_surf_model_extension_workstation_t workstation;
+ } extension;
+} s_surf_model_t;
- surf_model_t surf_model_init(void);
- void surf_model_exit(surf_model_t model);
+surf_model_t surf_model_init(void);
+void surf_model_exit(surf_model_t model);
- void *surf_model_resource_by_name(surf_model_t model, const char *name);
+void *surf_model_resource_by_name(surf_model_t model, const char *name);
#define surf_model_resource_set(model) (model)->resource_set
- typedef struct surf_resource {
- surf_model_t model;
- char *name;
- xbt_dict_t properties;
- } s_surf_resource_t, *surf_resource_t;
+typedef struct surf_resource {
+ surf_model_t model;
+ char *name;
+ xbt_dict_t properties;
+} s_surf_resource_t, *surf_resource_t;
/**
* Resource which have a metric handled by a maxmin system
*/
- typedef struct {
- double scale;
- double peak;
- tmgr_trace_event_t event;
- } s_surf_metric_t;
+typedef struct {
+ double scale;
+ double peak;
+ tmgr_trace_event_t event;
+} s_surf_metric_t;
- typedef struct surf_resource_lmm {
- s_surf_resource_t generic_resource;
- lmm_constraint_t constraint;
- e_surf_resource_state_t state_current;
- tmgr_trace_event_t state_event;
- s_surf_metric_t power;
- } s_surf_resource_lmm_t, *surf_resource_lmm_t;
+typedef struct surf_resource_lmm {
+ s_surf_resource_t generic_resource;
+ lmm_constraint_t constraint;
+ e_surf_resource_state_t state_current;
+ tmgr_trace_event_t state_event;
+ s_surf_metric_t power;
+} s_surf_resource_lmm_t, *surf_resource_lmm_t;
/**************************************/
/* Implementations of model object */
*
* \see surf_workstation_model_init_LegrandVelho()
*/
-XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(const char *filename);
+XBT_PUBLIC(void) surf_network_model_init_LegrandVelho(const char
+ *filename);
/** \brief Initializes the platform with the network model 'Constant'
* \ingroup SURF_models
/**
* brief initialize the the network model bypassing the XML parser
*/
-XBT_PUBLIC(void) surf_network_model_init_bypass(const char* id,double initial_bw,double initial_lat);
+XBT_PUBLIC(void) surf_network_model_init_bypass(const char *id,
+ double initial_bw,
+ double initial_lat);
#ifdef HAVE_GTNETS
/** \brief Initializes the platform with the network model GTNETS
/** \brief The list of all available network model models
* \ingroup SURF_models
*/
-XBT_PUBLIC_DATA(s_surf_model_description_t) surf_network_model_description[];
+XBT_PUBLIC_DATA(s_surf_model_description_t)
+ surf_network_model_description[];
/** \brief The workstation model
* network_model have been set up.
*
*/
-XBT_PUBLIC(void) surf_workstation_model_init_compound(const char *filename);
+XBT_PUBLIC(void) surf_workstation_model_init_compound(const char
+ *filename);
/** \brief Initializes the platform with the workstation model CLM03
* \ingroup SURF_models
* SimDag.
*
*/
-XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char *filename);
+XBT_PUBLIC(void) surf_workstation_model_init_KCCFLN05(const char
+ *filename);
/** \brief Initializes the platform with the model KCCFLN05
* \ingroup SURF_models
* the model to each action.
*
*/
-XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char *filename);
+XBT_PUBLIC(void) surf_workstation_model_init_ptask_L07(const char
+ *filename);
/** \brief The list of all available workstation model models
* \ingroup SURF_models
*/
XBT_PUBLIC_DATA(s_surf_model_description_t)
- surf_workstation_model_description[];
+ surf_workstation_model_description[];
/** \brief List of initialized models
* \ingroup SURF_models
* see surfxml_parse.c
* */
XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties);
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties);
/*public interface to create resource bypassing the parser via workstation_ptask_L07 model
*
* see surfxml_parse.c
* */
-XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties);
+XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name,
+ double power_peak,
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t
+ cpu_properties);
/**
* create link resource
* see surfxml_parse.c
*/
XBT_PUBLIC(void) surf_link_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties);
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties);
XBT_PUBLIC(void) surf_wsL07_link_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties);
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy,
+ xbt_dict_t properties);
/**
* add route element (link_ctn) bypassing the parser
*
* init AS from lua console
* see surf_routing.c
*/
-XBT_PUBLIC(void) routing_AS_init(const char* id,const char *mode);
-XBT_PUBLIC(void) routing_AS_end(const char* id);
+XBT_PUBLIC(void) routing_AS_init(const char *id, const char *mode);
+XBT_PUBLIC(void) routing_AS_end(const char *id);
// add host to network element list
-XBT_PUBLIC(void) routing_add_host(const char * host_id);
+XBT_PUBLIC(void) routing_add_host(const char *host_id);
//Set a new link on the actual list of link for a route or ASroute
XBT_PUBLIC(void) routing_add_link(const char *link_id);
//Set the endpoints for a route
-XBT_PUBLIC(void) routing_set_route(const char* src_id,const char* dst_id);
+XBT_PUBLIC(void) routing_set_route(const char *src_id, const char *dst_id);
//Store the route
XBT_PUBLIC(void) routing_store_route(void);
* interface between surf and lua bindings
* see surfxml_parse.c
*/
-XBT_PUBLIC(void) surf_AS_new(const char* id,const char *mode);
-XBT_PUBLIC(void) surf_AS_finalize(const char*id);
-XBT_PUBLIC(void) surf_route_add_host(const char*id);
-XBT_PUBLIC(void) surf_routing_add_route(const char* src_id,const char *dest_id,xbt_dynar_t links_id);
+XBT_PUBLIC(void) surf_AS_new(const char *id, const char *mode);
+XBT_PUBLIC(void) surf_AS_finalize(const char *id);
+XBT_PUBLIC(void) surf_route_add_host(const char *id);
+XBT_PUBLIC(void) surf_routing_add_route(const char *src_id,
+ const char *dest_id,
+ xbt_dynar_t links_id);
#include "surf/surf_resource.h"
#include "surf/surf_resource_lmm.h"
SG_END_DECL()
-#endif /* _SURF_SURF_H */
+#endif /* _SURF_SURF_H */
#define SURF_RESOURCE_H
static XBT_INLINE
-surf_resource_t surf_resource_new(size_t childsize,
- surf_model_t model, char *name, xbt_dict_t props) {
+ surf_resource_t surf_resource_new(size_t childsize,
+ surf_model_t model, char *name,
+ xbt_dict_t props)
+{
surf_resource_t res = xbt_malloc0(childsize);
res->model = model;
res->name = name;
return res;
}
-static XBT_INLINE void surf_resource_free(void* r) {
+static XBT_INLINE void surf_resource_free(void *r)
+{
surf_resource_t resource = r;
if (resource->name)
free(resource->name);
free(resource);
}
-static XBT_INLINE const char *surf_resource_name(const void *resource) {
- return ((surf_resource_t)resource)->name;
+static XBT_INLINE const char *surf_resource_name(const void *resource)
+{
+ return ((surf_resource_t) resource)->name;
}
-static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource) {
- return ((surf_resource_t)resource)->properties;
+static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource)
+{
+ return ((surf_resource_t) resource)->properties;
}
-#endif /* SURF_RESOURCE_H */
+#endif /* SURF_RESOURCE_H */
#include "surf/trace_mgr.h"
static XBT_INLINE
-surf_resource_lmm_t surf_resource_lmm_new(size_t childsize,
- /* for superclass */ surf_model_t model, char *name, xbt_dict_t props,
- lmm_system_t system, double constraint_value,
- tmgr_history_t history,
- int state_init, tmgr_trace_t state_trace,
- double metric_peak, tmgr_trace_t metric_trace) {
-
- surf_resource_lmm_t res = (surf_resource_lmm_t)surf_resource_new(childsize,model,name,props);
+ surf_resource_lmm_t surf_resource_lmm_new(size_t childsize,
+ /* for superclass */
+ surf_model_t model,
+ char *name, xbt_dict_t props,
+ lmm_system_t system,
+ double constraint_value,
+ tmgr_history_t history,
+ int state_init,
+ tmgr_trace_t state_trace,
+ double metric_peak,
+ tmgr_trace_t metric_trace)
+{
+
+ surf_resource_lmm_t res =
+ (surf_resource_lmm_t) surf_resource_new(childsize, model, name,
+ props);
res->constraint = lmm_constraint_new(system, res, constraint_value);
res->state_current = state_init;
if (state_trace)
- res->state_event = tmgr_history_add_trace(history, state_trace, 0.0, 0, res);
+ res->state_event =
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, res);
res->power.scale = 1.0;
res->power.peak = metric_peak;
if (metric_trace)
- res->power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, res);
+ res->power.event =
+ tmgr_history_add_trace(history, metric_trace, 0.0, 0, res);
return res;
}
-static XBT_INLINE e_surf_resource_state_t surf_resource_lmm_get_state(void *r) {
- surf_resource_lmm_t resource = (surf_resource_lmm_t)r;
+static XBT_INLINE e_surf_resource_state_t surf_resource_lmm_get_state(void
+ *r)
+{
+ surf_resource_lmm_t resource = (surf_resource_lmm_t) r;
return (resource)->state_current;
}
-#endif /* SURF_RESOURCE_LMM_H */
+#endif /* SURF_RESOURCE_LMM_H */
*/
XBT_PUBLIC(int) tmgr_trace_event_free(tmgr_trace_event_t trace_event);
-XBT_PUBLIC(tmgr_trace_event_t) tmgr_history_add_trace(tmgr_history_t history,
+XBT_PUBLIC(tmgr_trace_event_t) tmgr_history_add_trace(tmgr_history_t
+ history,
tmgr_trace_t trace,
double start_time,
unsigned int offset,
/* Access functions */
XBT_PUBLIC(double) tmgr_history_next_date(tmgr_history_t history);
-XBT_PUBLIC(tmgr_trace_event_t) tmgr_history_get_next_event_leq(tmgr_history_t
- history,
- double date,
- double *value,
- void **model);
+XBT_PUBLIC(tmgr_trace_event_t)
+ tmgr_history_get_next_event_leq(tmgr_history_t history, double date,
+ double *value, void **model);
XBT_PUBLIC(void) tmgr_finalize(void);
-#endif /* _SURF_TMGR_H */
+#endif /* _SURF_TMGR_H */
#define SLMFLAG_VIRTUAL 0x1
#define SLMFLAG_NO_SYMBOLS 0x4
- typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACK) (PSTR, ULONG, ULONG,
- PVOID);
+ typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACK) (PSTR, ULONG,
+ ULONG, PVOID);
BOOL WINAPI EnumerateLoadedModules(HANDLE, PENUMLOADED_MODULES_CALLBACK,
PVOID);
typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACK64) (PCSTR, DWORD64,
ULONG, PVOID);
- BOOL WINAPI EnumerateLoadedModules64(HANDLE, PENUMLOADED_MODULES_CALLBACK64,
+ BOOL WINAPI EnumerateLoadedModules64(HANDLE,
+ PENUMLOADED_MODULES_CALLBACK64,
PVOID);
- typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACKW64) (PCWSTR, DWORD64,
- ULONG, PVOID);
+ typedef BOOL(CALLBACK * PENUMLOADED_MODULES_CALLBACKW64) (PCWSTR,
+ DWORD64, ULONG,
+ PVOID);
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE,
PENUMLOADED_MODULES_CALLBACKW64,
PVOID);
typedef BOOL(CALLBACK * PSYM_ENUMMODULES_CALLBACK) (PCSTR, ULONG, PVOID);
- BOOL WINAPI SymEnumerateModules(HANDLE, PSYM_ENUMMODULES_CALLBACK, PVOID);
+ BOOL WINAPI SymEnumerateModules(HANDLE, PSYM_ENUMMODULES_CALLBACK,
+ PVOID);
typedef BOOL(CALLBACK * PSYM_ENUMMODULES_CALLBACK64) (PCSTR, DWORD64,
PVOID);
BOOL WINAPI SymEnumerateModules64(HANDLE, PSYM_ENUMMODULES_CALLBACK64,
DWORD WINAPI SymLoadModule(HANDLE, HANDLE, PCSTR, PCSTR, DWORD, DWORD);
DWORD64 WINAPI SymLoadModule64(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64,
DWORD);
- DWORD64 WINAPI SymLoadModuleEx(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64, DWORD,
- PMODLOAD_DATA, DWORD);
+ DWORD64 WINAPI SymLoadModuleEx(HANDLE, HANDLE, PCSTR, PCSTR, DWORD64,
+ DWORD, PMODLOAD_DATA, DWORD);
DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64,
DWORD, PMODLOAD_DATA, DWORD);
BOOL WINAPI SymUnloadModule(HANDLE, DWORD);
ULONG, PVOID);
BOOL WINAPI SymEnumTypes(HANDLE, ULONG64, PSYM_ENUMERATESYMBOLS_CALLBACK,
PVOID);
- BOOL WINAPI SymEnumTypesW(HANDLE, ULONG64, PSYM_ENUMERATESYMBOLS_CALLBACKW,
- PVOID);
+ BOOL WINAPI SymEnumTypesW(HANDLE, ULONG64,
+ PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID);
BOOL WINAPI SymFromAddr(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFO *);
BOOL WINAPI SymFromAddrW(HANDLE, DWORD64, DWORD64 *, SYMBOL_INFOW *);
BOOL WINAPI SymFromToken(HANDLE, DWORD64, DWORD, PSYMBOL_INFO);
PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID);
typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK) (PCSTR, DWORD, ULONG,
PVOID);
- typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACKW) (PCWSTR, DWORD, ULONG,
- PVOID);
+ typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACKW) (PCWSTR, DWORD,
+ ULONG, PVOID);
BOOL WINAPI SymEnumerateSymbols(HANDLE, ULONG, PSYM_ENUMSYMBOLS_CALLBACK,
PVOID);
- BOOL WINAPI SymEnumerateSymbolsW(HANDLE, ULONG, PSYM_ENUMSYMBOLS_CALLBACKW,
- PVOID);
- typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK64) (PCSTR, DWORD64, ULONG,
- PVOID);
+ BOOL WINAPI SymEnumerateSymbolsW(HANDLE, ULONG,
+ PSYM_ENUMSYMBOLS_CALLBACKW, PVOID);
+ typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK64) (PCSTR, DWORD64,
+ ULONG, PVOID);
typedef BOOL(CALLBACK * PSYM_ENUMSYMBOLS_CALLBACK64W) (PCWSTR, DWORD64,
ULONG, PVOID);
BOOL WINAPI SymEnumerateSymbols64(HANDLE, ULONG64,
BOOL WINAPI SymEnumSymbolsForAddr(HANDLE, DWORD64,
PSYM_ENUMERATESYMBOLS_CALLBACK, PVOID);
BOOL WINAPI SymEnumSymbolsForAddrW(HANDLE, DWORD64,
- PSYM_ENUMERATESYMBOLS_CALLBACKW, PVOID);
- typedef BOOL(CALLBACK * PSYMBOL_REGISTERED_CALLBACK) (HANDLE, ULONG, PVOID,
- PVOID);
- BOOL WINAPI SymRegisterCallback(HANDLE, PSYMBOL_REGISTERED_CALLBACK, PVOID);
+ PSYM_ENUMERATESYMBOLS_CALLBACKW,
+ PVOID);
+ typedef BOOL(CALLBACK * PSYMBOL_REGISTERED_CALLBACK) (HANDLE, ULONG,
+ PVOID, PVOID);
+ BOOL WINAPI SymRegisterCallback(HANDLE, PSYMBOL_REGISTERED_CALLBACK,
+ PVOID);
typedef BOOL(CALLBACK * PSYMBOL_REGISTERED_CALLBACK64) (HANDLE, ULONG,
- ULONG64, ULONG64);
+ ULONG64,
+ ULONG64);
BOOL WINAPI SymRegisterCallback64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64,
ULONG64);
BOOL WINAPI SymRegisterCallbackW64(HANDLE, PSYMBOL_REGISTERED_CALLBACK64,
BOOL WINAPI SymFromIndex(HANDLE, ULONG64, DWORD, PSYMBOL_INFO);
BOOL WINAPI SymFromIndexW(HANDLE, ULONG64, DWORD, PSYMBOL_INFOW);
BOOL WINAPI SymAddSymbol(HANDLE, ULONG64, PCSTR, DWORD64, DWORD, DWORD);
- BOOL WINAPI SymAddSymbolW(HANDLE, ULONG64, PCWSTR, DWORD64, DWORD, DWORD);
+ BOOL WINAPI SymAddSymbolW(HANDLE, ULONG64, PCWSTR, DWORD64, DWORD,
+ DWORD);
BOOL WINAPI SymDeleteSymbol(HANDLE, ULONG64, PCSTR, DWORD64, DWORD);
BOOL WINAPI SymDeleteSymbolW(HANDLE, ULONG64, PCWSTR, DWORD64, DWORD);
/*************************
* Source Files *
*************************/
- typedef BOOL(CALLBACK * PSYM_ENUMSOURCEFILES_CALLBACK) (PSOURCEFILE, PVOID);
+ typedef BOOL(CALLBACK * PSYM_ENUMSOURCEFILES_CALLBACK) (PSOURCEFILE,
+ PVOID);
typedef BOOL(CALLBACK * PSYM_ENUMSOURCEFILES_CALLBACKW) (PSOURCEFILEW,
PVOID);
PSYM_ENUMSOURCEFILES_CALLBACKW, PVOID);
BOOL WINAPI SymGetLineFromAddr(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE);
BOOL WINAPI SymGetLineFromAddrW(HANDLE, DWORD, PDWORD, PIMAGEHLP_LINEW);
- BOOL WINAPI SymGetLineFromAddr64(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
+ BOOL WINAPI SymGetLineFromAddr64(HANDLE, DWORD64, PDWORD,
+ PIMAGEHLP_LINE64);
BOOL WINAPI SymGetLineFromAddrW64(HANDLE, DWORD64, PDWORD,
PIMAGEHLP_LINEW64);
BOOL WINAPI SymGetLinePrev(HANDLE, PIMAGEHLP_LINE);
PIMAGEHLP_LINE64);
BOOL WINAPI SymGetLineFromNameW64(HANDLE, PCWSTR, PCWSTR, DWORD, PLONG,
PIMAGEHLP_LINEW64);
- ULONG WINAPI SymGetFileLineOffsets64(HANDLE, PCSTR, PCSTR, PDWORD64, ULONG);
+ ULONG WINAPI SymGetFileLineOffsets64(HANDLE, PCSTR, PCSTR, PDWORD64,
+ ULONG);
BOOL WINAPI SymGetSourceFile(HANDLE, ULONG64, PCSTR, PCSTR, PSTR, DWORD);
BOOL WINAPI SymGetSourceFileW(HANDLE, ULONG64, PCWSTR, PCWSTR, PWSTR,
DWORD);
- BOOL WINAPI SymGetSourceFileToken(HANDLE, ULONG64, PCSTR, PVOID *, DWORD *);
+ BOOL WINAPI SymGetSourceFileToken(HANDLE, ULONG64, PCSTR, PVOID *,
+ DWORD *);
BOOL WINAPI SymGetSourceFileTokenW(HANDLE, ULONG64, PCWSTR, PVOID *,
DWORD *);
BOOL WINAPI SymGetSourceFileFromToken(HANDLE, PVOID, PCSTR, PSTR, DWORD);
- BOOL WINAPI SymGetSourceFileFromTokenW(HANDLE, PVOID, PCWSTR, PWSTR, DWORD);
+ BOOL WINAPI SymGetSourceFileFromTokenW(HANDLE, PVOID, PCWSTR, PWSTR,
+ DWORD);
BOOL WINAPI SymGetSourceVarFromToken(HANDLE, PVOID, PCSTR, PCSTR, PSTR,
DWORD);
- BOOL WINAPI SymGetSourceVarFromTokenW(HANDLE, PVOID, PCWSTR, PCWSTR, PWSTR,
- DWORD);
+ BOOL WINAPI SymGetSourceVarFromTokenW(HANDLE, PVOID, PCWSTR, PCWSTR,
+ PWSTR, DWORD);
typedef struct _SRCCODEINFO {
DWORD SizeOfStruct;
PSYM_ENUMLINES_CALLBACK, PVOID);
BOOL WINAPI SymEnumLinesW(HANDLE, ULONG64, PCWSTR, PCWSTR,
PSYM_ENUMLINES_CALLBACKW, PVOID);
- BOOL WINAPI SymEnumSourceLines(HANDLE, ULONG64, PCSTR, PCSTR, DWORD, DWORD,
- PSYM_ENUMLINES_CALLBACK, PVOID);
+ BOOL WINAPI SymEnumSourceLines(HANDLE, ULONG64, PCSTR, PCSTR, DWORD,
+ DWORD, PSYM_ENUMLINES_CALLBACK, PVOID);
BOOL WINAPI SymEnumSourceLinesW(HANDLE, ULONG64, PCWSTR, PCWSTR, DWORD,
DWORD, PSYM_ENUMLINES_CALLBACKW, PVOID);
BOOL WINAPI SymCleanup(HANDLE);
HANDLE WINAPI FindDebugInfoFile(PCSTR, PCSTR, PSTR);
- typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACK) (HANDLE, PCSTR, PVOID);
- typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACKW) (HANDLE, PCWSTR, PVOID);
+ typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACK) (HANDLE, PCSTR,
+ PVOID);
+ typedef BOOL(CALLBACK * PFIND_DEBUG_FILE_CALLBACKW) (HANDLE, PCWSTR,
+ PVOID);
HANDLE WINAPI FindDebugInfoFileEx(PCSTR, PCSTR, PSTR,
PFIND_DEBUG_FILE_CALLBACK, PVOID);
HANDLE WINAPI FindDebugInfoFileExW(PCWSTR, PCWSTR, PWSTR,
PFIND_DEBUG_FILE_CALLBACKW, PVOID);
typedef BOOL(CALLBACK * PFINDFILEINPATHCALLBACK) (PCSTR, PVOID);
typedef BOOL(CALLBACK * PFINDFILEINPATHCALLBACKW) (PCWSTR, PVOID);
- BOOL WINAPI FindFileInPath(HANDLE, PCSTR, PCSTR, PVOID, DWORD, DWORD, DWORD,
- PSTR, PFINDFILEINPATHCALLBACK, PVOID);
+ BOOL WINAPI FindFileInPath(HANDLE, PCSTR, PCSTR, PVOID, DWORD, DWORD,
+ DWORD, PSTR, PFINDFILEINPATHCALLBACK, PVOID);
BOOL WINAPI SymFindFileInPath(HANDLE, PCSTR, PCSTR, PVOID, DWORD, DWORD,
- DWORD, PSTR, PFINDFILEINPATHCALLBACK, PVOID);
- BOOL WINAPI SymFindFileInPathW(HANDLE, PCWSTR, PCWSTR, PVOID, DWORD, DWORD,
- DWORD, PWSTR, PFINDFILEINPATHCALLBACKW,
- PVOID);
+ DWORD, PSTR, PFINDFILEINPATHCALLBACK,
+ PVOID);
+ BOOL WINAPI SymFindFileInPathW(HANDLE, PCWSTR, PCWSTR, PVOID, DWORD,
+ DWORD, DWORD, PWSTR,
+ PFINDFILEINPATHCALLBACKW, PVOID);
HANDLE WINAPI FindExecutableImage(PCSTR, PCSTR, PSTR);
typedef BOOL(CALLBACK * PFIND_EXE_FILE_CALLBACK) (HANDLE, PCSTR, PVOID);
- typedef BOOL(CALLBACK * PFIND_EXE_FILE_CALLBACKW) (HANDLE, PCWSTR, PVOID);
+ typedef BOOL(CALLBACK * PFIND_EXE_FILE_CALLBACKW) (HANDLE, PCWSTR,
+ PVOID);
HANDLE WINAPI FindExecutableImageEx(PCSTR, PCSTR, PSTR,
PFIND_EXE_FILE_CALLBACK, PVOID);
HANDLE WINAPI FindExecutableImageExW(PCWSTR, PCWSTR, PWSTR,
BOOL WINAPI SearchTreeForFileW(PCWSTR, PCWSTR, PWSTR);
typedef BOOL(CALLBACK * PENUMDIRTREE_CALLBACK) (PCSTR, PVOID);
typedef BOOL(CALLBACK * PENUMDIRTREE_CALLBACKW) (PCWSTR, PVOID);
- BOOL WINAPI EnumDirTree(HANDLE, PCSTR, PCSTR, PSTR, PENUMDIRTREE_CALLBACK,
- PVOID);
+ BOOL WINAPI EnumDirTree(HANDLE, PCSTR, PCSTR, PSTR,
+ PENUMDIRTREE_CALLBACK, PVOID);
BOOL WINAPI EnumDirTreeW(HANDLE, PCWSTR, PCWSTR, PWSTR,
PENUMDIRTREE_CALLBACKW, PVOID);
BOOL WINAPI SymMatchFileName(PCSTR, PCSTR, PSTR *, PSTR *);
/*************************
* Context management *
*************************/
- BOOL WINAPI SymSetContext(HANDLE, PIMAGEHLP_STACK_FRAME, PIMAGEHLP_CONTEXT);
+ BOOL WINAPI SymSetContext(HANDLE, PIMAGEHLP_STACK_FRAME,
+ PIMAGEHLP_CONTEXT);
/*************************
} STACKFRAME64, *LPSTACKFRAME64;
typedef BOOL(CALLBACK * PREAD_PROCESS_MEMORY_ROUTINE)
- (HANDLE, DWORD, PVOID, DWORD, PDWORD);
+ (HANDLE, DWORD, PVOID, DWORD, PDWORD);
typedef PVOID(CALLBACK * PFUNCTION_TABLE_ACCESS_ROUTINE) (HANDLE, DWORD);
typedef DWORD(CALLBACK * PGET_MODULE_BASE_ROUTINE) (HANDLE, DWORD);
typedef DWORD(CALLBACK * PTRANSLATE_ADDRESS_ROUTINE) (HANDLE, HANDLE,
BOOL WINAPI StackWalk(DWORD, HANDLE, HANDLE, LPSTACKFRAME, PVOID,
PREAD_PROCESS_MEMORY_ROUTINE,
PFUNCTION_TABLE_ACCESS_ROUTINE,
- PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE);
+ PGET_MODULE_BASE_ROUTINE,
+ PTRANSLATE_ADDRESS_ROUTINE);
typedef BOOL(CALLBACK * PREAD_PROCESS_MEMORY_ROUTINE64)
- (HANDLE, DWORD64, PVOID, DWORD, PDWORD);
+ (HANDLE, DWORD64, PVOID, DWORD, PDWORD);
typedef PVOID(CALLBACK * PFUNCTION_TABLE_ACCESS_ROUTINE64) (HANDLE,
DWORD64);
typedef DWORD64(CALLBACK * PGET_MODULE_BASE_ROUTINE64) (HANDLE, DWORD64);
PVOID WINAPI SymFunctionTableAccess(HANDLE, DWORD);
PVOID WINAPI SymFunctionTableAccess64(HANDLE, DWORD64);
- typedef PVOID(CALLBACK * PSYMBOL_FUNCENTRY_CALLBACK) (HANDLE, DWORD, PVOID);
+ typedef PVOID(CALLBACK * PSYMBOL_FUNCENTRY_CALLBACK) (HANDLE, DWORD,
+ PVOID);
typedef PVOID(CALLBACK * PSYMBOL_FUNCENTRY_CALLBACK64) (HANDLE, ULONG64,
ULONG64);
* Version, global stuff *
*************************/
- typedef BOOL(WINAPI * PSYMBOLSERVERPROC) (PCSTR, PCSTR, PVOID, DWORD, DWORD,
- PSTR);
+ typedef BOOL(WINAPI * PSYMBOLSERVERPROC) (PCSTR, PCSTR, PVOID, DWORD,
+ DWORD, PSTR);
typedef BOOL(WINAPI * PSYMBOLSERVERPROCA) (PCSTR, PCSTR, PVOID, DWORD,
DWORD, PSTR);
typedef BOOL(WINAPI * PSYMBOLSERVERPROCW) (PCWSTR, PCWSTR, PVOID, DWORD,
* @{
*/
/** \brief Thread data type (opaque structure) */
- typedef struct xbt_os_thread_ *xbt_os_thread_t;
+typedef struct xbt_os_thread_ *xbt_os_thread_t;
XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(const char *name,
pvoid_f_pvoid_t
- start_routine, void *param);
+ start_routine,
+ void *param);
XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
XBT_PUBLIC(const char *) xbt_os_thread_self_name(void);
/** \brief Thread mutex data type (opaque structure) */
- typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
+typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
XBT_PUBLIC(xbt_os_mutex_t) xbt_os_mutex_init(void);
XBT_PUBLIC(void) xbt_os_mutex_acquire(xbt_os_mutex_t mutex);
/** \brief Thread condition data type (opaque structure) */
- typedef struct xbt_os_cond_ *xbt_os_cond_t;
+typedef struct xbt_os_cond_ *xbt_os_cond_t;
XBT_PUBLIC(xbt_os_cond_t) xbt_os_cond_init(void);
-XBT_PUBLIC(void) xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex);
+XBT_PUBLIC(void) xbt_os_cond_wait(xbt_os_cond_t cond,
+ xbt_os_mutex_t mutex);
XBT_PUBLIC(void) xbt_os_cond_timedwait(xbt_os_cond_t cond,
xbt_os_mutex_t mutex, double delay);
XBT_PUBLIC(void) xbt_os_cond_signal(xbt_os_cond_t cond);
XBT_PUBLIC(void) xbt_os_cond_destroy(xbt_os_cond_t cond);
/** \brief Semaphore data type (opaque structure) */
- typedef struct xbt_os_sem_ *xbt_os_sem_t;
+typedef struct xbt_os_sem_ *xbt_os_sem_t;
XBT_PUBLIC(xbt_os_sem_t) xbt_os_sem_init(unsigned int value);
XBT_PUBLIC(void) xbt_os_sem_acquire(xbt_os_sem_t sem);
/** @} */
SG_END_DECL()
-#endif /* _XBT_OS_THREAD_H */
+#endif /* _XBT_OS_THREAD_H */
XBT_PUBLIC(double) xbt_os_time(void);
XBT_PUBLIC(void) xbt_os_sleep(double sec);
- typedef struct s_xbt_os_timer *xbt_os_timer_t;
+typedef struct s_xbt_os_timer *xbt_os_timer_t;
XBT_PUBLIC(xbt_os_timer_t) xbt_os_timer_new(void);
XBT_PUBLIC(void) xbt_os_timer_free(xbt_os_timer_t timer);
XBT_PUBLIC(void) xbt_os_timer_start(xbt_os_timer_t timer);
static xbt_dict_t current_task_category = NULL;
-void TRACE_category_alloc ()
+void TRACE_category_alloc()
{
current_task_category = xbt_dict_new();
}
-void TRACE_category_release ()
+void TRACE_category_release()
{
- xbt_dict_free (¤t_task_category);
+ xbt_dict_free(¤t_task_category);
}
-void TRACE_category_set (smx_process_t proc, const char *category)
+void TRACE_category_set(smx_process_t proc, const char *category)
{
char processid[100];
char *var_cpy = NULL;
- snprintf (processid, 100, "%p", proc);
- var_cpy = xbt_strdup (category);
- xbt_dict_set (current_task_category, processid, var_cpy, xbt_free);
+ snprintf(processid, 100, "%p", proc);
+ var_cpy = xbt_strdup(category);
+ xbt_dict_set(current_task_category, processid, var_cpy, xbt_free);
}
-char *TRACE_category_get (smx_process_t proc)
+char *TRACE_category_get(smx_process_t proc)
{
char processid[100];
- snprintf (processid, 100, "%p", proc);
- return xbt_dict_get_or_null (current_task_category, processid);
+ snprintf(processid, 100, "%p", proc);
+ return xbt_dict_get_or_null(current_task_category, processid);
}
-void TRACE_category_unset (smx_process_t proc)
+void TRACE_category_unset(smx_process_t proc)
{
char processid[100];
- snprintf (processid, 100, "%p", proc);
- if (xbt_dict_get_or_null (current_task_category, processid) != NULL){
- xbt_dict_remove (current_task_category, processid);
+ snprintf(processid, 100, "%p", proc);
+ if (xbt_dict_get_or_null(current_task_category, processid) != NULL) {
+ xbt_dict_remove(current_task_category, processid);
}
}
-void TRACE_msg_category_set (smx_process_t proc, m_task_t task)
+void TRACE_msg_category_set(smx_process_t proc, m_task_t task)
{
- TRACE_category_set (proc, task->category);
+ TRACE_category_set(proc, task->category);
}
#ifdef HAVE_TRACING
-char *TRACE_paje_msg_container (m_task_t task, char *host, char *output, int len)
+char *TRACE_paje_msg_container(m_task_t task, char *host, char *output,
+ int len)
{
- if (output){
- snprintf (output, len, "msg-%p-%s-%lld", task, host, task->counter);
+ if (output) {
+ snprintf(output, len, "msg-%p-%s-%lld", task, host, task->counter);
return output;
- }else{
+ } else {
return NULL;
}
}
-char *TRACE_paje_smx_container (smx_action_t action, int seqnumber, char *host, char *output, int len)
+char *TRACE_paje_smx_container(smx_action_t action, int seqnumber,
+ char *host, char *output, int len)
{
- if (output){
- snprintf (output, len, "smx-%p-%d", action, seqnumber);
+ if (output) {
+ snprintf(output, len, "smx-%p-%d", action, seqnumber);
return output;
- }else{
+ } else {
return NULL;
}
}
-char *TRACE_paje_surf_container (void *action, int seqnumber, char *output, int len)
+char *TRACE_paje_surf_container(void *action, int seqnumber, char *output,
+ int len)
{
- if (output){
- snprintf (output, len, "surf-%p-%d", action, seqnumber);
+ if (output) {
+ snprintf(output, len, "surf-%p-%d", action, seqnumber);
return output;
- }else{
+ } else {
return NULL;
}
}
-char *TRACE_host_container (m_host_t host, char *output, int len)
+char *TRACE_host_container(m_host_t host, char *output, int len)
{
- if (output){
- snprintf (output, len, "%s", MSG_host_get_name(host));
- return output;
- }else{
- return NULL;
+ if (output) {
+ snprintf(output, len, "%s", MSG_host_get_name(host));
+ return output;
+ } else {
+ return NULL;
}
}
-char *TRACE_task_container (m_task_t task, char *output, int len)
+char *TRACE_task_container(m_task_t task, char *output, int len)
{
- if (output){
- snprintf (output, len, "%p-%lld", task, task->counter);
- return output;
- }else{
- return NULL;
+ if (output) {
+ snprintf(output, len, "%p-%lld", task, task->counter);
+ return output;
+ } else {
+ return NULL;
}
}
-char *TRACE_process_container (m_process_t process, char *output, int len)
+char *TRACE_process_container(m_process_t process, char *output, int len)
{
- if (output){
- snprintf (output, len, "%s-%p", MSG_process_get_name(process), process);
- return output;
- }else{
- return NULL;
+ if (output) {
+ snprintf(output, len, "%s-%p", MSG_process_get_name(process), process);
+ return output;
+ } else {
+ return NULL;
}
}
-char *TRACE_process_alias_container (m_process_t process, m_host_t host, char *output, int len)
+char *TRACE_process_alias_container(m_process_t process, m_host_t host,
+ char *output, int len)
{
- if (output){
- snprintf (output, len, "%p-%p", process, host);
- return output;
- }else{
- return NULL;
+ if (output) {
+ snprintf(output, len, "%p-%p", process, host);
+ return output;
+ } else {
+ return NULL;
}
}
-char *TRACE_task_alias_container (m_task_t task, m_process_t process, m_host_t host, char *output, int len)
+char *TRACE_task_alias_container(m_task_t task, m_process_t process,
+ m_host_t host, char *output, int len)
{
- if (output){
- snprintf (output, len, "%p-%lld-%p-%p", task, task->counter, process, host);
- return output;
- }else{
- return NULL;
+ if (output) {
+ snprintf(output, len, "%p-%lld-%p-%p", task, task->counter, process,
+ host);
+ return output;
+ } else {
+ return NULL;
}
}
static int trace_configured = 0;
-int TRACE_is_configured (void)
+int TRACE_is_configured(void)
{
return trace_configured;
}
-int TRACE_smpi_is_enabled (void)
+int TRACE_smpi_is_enabled(void)
{
return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI);
}
-int TRACE_platform_is_enabled (void)
+int TRACE_platform_is_enabled(void)
{
return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_PLATFORM);
}
-int TRACE_msg_task_is_enabled (void)
+int TRACE_msg_task_is_enabled(void)
{
return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_TASK);
}
-int TRACE_msg_process_is_enabled (void)
+int TRACE_msg_process_is_enabled(void)
{
return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_PROCESS);
}
-int TRACE_msg_volume_is_enabled (void)
+int TRACE_msg_volume_is_enabled(void)
{
return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_VOLUME);
}
-char *TRACE_get_filename (void)
+char *TRACE_get_filename(void)
{
- return xbt_cfg_get_string (_surf_cfg_set, OPT_TRACING_FILENAME);
+ return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME);
}
-char *TRACE_get_platform_method (void)
+char *TRACE_get_platform_method(void)
{
- return xbt_cfg_get_string (_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD);
+ return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD);
}
void TRACE_global_init(int *argc, char **argv)
/* name of the tracefile */
char *default_tracing_filename = xbt_strdup("simgrid.trace");
xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_FILENAME,
- "Trace file created by the instrumented SimGrid.",
- xbt_cfgelm_string, &default_tracing_filename, 1, 1,
- NULL, NULL);
+ "Trace file created by the instrumented SimGrid.",
+ xbt_cfgelm_string, &default_tracing_filename, 1, 1,
+ NULL, NULL);
/* smpi */
int default_tracing_smpi = 0;
NULL, NULL);
/* platform method */
- char *default_tracing_platform_method = xbt_strdup ("b");
+ char *default_tracing_platform_method = xbt_strdup("b");
xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD,
"Tracing method used to register categorized resource behavior.",
- xbt_cfgelm_string, &default_tracing_platform_method, 1, 1,
- NULL, NULL);
+ xbt_cfgelm_string, &default_tracing_platform_method, 1,
+ 1, NULL, NULL);
/* msg task */
int default_tracing_msg_task = 0;
#include "instr/private.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(tracing,"Tracing Interface");
+XBT_LOG_NEW_DEFAULT_CATEGORY(tracing, "Tracing Interface");
static xbt_dict_t defined_types;
static xbt_dict_t created_categories;
-int TRACE_start ()
+int TRACE_start()
{
- if (!TRACE_is_configured()){
- THROW0 (tracing_error, TRACE_ERROR_START,
- "TRACE_start should be called after SimGrid initialization functions.");
+ if (!TRACE_is_configured()) {
+ THROW0(tracing_error, TRACE_ERROR_START,
+ "TRACE_start should be called after SimGrid initialization functions.");
return 0;
}
- if (IS_TRACING) { /* what? trace is already active... ignore.. */
- THROW0 (tracing_error, TRACE_ERROR_START,
- "TRACE_start called, but tracing is already active.");
+ if (IS_TRACING) { /* what? trace is already active... ignore.. */
+ THROW0(tracing_error, TRACE_ERROR_START,
+ "TRACE_start called, but tracing is already active.");
return 0;
}
- char *filename = TRACE_get_filename ();
- if (!filename){
- THROW0 (tracing_error, TRACE_ERROR_START,
- "Trace filename is not initialized.");
+ char *filename = TRACE_get_filename();
+ if (!filename) {
+ THROW0(tracing_error, TRACE_ERROR_START,
+ "Trace filename is not initialized.");
return 0;
}
FILE *file = fopen(filename, "w");
if (!file) {
- THROW1 (tracing_error, TRACE_ERROR_START,
- "Tracefile %s could not be opened for writing.", filename);
+ THROW1(tracing_error, TRACE_ERROR_START,
+ "Tracefile %s could not be opened for writing.", filename);
} else {
- TRACE_paje_start (file);
+ TRACE_paje_start(file);
}
TRACE_paje_create_header();
pajeDefineContainerType("HOST", "PLATFORM", "HOST");
pajeDefineContainerType("LINK", "PLATFORM", "LINK");
- if (IS_TRACING_PLATFORM){
- pajeDefineVariableType ("power", "HOST", "power");
- pajeDefineVariableType ("power_used", "HOST", "power_used");
- pajeDefineVariableType ("bandwidth", "LINK", "bandwidth");
- pajeDefineVariableType ("bandwidth_used", "LINK", "bandwidth_used");
- pajeDefineVariableType ("latency", "LINK", "latency");
- pajeDefineEventType ("source", "LINK", "source");
- pajeDefineEventType ("destination", "LINK", "destination");
+ if (IS_TRACING_PLATFORM) {
+ pajeDefineVariableType("power", "HOST", "power");
+ pajeDefineVariableType("power_used", "HOST", "power_used");
+ pajeDefineVariableType("bandwidth", "LINK", "bandwidth");
+ pajeDefineVariableType("bandwidth_used", "LINK", "bandwidth_used");
+ pajeDefineVariableType("latency", "LINK", "latency");
+ pajeDefineEventType("source", "LINK", "source");
+ pajeDefineEventType("destination", "LINK", "destination");
}
- if (IS_TRACING_PROCESSES || IS_TRACING_VOLUME){
+ if (IS_TRACING_PROCESSES || IS_TRACING_VOLUME) {
//processes grouped by host
pajeDefineContainerType("PROCESS", "HOST", "PROCESS");
}
- if (IS_TRACING_PROCESSES){
+ if (IS_TRACING_PROCESSES) {
pajeDefineStateType("category", "PROCESS", "category");
pajeDefineStateType("presence", "PROCESS", "presence");
}
- if (IS_TRACING_VOLUME){
- pajeDefineLinkType ("volume", "0", "PROCESS", "PROCESS", "volume");
+ if (IS_TRACING_VOLUME) {
+ pajeDefineLinkType("volume", "0", "PROCESS", "PROCESS", "volume");
}
- if (IS_TRACING_TASKS){
+ if (IS_TRACING_TASKS) {
//tasks grouped by host
pajeDefineContainerType("TASK", "HOST", "TASK");
pajeDefineStateType("category", "TASK", "category");
pajeDefineStateType("presence", "TASK", "presence");
}
- if (IS_TRACING_SMPI){
- pajeDefineContainerType ("MPI_PROCESS", "HOST", "MPI_PROCESS");
- pajeDefineStateType ("MPI_STATE", "MPI_PROCESS", "MPI_STATE");
- pajeDefineLinkType ("MPI_LINK", "0", "MPI_PROCESS", "MPI_PROCESS", "MPI_LINK");
+ if (IS_TRACING_SMPI) {
+ pajeDefineContainerType("MPI_PROCESS", "HOST", "MPI_PROCESS");
+ pajeDefineStateType("MPI_STATE", "MPI_PROCESS", "MPI_STATE");
+ pajeDefineLinkType("MPI_LINK", "0", "MPI_PROCESS", "MPI_PROCESS",
+ "MPI_LINK");
}
/* creating the platform */
- pajeCreateContainer(MSG_get_clock(), "platform", "PLATFORM", "0", "simgrid-platform");
+ pajeCreateContainer(MSG_get_clock(), "platform", "PLATFORM", "0",
+ "simgrid-platform");
/* other trace initialization */
defined_types = xbt_dict_new();
created_categories = xbt_dict_new();
- TRACE_msg_task_alloc ();
- TRACE_category_alloc ();
- TRACE_surf_alloc ();
- TRACE_msg_process_alloc ();
- TRACE_smpi_alloc ();
+ TRACE_msg_task_alloc();
+ TRACE_category_alloc();
+ TRACE_surf_alloc();
+ TRACE_msg_process_alloc();
+ TRACE_smpi_alloc();
return 0;
}
-int TRACE_end() {
- FILE *file = NULL;
- if (!IS_TRACING) return 1;
+int TRACE_end()
+{
+ FILE *file = NULL;
+ if (!IS_TRACING)
+ return 1;
file = TRACE_paje_end();
- fclose (file);
+ fclose(file);
return 0;
}
-int TRACE_category (const char *category)
+int TRACE_category(const char *category)
{
static int first_time = 1;
- if (!IS_TRACING) return 1;
+ if (!IS_TRACING)
+ return 1;
- if (first_time){
- TRACE_define_type ("user_type", "0", 1);
- first_time = 0;
+ if (first_time) {
+ TRACE_define_type("user_type", "0", 1);
+ first_time = 0;
}
- return TRACE_create_category (category, "user_type", "0");
+ return TRACE_create_category(category, "user_type", "0");
}
-void TRACE_define_type (const char *type,
- const char *parent_type, int final) {
- char *val_one = NULL;
- if (!IS_TRACING) return;
+void TRACE_define_type(const char *type,
+ const char *parent_type, int final)
+{
+ char *val_one = NULL;
+ if (!IS_TRACING)
+ return;
//check if type is already defined
- if (xbt_dict_get_or_null (defined_types, type)){
- THROW1 (tracing_error, TRACE_ERROR_TYPE_ALREADY_DEFINED, "Type %s is already defined", type);
+ if (xbt_dict_get_or_null(defined_types, type)) {
+ THROW1(tracing_error, TRACE_ERROR_TYPE_ALREADY_DEFINED,
+ "Type %s is already defined", type);
}
//check if parent_type is already defined
- if (strcmp(parent_type, "0") && !xbt_dict_get_or_null (defined_types, parent_type)) {
- THROW1 (tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED, "Type (used as parent) %s is not defined", parent_type);
+ if (strcmp(parent_type, "0")
+ && !xbt_dict_get_or_null(defined_types, parent_type)) {
+ THROW1(tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED,
+ "Type (used as parent) %s is not defined", parent_type);
}
pajeDefineContainerType(type, parent_type, type);
if (final) {
//for m_process_t
- if (IS_TRACING_PROCESSES) pajeDefineContainerType ("process", type, "process");
- if (IS_TRACING_PROCESSES) pajeDefineStateType ("process-state", "process", "process-state");
-
- if (IS_TRACING_TASKS) pajeDefineContainerType ("task", type, "task");
- if (IS_TRACING_TASKS) pajeDefineStateType ("task-state", "task", "task-state");
- }
- val_one = xbt_strdup ("1");
- xbt_dict_set (defined_types, type, &val_one, xbt_free);
+ if (IS_TRACING_PROCESSES)
+ pajeDefineContainerType("process", type, "process");
+ if (IS_TRACING_PROCESSES)
+ pajeDefineStateType("process-state", "process", "process-state");
+
+ if (IS_TRACING_TASKS)
+ pajeDefineContainerType("task", type, "task");
+ if (IS_TRACING_TASKS)
+ pajeDefineStateType("task-state", "task", "task-state");
+ }
+ val_one = xbt_strdup("1");
+ xbt_dict_set(defined_types, type, &val_one, xbt_free);
}
-int TRACE_create_category (const char *category,
- const char *type, const char *parent_category)
+int TRACE_create_category(const char *category,
+ const char *type, const char *parent_category)
{
char state[100];
char *val_one = NULL;
- if (!IS_TRACING) return 1;
+ if (!IS_TRACING)
+ return 1;
//check if type is defined
- if (!xbt_dict_get_or_null (defined_types, type)) {
- THROW1 (tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED, "Type %s is not defined", type);
- return 1;
+ if (!xbt_dict_get_or_null(defined_types, type)) {
+ THROW1(tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED,
+ "Type %s is not defined", type);
+ return 1;
}
//check if parent_category exists
- if (strcmp(parent_category, "0") && !xbt_dict_get_or_null (created_categories, parent_category)){
- THROW1 (tracing_error, TRACE_ERROR_CATEGORY_NOT_DEFINED, "Category (used as parent) %s is not created", parent_category);
- return 1;
+ if (strcmp(parent_category, "0")
+ && !xbt_dict_get_or_null(created_categories, parent_category)) {
+ THROW1(tracing_error, TRACE_ERROR_CATEGORY_NOT_DEFINED,
+ "Category (used as parent) %s is not created", parent_category);
+ return 1;
}
//check if category is created
- if (xbt_dict_get_or_null (created_categories, category)){
- return 1;
+ if (xbt_dict_get_or_null(created_categories, category)) {
+ return 1;
}
- pajeCreateContainer(MSG_get_clock(), category, type, parent_category, category);
+ pajeCreateContainer(MSG_get_clock(), category, type, parent_category,
+ category);
/* for registering application categories on top of platform */
- snprintf (state, 100, "b%s", category);
- if (IS_TRACING_PLATFORM) pajeDefineVariableType (state, "LINK", state);
- snprintf (state, 100, "p%s", category);
- if (IS_TRACING_PLATFORM) pajeDefineVariableType (state, "HOST", state);
+ snprintf(state, 100, "b%s", category);
+ if (IS_TRACING_PLATFORM)
+ pajeDefineVariableType(state, "LINK", state);
+ snprintf(state, 100, "p%s", category);
+ if (IS_TRACING_PLATFORM)
+ pajeDefineVariableType(state, "HOST", state);
- val_one = xbt_strdup ("1");
- xbt_dict_set (created_categories, category, &val_one, xbt_free);
+ val_one = xbt_strdup("1");
+ xbt_dict_set(created_categories, category, &val_one, xbt_free);
return 0;
}
-void TRACE_declare_mark (const char *mark_type)
+void TRACE_declare_mark(const char *mark_type)
{
- if (!IS_TRACING) return;
- if (!mark_type) return;
+ if (!IS_TRACING)
+ return;
+ if (!mark_type)
+ return;
- pajeDefineEventType (mark_type, "0", mark_type);
+ pajeDefineEventType(mark_type, "0", mark_type);
}
-void TRACE_mark (const char *mark_type, const char *mark_value)
+void TRACE_mark(const char *mark_type, const char *mark_value)
{
- if (!IS_TRACING) return;
- if (!mark_type || !mark_value) return;
+ if (!IS_TRACING)
+ return;
+ if (!mark_type || !mark_value)
+ return;
- pajeNewEvent (MSG_get_clock(), mark_type, "0", mark_value);
+ pajeNewEvent(MSG_get_clock(), mark_type, "0", mark_value);
}
-int TRACE_smpi_set_category (const char *category)
+int TRACE_smpi_set_category(const char *category)
{
//if category is NULL, trace of platform is disabled
- if (!IS_TRACING) return 1;
- if (category != NULL){
- int ret = TRACE_category (category);
- TRACE_category_set (SIMIX_process_self(), category);
+ if (!IS_TRACING)
+ return 1;
+ if (category != NULL) {
+ int ret = TRACE_category(category);
+ TRACE_category_set(SIMIX_process_self(), category);
return ret;
- }else{
- TRACE_category_unset (SIMIX_process_self());
+ } else {
+ TRACE_category_unset(SIMIX_process_self());
return 0;
}
}
-#endif /* HAVE_TRACING */
+#endif /* HAVE_TRACING */
static xbt_dict_t process_containers = NULL;
-void TRACE_msg_process_alloc (void)
+void TRACE_msg_process_alloc(void)
{
process_containers = xbt_dict_new();
}
-void TRACE_msg_process_release (void)
+void TRACE_msg_process_release(void)
{
- xbt_dict_free (&process_containers);
+ xbt_dict_free(&process_containers);
}
-static void TRACE_msg_process_location (m_process_t process)
+static void TRACE_msg_process_location(m_process_t process)
{
- char name[200], alias[200];
- m_host_t host = NULL;
- if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME)) return;
+ char name[200], alias[200];
+ m_host_t host = NULL;
+ if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME))
+ return;
- host = MSG_process_get_host (process);
- TRACE_process_container (process, name, 200);
- TRACE_process_alias_container (process, host, alias, 200);
+ host = MSG_process_get_host(process);
+ TRACE_process_container(process, name, 200);
+ TRACE_process_alias_container(process, host, alias, 200);
//check if process_alias container is already created
- if (!xbt_dict_get_or_null (process_containers, alias)){
- pajeCreateContainer (MSG_get_clock(), alias, "PROCESS", MSG_host_get_name(host), name);
- if (IS_TRACING_PROCESSES) pajeSetState (MSG_get_clock(), "category", alias, process->category);
- xbt_dict_set (process_containers, xbt_strdup(alias), xbt_strdup("1"), xbt_free);
+ if (!xbt_dict_get_or_null(process_containers, alias)) {
+ pajeCreateContainer(MSG_get_clock(), alias, "PROCESS",
+ MSG_host_get_name(host), name);
+ if (IS_TRACING_PROCESSES)
+ pajeSetState(MSG_get_clock(), "category", alias, process->category);
+ xbt_dict_set(process_containers, xbt_strdup(alias), xbt_strdup("1"),
+ xbt_free);
}
}
-static void TRACE_msg_process_present (m_process_t process)
+static void TRACE_msg_process_present(m_process_t process)
{
- char alias[200];
- m_host_t host = NULL;
- if (!IS_TRACING_PROCESSES) return;
+ char alias[200];
+ m_host_t host = NULL;
+ if (!IS_TRACING_PROCESSES)
+ return;
//updating presence state of this process location
- host = MSG_process_get_host (process);
- TRACE_process_alias_container (process, host, alias, 200);
- pajePushState (MSG_get_clock(), "presence", alias, "presence");
+ host = MSG_process_get_host(process);
+ TRACE_process_alias_container(process, host, alias, 200);
+ pajePushState(MSG_get_clock(), "presence", alias, "presence");
}
/*
* TRACE_msg_set_process_category: tracing interface function
*/
-void TRACE_msg_set_process_category (m_process_t process, const char *category)
+void TRACE_msg_set_process_category(m_process_t process,
+ const char *category)
{
- char name[200];
- if (!IS_TRACING) return;
+ char name[200];
+ if (!IS_TRACING)
+ return;
//set process category
process->category = xbt_strdup(category);
//create container of type "PROCESS" to indicate location
- TRACE_msg_process_location (process);
- TRACE_msg_process_present (process);
+ TRACE_msg_process_location(process);
+ TRACE_msg_process_present(process);
//create container of type "process" to indicate behavior
- TRACE_process_container (process, name, 200);
- if (IS_TRACING_PROCESSES) pajeCreateContainer (MSG_get_clock(), name, "process", category, name);
- if (IS_TRACING_PROCESSES) pajeSetState (MSG_get_clock(), "process-state", name, "executing");
+ TRACE_process_container(process, name, 200);
+ if (IS_TRACING_PROCESSES)
+ pajeCreateContainer(MSG_get_clock(), name, "process", category, name);
+ if (IS_TRACING_PROCESSES)
+ pajeSetState(MSG_get_clock(), "process-state", name, "executing");
}
/*
* Instrumentation functions to trace MSG processes (m_process_t)
*/
-void TRACE_msg_process_change_host (m_process_t process, m_host_t old_host, m_host_t new_host)
+void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host,
+ m_host_t new_host)
{
- char alias[200];
- if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME) || !IS_TRACED(process)) return;
+ char alias[200];
+ if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME) || !IS_TRACED(process))
+ return;
//disabling presence in old_host (__TRACE_msg_process_not_present)
- TRACE_process_alias_container (process, old_host, alias, 200);
- if (IS_TRACING_PROCESSES) pajePopState (MSG_get_clock(), "presence", alias);
+ TRACE_process_alias_container(process, old_host, alias, 200);
+ if (IS_TRACING_PROCESSES)
+ pajePopState(MSG_get_clock(), "presence", alias);
- TRACE_msg_process_location (process);
- TRACE_msg_process_present (process);
+ TRACE_msg_process_location(process);
+ TRACE_msg_process_present(process);
}
-void TRACE_msg_process_kill (m_process_t process)
+void TRACE_msg_process_kill(m_process_t process)
{
- char name[200];
- if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
+ char name[200];
+ if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
+ return;
- TRACE_process_container (process, name, 200);
- pajeDestroyContainer (MSG_get_clock(), "process", name);
+ TRACE_process_container(process, name, 200);
+ pajeDestroyContainer(MSG_get_clock(), "process", name);
}
-void TRACE_msg_process_suspend (m_process_t process)
-{ char name[200];
- if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
+void TRACE_msg_process_suspend(m_process_t process)
+{
+ char name[200];
+ if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
+ return;
- TRACE_process_container (process, name, 200);
- pajeSetState (MSG_get_clock(), "process-state", name, "suspend");
+ TRACE_process_container(process, name, 200);
+ pajeSetState(MSG_get_clock(), "process-state", name, "suspend");
}
-void TRACE_msg_process_resume (m_process_t process)
+void TRACE_msg_process_resume(m_process_t process)
{
char name[200];
- if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
+ if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
+ return;
- TRACE_process_container (process, name, 200);
- pajeSetState (MSG_get_clock(), "process-state", name, "executing");
+ TRACE_process_container(process, name, 200);
+ pajeSetState(MSG_get_clock(), "process-state", name, "executing");
}
-void TRACE_msg_process_sleep_in (m_process_t process)
+void TRACE_msg_process_sleep_in(m_process_t process)
{
- char name[200];
- if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
+ char name[200];
+ if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
+ return;
- TRACE_process_container (process, name, 200);
- pajeSetState (MSG_get_clock(), "process-state", name, "sleep");
+ TRACE_process_container(process, name, 200);
+ pajeSetState(MSG_get_clock(), "process-state", name, "sleep");
}
-void TRACE_msg_process_sleep_out (m_process_t process)
+void TRACE_msg_process_sleep_out(m_process_t process)
{
- char name[200];
- if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
+ char name[200];
+ if (!IS_TRACING_PROCESSES || !IS_TRACED(process))
+ return;
- TRACE_process_container (process, name, 200);
- pajeSetState (MSG_get_clock(), "process-state", name, "executing");
+ TRACE_process_container(process, name, 200);
+ pajeSetState(MSG_get_clock(), "process-state", name, "executing");
}
-void TRACE_msg_process_end (m_process_t process)
+void TRACE_msg_process_end(m_process_t process)
{
- char name[200], alias[200];
- m_host_t host = NULL;
- if (!IS_TRACED(process)) return;
-
- host = MSG_process_get_host (process);
- TRACE_process_container (process, name, 200);
- TRACE_process_alias_container (process, host, alias, 200);
- if (IS_TRACING_PROCESSES) pajeDestroyContainer (MSG_get_clock(), "process", name);
- if (IS_TRACING_PROCESSES) pajeDestroyContainer (MSG_get_clock(), "PROCESS", alias);
+ char name[200], alias[200];
+ m_host_t host = NULL;
+ if (!IS_TRACED(process))
+ return;
+
+ host = MSG_process_get_host(process);
+ TRACE_process_container(process, name, 200);
+ TRACE_process_alias_container(process, host, alias, 200);
+ if (IS_TRACING_PROCESSES)
+ pajeDestroyContainer(MSG_get_clock(), "process", name);
+ if (IS_TRACING_PROCESSES)
+ pajeDestroyContainer(MSG_get_clock(), "PROCESS", alias);
}
#endif
static xbt_dict_t task_containers = NULL;
-void TRACE_msg_task_alloc (void)
+void TRACE_msg_task_alloc(void)
{
task_containers = xbt_dict_new();
}
-void TRACE_msg_task_release (void)
+void TRACE_msg_task_release(void)
{
- xbt_dict_free (&task_containers);
+ xbt_dict_free(&task_containers);
}
-static void TRACE_task_location (m_task_t task)
+static void TRACE_task_location(m_task_t task)
{
- char container[200];
- char name[200], alias[200];
- char *val_one = NULL;
- m_process_t process = NULL;
- m_host_t host = NULL;
- if (!IS_TRACING_TASKS) return;
+ char container[200];
+ char name[200], alias[200];
+ char *val_one = NULL;
+ m_process_t process = NULL;
+ m_host_t host = NULL;
+ if (!IS_TRACING_TASKS)
+ return;
process = MSG_process_self();
- host = MSG_process_get_host (process);
+ host = MSG_process_get_host(process);
//tasks are grouped by host
- TRACE_host_container (host, container, 200);
- TRACE_task_container (task, name, 200);
- TRACE_task_alias_container (task, process, host, alias, 200);
+ TRACE_host_container(host, container, 200);
+ TRACE_task_container(task, name, 200);
+ TRACE_task_alias_container(task, process, host, alias, 200);
//check if task container is already created
- if (!xbt_dict_get_or_null (task_containers, alias)){
- pajeCreateContainer (MSG_get_clock(), alias, "TASK", container, name);
- pajeSetState (MSG_get_clock(), "category", alias, task->category);
- val_one = xbt_strdup ("1");
- xbt_dict_set (task_containers, alias, val_one, xbt_free);
+ if (!xbt_dict_get_or_null(task_containers, alias)) {
+ pajeCreateContainer(MSG_get_clock(), alias, "TASK", container, name);
+ pajeSetState(MSG_get_clock(), "category", alias, task->category);
+ val_one = xbt_strdup("1");
+ xbt_dict_set(task_containers, alias, val_one, xbt_free);
}
}
-static void TRACE_task_location_present (m_task_t task)
+static void TRACE_task_location_present(m_task_t task)
{
- char alias[200];
- m_process_t process = NULL;
- m_host_t host = NULL;
- if (!IS_TRACING_TASKS) return;
+ char alias[200];
+ m_process_t process = NULL;
+ m_host_t host = NULL;
+ if (!IS_TRACING_TASKS)
+ return;
//updating presence state of this task location
process = MSG_process_self();
- host = MSG_process_get_host (process);
+ host = MSG_process_get_host(process);
- TRACE_task_alias_container (task, process, host, alias, 200);
- pajePushState (MSG_get_clock(), "presence", alias, "presence");
+ TRACE_task_alias_container(task, process, host, alias, 200);
+ pajePushState(MSG_get_clock(), "presence", alias, "presence");
}
-static void TRACE_task_location_not_present (m_task_t task)
+static void TRACE_task_location_not_present(m_task_t task)
{
- char alias[200];
- m_process_t process = NULL;
- m_host_t host = NULL;
- if (!IS_TRACING_TASKS) return;
+ char alias[200];
+ m_process_t process = NULL;
+ m_host_t host = NULL;
+ if (!IS_TRACING_TASKS)
+ return;
//updating presence state of this task location
process = MSG_process_self();
- host = MSG_process_get_host (process);
+ host = MSG_process_get_host(process);
- TRACE_task_alias_container (task, process, host, alias, 200);
- pajePopState (MSG_get_clock(), "presence", alias);
+ TRACE_task_alias_container(task, process, host, alias, 200);
+ pajePopState(MSG_get_clock(), "presence", alias);
}
/*
*/
void TRACE_msg_set_task_category(m_task_t task, const char *category)
{
- char name[200];
- if (!IS_TRACING) return;
+ char name[200];
+ if (!IS_TRACING)
+ return;
//set task category
- task->category = xbt_new (char, strlen (category)+1);
- strncpy(task->category, category, strlen(category)+1);
+ task->category = xbt_new(char, strlen(category) + 1);
+ strncpy(task->category, category, strlen(category) + 1);
//tracing task location based on host
- TRACE_task_location (task);
- TRACE_task_location_present (task);
+ TRACE_task_location(task);
+ TRACE_task_location_present(task);
- TRACE_task_container (task, name, 200);
+ TRACE_task_container(task, name, 200);
//create container of type "task" to indicate behavior
- if (IS_TRACING_TASKS) pajeCreateContainer (MSG_get_clock(), name, "task", category, name);
- if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "created");
+ if (IS_TRACING_TASKS)
+ pajeCreateContainer(MSG_get_clock(), name, "task", category, name);
+ if (IS_TRACING_TASKS)
+ pajePushState(MSG_get_clock(), "task-state", name, "created");
}
/* MSG_task_create related function*/
-void TRACE_msg_task_create (m_task_t task)
+void TRACE_msg_task_create(m_task_t task)
{
static long long counter = 0;
task->counter = counter++;
}
/* MSG_task_execute related functions */
-void TRACE_msg_task_execute_start (m_task_t task)
+void TRACE_msg_task_execute_start(m_task_t task)
{
- char name[200];
- if (!IS_TRACING || !IS_TRACED(task)) return;
+ char name[200];
+ if (!IS_TRACING || !IS_TRACED(task))
+ return;
- TRACE_task_container (task, name, 200);
- if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "execute");
+ TRACE_task_container(task, name, 200);
+ if (IS_TRACING_TASKS)
+ pajePushState(MSG_get_clock(), "task-state", name, "execute");
- TRACE_msg_category_set (SIMIX_process_self(), task);
+ TRACE_msg_category_set(SIMIX_process_self(), task);
}
-void TRACE_msg_task_execute_end (m_task_t task)
+void TRACE_msg_task_execute_end(m_task_t task)
{
- char name[200];
- if (!IS_TRACING || !IS_TRACED(task)) return;
+ char name[200];
+ if (!IS_TRACING || !IS_TRACED(task))
+ return;
- TRACE_task_container (task, name, 200);
- if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
+ TRACE_task_container(task, name, 200);
+ if (IS_TRACING_TASKS)
+ pajePopState(MSG_get_clock(), "task-state", name);
TRACE_category_unset(SIMIX_process_self());
}
/* MSG_task_destroy related functions */
-void TRACE_msg_task_destroy (m_task_t task)
+void TRACE_msg_task_destroy(m_task_t task)
{
- char name[200];
- if (!IS_TRACING || !IS_TRACED(task)) return;
+ char name[200];
+ if (!IS_TRACING || !IS_TRACED(task))
+ return;
- TRACE_task_container (task, name, 200);
- if (IS_TRACING_TASKS) pajeDestroyContainer (MSG_get_clock(), "task", name);
+ TRACE_task_container(task, name, 200);
+ if (IS_TRACING_TASKS)
+ pajeDestroyContainer(MSG_get_clock(), "task", name);
//finish the location of this task
- TRACE_task_location_not_present (task);
+ TRACE_task_location_not_present(task);
//free category
- xbt_free (task->category);
+ xbt_free(task->category);
return;
}
/* MSG_task_get related functions */
-void TRACE_msg_task_get_start (void)
+void TRACE_msg_task_get_start(void)
{
- if (!IS_TRACING) return;
+ if (!IS_TRACING)
+ return;
}
-void TRACE_msg_task_get_end (double start_time, m_task_t task)
+void TRACE_msg_task_get_end(double start_time, m_task_t task)
{
- char name[200];
- if (!IS_TRACING || !IS_TRACED(task)) return;
+ char name[200];
+ if (!IS_TRACING || !IS_TRACED(task))
+ return;
- TRACE_task_container (task, name, 200);
- if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
+ TRACE_task_container(task, name, 200);
+ if (IS_TRACING_TASKS)
+ pajePopState(MSG_get_clock(), "task-state", name);
- TRACE_msg_volume_finish (task);
+ TRACE_msg_volume_finish(task);
- TRACE_task_location (task);
- TRACE_task_location_present (task);
+ TRACE_task_location(task);
+ TRACE_task_location_present(task);
}
/* MSG_task_put related functions */
-int TRACE_msg_task_put_start (m_task_t task)
+int TRACE_msg_task_put_start(m_task_t task)
{
- char name[200];
- if (!IS_TRACING || !IS_TRACED(task)) return 0;
+ char name[200];
+ if (!IS_TRACING || !IS_TRACED(task))
+ return 0;
- TRACE_task_container (task, name, 200);
- if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
- if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "communicate");
+ TRACE_task_container(task, name, 200);
+ if (IS_TRACING_TASKS)
+ pajePopState(MSG_get_clock(), "task-state", name);
+ if (IS_TRACING_TASKS)
+ pajePushState(MSG_get_clock(), "task-state", name, "communicate");
- TRACE_msg_volume_start (task);
+ TRACE_msg_volume_start(task);
//trace task location grouped by host
- TRACE_task_location_not_present (task);
+ TRACE_task_location_not_present(task);
//set current category
- TRACE_msg_category_set (SIMIX_process_self(), task);
+ TRACE_msg_category_set(SIMIX_process_self(), task);
return 1;
}
-void TRACE_msg_task_put_end (void)
+void TRACE_msg_task_put_end(void)
{
- if (!IS_TRACING) return;
+ if (!IS_TRACING)
+ return;
- TRACE_category_unset (SIMIX_process_self());
+ TRACE_category_unset(SIMIX_process_self());
}
#endif
#ifdef HAVE_TRACING
-void TRACE_msg_volume_start (m_task_t task)
+void TRACE_msg_volume_start(m_task_t task)
{
- m_process_t process = NULL;
- m_host_t host = NULL;
- char process_name[200], process_alias[200];
- char task_name[200];
- double volume = 0;
- if (!IS_TRACING_VOLUME) return;
+ m_process_t process = NULL;
+ m_host_t host = NULL;
+ char process_name[200], process_alias[200];
+ char task_name[200];
+ double volume = 0;
+ if (!IS_TRACING_VOLUME)
+ return;
/* check if task is traced */
- if (!IS_TRACED(task)) return;
+ if (!IS_TRACED(task))
+ return;
/* check if process is traced */
- process = MSG_process_self ();
- if (!IS_TRACED(process)) return;
+ process = MSG_process_self();
+ if (!IS_TRACED(process))
+ return;
- host = MSG_process_get_host (process);
- TRACE_process_container (process, process_name, 200);
- TRACE_process_alias_container (process, host, process_alias, 200);
- TRACE_task_container (task, task_name, 200);
+ host = MSG_process_get_host(process);
+ TRACE_process_container(process, process_name, 200);
+ TRACE_process_alias_container(process, host, process_alias, 200);
+ TRACE_task_container(task, task_name, 200);
- volume = MSG_task_get_data_size (task);
+ volume = MSG_task_get_data_size(task);
- pajeStartLinkWithVolume (MSG_get_clock(), "volume", "0", task->category, process_alias, task_name, volume);
+ pajeStartLinkWithVolume(MSG_get_clock(), "volume", "0", task->category,
+ process_alias, task_name, volume);
}
-void TRACE_msg_volume_finish (m_task_t task)
+void TRACE_msg_volume_finish(m_task_t task)
{
- char process_name[200], process_alias[200];
- char task_name[200];
- m_process_t process = NULL;
- m_host_t host = NULL;
- if (!IS_TRACING_VOLUME) return;
+ char process_name[200], process_alias[200];
+ char task_name[200];
+ m_process_t process = NULL;
+ m_host_t host = NULL;
+ if (!IS_TRACING_VOLUME)
+ return;
/* check if task is traced */
- if (!IS_TRACED(task)) return;
+ if (!IS_TRACED(task))
+ return;
/* check if process is traced */
- process = MSG_process_self ();
- if (!IS_TRACED(process)) return;
+ process = MSG_process_self();
+ if (!IS_TRACED(process))
+ return;
- host = MSG_process_get_host (process);
- TRACE_process_container (process, process_name, 200);
- TRACE_process_alias_container (process, host, process_alias, 200);
- TRACE_task_container (task, task_name, 200);
+ host = MSG_process_get_host(process);
+ TRACE_process_container(process, process_name, 200);
+ TRACE_process_alias_container(process, host, process_alias, 200);
+ TRACE_task_container(task, task_name, 200);
- pajeEndLink (MSG_get_clock(), "volume", "0", task->category, process_alias, task_name);
+ pajeEndLink(MSG_get_clock(), "volume", "0", task->category,
+ process_alias, task_name);
}
#endif
#define TRACE_LINE_SIZE 1000
-void TRACE_paje_start (FILE *file)
+void TRACE_paje_start(FILE * file)
{
tracing_file = file;
tracing_active = 1;
}
-FILE *TRACE_paje_end (void)
+FILE *TRACE_paje_end(void)
{
tracing_active = 0;
return tracing_file;
}
-void TRACE_paje_create_header(void) {
+void TRACE_paje_create_header(void)
+{
if (!tracing_active)
return;
- fprintf(
- tracing_file,
- "\
+ fprintf(tracing_file, "\
%%EventDef PajeDefineContainerType %d \n\
%% Alias string \n\
%% ContainerType string \n\
%% EntityType string \n\
%% Container string \n\
%% Value string \n\
-%%EndEventDef\n",
- pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId,
- pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId,
- pajeDestroyContainerId, pajeSetStateId,
- pajePopStateId,
- pajeStartLinkId, pajeEndLinkId,
- pajePushStateId,
- pajeSetVariableId,
- pajeAddVariableId,
- pajeSubVariableId,
- pajeDefineVariableTypeId,
- pajeStartLinkWithVolumeId,
- pajeNewEventId);
+%%EndEventDef\n", pajeDefineContainerTypeId, pajeDefineStateTypeId, pajeDefineEntityValueId, pajeDefineEventTypeId, pajeDefineLinkTypeId, pajeCreateContainerId, pajeDestroyContainerId, pajeSetStateId, pajePopStateId, pajeStartLinkId, pajeEndLinkId, pajePushStateId, pajeSetVariableId, pajeAddVariableId, pajeSubVariableId, pajeDefineVariableTypeId, pajeStartLinkWithVolumeId, pajeNewEventId);
}
/* internal to this file */
-static void __pajeCreateContainer (char *output, int len, int eventid, double time, const char *alias, const char *type,
- const char *container, const char *name)
+static void __pajeCreateContainer(char *output, int len, int eventid,
+ double time, const char *alias,
+ const char *type, const char *container,
+ const char *name)
{
- snprintf (output, len, "%d %lf %s %s %s %s", eventid, time,
- alias, type, container, name);
+ snprintf(output, len, "%d %lf %s %s %s %s", eventid, time,
+ alias, type, container, name);
}
-static void __pajeSetState (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
+static void __pajeSetState(char *output, int len, int eventid, double time,
+ const char *entityType, const char *container,
+ const char *value)
{
- snprintf (output, len, "%d %lf %s %s %s", eventid, time, entityType, container, value);
+ snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
+ container, value);
}
-static void __pajeSetVariable (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value)
+static void __pajeSetVariable(char *output, int len, int eventid,
+ double time, const char *entityType,
+ const char *container, const char *value)
{
- snprintf (output, len, "%d %lf %s %s %s", eventid, time, entityType, container, value);
+ snprintf(output, len, "%d %lf %s %s %s", eventid, time, entityType,
+ container, value);
}
-static void __pajeStartLink (char *output, int len, int eventid, double time, const char *entityType, const char *container, const char *value,
-const char *sourceContainer, const char *key)
+static void __pajeStartLink(char *output, int len, int eventid,
+ double time, const char *entityType,
+ const char *container, const char *value,
+ const char *sourceContainer, const char *key)
{
- snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType, container, value, sourceContainer, key);
+ snprintf(output, len, "%d %lf %s %s %s %s %s", eventid, time, entityType,
+ container, value, sourceContainer, key);
}
/* internal do the instrumentation module */
void pajeDefineContainerType(const char *alias, const char *containerType,
- const char *name) {
+ const char *name)
+{
fprintf(tracing_file, "%d %s %s %s\n", pajeDefineContainerTypeId, alias,
- containerType, name);
+ containerType, name);
}
void pajeDefineStateType(const char *alias, const char *containerType,
- const char *name) {
+ const char *name)
+{
fprintf(tracing_file, "%d %s %s %s\n", pajeDefineStateTypeId, alias,
- containerType, name);
+ containerType, name);
}
void pajeDefineEventType(const char *alias, const char *containerType,
- const char *name) {
+ const char *name)
+{
fprintf(tracing_file, "%d %s %s %s\n", pajeDefineEventTypeId, alias,
- containerType, name);
+ containerType, name);
}
void pajeDefineLinkType(const char *alias, const char *containerType,
- const char *sourceContainerType, const char *destContainerType,
- const char *name) {
+ const char *sourceContainerType,
+ const char *destContainerType, const char *name)
+{
fprintf(tracing_file, "%d %s %s %s %s %s\n", pajeDefineLinkTypeId, alias,
- containerType, sourceContainerType, destContainerType, name);
+ containerType, sourceContainerType, destContainerType, name);
}
-void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name) {
+void pajeCreateContainer(double time, const char *alias, const char *type,
+ const char *container, const char *name)
+{
char line[TRACE_LINE_SIZE];
- __pajeCreateContainer (line, TRACE_LINE_SIZE, pajeCreateContainerId, time, alias, type, container, name);
- fprintf (tracing_file, "%s\n", line);
+ __pajeCreateContainer(line, TRACE_LINE_SIZE, pajeCreateContainerId, time,
+ alias, type, container, name);
+ fprintf(tracing_file, "%s\n", line);
}
-void pajeDestroyContainer (double time, const char *type, const char *container)
+void pajeDestroyContainer(double time, const char *type,
+ const char *container)
{
- fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time, type, container);
+ fprintf(tracing_file, "%d %lf %s %s\n", pajeDestroyContainerId, time,
+ type, container);
}
-void pajeSetState (double time, const char *entityType, const char *container, const char *value)
+void pajeSetState(double time, const char *entityType,
+ const char *container, const char *value)
{
char line[TRACE_LINE_SIZE];
- __pajeSetState (line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType, container, value);
+ __pajeSetState(line, TRACE_LINE_SIZE, pajeSetStateId, time, entityType,
+ container, value);
fprintf(tracing_file, "%s\n", line);
}
-void pajePushState (double time, const char *entityType, const char *container, const char *value)
+void pajePushState(double time, const char *entityType,
+ const char *container, const char *value)
{
char line[TRACE_LINE_SIZE];
- __pajeSetState (line, TRACE_LINE_SIZE, pajePushStateId, time, entityType, container, value);
+ __pajeSetState(line, TRACE_LINE_SIZE, pajePushStateId, time, entityType,
+ container, value);
fprintf(tracing_file, "%s\n", line);
}
-void pajePopState (double time, const char *entityType, const char *container)
+void pajePopState(double time, const char *entityType,
+ const char *container)
{
- fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType, container);
+ fprintf(tracing_file, "%d %lf %s %s\n", pajePopStateId, time, entityType,
+ container);
}
-void pajeStartLink (double time, const char *entityType, const char *container, const char *value,
- const char *sourceContainer, const char *key)
+void pajeStartLink(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *sourceContainer, const char *key)
{
char line[TRACE_LINE_SIZE];
- __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType, container, value, sourceContainer, key);
- fprintf (tracing_file, "%s\n", line);
+ __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkId, time, entityType,
+ container, value, sourceContainer, key);
+ fprintf(tracing_file, "%s\n", line);
}
-void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value,
- const char *sourceContainer, const char *key, double volume)
+void pajeStartLinkWithVolume(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *sourceContainer, const char *key,
+ double volume)
{
char line[TRACE_LINE_SIZE];
- __pajeStartLink (line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time, entityType, container, value, sourceContainer, key);
- fprintf (tracing_file, "%s %f\n", line, volume);
+ __pajeStartLink(line, TRACE_LINE_SIZE, pajeStartLinkWithVolumeId, time,
+ entityType, container, value, sourceContainer, key);
+ fprintf(tracing_file, "%s %f\n", line, volume);
}
-void pajeEndLink (double time, const char *entityType, const char *container, const char *value,
- const char *destContainer, const char *key)
+void pajeEndLink(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *destContainer, const char *key)
{
- fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time, entityType, container, value, destContainer, key);
+ fprintf(tracing_file, "%d %lf %s %s %s %s %s\n", pajeEndLinkId, time,
+ entityType, container, value, destContainer, key);
}
-void pajeDefineVariableType(const char *alias, const char *containerType, const char *name) {
- fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias, containerType, name);
+void pajeDefineVariableType(const char *alias, const char *containerType,
+ const char *name)
+{
+ fprintf(tracing_file, "%d %s %s %s\n", pajeDefineVariableTypeId, alias,
+ containerType, name);
}
-void pajeSetVariable (double time, const char *entityType, const char *container, const char *value)
+void pajeSetVariable(double time, const char *entityType,
+ const char *container, const char *value)
{
char line[TRACE_LINE_SIZE];
- __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSetVariableId, time, entityType, container, value);
+ __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSetVariableId, time,
+ entityType, container, value);
fprintf(tracing_file, "%s\n", line);
}
-void pajeAddVariable (double time, const char *entityType, const char *container, const char *value)
+void pajeAddVariable(double time, const char *entityType,
+ const char *container, const char *value)
{
char line[TRACE_LINE_SIZE];
- __pajeSetVariable (line, TRACE_LINE_SIZE, pajeAddVariableId, time, entityType, container, value);
+ __pajeSetVariable(line, TRACE_LINE_SIZE, pajeAddVariableId, time,
+ entityType, container, value);
fprintf(tracing_file, "%s\n", line);
}
-void pajeSubVariable (double time, const char *entityType, const char *container, const char *value)
+void pajeSubVariable(double time, const char *entityType,
+ const char *container, const char *value)
{
char line[TRACE_LINE_SIZE];
- __pajeSetVariable (line, TRACE_LINE_SIZE, pajeSubVariableId, time, entityType, container, value);
+ __pajeSetVariable(line, TRACE_LINE_SIZE, pajeSubVariableId, time,
+ entityType, container, value);
fprintf(tracing_file, "%s\n", line);
}
-void pajeNewEvent (double time, const char *entityType, const char *container, const char *value)
+void pajeNewEvent(double time, const char *entityType,
+ const char *container, const char *value)
{
- fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time, entityType, container, value);
+ fprintf(tracing_file, "%d %lf %s %s %s\n", pajeNewEventId, time,
+ entityType, container, value);
}
#endif
#ifdef HAVE_TRACING
-extern int tracing_active; /* declared in paje.c */
+extern int tracing_active; /* declared in paje.c */
#define IS_TRACING (tracing_active)
#define IS_TRACED(n) (n->category)
/* from paje.c */
void TRACE_paje_create_header(void);
-void TRACE_paje_start (FILE *file);
-FILE *TRACE_paje_end (void);
-void pajeDefineContainerType(const char *alias, const char *containerType, const char *name);
-void pajeDefineStateType(const char *alias, const char *containerType, const char *name);
-void pajeDefineEventType(const char *alias, const char *containerType, const char *name);
-void pajeDefineLinkType(const char *alias, const char *containerType, const char *sourceContainerType, const char *destContainerType, const char *name);
-void pajeCreateContainer(double time, const char *alias, const char *type, const char *container, const char *name);
-void pajeDestroyContainer (double time, const char *type, const char *container);
-void pajeSetState (double time, const char *entityType, const char *container, const char *value);
-void pajePushState (double time, const char *entityType, const char *container, const char *value);
-void pajePopState (double time, const char *entityType, const char *container);
-void pajeStartLink (double time, const char *entityType, const char *container, const char *value, const char *sourceContainer, const char *key);
-void pajeStartLinkWithVolume (double time, const char *entityType, const char *container, const char *value, const char *sourceContainer, const char *key, double volume);
-void pajeEndLink (double time, const char *entityType, const char *container, const char *value, const char *destContainer, const char *key);
-void pajeDefineVariableType(const char *alias, const char *containerType, const char *name);
-void pajeSetVariable (double time, const char *entityType, const char *container, const char *value);
-void pajeAddVariable (double time, const char *entityType, const char *container, const char *value);
-void pajeSubVariable (double time, const char *entityType, const char *container, const char *value);
-void pajeNewEvent (double time, const char *entityType, const char *container, const char *value);
+void TRACE_paje_start(FILE * file);
+FILE *TRACE_paje_end(void);
+void pajeDefineContainerType(const char *alias, const char *containerType,
+ const char *name);
+void pajeDefineStateType(const char *alias, const char *containerType,
+ const char *name);
+void pajeDefineEventType(const char *alias, const char *containerType,
+ const char *name);
+void pajeDefineLinkType(const char *alias, const char *containerType,
+ const char *sourceContainerType,
+ const char *destContainerType, const char *name);
+void pajeCreateContainer(double time, const char *alias, const char *type,
+ const char *container, const char *name);
+void pajeDestroyContainer(double time, const char *type,
+ const char *container);
+void pajeSetState(double time, const char *entityType,
+ const char *container, const char *value);
+void pajePushState(double time, const char *entityType,
+ const char *container, const char *value);
+void pajePopState(double time, const char *entityType,
+ const char *container);
+void pajeStartLink(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *sourceContainer, const char *key);
+void pajeStartLinkWithVolume(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *sourceContainer, const char *key,
+ double volume);
+void pajeEndLink(double time, const char *entityType,
+ const char *container, const char *value,
+ const char *destContainer, const char *key);
+void pajeDefineVariableType(const char *alias, const char *containerType,
+ const char *name);
+void pajeSetVariable(double time, const char *entityType,
+ const char *container, const char *value);
+void pajeAddVariable(double time, const char *entityType,
+ const char *container, const char *value);
+void pajeSubVariable(double time, const char *entityType,
+ const char *container, const char *value);
+void pajeNewEvent(double time, const char *entityType,
+ const char *container, const char *value);
/* from general.c */
-char *TRACE_paje_msg_container (m_task_t task, char *host, char *output, int len);
-char *TRACE_paje_smx_container (smx_action_t action, int seqnumber, char *host, char *output, int len);
-char *TRACE_paje_surf_container (void *action, int seqnumber, char *output, int len);
-char *TRACE_host_container (m_host_t host, char *output, int len);
-char *TRACE_task_container (m_task_t task, char *output, int len);
-char *TRACE_process_container (m_process_t process, char *output, int len);
-char *TRACE_process_alias_container (m_process_t process, m_host_t host, char *output, int len);
-char *TRACE_task_alias_container (m_task_t task, m_process_t process, m_host_t host, char *output, int len);
+char *TRACE_paje_msg_container(m_task_t task, char *host, char *output,
+ int len);
+char *TRACE_paje_smx_container(smx_action_t action, int seqnumber,
+ char *host, char *output, int len);
+char *TRACE_paje_surf_container(void *action, int seqnumber, char *output,
+ int len);
+char *TRACE_host_container(m_host_t host, char *output, int len);
+char *TRACE_task_container(m_task_t task, char *output, int len);
+char *TRACE_process_container(m_process_t process, char *output, int len);
+char *TRACE_process_alias_container(m_process_t process, m_host_t host,
+ char *output, int len);
+char *TRACE_task_alias_container(m_task_t task, m_process_t process,
+ m_host_t host, char *output, int len);
/* from categories.c */
-void TRACE_category_alloc (void);
-void TRACE_category_release (void);
-void TRACE_category_set (smx_process_t proc, const char *category);
-char *TRACE_category_get (smx_process_t proc);
-void TRACE_category_unset (smx_process_t proc);
-void TRACE_msg_category_set (smx_process_t proc, m_task_t task);
+void TRACE_category_alloc(void);
+void TRACE_category_release(void);
+void TRACE_category_set(smx_process_t proc, const char *category);
+char *TRACE_category_get(smx_process_t proc);
+void TRACE_category_unset(smx_process_t proc);
+void TRACE_msg_category_set(smx_process_t proc, m_task_t task);
/* declaration of instrumentation functions from msg_task_instr.c */
-void TRACE_msg_task_alloc (void);
-void TRACE_msg_task_release (void);
-void TRACE_msg_task_create (m_task_t task);
-void TRACE_msg_task_execute_start (m_task_t task);
-void TRACE_msg_task_execute_end (m_task_t task);
-void TRACE_msg_task_destroy (m_task_t task);
+void TRACE_msg_task_alloc(void);
+void TRACE_msg_task_release(void);
+void TRACE_msg_task_create(m_task_t task);
+void TRACE_msg_task_execute_start(m_task_t task);
+void TRACE_msg_task_execute_end(m_task_t task);
+void TRACE_msg_task_destroy(m_task_t task);
void TRACE_msg_task_get_start(void);
-void TRACE_msg_task_get_end (double start_time, m_task_t task);
-int TRACE_msg_task_put_start (m_task_t task); //returns TRUE if the task_put_end must be called
-void TRACE_msg_task_put_end (void);
+void TRACE_msg_task_get_end(double start_time, m_task_t task);
+int TRACE_msg_task_put_start(m_task_t task); //returns TRUE if the task_put_end must be called
+void TRACE_msg_task_put_end(void);
/* declaration of instrumentation functions from msg_process_instr.c */
-void TRACE_msg_process_alloc (void);
-void TRACE_msg_process_release (void);
-void TRACE_msg_process_change_host (m_process_t process, m_host_t old_host, m_host_t new_host);
-void TRACE_msg_process_kill (m_process_t process);
-void TRACE_msg_process_suspend (m_process_t process);
-void TRACE_msg_process_resume (m_process_t process);
-void TRACE_msg_process_sleep_in (m_process_t process); //called from msg/gos.c
-void TRACE_msg_process_sleep_out (m_process_t process);
-void TRACE_msg_process_end (m_process_t process);
+void TRACE_msg_process_alloc(void);
+void TRACE_msg_process_release(void);
+void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host,
+ m_host_t new_host);
+void TRACE_msg_process_kill(m_process_t process);
+void TRACE_msg_process_suspend(m_process_t process);
+void TRACE_msg_process_resume(m_process_t process);
+void TRACE_msg_process_sleep_in(m_process_t process); //called from msg/gos.c
+void TRACE_msg_process_sleep_out(m_process_t process);
+void TRACE_msg_process_end(m_process_t process);
/* declaration of instrumentation functions from msg_volume.c */
-void TRACE_msg_volume_start (m_task_t task);
-void TRACE_msg_volume_finish (m_task_t task);
+void TRACE_msg_volume_start(m_task_t task);
+void TRACE_msg_volume_finish(m_task_t task);
/* from smx.c */
-void TRACE_smx_action_execute (smx_action_t act);
-void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc);
-void TRACE_smx_action_destroy (smx_action_t act);
+void TRACE_smx_action_execute(smx_action_t act);
+void TRACE_smx_action_communicate(smx_action_t act, smx_process_t proc);
+void TRACE_smx_action_destroy(smx_action_t act);
/* from surf_instr.c */
-void TRACE_surf_alloc (void);
-void TRACE_surf_release (void);
-void TRACE_surf_host_declaration (const char *name, double power);
-void TRACE_surf_host_set_power (double date, const char *resource, double power);
-void TRACE_surf_host_define_id (const char *name, int host_id);
-void TRACE_surf_host_vivaldi_parse (char *host, double x, double y, double h);
-void TRACE_surf_link_declaration (void *link, char *name, double bw, double lat);
-void TRACE_surf_link_set_bandwidth (double date, void *link, double bandwidth);
-void TRACE_surf_link_set_latency (double date, void *link, double latency);
-void TRACE_surf_save_onelink (void);
-int TRACE_surf_link_is_traced (void *link);
-void TRACE_surf_action (surf_action_t surf_action, const char *category);
+void TRACE_surf_alloc(void);
+void TRACE_surf_release(void);
+void TRACE_surf_host_declaration(const char *name, double power);
+void TRACE_surf_host_set_power(double date, const char *resource,
+ double power);
+void TRACE_surf_host_define_id(const char *name, int host_id);
+void TRACE_surf_host_vivaldi_parse(char *host, double x, double y,
+ double h);
+void TRACE_surf_link_declaration(void *link, char *name, double bw,
+ double lat);
+void TRACE_surf_link_set_bandwidth(double date, void *link,
+ double bandwidth);
+void TRACE_surf_link_set_latency(double date, void *link, double latency);
+void TRACE_surf_save_onelink(void);
+int TRACE_surf_link_is_traced(void *link);
+void TRACE_surf_action(surf_action_t surf_action, const char *category);
//for tracing gtnets
-void TRACE_surf_gtnets_communicate (void *action, int src, int dst);
-int TRACE_surf_gtnets_get_src (void *action);
-int TRACE_surf_gtnets_get_dst (void *action);
-void TRACE_surf_gtnets_destroy (void *action);
+void TRACE_surf_gtnets_communicate(void *action, int src, int dst);
+int TRACE_surf_gtnets_get_src(void *action);
+int TRACE_surf_gtnets_get_dst(void *action);
+void TRACE_surf_gtnets_destroy(void *action);
/* from smpi_instr.c */
-void TRACE_smpi_alloc (void);
-void TRACE_smpi_release (void);
-void TRACE_smpi_init (int rank);
-void TRACE_smpi_finalize (int rank);
-void TRACE_smpi_start (void);
-void TRACE_smpi_collective_in (int rank, int root, const char *operation);
-void TRACE_smpi_collective_out (int rank, int root, const char *operation);
-void TRACE_smpi_ptp_in (int rank, int src, int dst, const char *operation);
-void TRACE_smpi_ptp_out (int rank, int src, int dst, const char *operation);
-void TRACE_smpi_send (int rank, int src, int dst);
-void TRACE_smpi_recv (int rank, int src, int dst);
+void TRACE_smpi_alloc(void);
+void TRACE_smpi_release(void);
+void TRACE_smpi_init(int rank);
+void TRACE_smpi_finalize(int rank);
+void TRACE_smpi_start(void);
+void TRACE_smpi_collective_in(int rank, int root, const char *operation);
+void TRACE_smpi_collective_out(int rank, int root, const char *operation);
+void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation);
+void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation);
+void TRACE_smpi_send(int rank, int src, int dst);
+void TRACE_smpi_recv(int rank, int src, int dst);
/* from instr_config.c */
-int TRACE_is_configured (void);
-int TRACE_smpi_is_enabled (void);
-int TRACE_platform_is_enabled (void);
-int TRACE_msg_task_is_enabled (void);
-int TRACE_msg_process_is_enabled (void);
-int TRACE_msg_volume_is_enabled (void);
-char *TRACE_get_filename (void);
-char *TRACE_get_platform_method (void);
+int TRACE_is_configured(void);
+int TRACE_smpi_is_enabled(void);
+int TRACE_platform_is_enabled(void);
+int TRACE_msg_task_is_enabled(void);
+int TRACE_msg_process_is_enabled(void);
+int TRACE_msg_volume_is_enabled(void);
+char *TRACE_get_filename(void);
+char *TRACE_get_platform_method(void);
void TRACE_global_init(int *argc, char **argv);
/* from resource_utilization.c */
-void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, surf_action_t surf_action, double value, double now, double delta);
-void TRACE_surf_link_set_utilization (void *link, smx_action_t smx_action, surf_action_t surf_action, double value, double now, double delta);
-void TRACE_surf_resource_utilization_start (smx_action_t action);
-void TRACE_surf_resource_utilization_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value);
-void TRACE_surf_resource_utilization_end (smx_action_t action);
-void TRACE_surf_resource_utilization_alloc (void);
-void TRACE_surf_resource_utilization_release (void);
+void TRACE_surf_host_set_utilization(const char *name,
+ smx_action_t smx_action,
+ surf_action_t surf_action,
+ double value, double now,
+ double delta);
+void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
+ surf_action_t surf_action,
+ double value, double now,
+ double delta);
+void TRACE_surf_resource_utilization_start(smx_action_t action);
+void TRACE_surf_resource_utilization_event(smx_action_t action, double now,
+ double delta,
+ const char *variable,
+ const char *resource,
+ double value);
+void TRACE_surf_resource_utilization_end(smx_action_t action);
+void TRACE_surf_resource_utilization_alloc(void);
+void TRACE_surf_resource_utilization_release(void);
/* sd_instr.c */
-void TRACE_sd_task_create (SD_task_t task);
-void TRACE_sd_task_destroy (SD_task_t task);
+void TRACE_sd_task_create(SD_task_t task);
+void TRACE_sd_task_destroy(SD_task_t task);
#endif
-#endif /* PRIVATE_H_ */
+#endif /* PRIVATE_H_ */
#define VARIABLE_SEPARATOR '#'
//to check if variables were previously set to 0, otherwise paje won't simulate them
-static xbt_dict_t platform_variables; /* host or link name -> array of categories */
+static xbt_dict_t platform_variables; /* host or link name -> array of categories */
//B
static xbt_dict_t method_b_dict;
static xbt_dict_t method_c_dict;
/* auxiliary function for resource utilization tracing */
-static char *strsplit (char *input, int field, char del) //caller should free the returned string
+static char *strsplit(char *input, int field, char del) //caller should free the returned string
{
char *ret = NULL;
int length = strlen(input), i;
- int s = 0, e = length+1;
+ int s = 0, e = length + 1;
int current_field = 0;
- for (i = 0; i < length; i++){
- if (input[i] == del){
- if (current_field == field){
- e = i-1;
- break;
- }else{
- s = i+1;
- current_field++;
- }
- }
+ for (i = 0; i < length; i++) {
+ if (input[i] == del) {
+ if (current_field == field) {
+ e = i - 1;
+ break;
+ } else {
+ s = i + 1;
+ current_field++;
+ }
+ }
}
//copy string from s to e (with length equal to e-s) and return
- ret = malloc ((e-s+2)*sizeof(char));
- strncpy (ret, input+s, e-s+1);
- ret[e-s+1] = '\0';
+ ret = malloc((e - s + 2) * sizeof(char));
+ strncpy(ret, input + s, e - s + 1);
+ ret[e - s + 1] = '\0';
return ret;
}
//resource utilization tracing method
-static void (*TRACE_method_alloc)(void) = NULL;
-static void (*TRACE_method_release)(void) = NULL;
-static void (*TRACE_method_start)(smx_action_t action) = NULL;
-static void (*TRACE_method_event)(smx_action_t action, double now, double delta, const char *variable, const char *resource, double value) = NULL;
-static void (*TRACE_method_end)(smx_action_t action) = NULL;
+static void (*TRACE_method_alloc) (void) = NULL;
+static void (*TRACE_method_release) (void) = NULL;
+static void (*TRACE_method_start) (smx_action_t action) = NULL;
+static void (*TRACE_method_event) (smx_action_t action, double now,
+ double delta, const char *variable,
+ const char *resource, double value) =
+ NULL;
+static void (*TRACE_method_end) (smx_action_t action) = NULL;
//used by all methods
-static void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable, const char *resource)
+static void __TRACE_surf_check_variable_set_to_zero(double now,
+ const char *variable,
+ const char *resource)
{
/* check if we have to set it to 0 */
- if (!xbt_dict_get_or_null (platform_variables, resource)){
- xbt_dynar_t array = xbt_dynar_new(sizeof(char*), xbt_free);
+ if (!xbt_dict_get_or_null(platform_variables, resource)) {
+ xbt_dynar_t array = xbt_dynar_new(sizeof(char *), xbt_free);
char *var_cpy = xbt_strdup(variable);
- xbt_dynar_push (array, &var_cpy);
- if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
- xbt_dict_set (platform_variables, resource, array, xbt_dynar_free_voidp);
- }else{
- xbt_dynar_t array = xbt_dict_get (platform_variables, resource);
+ xbt_dynar_push(array, &var_cpy);
+ if (IS_TRACING_PLATFORM)
+ pajeSetVariable(now, variable, resource, "0");
+ xbt_dict_set(platform_variables, resource, array,
+ xbt_dynar_free_voidp);
+ } else {
+ xbt_dynar_t array = xbt_dict_get(platform_variables, resource);
unsigned int i;
- char* cat;
+ char *cat;
int flag = 0;
- xbt_dynar_foreach (array, i, cat) {
- if (strcmp(variable, cat)==0){
+ xbt_dynar_foreach(array, i, cat) {
+ if (strcmp(variable, cat) == 0) {
flag = 1;
}
}
- if (flag==0){
+ if (flag == 0) {
char *var_cpy = xbt_strdup(variable);
- xbt_dynar_push (array, &var_cpy);
- if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
+ xbt_dynar_push(array, &var_cpy);
+ if (IS_TRACING_PLATFORM)
+ pajeSetVariable(now, variable, resource, "0");
}
}
/* end of check */
#define A_METHOD
//A
-static void __TRACE_A_alloc (void) {}
-static void __TRACE_A_release (void) {}
-static void __TRACE_A_start (smx_action_t action) {}
-static void __TRACE_A_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+static void __TRACE_A_alloc(void)
+{
+}
+
+static void __TRACE_A_release(void)
+{
+}
+
+static void __TRACE_A_start(smx_action_t action)
+{
+}
+
+static void __TRACE_A_event(smx_action_t action, double now, double delta,
+ const char *variable, const char *resource,
+ double value)
{
- if (!IS_TRACING_PLATFORM) return;
+ if (!IS_TRACING_PLATFORM)
+ return;
char valuestr[100];
- snprintf (valuestr, 100, "%f", value);
+ snprintf(valuestr, 100, "%f", value);
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- pajeAddVariable (now, variable, resource, valuestr);
- pajeSubVariable (now+delta, variable, resource, valuestr);
+ __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
+ pajeAddVariable(now, variable, resource, valuestr);
+ pajeSubVariable(now + delta, variable, resource, valuestr);
+}
+
+static void __TRACE_A_end(smx_action_t action)
+{
}
-static void __TRACE_A_end (smx_action_t action) {}
#define B_METHOD
//B
-static void __TRACE_B_alloc (void)
+static void __TRACE_B_alloc(void)
{
- method_b_dict = xbt_dict_new();
+ method_b_dict = xbt_dict_new();
}
-static void __TRACE_B_release (void)
+static void __TRACE_B_release(void)
{
xbt_dict_cursor_t cursor = NULL;
unsigned int cursor_ar = 0;
- char *key, *value, *res;
- char *resource;
- char *aux = NULL;
- char *var_cpy = NULL;
- xbt_dynar_t resources = NULL;
- if (!IS_TRACING_PLATFORM) return;
- if (!xbt_dict_length(method_b_dict)){
+ char *key, *value, *res;
+ char *resource;
+ char *aux = NULL;
+ char *var_cpy = NULL;
+ xbt_dynar_t resources = NULL;
+ if (!IS_TRACING_PLATFORM)
+ return;
+ if (!xbt_dict_length(method_b_dict)) {
return;
- }else{
+ } else {
/* get all resources from method_b_dict */
- resources = xbt_dynar_new(sizeof(char*), xbt_free);
+ resources = xbt_dynar_new(sizeof(char *), xbt_free);
xbt_dict_foreach(method_b_dict, cursor, key, value) {
- res = strsplit (key, 0, VARIABLE_SEPARATOR);
- aux = strsplit (key, 1, VARIABLE_SEPARATOR);
- if (strcmp (aux, "Time") == 0){ //only need to add one of three
- var_cpy = xbt_strdup (res);
- xbt_dynar_push (resources, &var_cpy);
+ res = strsplit(key, 0, VARIABLE_SEPARATOR);
+ aux = strsplit(key, 1, VARIABLE_SEPARATOR);
+ if (strcmp(aux, "Time") == 0) { //only need to add one of three
+ var_cpy = xbt_strdup(res);
+ xbt_dynar_push(resources, &var_cpy);
}
- free (aux);
- free (res);
+ free(aux);
+ free(res);
}
/* iterate through resources array */
- xbt_dynar_foreach (resources, cursor_ar, resource) {
+ xbt_dynar_foreach(resources, cursor_ar, resource) {
char timekey[100], valuekey[100], variablekey[100];
char *time = NULL;
char *value = NULL;
char *variable = NULL;
- snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
- snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
- snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
- time = xbt_dict_get_or_null (method_b_dict, timekey);
- if (!time) continue;
- value = xbt_dict_get (method_b_dict, valuekey);
- variable = xbt_dict_get (method_b_dict, variablekey);
- pajeSubVariable (atof(time), variable, resource, value);
-
- xbt_dict_remove (method_b_dict, timekey);
- xbt_dict_remove (method_b_dict, valuekey);
- xbt_dict_remove (method_b_dict, variablekey);
+ snprintf(timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
+ snprintf(valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
+ snprintf(variablekey, 100, "%s%cVariable", resource,
+ VARIABLE_SEPARATOR);
+
+ time = xbt_dict_get_or_null(method_b_dict, timekey);
+ if (!time)
+ continue;
+ value = xbt_dict_get(method_b_dict, valuekey);
+ variable = xbt_dict_get(method_b_dict, variablekey);
+ pajeSubVariable(atof(time), variable, resource, value);
+
+ xbt_dict_remove(method_b_dict, timekey);
+ xbt_dict_remove(method_b_dict, valuekey);
+ xbt_dict_remove(method_b_dict, variablekey);
}
}
- xbt_dict_free (&method_b_dict);
+ xbt_dict_free(&method_b_dict);
+}
+
+static void __TRACE_B_start(smx_action_t action)
+{
}
-static void __TRACE_B_start (smx_action_t action) {}
-static void __TRACE_B_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+static void __TRACE_B_event(smx_action_t action, double now, double delta,
+ const char *variable, const char *resource,
+ double value)
{
- if (!IS_TRACING_PLATFORM) return;
+ if (!IS_TRACING_PLATFORM)
+ return;
char valuestr[100];
char nowstr[100], nowdeltastr[100];
* variables. It should be re-checked before put in production.
*/
- snprintf (valuestr, 100, "%f", value);
- snprintf (nowstr, 100, "%f", now);
- snprintf (nowdeltastr, 100, "%f", now+delta);
- snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
- snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
- snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
- lastvariable = xbt_dict_get_or_null (method_b_dict, variablekey);
- if (lastvariable == NULL){
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- pajeAddVariable (now, variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- variable_cpy = xbt_strdup (variable);
- xbt_dict_set (method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, valuekey, valuestr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, variablekey, variable_cpy, xbt_free);
- }else{
- lasttime = xbt_dict_get_or_null (method_b_dict, timekey);
- lastvalue = xbt_dict_get_or_null (method_b_dict, valuekey);
+ snprintf(valuestr, 100, "%f", value);
+ snprintf(nowstr, 100, "%f", now);
+ snprintf(nowdeltastr, 100, "%f", now + delta);
+ snprintf(timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
+ snprintf(valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
+ snprintf(variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
+
+ lastvariable = xbt_dict_get_or_null(method_b_dict, variablekey);
+ if (lastvariable == NULL) {
+ __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
+ pajeAddVariable(now, variable, resource, valuestr);
+ nowdeltastr_cpy = xbt_strdup(nowdeltastr);
+ valuestr_cpy = xbt_strdup(valuestr);
+ variable_cpy = xbt_strdup(variable);
+ xbt_dict_set(method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, valuekey, valuestr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, variablekey, variable_cpy, xbt_free);
+ } else {
+ lasttime = xbt_dict_get_or_null(method_b_dict, timekey);
+ lastvalue = xbt_dict_get_or_null(method_b_dict, valuekey);
/* check if it is the same variable */
- if (strcmp(lastvariable, variable) == 0){ /* same variable */
+ if (strcmp(lastvariable, variable) == 0) { /* same variable */
/* check if lasttime equals now */
- if (atof(lasttime) == now){ /* lastime == now */
+ if (atof(lasttime) == now) { /* lastime == now */
/* check if lastvalue equals valuestr */
- if (atof(lastvalue) == value){ /* lastvalue == value (good, just advance time) */
- char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- xbt_dict_set (method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
- }else{ /* value has changed */
+ if (atof(lastvalue) == value) { /* lastvalue == value (good, just advance time) */
+ char *nowdeltastr_cpy = xbt_strdup(nowdeltastr);
+ xbt_dict_set(method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
+ } else { /* value has changed */
/* value has changed, subtract previous value, add new one */
- pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
- pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- xbt_dict_set (method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, valuekey, valuestr_cpy, xbt_free);
+ pajeSubVariable(atof(lasttime), variable, resource, lastvalue);
+ pajeAddVariable(atof(nowstr), variable, resource, valuestr);
+ nowdeltastr_cpy = xbt_strdup(nowdeltastr);
+ valuestr_cpy = xbt_strdup(valuestr);
+ xbt_dict_set(method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, valuekey, valuestr_cpy, xbt_free);
}
- }else{ /* lasttime != now */
+ } else { /* lasttime != now */
/* the last time is different from new starting time, subtract to lasttime and add from nowstr */
- pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
- pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- xbt_dict_set (method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, valuekey, valuestr_cpy, xbt_free);
+ pajeSubVariable(atof(lasttime), variable, resource, lastvalue);
+ pajeAddVariable(atof(nowstr), variable, resource, valuestr);
+ nowdeltastr_cpy = xbt_strdup(nowdeltastr);
+ valuestr_cpy = xbt_strdup(valuestr);
+ xbt_dict_set(method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, valuekey, valuestr_cpy, xbt_free);
}
- }else{ /* variable has changed */
- pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- pajeAddVariable (now, variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- variable_cpy = xbt_strdup (variable);
- xbt_dict_set (method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, valuekey, valuestr_cpy, xbt_free);
- xbt_dict_set (method_b_dict, variablekey, variable_cpy, xbt_free);
+ } else { /* variable has changed */
+ pajeSubVariable(atof(lasttime), lastvariable, resource, lastvalue);
+ __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
+ pajeAddVariable(now, variable, resource, valuestr);
+ nowdeltastr_cpy = xbt_strdup(nowdeltastr);
+ valuestr_cpy = xbt_strdup(valuestr);
+ variable_cpy = xbt_strdup(variable);
+ xbt_dict_set(method_b_dict, timekey, nowdeltastr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, valuekey, valuestr_cpy, xbt_free);
+ xbt_dict_set(method_b_dict, variablekey, variable_cpy, xbt_free);
}
}
return;
}
-static void __TRACE_B_end (smx_action_t action) {}
+
+static void __TRACE_B_end(smx_action_t action)
+{
+}
#define C_METHOD
//C
-static void __TRACE_C_alloc (void)
+static void __TRACE_C_alloc(void)
{
method_c_dict = xbt_dict_new();
}
-static void __TRACE_C_release (void)
+static void __TRACE_C_release(void)
{
- xbt_dict_free (&method_c_dict);
+ xbt_dict_free(&method_c_dict);
}
-static void __TRACE_C_start (smx_action_t action)
+static void __TRACE_C_start(smx_action_t action)
{
char key[100];
- snprintf (key, 100, "%p", action);
+ snprintf(key, 100, "%p", action);
//check if exists
- if (xbt_dict_get_or_null (method_c_dict, key)){
- xbt_dict_remove (method_c_dict, key); //should never execute here, but it does
+ if (xbt_dict_get_or_null(method_c_dict, key)) {
+ xbt_dict_remove(method_c_dict, key); //should never execute here, but it does
}
- xbt_dict_set (method_c_dict, key, xbt_dict_new(), xbt_free);
+ xbt_dict_set(method_c_dict, key, xbt_dict_new(), xbt_free);
}
-static void __TRACE_C_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+static void __TRACE_C_event(smx_action_t action, double now, double delta,
+ const char *variable, const char *resource,
+ double value)
{
char key[100];
- snprintf (key, 100, "%p", action);
+ snprintf(key, 100, "%p", action);
- xbt_dict_t action_dict = xbt_dict_get (method_c_dict, key);
+ xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key);
//setting start time
- if (!xbt_dict_get_or_null (action_dict, "start")){
+ if (!xbt_dict_get_or_null(action_dict, "start")) {
char start_time[100];
- snprintf (start_time, 100, "%f", now);
- xbt_dict_set (action_dict, "start", xbt_strdup (start_time), xbt_free);
+ snprintf(start_time, 100, "%f", now);
+ xbt_dict_set(action_dict, "start", xbt_strdup(start_time), xbt_free);
}
//updating end time
char end_time[100];
- snprintf (end_time, 100, "%f", now+delta);
- xbt_dict_set (action_dict, "end", xbt_strdup (end_time), xbt_free);
+ snprintf(end_time, 100, "%f", now + delta);
+ xbt_dict_set(action_dict, "end", xbt_strdup(end_time), xbt_free);
//accumulate the value resource-variable
char res_var[300];
- snprintf (res_var, 300, "%s %s", resource, variable);
+ snprintf(res_var, 300, "%s %s", resource, variable);
double current_value_f;
- char *current_value = xbt_dict_get_or_null (action_dict, res_var);
- if (current_value){
- current_value_f = atof (current_value);
- current_value_f += value*delta;
- }else{
- current_value_f = value*delta;
+ char *current_value = xbt_dict_get_or_null(action_dict, res_var);
+ if (current_value) {
+ current_value_f = atof(current_value);
+ current_value_f += value * delta;
+ } else {
+ current_value_f = value * delta;
}
char new_current_value[100];
- snprintf (new_current_value, 100, "%f", current_value_f);
- xbt_dict_set (action_dict, res_var, xbt_strdup (new_current_value), xbt_free);
+ snprintf(new_current_value, 100, "%f", current_value_f);
+ xbt_dict_set(action_dict, res_var, xbt_strdup(new_current_value),
+ xbt_free);
}
-static void __TRACE_C_end (smx_action_t action)
+static void __TRACE_C_end(smx_action_t action)
{
char key[100];
- snprintf (key, 100, "%p", action);
+ snprintf(key, 100, "%p", action);
- xbt_dict_t action_dict = xbt_dict_get (method_c_dict, key);
- double start_time = atof(xbt_dict_get (action_dict, "start"));
- double end_time = atof(xbt_dict_get (action_dict, "end"));
+ xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key);
+ double start_time = atof(xbt_dict_get(action_dict, "start"));
+ double end_time = atof(xbt_dict_get(action_dict, "end"));
- xbt_dict_cursor_t cursor=NULL;
+ xbt_dict_cursor_t cursor = NULL;
char *action_dict_key, *action_dict_value;
- xbt_dict_foreach(action_dict,cursor,action_dict_key,action_dict_value) {
+ xbt_dict_foreach(action_dict, cursor, action_dict_key, action_dict_value) {
char resource[100], variable[100];
- if (sscanf (action_dict_key, "%s %s", resource, variable) != 2) continue;
- __TRACE_surf_check_variable_set_to_zero (start_time, variable, resource);
+ if (sscanf(action_dict_key, "%s %s", resource, variable) != 2)
+ continue;
+ __TRACE_surf_check_variable_set_to_zero(start_time, variable,
+ resource);
char value_str[100];
- if(end_time-start_time != 0){
- snprintf (value_str, 100, "%f", atof(action_dict_value)/(end_time-start_time));
- pajeAddVariable (start_time, variable, resource, value_str);
- pajeSubVariable (end_time, variable, resource, value_str);
+ if (end_time - start_time != 0) {
+ snprintf(value_str, 100, "%f",
+ atof(action_dict_value) / (end_time - start_time));
+ pajeAddVariable(start_time, variable, resource, value_str);
+ pajeSubVariable(end_time, variable, resource, value_str);
}
}
- xbt_dict_remove (method_c_dict, key);
+ xbt_dict_remove(method_c_dict, key);
}
#define RESOURCE_UTILIZATION_INTERFACE
/*
* TRACE_surf_link_set_utilization: entry point from SimGrid
*/
-void TRACE_surf_link_set_utilization (void *link, smx_action_t smx_action, surf_action_t surf_action, double value, double now, double delta)
+void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
+ surf_action_t surf_action,
+ double value, double now,
+ double delta)
{
- if (!IS_TRACING) return;
- if (!value) return;
+ if (!IS_TRACING)
+ return;
+ if (!value)
+ return;
//only trace link utilization if link is known by tracing mechanism
- if (!TRACE_surf_link_is_traced (link)) return;
- if (!value) return;
+ if (!TRACE_surf_link_is_traced(link))
+ return;
+ if (!value)
+ return;
//trace uncategorized link utilization
char resource[100];
- snprintf (resource, 100, "%p", link);
- TRACE_surf_resource_utilization_event (smx_action, now, delta, "bandwidth_used", resource, value);
+ snprintf(resource, 100, "%p", link);
+ TRACE_surf_resource_utilization_event(smx_action, now, delta,
+ "bandwidth_used", resource, value);
//trace categorized utilization
- if (!IS_TRACED(surf_action)) return;
+ if (!IS_TRACED(surf_action))
+ return;
char type[100];
- snprintf (type, 100, "b%s", surf_action->category);
- TRACE_surf_resource_utilization_event (smx_action, now, delta, type, resource, value);
+ snprintf(type, 100, "b%s", surf_action->category);
+ TRACE_surf_resource_utilization_event(smx_action, now, delta, type,
+ resource, value);
return;
}
/*
* TRACE_surf_host_set_utilization: entry point from SimGrid
*/
-void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, surf_action_t surf_action, double value, double now, double delta)
+void TRACE_surf_host_set_utilization(const char *name,
+ smx_action_t smx_action,
+ surf_action_t surf_action,
+ double value, double now,
+ double delta)
{
- if (!IS_TRACING) return;
- if (!value) return;
+ if (!IS_TRACING)
+ return;
+ if (!value)
+ return;
//trace uncategorized host utilization
- TRACE_surf_resource_utilization_event (smx_action, now, delta, "power_used", name, value);
+ TRACE_surf_resource_utilization_event(smx_action, now, delta,
+ "power_used", name, value);
//trace categorized utilization
- if (!IS_TRACED(surf_action)) return;
+ if (!IS_TRACED(surf_action))
+ return;
char type[100];
- snprintf (type, 100, "p%s", surf_action->category);
- TRACE_surf_resource_utilization_event (smx_action, now, delta, type, name, value);
+ snprintf(type, 100, "p%s", surf_action->category);
+ TRACE_surf_resource_utilization_event(smx_action, now, delta, type, name,
+ value);
return;
}
/*
* __TRACE_surf_resource_utilization_*: entry points from tracing functions
*/
-void TRACE_surf_resource_utilization_start (smx_action_t action)
+void TRACE_surf_resource_utilization_start(smx_action_t action)
{
- if (!IS_TRACING) return;
- TRACE_method_start (action);
+ if (!IS_TRACING)
+ return;
+ TRACE_method_start(action);
}
-void TRACE_surf_resource_utilization_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+void TRACE_surf_resource_utilization_event(smx_action_t action, double now,
+ double delta,
+ const char *variable,
+ const char *resource,
+ double value)
{
- if (!IS_TRACING) return;
- TRACE_method_event (action, now, delta, variable, resource, value);
+ if (!IS_TRACING)
+ return;
+ TRACE_method_event(action, now, delta, variable, resource, value);
}
-void TRACE_surf_resource_utilization_end (smx_action_t action)
+void TRACE_surf_resource_utilization_end(smx_action_t action)
{
- if (!IS_TRACING) return;
- TRACE_method_end (action);
+ if (!IS_TRACING)
+ return;
+ TRACE_method_end(action);
}
-void TRACE_surf_resource_utilization_release ()
+void TRACE_surf_resource_utilization_release()
{
- if (!IS_TRACING) return;
- TRACE_method_release ();
+ if (!IS_TRACING)
+ return;
+ TRACE_method_release();
}
-static void __TRACE_define_method (char *method)
+static void __TRACE_define_method(char *method)
{
- if (!strcmp(method, "a")){
+ if (!strcmp(method, "a")) {
TRACE_method_alloc = __TRACE_A_alloc;
TRACE_method_release = __TRACE_A_release;
TRACE_method_start = __TRACE_A_start;
TRACE_method_event = __TRACE_A_event;
TRACE_method_end = __TRACE_A_end;
- }else if (!strcmp(method, "c")){
+ } else if (!strcmp(method, "c")) {
TRACE_method_alloc = __TRACE_C_alloc;
TRACE_method_release = __TRACE_C_release;
TRACE_method_start = __TRACE_C_start;
TRACE_method_event = __TRACE_C_event;
TRACE_method_end = __TRACE_C_end;
- }else{ //default is B
+ } else { //default is B
TRACE_method_alloc = __TRACE_B_alloc;
TRACE_method_release = __TRACE_B_release;
TRACE_method_start = __TRACE_B_start;
}
}
-void TRACE_surf_resource_utilization_alloc ()
+void TRACE_surf_resource_utilization_alloc()
{
platform_variables = xbt_dict_new();
- __TRACE_define_method (TRACE_get_platform_method());
- TRACE_method_alloc ();
+ __TRACE_define_method(TRACE_get_platform_method());
+ TRACE_method_alloc();
}
#endif
#ifdef HAVE_TRACING
-void TRACE_sd_task_create (SD_task_t task)
+void TRACE_sd_task_create(SD_task_t task)
{
- if (!IS_TRACING) return;
+ if (!IS_TRACING)
+ return;
task->category = NULL;
}
-void TRACE_sd_task_destroy (SD_task_t task)
+void TRACE_sd_task_destroy(SD_task_t task)
{
- if (!IS_TRACING) return;
- if (task->category) xbt_free (task->category);
+ if (!IS_TRACING)
+ return;
+ if (task->category)
+ xbt_free(task->category);
}
void TRACE_sd_set_task_category(SD_task_t task, const char *category)
{
- if (!IS_TRACING) return;
- task->category = xbt_new (char, strlen (category)+1);
- strncpy(task->category, category, strlen(category)+1);
+ if (!IS_TRACING)
+ return;
+ task->category = xbt_new(char, strlen(category) + 1);
+ strncpy(task->category, category, strlen(category) + 1);
}
#endif
static xbt_dict_t keys;
-static char *TRACE_smpi_container (int rank, char *container, int n)
+static char *TRACE_smpi_container(int rank, char *container, int n)
{
- snprintf (container, n, "rank-%d", rank);
+ snprintf(container, n, "rank-%d", rank);
return container;
}
-static char *TRACE_smpi_put_key (int src, int dst, char *key, int n)
+static char *TRACE_smpi_put_key(int src, int dst, char *key, int n)
{
//get the dynar for src#dst
char aux[100];
- snprintf (aux, 100, "%d#%d", src, dst);
- xbt_dynar_t d = xbt_dict_get_or_null (keys, aux);
- if (d == NULL){
- d = xbt_dynar_new (sizeof(char*), xbt_free);
- xbt_dict_set (keys, aux, d, xbt_free);
+ snprintf(aux, 100, "%d#%d", src, dst);
+ xbt_dynar_t d = xbt_dict_get_or_null(keys, aux);
+ if (d == NULL) {
+ d = xbt_dynar_new(sizeof(char *), xbt_free);
+ xbt_dict_set(keys, aux, d, xbt_free);
}
//generate the key
static long long counter = 0;
- snprintf (key, n, "%d%d%lld", src, dst, counter++);
+ snprintf(key, n, "%d%d%lld", src, dst, counter++);
- xbt_dynar_insert_at (d, 0, xbt_strdup (key));
+ xbt_dynar_insert_at(d, 0, xbt_strdup(key));
return key;
}
-static char *TRACE_smpi_get_key (int src, int dst, char *key, int n)
+static char *TRACE_smpi_get_key(int src, int dst, char *key, int n)
{
char aux[100];
- snprintf (aux, 100, "%d#%d", src, dst);
- xbt_dynar_t d = xbt_dict_get_or_null (keys, aux);
+ snprintf(aux, 100, "%d#%d", src, dst);
+ xbt_dynar_t d = xbt_dict_get_or_null(keys, aux);
- int length = xbt_dynar_length (d);
+ int length = xbt_dynar_length(d);
char stored_key[n];
- xbt_dynar_remove_at (d, length-1, stored_key);
- strncpy (key, stored_key, n);
+ xbt_dynar_remove_at(d, length - 1, stored_key);
+ strncpy(key, stored_key, n);
return key;
}
-void TRACE_smpi_alloc ()
+void TRACE_smpi_alloc()
{
keys = xbt_dict_new();
}
-void TRACE_smpi_start (void)
+void TRACE_smpi_start(void)
{
- if (IS_TRACING_SMPI){
- TRACE_start ();
+ if (IS_TRACING_SMPI) {
+ TRACE_start();
}
}
-void TRACE_smpi_release (void)
+void TRACE_smpi_release(void)
{
- TRACE_surf_release ();
- if (IS_TRACING_SMPI){
+ TRACE_surf_release();
+ if (IS_TRACING_SMPI) {
TRACE_end();
}
}
-void TRACE_smpi_init (int rank)
+void TRACE_smpi_init(int rank)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- TRACE_smpi_container (rank, str, 100);
- pajeCreateContainer (SIMIX_get_clock(), str, "MPI_PROCESS",
- SIMIX_host_get_name(SIMIX_host_self()), str);
+ TRACE_smpi_container(rank, str, 100);
+ pajeCreateContainer(SIMIX_get_clock(), str, "MPI_PROCESS",
+ SIMIX_host_get_name(SIMIX_host_self()), str);
}
-void TRACE_smpi_finalize (int rank)
+void TRACE_smpi_finalize(int rank)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- pajeDestroyContainer (SIMIX_get_clock(), "MPI_PROCESS",
- TRACE_smpi_container (rank, str, 100));
+ pajeDestroyContainer(SIMIX_get_clock(), "MPI_PROCESS",
+ TRACE_smpi_container(rank, str, 100));
}
-void TRACE_smpi_collective_in (int rank, int root, const char *operation)
+void TRACE_smpi_collective_in(int rank, int root, const char *operation)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- pajePushState (SIMIX_get_clock(), "MPI_STATE",
- TRACE_smpi_container (rank, str, 100), operation);
+ pajePushState(SIMIX_get_clock(), "MPI_STATE",
+ TRACE_smpi_container(rank, str, 100), operation);
}
-void TRACE_smpi_collective_out (int rank, int root, const char *operation)
+void TRACE_smpi_collective_out(int rank, int root, const char *operation)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- pajePopState (SIMIX_get_clock(), "MPI_STATE",
- TRACE_smpi_container (rank, str, 100));
+ pajePopState(SIMIX_get_clock(), "MPI_STATE",
+ TRACE_smpi_container(rank, str, 100));
}
-void TRACE_smpi_ptp_in (int rank, int src, int dst, const char *operation)
+void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- pajePushState (SIMIX_get_clock(), "MPI_STATE",
- TRACE_smpi_container (rank, str, 100), operation);
+ pajePushState(SIMIX_get_clock(), "MPI_STATE",
+ TRACE_smpi_container(rank, str, 100), operation);
}
-void TRACE_smpi_ptp_out (int rank, int src, int dst, const char *operation)
+void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char str[100];
- pajePopState (SIMIX_get_clock(), "MPI_STATE",
- TRACE_smpi_container (rank, str, 100));
+ pajePopState(SIMIX_get_clock(), "MPI_STATE",
+ TRACE_smpi_container(rank, str, 100));
}
-void TRACE_smpi_send (int rank, int src, int dst)
+void TRACE_smpi_send(int rank, int src, int dst)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char key[100], str[100];
- TRACE_smpi_put_key (src, dst, key, 100);
- pajeStartLink (SIMIX_get_clock(), "MPI_LINK", "0", "PTP",
- TRACE_smpi_container (src, str, 100), key);
+ TRACE_smpi_put_key(src, dst, key, 100);
+ pajeStartLink(SIMIX_get_clock(), "MPI_LINK", "0", "PTP",
+ TRACE_smpi_container(src, str, 100), key);
}
-void TRACE_smpi_recv (int rank, int src, int dst)
+void TRACE_smpi_recv(int rank, int src, int dst)
{
- if (!IS_TRACING_SMPI) return;
+ if (!IS_TRACING_SMPI)
+ return;
char key[100], str[100];
- TRACE_smpi_get_key (src, dst, key, 100);
- pajeEndLink (SIMIX_get_clock(), "MPI_LINK", "0", "PTP",
- TRACE_smpi_container (dst, str, 100), key);
+ TRACE_smpi_get_key(src, dst, key, 100);
+ pajeEndLink(SIMIX_get_clock(), "MPI_LINK", "0", "PTP",
+ TRACE_smpi_container(dst, str, 100), key);
}
#endif
-
#ifdef HAVE_TRACING
-static long long int counter = 0; /* to uniquely identify simix actions */
+static long long int counter = 0; /* to uniquely identify simix actions */
-void TRACE_smx_action_execute (smx_action_t act)
+void TRACE_smx_action_execute(smx_action_t act)
{
- char *category = NULL;
- if (!IS_TRACING) return;
+ char *category = NULL;
+ if (!IS_TRACING)
+ return;
act->counter = counter++;
- category = TRACE_category_get (SIMIX_process_self());
- if (category){
- act->category = xbt_new (char, strlen (category)+1);
- strncpy (act->category, category, strlen(category)+1);
+ category = TRACE_category_get(SIMIX_process_self());
+ if (category) {
+ act->category = xbt_new(char, strlen(category) + 1);
+ strncpy(act->category, category, strlen(category) + 1);
}
- TRACE_surf_resource_utilization_start (act);
+ TRACE_surf_resource_utilization_start(act);
}
-void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
+void TRACE_smx_action_communicate(smx_action_t act, smx_process_t proc)
{
- char *category = NULL;
- if (!IS_TRACING) return;
+ char *category = NULL;
+ if (!IS_TRACING)
+ return;
act->counter = counter++;
- category = TRACE_category_get (proc);
- if (category){
- act->category = xbt_strdup (category);
+ category = TRACE_category_get(proc);
+ if (category) {
+ act->category = xbt_strdup(category);
}
- TRACE_surf_resource_utilization_start (act);
+ TRACE_surf_resource_utilization_start(act);
}
-void TRACE_smx_action_destroy (smx_action_t act)
+void TRACE_smx_action_destroy(smx_action_t act)
{
- if (!IS_TRACING || !IS_TRACED(act)) return;
+ if (!IS_TRACING || !IS_TRACED(act))
+ return;
- if (act->category){
- xbt_free (act->category);
+ if (act->category) {
+ xbt_free(act->category);
}
- TRACE_surf_resource_utilization_end (act);
+ TRACE_surf_resource_utilization_end(act);
}
#endif
#ifdef HAVE_TRACING
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(tracing_surf,tracing,"Tracing Surf");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(tracing_surf, tracing, "Tracing Surf");
#define VARIABLE_SEPARATOR '#'
static xbt_dict_t created_links;
static xbt_dict_t host_containers;
-static xbt_dict_t resource_variables; /* (host|link)#variable -> value */
+static xbt_dict_t resource_variables; /* (host|link)#variable -> value */
/* to trace gtnets */
-static xbt_dict_t gtnets_src; /* %p (action) -> %s */
-static xbt_dict_t gtnets_dst; /* %p (action) -> %s */
+static xbt_dict_t gtnets_src; /* %p (action) -> %s */
+static xbt_dict_t gtnets_dst; /* %p (action) -> %s */
-void TRACE_surf_alloc (void)
+void TRACE_surf_alloc(void)
{
created_links = xbt_dict_new();
host_containers = xbt_dict_new();
- resource_variables = xbt_dict_new ();
- gtnets_src = xbt_dict_new ();
- gtnets_dst = xbt_dict_new ();
+ resource_variables = xbt_dict_new();
+ gtnets_src = xbt_dict_new();
+ gtnets_dst = xbt_dict_new();
TRACE_surf_resource_utilization_alloc();
}
-void TRACE_surf_release (void)
+void TRACE_surf_release(void)
{
char *key, *value;
xbt_dict_cursor_t cursor = NULL;
/* get all host from host_containers */
xbt_dict_foreach(host_containers, cursor, key, value) {
- pajeDestroyContainer (MSG_get_clock(), "HOST", key);
+ pajeDestroyContainer(MSG_get_clock(), "HOST", key);
}
xbt_dict_foreach(created_links, cursor, key, value) {
- pajeDestroyContainer (MSG_get_clock(), "LINK", key);
+ pajeDestroyContainer(MSG_get_clock(), "LINK", key);
}
}
-static void TRACE_surf_set_resource_variable (double date, const char *variable, const char *resource, double value)
+static void TRACE_surf_set_resource_variable(double date,
+ const char *variable,
+ const char *resource,
+ double value)
{
- char aux[100], key[100];
- char *last_value = NULL;
- if (!IS_TRACING) return;
- snprintf (aux, 100, "%f", value);
- snprintf (key, 100, "%s%c%s", resource, VARIABLE_SEPARATOR, variable);
+ char aux[100], key[100];
+ char *last_value = NULL;
+ if (!IS_TRACING)
+ return;
+ snprintf(aux, 100, "%f", value);
+ snprintf(key, 100, "%s%c%s", resource, VARIABLE_SEPARATOR, variable);
last_value = xbt_dict_get_or_null(resource_variables, key);
- if (last_value){
- if (atof(last_value) == value){
+ if (last_value) {
+ if (atof(last_value) == value) {
return;
}
}
- if (IS_TRACING_PLATFORM) pajeSetVariable (date, variable, resource, aux);
- xbt_dict_set (resource_variables, xbt_strdup(key), xbt_strdup(aux), xbt_free);
+ if (IS_TRACING_PLATFORM)
+ pajeSetVariable(date, variable, resource, aux);
+ xbt_dict_set(resource_variables, xbt_strdup(key), xbt_strdup(aux),
+ xbt_free);
}
/*
* main: create LINK container, set initial bandwidth and latency
* return: void
*/
-void TRACE_surf_link_declaration (void *link, char *name, double bw, double lat)
+void TRACE_surf_link_declaration(void *link, char *name, double bw,
+ double lat)
{
- if (!IS_TRACING) return;
+ if (!IS_TRACING)
+ return;
//filter out loopback
- if (!strcmp (name, "loopback") || !strcmp (name, "__loopback__")) return;
+ if (!strcmp(name, "loopback") || !strcmp(name, "__loopback__"))
+ return;
char alias[100];
- snprintf (alias, 100, "%p", link);
- pajeCreateContainer (SIMIX_get_clock(), alias, "LINK", "platform", name);
- xbt_dict_set (created_links, alias, xbt_strdup ("1"), xbt_free);
- TRACE_surf_link_set_bandwidth (SIMIX_get_clock(), link, bw);
- TRACE_surf_link_set_latency (SIMIX_get_clock(), link, lat);
+ snprintf(alias, 100, "%p", link);
+ pajeCreateContainer(SIMIX_get_clock(), alias, "LINK", "platform", name);
+ xbt_dict_set(created_links, alias, xbt_strdup("1"), xbt_free);
+ TRACE_surf_link_set_bandwidth(SIMIX_get_clock(), link, bw);
+ TRACE_surf_link_set_latency(SIMIX_get_clock(), link, lat);
}
/*
* main: create HOST containers, set initial power value
* return: void
*/
-void TRACE_surf_host_declaration (const char *name, double power)
+void TRACE_surf_host_declaration(const char *name, double power)
{
- if (!IS_TRACING) return;
- pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
- xbt_dict_set (host_containers, name, xbt_strdup("1"), xbt_free);
- TRACE_surf_host_set_power (SIMIX_get_clock(), name, power);
+ if (!IS_TRACING)
+ return;
+ pajeCreateContainer(SIMIX_get_clock(), name, "HOST", "platform", name);
+ xbt_dict_set(host_containers, name, xbt_strdup("1"), xbt_free);
+ TRACE_surf_host_set_power(SIMIX_get_clock(), name, power);
}
-void TRACE_surf_host_set_power (double date, const char *resource, double power)
+void TRACE_surf_host_set_power(double date, const char *resource,
+ double power)
{
- TRACE_surf_set_resource_variable (date, "power", resource, power);
+ TRACE_surf_set_resource_variable(date, "power", resource, power);
}
-void TRACE_surf_link_set_bandwidth (double date, void *link, double bandwidth)
+void TRACE_surf_link_set_bandwidth(double date, void *link,
+ double bandwidth)
{
- if (!TRACE_surf_link_is_traced (link)) return;
+ if (!TRACE_surf_link_is_traced(link))
+ return;
char resource[100];
- snprintf (resource, 100, "%p", link);
- TRACE_surf_set_resource_variable (date, "bandwidth", resource, bandwidth);
+ snprintf(resource, 100, "%p", link);
+ TRACE_surf_set_resource_variable(date, "bandwidth", resource, bandwidth);
}
-void TRACE_surf_link_set_latency (double date, void *link, double latency)
+void TRACE_surf_link_set_latency(double date, void *link, double latency)
{
- if (!TRACE_surf_link_is_traced (link)) return;
+ if (!TRACE_surf_link_is_traced(link))
+ return;
char resource[100];
- snprintf (resource, 100, "%p", link);
- TRACE_surf_set_resource_variable (date, "latency", resource, latency);
+ snprintf(resource, 100, "%p", link);
+ TRACE_surf_set_resource_variable(date, "latency", resource, latency);
}
/* to trace gtnets */
-void TRACE_surf_gtnets_communicate (void *action, int src, int dst)
+void TRACE_surf_gtnets_communicate(void *action, int src, int dst)
{
- char key[100], aux[100];
- if (!IS_TRACING) return;
- snprintf (key, 100, "%p", action);
-
- snprintf (aux, 100, "%d", src);
- xbt_dict_set (gtnets_src, key, xbt_strdup(aux), xbt_free);
- snprintf (aux, 100, "%d", dst);
- xbt_dict_set (gtnets_dst, key, xbt_strdup(aux), xbt_free);
+ char key[100], aux[100];
+ if (!IS_TRACING)
+ return;
+ snprintf(key, 100, "%p", action);
+
+ snprintf(aux, 100, "%d", src);
+ xbt_dict_set(gtnets_src, key, xbt_strdup(aux), xbt_free);
+ snprintf(aux, 100, "%d", dst);
+ xbt_dict_set(gtnets_dst, key, xbt_strdup(aux), xbt_free);
}
-int TRACE_surf_gtnets_get_src (void *action)
+int TRACE_surf_gtnets_get_src(void *action)
{
- char key[100];
- char *aux = NULL;
- if (!IS_TRACING) return -1;
- snprintf (key, 100, "%p", action);
+ char key[100];
+ char *aux = NULL;
+ if (!IS_TRACING)
+ return -1;
+ snprintf(key, 100, "%p", action);
- aux = xbt_dict_get_or_null (gtnets_src, key);
- if (aux){
- return atoi(aux);
- }else{
+ aux = xbt_dict_get_or_null(gtnets_src, key);
+ if (aux) {
+ return atoi(aux);
+ } else {
return -1;
}
}
-int TRACE_surf_gtnets_get_dst (void *action)
+int TRACE_surf_gtnets_get_dst(void *action)
{
- char key[100];
- char *aux = NULL;
- if (!IS_TRACING) return -1;
- snprintf (key, 100, "%p", action);
+ char key[100];
+ char *aux = NULL;
+ if (!IS_TRACING)
+ return -1;
+ snprintf(key, 100, "%p", action);
- aux = xbt_dict_get_or_null (gtnets_dst, key);
- if (aux){
- return atoi(aux);
- }else{
+ aux = xbt_dict_get_or_null(gtnets_dst, key);
+ if (aux) {
+ return atoi(aux);
+ } else {
return -1;
}
}
-void TRACE_surf_gtnets_destroy (void *action)
+void TRACE_surf_gtnets_destroy(void *action)
{
char key[100];
- if (!IS_TRACING) return;
- snprintf (key, 100, "%p", action);
- xbt_dict_remove (gtnets_src, key);
- xbt_dict_remove (gtnets_dst, key);
+ if (!IS_TRACING)
+ return;
+ snprintf(key, 100, "%p", action);
+ xbt_dict_remove(gtnets_src, key);
+ xbt_dict_remove(gtnets_dst, key);
}
-void TRACE_surf_host_vivaldi_parse (char *host, double x, double y, double h)
+void TRACE_surf_host_vivaldi_parse(char *host, double x, double y,
+ double h)
{
- char valuestr[100];
- if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
-
- snprintf (valuestr, 100, "%g", x);
- pajeSetVariable (0, "vivaldi_x", host, valuestr);
- snprintf (valuestr, 100, "%g", y);
- pajeSetVariable (0, "vivaldi_y", host, valuestr);
- snprintf (valuestr, 100, "%g", h);
- pajeSetVariable (0, "vivaldi_h", host, valuestr);
+ char valuestr[100];
+ if (!IS_TRACING || !IS_TRACING_PLATFORM)
+ return;
+
+ snprintf(valuestr, 100, "%g", x);
+ pajeSetVariable(0, "vivaldi_x", host, valuestr);
+ snprintf(valuestr, 100, "%g", y);
+ pajeSetVariable(0, "vivaldi_y", host, valuestr);
+ snprintf(valuestr, 100, "%g", h);
+ pajeSetVariable(0, "vivaldi_h", host, valuestr);
}
extern routing_global_t global_routing;
-void TRACE_surf_save_onelink (void)
+void TRACE_surf_save_onelink(void)
{
- if (!IS_TRACING) return;
+ if (!IS_TRACING)
+ return;
//get the onelinks from the parsed platform
xbt_dynar_t onelink_routes = global_routing->get_onelink_routes();
- if (!onelink_routes) return;
+ if (!onelink_routes)
+ return;
//save them in trace file
onelink_t onelink;
char *dst = onelink->dst;
void *link = onelink->link_ptr;
- if (TRACE_surf_link_is_traced (link)){
+ if (TRACE_surf_link_is_traced(link)) {
char resource[100];
- snprintf (resource, 100, "%p", link);
+ snprintf(resource, 100, "%p", link);
- pajeNewEvent (0.1, "source", resource, src);
- pajeNewEvent (0.1, "destination", resource, dst);
+ pajeNewEvent(0.1, "source", resource, src);
+ pajeNewEvent(0.1, "destination", resource, dst);
}
}
}
-int TRACE_surf_link_is_traced (void *link)
+int TRACE_surf_link_is_traced(void *link)
{
char alias[100];
- snprintf (alias, 100, "%p", link);
- if (xbt_dict_get_or_null (created_links, alias)){
+ snprintf(alias, 100, "%p", link);
+ if (xbt_dict_get_or_null(created_links, alias)) {
return 1;
- }else{
+ } else {
return 0;
}
}
-void TRACE_surf_action (surf_action_t surf_action, const char *category)
+void TRACE_surf_action(surf_action_t surf_action, const char *category)
{
- if (!IS_TRACING) return;
- if (!IS_TRACING_PLATFORM) return;
- if (!category){
- xbt_die ("invalid tracing category");
+ if (!IS_TRACING)
+ return;
+ if (!IS_TRACING_PLATFORM)
+ return;
+ if (!category) {
+ xbt_die("invalid tracing category");
}
- surf_action->category = xbt_new (char, strlen (category)+1);
- strncpy (surf_action->category, category, strlen(category)+1);
+ surf_action->category = xbt_new(char, strlen(category) + 1);
+ strncpy(surf_action->category, category, strlen(category) + 1);
}
#endif
extern routing_global_t global_routing;
-void TRACE_user_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what)
+void TRACE_user_link_variable(double time, const char *src,
+ const char *dst, const char *variable,
+ double value, const char *what)
{
- if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
+ if (!IS_TRACING || !IS_TRACING_PLATFORM)
+ return;
char valuestr[100];
- snprintf (valuestr, 100, "%g", value);
+ snprintf(valuestr, 100, "%g", value);
- if (strcmp (what, "declare") == 0){
- pajeDefineVariableType (variable, "LINK", variable);
+ if (strcmp(what, "declare") == 0) {
+ pajeDefineVariableType(variable, "LINK", variable);
return;
}
- if (!global_routing) return;
+ if (!global_routing)
+ return;
xbt_dynar_t route = global_routing->get_route(src, dst);
unsigned int i;
void *link_ptr;
xbt_dynar_foreach(route, i, link_ptr) {
char resource[100];
- snprintf (resource, 100, "%p", link_ptr);
+ snprintf(resource, 100, "%p", link_ptr);
- if (strcmp (what, "set") == 0){
- pajeSetVariable (time, variable, resource, valuestr);
- }else if (strcmp (what, "add") == 0){
- pajeAddVariable (time, variable, resource, valuestr);
- }else if (strcmp (what, "sub") == 0){
- pajeSubVariable (time, variable, resource, valuestr);
+ if (strcmp(what, "set") == 0) {
+ pajeSetVariable(time, variable, resource, valuestr);
+ } else if (strcmp(what, "add") == 0) {
+ pajeAddVariable(time, variable, resource, valuestr);
+ } else if (strcmp(what, "sub") == 0) {
+ pajeSubVariable(time, variable, resource, valuestr);
}
}
}
-void TRACE_user_host_variable (double time, const char *variable, double value, const char *what)
+void TRACE_user_host_variable(double time, const char *variable,
+ double value, const char *what)
{
char valuestr[100];
- if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
+ if (!IS_TRACING || !IS_TRACING_PLATFORM)
+ return;
- snprintf (valuestr, 100, "%g", value);
+ snprintf(valuestr, 100, "%g", value);
- if (strcmp (what, "declare") == 0){
- pajeDefineVariableType (variable, "HOST", variable);
- }else if (strcmp (what, "set") == 0){
- pajeSetVariable (time, variable, MSG_host_self()->name, valuestr);
- }else if (strcmp (what, "add") == 0){
- pajeAddVariable (time, variable, MSG_host_self()->name, valuestr);
- }else if (strcmp (what, "sub") == 0){
- pajeSubVariable (time, variable, MSG_host_self()->name, valuestr);
+ if (strcmp(what, "declare") == 0) {
+ pajeDefineVariableType(variable, "HOST", variable);
+ } else if (strcmp(what, "set") == 0) {
+ pajeSetVariable(time, variable, MSG_host_self()->name, valuestr);
+ } else if (strcmp(what, "add") == 0) {
+ pajeAddVariable(time, variable, MSG_host_self()->name, valuestr);
+ } else if (strcmp(what, "sub") == 0) {
+ pajeSubVariable(time, variable, MSG_host_self()->name, valuestr);
}
}
-#endif /* HAVE_TRACING */
+#endif /* HAVE_TRACING */
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_processCreate(JNIEnv * env, jclass cls,
- jobject jprocess_arg, jobject jhost)
+ jobject jprocess_arg,
+ jobject jhost)
{
jobject jprocess; /* the global reference to the java process instance */
jstring jname; /* the name of the java process instance */
msg_mailbox_t mailbox;
DEBUG4
- ("Java_simgrid_msg_MsgNative_processCreate(env=%p,cls=%p,jproc=%p,jhost=%p)",
- env, cls, jprocess_arg, jhost);
+ ("Java_simgrid_msg_MsgNative_processCreate(env=%p,cls=%p,jproc=%p,jhost=%p)",
+ env, cls, jprocess_arg, jhost);
/* get the name of the java process */
jname = jprocess_get_name(jprocess_arg, env);
/* create a new context */
DEBUG8
- ("fill in process %s/%s (pid=%d) %p (sd=%p, host=%p, host->sd=%p); env=%p",
- process->name, process->simdata->m_host->name, process->simdata->PID,
- process, process->simdata, process->simdata->m_host,
- process->simdata->m_host->simdata, env);
-
- process->simdata->s_process =
- SIMIX_process_create(process->name, (xbt_main_func_t)jprocess,
- /*data */ (void *) process,
- process->simdata->m_host->simdata->smx_host->name,
- 0, NULL, NULL);
-
+ ("fill in process %s/%s (pid=%d) %p (sd=%p, host=%p, host->sd=%p); env=%p",
+ process->name, process->simdata->m_host->name,
+ process->simdata->PID, process, process->simdata,
+ process->simdata->m_host, process->simdata->m_host->simdata, env);
+
+ process->simdata->s_process =
+ SIMIX_process_create(process->name, (xbt_main_func_t) jprocess,
+ /*data */ (void *) process,
+ process->simdata->m_host->simdata->
+ smx_host->name, 0, NULL, NULL);
+
DEBUG1("context created (s_process=%p)", process->simdata->s_process);
if (SIMIX_process_self()) { /* someone created me */
- process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
+ process->simdata->PPID =
+ MSG_process_get_PID(SIMIX_process_self()->data);
} else {
process->simdata->PPID = -1;
}
/* add the process to the list of the processes of the simulation */
xbt_fifo_unshift(msg_global->process_list, process);
- sprintf(alias, "%s:%s", (process->simdata->m_host->simdata->smx_host)->name,
+ sprintf(alias, "%s:%s",
+ (process->simdata->m_host->simdata->smx_host)->name,
process->name);
mailbox = MSG_mailbox_new(alias);
-
+
}
JNIEXPORT void JNICALL
/* try to suspend the process */
MSG_error_t rv = MSG_process_suspend(process);
-
- jxbt_check_res("MSG_process_suspend()",rv,MSG_OK,
- bprintf("unexpected error , please report this bug"));
-
+
+ jxbt_check_res("MSG_process_suspend()", rv, MSG_OK,
+ bprintf("unexpected error , please report this bug"));
+
}
JNIEXPORT void JNICALL
m_process_t process = jprocess_to_native_process(jprocess, env);
if (!process) {
- jxbt_throw_notbound(env,"process", jprocess);
+ jxbt_throw_notbound(env, "process", jprocess);
return;
}
/* try to resume the process */
- MSG_error_t rv = MSG_process_resume(process);
-
- jxbt_check_res("MSG_process_resume()",rv,MSG_OK,
- bprintf("unexpected error , please report this bug"));
+ MSG_error_t rv = MSG_process_resume(process);
+
+ jxbt_check_res("MSG_process_resume()", rv, MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
JNIEXPORT jboolean JNICALL
}
JNIEXPORT jobject JNICALL
-Java_simgrid_msg_MsgNative_processFromPID(JNIEnv * env, jclass cls, jint PID)
+Java_simgrid_msg_MsgNative_processFromPID(JNIEnv * env, jclass cls,
+ jint PID)
{
m_process_t process = MSG_process_from_PID(PID);
/* try to change the host of the process */
MSG_error_t rv = MSG_process_change_host(host);
- jxbt_check_res("MSG_process_change_host()",rv,MSG_OK,
- bprintf("unexpected error , please report this bug"));
+ jxbt_check_res("MSG_process_change_host()", rv, MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
Java_simgrid_msg_MsgNative_processWaitFor(JNIEnv * env, jclass cls,
jdouble seconds)
{
- MSG_error_t rv= MSG_process_sleep((double) seconds);
-
- jxbt_check_res("MSG_process_sleep()",rv, MSG_HOST_FAILURE,
- bprintf("while process was waiting for %f seconds",(double)seconds));
-
+ MSG_error_t rv = MSG_process_sleep((double) seconds);
+
+ jxbt_check_res("MSG_process_sleep()", rv, MSG_HOST_FAILURE,
+ bprintf("while process was waiting for %f seconds",
+ (double) seconds));
+
}
return NULL;
}
- if (!MSG_host_get_data(host)) { /* native host not associated yet with java host */
+ if (!MSG_host_get_data(host)) { /* native host not associated yet with java host */
/* instanciate a new java host */
jhost = jhost_new_instance(env);
/* the native host data field is set with the global reference to the
* java host returned by this function
*/
- MSG_host_set_data(host,(void *) jhost);
+ MSG_host_set_data(host, (void *) jhost);
}
/* return the global reference to the java host instance */
/* Bind & store it */
jhost_bind(jhost, host, env);
- MSG_host_set_data(host,(void *) jhost);
+ MSG_host_set_data(host, (void *) jhost);
} else {
jhost = (jobject) MSG_host_get_data(host);
}
***************************************************************************************/
JNIEXPORT void JNICALL
-Java_simgrid_msg_MsgNative_taskCreate(JNIEnv * env, jclass cls, jobject jtask,
- jstring jname, jdouble jcomputeDuration,
+Java_simgrid_msg_MsgNative_taskCreate(JNIEnv * env, jclass cls,
+ jobject jtask, jstring jname,
+ jdouble jcomputeDuration,
jdouble jmessageSize)
{
m_task_t task; /* the native task to create */
- const char *name=NULL; /* the name of the task */
+ const char *name = NULL; /* the name of the task */
if (jcomputeDuration < 0) {
jxbt_throw_illegal(env,
- bprintf("Task ComputeDuration (%f) cannot be negative",
- (double) jcomputeDuration));
+ bprintf
+ ("Task ComputeDuration (%f) cannot be negative",
+ (double) jcomputeDuration));
return;
}
/* create the task */
task =
- MSG_task_create(name, (double) jcomputeDuration, (double) jmessageSize,
- NULL);
+ MSG_task_create(name, (double) jcomputeDuration,
+ (double) jmessageSize, NULL);
if (jname)
(*env)->ReleaseStringUTFChars(env, jname, name);
/* bind & store the task */
jtask_bind(jtask, task, env);
- MSG_task_set_data(task,jtask);
+ MSG_task_set_data(task, jtask);
}
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_parallel_taskCreate(JNIEnv * env, jclass cls,
- jobject jtask, jstring jname,
+ jobject jtask,
+ jstring jname,
jobjectArray jhosts,
jdoubleArray
jcomputeDurations_arg,
- jdoubleArray jmessageSizes_arg)
+ jdoubleArray
+ jmessageSizes_arg)
{
m_task_t task; /* the native parallel task to create */
if (!jmessageSizes_arg) {
jxbt_throw_null(env,
- xbt_strdup("Parallel task message sizes cannot be null"));
+ xbt_strdup
+ ("Parallel task message sizes cannot be null"));
return;
}
messageSizes = xbt_new0(double, host_count * host_count);
jcomputeDurations =
- (*env)->GetDoubleArrayElements(env, jcomputeDurations_arg, 0);
- jmessageSizes = (*env)->GetDoubleArrayElements(env, jmessageSizes_arg, 0);
+ (*env)->GetDoubleArrayElements(env, jcomputeDurations_arg, 0);
+ jmessageSizes =
+ (*env)->GetDoubleArrayElements(env, jmessageSizes_arg, 0);
for (index = 0; index < host_count; index++) {
jhost = (*env)->GetObjectArrayElement(env, jhosts, index);
name = (*env)->GetStringUTFChars(env, jname, 0);
task =
- MSG_parallel_task_create(name, host_count, hosts, computeDurations,
- messageSizes, NULL);
+ MSG_parallel_task_create(name, host_count, hosts, computeDurations,
+ messageSizes, NULL);
(*env)->ReleaseStringUTFChars(env, jname, name);
/* associate the java task object and the native task */
jtask_bind(jtask, task, env);
- MSG_task_set_data(task,(void*) jtask);
+ MSG_task_set_data(task, (void *) jtask);
if (!MSG_task_get_data(task))
jxbt_throw_jni(env, "global ref allocation failed");
}
JNIEXPORT void JNICALL
-Java_simgrid_msg_MsgNative_taskCancel(JNIEnv * env, jclass cls, jobject jtask)
+Java_simgrid_msg_MsgNative_taskCancel(JNIEnv * env, jclass cls,
+ jobject jtask)
{
m_task_t ptask = jtask_to_native_task(jtask, env);
}
MSG_error_t rv = MSG_task_cancel(ptask);
-
- jxbt_check_res("MSG_task_cancel()",rv,MSG_OK,
- bprintf("unexpected error , please report this bug"));
+
+ jxbt_check_res("MSG_task_cancel()", rv, MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
JNIEXPORT jdouble JNICALL
}
JNIEXPORT jdouble JNICALL
-Java_simgrid_msg_MsgNative_taskGetRemainingDuration(JNIEnv * env, jclass cls,
+Java_simgrid_msg_MsgNative_taskGetRemainingDuration(JNIEnv * env,
+ jclass cls,
jobject jtask)
{
m_task_t ptask = jtask_to_native_task(jtask, env);
return;
}
jtask = (jobject) MSG_task_get_data(task);
-
+
MSG_error_t rv = MSG_task_destroy(task);
-
- jxbt_check_res("MSG_task_destroy()",rv,MSG_OK,
- bprintf("unexpected error , please report this bug"));
+
+ jxbt_check_res("MSG_task_destroy()", rv, MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
JNIEXPORT void JNICALL
}
MSG_error_t rv = MSG_task_execute(task);
-
- jxbt_check_res("MSG_task_execute()",rv,MSG_HOST_FAILURE|MSG_TASK_CANCELLED,
- bprintf("while executing task %s", MSG_task_get_name(task)));
+
+ jxbt_check_res("MSG_task_execute()", rv,
+ MSG_HOST_FAILURE | MSG_TASK_CANCELLED,
+ bprintf("while executing task %s",
+ MSG_task_get_name(task)));
}
/***************************************************************************************
JNIEXPORT void JNICALL
-Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs) {
+Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
+{
char **argv = NULL;
int index;
int argc = 0;
}
JNIEXPORT void JNICALL
- JNICALL Java_simgrid_msg_Msg_run(JNIEnv * env, jclass cls) {
+ JNICALL Java_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
+{
MSG_error_t rv;
- int index;//xbt_fifo_item_t item = NULL;
+ int index; //xbt_fifo_item_t item = NULL;
m_host_t *hosts;
jobject jhost;
/* Run everything */
- rv= MSG_main();
- jxbt_check_res("MSG_main()",rv,MSG_OK,
- bprintf("unexpected error : MSG_main() failed .. please report this bug "));
+ rv = MSG_main();
+ jxbt_check_res("MSG_main()", rv, MSG_OK,
+ bprintf
+ ("unexpected error : MSG_main() failed .. please report this bug "));
DEBUG0
- ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
+ ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
DEBUG0("Clean java world");
/* Cleanup java hosts */
hosts = MSG_get_host_table();
- for (index=0;index<MSG_get_host_number()-1;index++)
- {
- jhost = (jobject)hosts[index]->data;
- if(jhost)
- jhost_unref(env,jhost);
+ for (index = 0; index < MSG_get_host_number() - 1; index++) {
+ jhost = (jobject) hosts[index]->data;
+ if (jhost)
+ jhost_unref(env, jhost);
}
DEBUG0("Clean native world");
/* cleanup native stuff */
rv = MSG_OK != MSG_clean();
- jxbt_check_res("MSG_clean()",rv,MSG_OK,
- bprintf("unexpected error : MSG_clean() failed .. please report this bug "));
+ jxbt_check_res("MSG_clean()", rv, MSG_OK,
+ bprintf
+ ("unexpected error : MSG_clean() failed .. please report this bug "));
}
jstring jplatformFile)
{
- const char *platformFile = (*env)->GetStringUTFChars(env, jplatformFile, 0);
+ const char *platformFile =
+ (*env)->GetStringUTFChars(env, jplatformFile, 0);
MSG_create_environment(platformFile);
if (!jhost) {
jname = (*env)->NewStringUTF(env, MSG_host_get_name(host));
- jhost = Java_simgrid_msg_MsgNative_hostGetByName(env, cls_arg, jname);
+ jhost =
+ Java_simgrid_msg_MsgNative_hostGetByName(env, cls_arg, jname);
/* FIXME: leak of jname ? */
}
(*env)->ReleaseStringUTFChars(env, jname, name);
if (errmsg) {
- char *thrown = bprintf("xbt_select_context_factory() failed: %s", errmsg);
+ char *thrown =
+ bprintf("xbt_select_context_factory() failed: %s", errmsg);
free(errmsg);
jxbt_throw_jni(env, thrown);
}
}
/* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
- MSG_task_set_data(task,(void *) (*env)->NewGlobalRef(env, jtask));
+ MSG_task_set_data(task, (void *) (*env)->NewGlobalRef(env, jtask));
rv = MSG_task_send_with_timeout(task, alias, (double) jtimeout);
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- jxbt_check_res("MSG_task_send_with_timeout()",rv, MSG_HOST_FAILURE|MSG_TRANSFER_FAILURE|MSG_TIMEOUT,
- bprintf("while sending task %s to mailbox %s", MSG_task_get_name(task),alias));
+ jxbt_check_res("MSG_task_send_with_timeout()", rv,
+ MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
+ bprintf("while sending task %s to mailbox %s",
+ MSG_task_get_name(task), alias));
}
JNIEXPORT void JNICALL
alias = (*env)->GetStringUTFChars(env, jalias, 0);
/* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
- MSG_task_set_data(task,(void *) (*env)->NewGlobalRef(env, jtask));
+ MSG_task_set_data(task, (void *) (*env)->NewGlobalRef(env, jtask));
rv = MSG_task_send_bounded(task, alias, (double) jmaxRate);
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- jxbt_check_res("MSG_task_send_bounded()",rv, MSG_HOST_FAILURE|MSG_TRANSFER_FAILURE|MSG_TIMEOUT,
- bprintf("while sending task %s to mailbox %s with max rate %f", MSG_task_get_name(task),alias,(double)jmaxRate));
-
+ jxbt_check_res("MSG_task_send_bounded()", rv,
+ MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
+ bprintf
+ ("while sending task %s to mailbox %s with max rate %f",
+ MSG_task_get_name(task), alias, (double) jmaxRate));
+
}
JNIEXPORT jobject JNICALL
/* Convert the global ref into a local ref so that the JVM can free the stuff */
jtask_local = (*env)->NewLocalRef(env, jtask_global);
(*env)->DeleteGlobalRef(env, jtask_global);
- MSG_task_set_data(task,NULL);
+ MSG_task_set_data(task, NULL);
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- jxbt_check_res("MSG_task_receive_ext()",rv, MSG_HOST_FAILURE|MSG_TRANSFER_FAILURE|MSG_TIMEOUT,
- bprintf("while receiving from mailbox %s",alias));
+ jxbt_check_res("MSG_task_receive_ext()", rv,
+ MSG_HOST_FAILURE | MSG_TRANSFER_FAILURE | MSG_TIMEOUT,
+ bprintf("while receiving from mailbox %s", alias));
return (jobject) jtask_local;
}
JNIEXPORT jint JNICALL
Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls,
- jstring jalias, jobject jhost)
+ jstring jalias,
+ jobject jhost)
{
int rv;
const char *alias;
{
const char *deploymentFile =
- (*env)->GetStringUTFChars(env, jdeploymentFile, 0);
+ (*env)->GetStringUTFChars(env, jdeploymentFile, 0);
surf_parse_reset_parser();
japplication_handler_on_start_document();
if (surf_parse())
- jxbt_throw_jni(env,"surf_parse() failed");
+ jxbt_throw_jni(env, "surf_parse() failed");
surf_parse_close();
* Signature (Lsimgrid/msg/Process;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_processResume
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)Z
*/
JNIEXPORT jboolean JNICALL Java_simgrid_msg_MsgNative_processIsSuspended
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_processKill
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)Lsimgrid/msg/Host;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_processGetHost
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (I)Lsimgrid/msg/Process;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_processFromPID
- (JNIEnv *, jclass, jint);
+ (JNIEnv *, jclass, jint);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_processGetPID
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_processGetPPID
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature ()Lsimgrid/msg/Process;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_processSelf
- (JNIEnv *, jclass);
+ (JNIEnv *, jclass);
/*
* Class simgrid_msg_Msg
* Signature ()I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_processSelfPID
- (JNIEnv *, jclass);
+ (JNIEnv *, jclass);
/*
* Class simgrid_msg_Msg
* Signature ()I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_processSelfPPID
- (JNIEnv *, jclass);
+ (JNIEnv *, jclass);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;Lsimgrid/msg/Host;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_processChangeHost
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (D)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_processWaitFor
- (JNIEnv *, jclass, jdouble);
+ (JNIEnv *, jclass, jdouble);
/*
* Class simgrid_msg_Msg
* Signature (Ljava/lang/String;)Lsimgrid/msg/Host;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_hostGetByName
- (JNIEnv *, jclass, jstring);
+ (JNIEnv *, jclass, jstring);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Host;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_simgrid_msg_MsgNative_hostGetName
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature ()I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_hostGetNumber
- (JNIEnv *, jclass);
+ (JNIEnv *, jclass);
/*
* Class simgrid_msg_Msg
* Signature ()Lsimgrid/msg/Host;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_hostSelf
- (JNIEnv *, jclass);
+ (JNIEnv *, jclass);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Host;)D
*/
JNIEXPORT jdouble JNICALL Java_simgrid_msg_MsgNative_hostGetSpeed
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
JNIEXPORT jint JNICALL
Java_simgrid_msg_MsgNative_hostGetLoad(JNIEnv * env, jclass cls,
* Signature (Lsimgrid/msg/Host;)Z
*/
JNIEXPORT jboolean JNICALL Java_simgrid_msg_MsgNative_hostIsAvail
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;Ljava/lang/String;DD)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_taskCreate
- (JNIEnv *, jclass, jobject, jstring, jdouble, jdouble);
+ (JNIEnv *, jclass, jobject, jstring, jdouble, jdouble);
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_parallel_taskCreate(JNIEnv *, jclass, jobject,
* Signature (Lsimgrid/msg/Task;)Lsimgrid/msg/Process;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_taskGetSender
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)Lsimgrid/msg/Host;
*/
JNIEXPORT jobject JNICALL Java_simgrid_msg_MsgNative_taskGetSource
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_simgrid_msg_MsgNative_taskGetName
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_taskCancel
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)D
*/
JNIEXPORT jdouble JNICALL Java_simgrid_msg_MsgNative_taskGetComputeDuration
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Method taskGetRemainingDuration
* Signature (Lsimgrid/msg/Task;)D
*/
-JNIEXPORT jdouble JNICALL Java_simgrid_msg_MsgNative_taskGetRemainingDuration
- (JNIEnv *, jclass, jobject);
+JNIEXPORT jdouble JNICALL
+Java_simgrid_msg_MsgNative_taskGetRemainingDuration(JNIEnv *, jclass,
+ jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;D)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_taskSetPriority
- (JNIEnv *, jclass, jobject, jdouble);
+ (JNIEnv *, jclass, jobject, jdouble);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_taskDestroy
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Task;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_taskExecute
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
JNIEXPORT jobject JNICALL
- Java_simgrid_msg_MsgNative_taskReceive
- (JNIEnv *, jclass, jstring, jdouble, jobject);
+ Java_simgrid_msg_MsgNative_taskReceive
+ (JNIEnv *, jclass, jstring, jdouble, jobject);
JNIEXPORT void JNICALL
- Java_simgrid_msg_MsgNative_taskSend
- (JNIEnv *, jclass, jstring, jobject, jdouble);
+ Java_simgrid_msg_MsgNative_taskSend
+ (JNIEnv *, jclass, jstring, jobject, jdouble);
/*
* Class simgrid_msg_Msg
JNIEXPORT jdouble JNICALL Java_simgrid_msg_Msg_getClock(JNIEnv *, jclass);
JNIEXPORT void JNICALL
- JNICALL Java_simgrid_msg_Msg_run(JNIEnv * env, jclass cls);
+ JNICALL Java_simgrid_msg_Msg_run(JNIEnv * env, jclass cls);
JNIEXPORT void JNICALL
Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs);
* Signature (I)I
*/
JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_processKillAll
- (JNIEnv *, jclass, jint);
+ (JNIEnv *, jclass, jint);
/*
* Class simgrid_msg_Msg
* Signature (Lsimgrid/msg/Process;)V
*/
JNIEXPORT void JNICALL Java_simgrid_msg_MsgNative_processExit
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject);
-JNIEXPORT void JNICALL Java_simgrid_msg_Msg_info(JNIEnv *, jclass, jstring);
+JNIEXPORT void JNICALL Java_simgrid_msg_Msg_info(JNIEnv *, jclass,
+ jstring);
JNIEXPORT jobjectArray JNICALL
Java_simgrid_msg_MsgNative_allHosts(JNIEnv *, jclass);
Java_simgrid_msg_MsgNative_selectContextFactory(JNIEnv *, jclass, jstring);
JNIEXPORT void JNICALL
-Java_simgrid_msg_MsgNative_taskSendBounded(JNIEnv *, jclass, jstring, jobject,
- jdouble);
+Java_simgrid_msg_MsgNative_taskSendBounded(JNIEnv *, jclass, jstring,
+ jobject, jdouble);
JNIEXPORT jboolean JNICALL
Java_simgrid_msg_MsgNative_taskListen(JNIEnv *, jclass, jstring);
Java_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls,
jstring jdeploymentFile);
-#endif /* !MSG4JAVA_H */
+#endif /* !MSG4JAVA_H */
/* Upcalls to the Java functions used as callback to the FleXML parser. */
-
+
/* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
* All rights reserved. */
#include "surf/surfxml_parse.h"
#include "jxbt_utilities.h"
-void japplication_handler_on_start_document(void) {
+void japplication_handler_on_start_document(void)
+{
jclass cls;
- JNIEnv * env = get_current_thread_env();
+ JNIEnv *env = get_current_thread_env();
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onStartDocument", "()V");
+ "onStartDocument", "()V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
(*env)->CallStaticVoidMethod(env, cls, id);
}
-void japplication_handler_on_end_document(void) {
+void japplication_handler_on_end_document(void)
+{
jclass cls;
- JNIEnv * env = get_current_thread_env();
+ JNIEnv *env = get_current_thread_env();
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onEndDocument", "()V");
+ "onEndDocument", "()V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
(*env)->CallStaticVoidMethod(env, cls, id);
}
-void japplication_handler_on_begin_process(void) {
+void japplication_handler_on_begin_process(void)
+{
jstring jhostName;
jstring jfunction;
jclass cls;
- JNIEnv * env = get_current_thread_env();
+ JNIEnv *env = get_current_thread_env();
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onBeginProcess",
- "(Ljava/lang/String;Ljava/lang/String;)V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ "onBeginProcess",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
jhostName = (jstring) (*env)->NewStringUTF(env, A_surfxml_process_host);
jfunction =
(*env)->CallStaticVoidMethod(env, cls, id, jhostName, jfunction);
}
-void japplication_handler_on_process_arg(void) {
+void japplication_handler_on_process_arg(void)
+{
jstring jarg;
jclass cls;
- JNIEnv * env = get_current_thread_env();
+ JNIEnv *env = get_current_thread_env();
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onProcessArg", "(Ljava/lang/String;)V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ "onProcessArg", "(Ljava/lang/String;)V");
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
jarg = (jstring) (*env)->NewStringUTF(env, A_surfxml_argument_value);
(*env)->CallStaticVoidMethod(env, cls, id, jarg);
}
-void japplication_handler_on_property(void) {
+void japplication_handler_on_property(void)
+{
jstring jid;
jstring jvalue;
jclass cls;
- JNIEnv * env = get_current_thread_env();
+ JNIEnv *env = get_current_thread_env();
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onProperty",
- "(Ljava/lang/String;Ljava/lang/String;)V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ "onProperty",
+ "(Ljava/lang/String;Ljava/lang/String;)V");
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
jid = (jstring) (*env)->NewStringUTF(env, A_surfxml_prop_id);
(*env)->CallStaticVoidMethod(env, cls, id, jid, jvalue);
}
-void japplication_handler_on_end_process(void) {
- JNIEnv * env = get_current_thread_env();
+void japplication_handler_on_end_process(void)
+{
+ JNIEnv *env = get_current_thread_env();
jclass cls;
jmethodID id =
jxbt_get_static_smethod(env, "simgrid/msg/ApplicationHandler",
- "onEndProcess", "()V");
- if (!id || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
+ "onEndProcess", "()V");
+ if (!id
+ || !(cls = jxbt_get_class(env, "simgrid/msg/ApplicationHandler")))
return;
(*env)->CallStaticVoidMethod(env, cls, id);
}
/* Upcalls to the Java functions used as callback to the FleXML parser. */
-
+
/* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
* All rights reserved. */
#ifndef MSG_JAPPLICATION_HANDLER_H
#define MSG_JAPPLICATION_HANDLER_H
-
+
#include <jni.h>
#include "msg/msg.h"
void japplication_handler_on_start_document(void);
void japplication_handler_on_property(void);
void japplication_handler_on_end_process(void);
-#endif /* !MSG_JAPPLICATION_HANDLER_H */
+#endif /* !MSG_JAPPLICATION_HANDLER_H */
*/
jboolean jhost_is_valid(jobject jhost, JNIEnv * env);
-#endif /*!MSG_JHOST_H */
+#endif /*!MSG_JHOST_H */
jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "isAlive", "()Z");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "isAlive", "()Z");
if (!id)
return 0;
void jprocess_join(jobject jprocess, JNIEnv * env)
{
- jmethodID id = jxbt_get_smethod(env, "simgrid/msg/Process", "join", "()V");
+ jmethodID id =
+ jxbt_get_smethod(env, "simgrid/msg/Process", "join", "()V");
if (!id)
return;
void jprocess_exit(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "interrupt", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "interrupt", "()V");
if (!id)
return;
void jprocess_yield(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "switchProcess", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "switchProcess", "()V");
if (!id)
return;
void jprocess_lock_mutex(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "lockMutex", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "lockMutex", "()V");
if (!id)
return;
void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "unlockMutex", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "unlockMutex", "()V");
if (!id)
return;
void jprocess_signal_cond(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "signalCond", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "signalCond", "()V");
if (!id)
return;
void jprocess_wait_cond(jobject jprocess, JNIEnv * env)
{
jmethodID id =
- jxbt_get_smethod(env, "simgrid/msg/Process", "waitCond", "()V");
+ jxbt_get_smethod(env, "simgrid/msg/Process", "waitCond", "()V");
if (!id)
return;
void jprocess_start(jobject jprocess, JNIEnv * env)
{
- jmethodID id = jxbt_get_smethod(env, "simgrid/msg/Process", "start", "()V");
+ jmethodID id =
+ jxbt_get_smethod(env, "simgrid/msg/Process", "start", "()V");
if (!id)
return;
jstring jprocess_get_name(jobject jprocess, JNIEnv * env)
{
- jfieldID id =
- jxbt_get_sfield(env, "simgrid/msg/Process", "name", "Ljava/lang/String;");
+ jfieldID id = jxbt_get_sfield(env, "simgrid/msg/Process", "name",
+ "Ljava/lang/String;");
jobject jname;
if (!id)
void jprocess_unschedule(smx_context_t context);
-#endif /* !MSG_JPROCESS_H */
+#endif /* !MSG_JPROCESS_H */
*/
jboolean jtask_is_valid(jobject jtask, JNIEnv * env);
-#endif /* !MSG_JTASK_H */
+#endif /* !MSG_JTASK_H */
if (!id) {
jmethodID tostr_id =
- (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
+ (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
jstring jclassname =
- (jstring) (*env)->CallObjectMethod(env, cls, tostr_id, NULL);
+ (jstring) (*env)->CallObjectMethod(env, cls, tostr_id, NULL);
const char *classname = (*env)->GetStringUTFChars(env, jclassname, 0);
- char *m =
- bprintf("Cannot find method %s(%s) in %s", name, signature, classname);
+ char *m = bprintf("Cannot find method %s(%s) in %s", name, signature,
+ classname);
(*env)->ReleaseStringUTFChars(env, jclassname, classname);
if (!id) {
jmethodID tostr_id =
- (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
+ (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
jstring jclassname =
- (jstring) (*env)->CallObjectMethod(env, cls, tostr_id, NULL);
+ (jstring) (*env)->CallObjectMethod(env, cls, tostr_id, NULL);
const char *classname = (*env)->GetStringUTFChars(env, jclassname, 0);
char *m =
- bprintf("Cannot find static method %s(%s) in %s", name, signature,
- classname);
+ bprintf("Cannot find static method %s(%s) in %s", name, signature,
+ classname);
(*env)->ReleaseStringUTFChars(env, jclassname, classname);
if (!id) {
char *m =
- bprintf("Cannot find static method %s(%s) in %s", name, signature,
- classname);
+ bprintf("Cannot find static method %s(%s) in %s", name, signature,
+ classname);
jxbt_throw_jni(env, m);
id = (*env)->GetMethodID(env, cls, name, signature);
if (!id) {
- char *m =
- bprintf("Cannot find method %s(%s) in %s", name, signature, classname);
+ char *m = bprintf("Cannot find method %s(%s) in %s", name, signature,
+ classname);
jxbt_throw_jni(env, m);
if (!id) {
jmethodID getname_id =
- (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
+ (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String;");
jstring jclassname =
- (jstring) (*env)->CallObjectMethod(env, cls, getname_id, NULL);
+ (jstring) (*env)->CallObjectMethod(env, cls, getname_id, NULL);
const char *classname = (*env)->GetStringUTFChars(env, jclassname, 0);
- char *m =
- bprintf("Cannot find field %s %s in %s", signature, name, classname);
+ char *m = bprintf("Cannot find field %s %s in %s", signature, name,
+ classname);
(*env)->ReleaseStringUTFChars(env, jclassname, classname);
id = (*env)->GetFieldID(env, cls, name, signature);
if (!id) {
- char *m =
- bprintf("Cannot find field %s %s in %s", signature, name, classname);
+ char *m = bprintf("Cannot find field %s %s in %s", signature, name,
+ classname);
jxbt_throw_jni(env, m);
{
jclass cls = (*env)->FindClass(env, name);
- xbt_assert2(cls, "%s (Plus severe error: class %s not found)\n", msg, name);
+ xbt_assert2(cls, "%s (Plus severe error: class %s not found)\n", msg,
+ name);
(*env)->ThrowNew(env, cls, msg);
}
// tranfert failure
-void jxbt_throw_transfer_failure(JNIEnv *env,char *details) {
-
- jxbt_throw_by_name(env,
- "simgrid/msg/TransferFailureException",
- details);
-
+void jxbt_throw_transfer_failure(JNIEnv * env, char *details)
+{
+
+ jxbt_throw_by_name(env, "simgrid/msg/TransferFailureException", details);
+
}
// host failure Exception
-void jxbt_throw_host_failure(JNIEnv *env,char *details) {
-
- jxbt_throw_by_name(env,
- "simgrid/msg/HostFailureException",
- bprintf("Host Failure %s",details));
-
+void jxbt_throw_host_failure(JNIEnv * env, char *details)
+{
+
+ jxbt_throw_by_name(env,
+ "simgrid/msg/HostFailureException",
+ bprintf("Host Failure %s", details));
+
}
// time out failure Exception
-void jxbt_throw_time_out_failure(JNIEnv *env,char *details) {
-
- jxbt_throw_by_name(env,
- "simgrid/msg/TimeoutException",
- details);
-
+void jxbt_throw_time_out_failure(JNIEnv * env, char *details)
+{
+
+ jxbt_throw_by_name(env, "simgrid/msg/TimeoutException", details);
+
}
// task Cancelled exception
-void jxbt_throw_task_cancelled(JNIEnv *env,char *details)
+void jxbt_throw_task_cancelled(JNIEnv * env, char *details)
{
-
- jxbt_throw_by_name(env,
- "simgrid/msg/TaskCancelledException",
- details);
-
-}
\ No newline at end of file
+
+ jxbt_throw_by_name(env, "simgrid/msg/TaskCancelledException", details);
+
+}
/** Thrown when looking for an host from name does not lead to anything */
void jxbt_throw_process_not_found(JNIEnv * env, const char *invalid_name);
/** Thrown when a transfer failure accure while Sending task */
-void jxbt_throw_transfer_failure(JNIEnv * env,char *detail);
+void jxbt_throw_transfer_failure(JNIEnv * env, char *detail);
/** Thrown when a host failure accures while Sending task*/
-void jxbt_throw_host_failure(JNIEnv *env,char *details);
+void jxbt_throw_host_failure(JNIEnv * env, char *details);
/** Thrown when a time out accures While Sending task */
-void jxbt_throw_time_out_failure(JNIEnv *env,char *details);
+void jxbt_throw_time_out_failure(JNIEnv * env, char *details);
/**Thrown when a task is canceled */
-void jxbt_throw_task_cancelled(JNIEnv *env,char *details);
+void jxbt_throw_task_cancelled(JNIEnv * env, char *details);
-#endif /* ! JXBT_UTILITY_H */
+#endif /* ! JXBT_UTILITY_H */
#include "private.h"
void MC_take_snapshot(mc_snapshot_t snapshot)
-{
+{
/* Save the heap! */
- snapshot->heap_size = MC_save_heap(&(snapshot->heap));
+ snapshot->heap_size = MC_save_heap(&(snapshot->heap));
/* Save data and bss that */
snapshot->data_size = MC_save_dataseg(&(snapshot->data));
}
void MC_restore_snapshot(mc_snapshot_t snapshot)
-{
+{
MC_restore_heap(snapshot->heap, snapshot->heap_size);
- MC_restore_dataseg(snapshot->data, snapshot->data_size);
+ MC_restore_dataseg(snapshot->data, snapshot->data_size);
}
void MC_free_snapshot(mc_snapshot_t snapshot)
{
xbt_free(snapshot->heap);
xbt_free(snapshot->data);
- xbt_free(snapshot);
+ xbt_free(snapshot);
}
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dfs, mc,
- "Logging specific to MC DFS exploration");
+ "Logging specific to MC DFS exploration");
void MC_dfs_init()
{
- mc_transition_t trans = NULL;
+ mc_transition_t trans = NULL;
mc_state_t initial_state = NULL;
xbt_setset_cursor_t cursor = NULL;
-
+
MC_SET_RAW_MEM;
initial_state = MC_state_new();
/* Add the state data structure for the initial state */
xbt_fifo_unshift(mc_stack, initial_state);
MC_UNSET_RAW_MEM;
-
- DEBUG0("**************************************************");
+
+ DEBUG0("**************************************************");
DEBUG0("Initial state");
-
+
/* Schedule all the processes to detect the transitions from the initial state */
MC_schedule_enabled_processes();
MC_SET_RAW_MEM;
- xbt_setset_add(initial_state->enabled_transitions, initial_state->transitions);
- xbt_setset_foreach(initial_state->enabled_transitions, cursor, trans){
- if(trans->type == mc_wait
- && (trans->wait.comm->src_proc == NULL || trans->wait.comm->dst_proc == NULL)){
+ xbt_setset_add(initial_state->enabled_transitions,
+ initial_state->transitions);
+ xbt_setset_foreach(initial_state->enabled_transitions, cursor, trans) {
+ if (trans->type == mc_wait
+ && (trans->wait.comm->src_proc == NULL
+ || trans->wait.comm->dst_proc == NULL)) {
xbt_setset_set_remove(initial_state->enabled_transitions, trans);
}
}
/* Fill the interleave set of the initial state with all enabled transitions */
- xbt_setset_add(initial_state->interleave, initial_state->enabled_transitions);
+ xbt_setset_add(initial_state->interleave,
+ initial_state->enabled_transitions);
/* Update Statistics */
- mc_stats->state_size += xbt_setset_set_size(initial_state->enabled_transitions);
-
+ mc_stats->state_size +=
+ xbt_setset_set_size(initial_state->enabled_transitions);
+
MC_UNSET_RAW_MEM;
}
*/
void MC_dfs(void)
{
- mc_transition_t trans = NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
mc_state_t next_state = NULL;
xbt_setset_cursor_t cursor = NULL;
-
- while(xbt_fifo_size(mc_stack) > 0){
+
+ while (xbt_fifo_size(mc_stack) > 0) {
DEBUG0("**************************************************");
/* FIXME: Think about what happens if there are no transitions but there are
some actions on the models. (ex. all the processes do a sleep(0) in a round). */
/* Get current state */
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
-
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+
/* If there are transitions to execute and the maximun depth has not been reached
then perform one step of the exploration algorithm */
- if(xbt_setset_set_size(current_state->interleave) > 0 && xbt_fifo_size(mc_stack) < MAX_DEPTH){
+ if (xbt_setset_set_size(current_state->interleave) > 0
+ && xbt_fifo_size(mc_stack) < MAX_DEPTH) {
- DEBUG3("Exploration detph=%d (state=%p)(%d transitions)", xbt_fifo_size(mc_stack),
- current_state, xbt_setset_set_size(current_state->interleave));
+ DEBUG3("Exploration detph=%d (state=%p)(%d transitions)",
+ xbt_fifo_size(mc_stack), current_state,
+ xbt_setset_set_size(current_state->interleave));
/* Update statistics */
mc_stats->visited_states++;
mc_stats->executed_transitions++;
-
+
/* Choose a transition to execute from the interleave set of the current state,
and create the data structures for the new expanded state in the exploration
stack. */
/* Schedule every process that got enabled due to the executed transition */
MC_schedule_enabled_processes();
-
+
/* Calculate the enabled transitions set of the next state:
- -add the transition sets of the current state and the next state
- -remove the executed transition from that set
- -remove all the transitions that are disabled (mc_wait only)
- -use the resulting set as the enabled transitions of the next state */
+ -add the transition sets of the current state and the next state
+ -remove the executed transition from that set
+ -remove all the transitions that are disabled (mc_wait only)
+ -use the resulting set as the enabled transitions of the next state */
MC_SET_RAW_MEM;
xbt_setset_add(next_state->transitions, current_state->transitions);
xbt_setset_set_remove(next_state->transitions, trans);
- xbt_setset_add(next_state->enabled_transitions, next_state->transitions);
- xbt_setset_foreach(next_state->enabled_transitions, cursor, trans){
- if(trans->type == mc_wait
- && (trans->wait.comm->src_proc == NULL || trans->wait.comm->dst_proc == NULL)){
+ xbt_setset_add(next_state->enabled_transitions,
+ next_state->transitions);
+ xbt_setset_foreach(next_state->enabled_transitions, cursor, trans) {
+ if (trans->type == mc_wait
+ && (trans->wait.comm->src_proc == NULL
+ || trans->wait.comm->dst_proc == NULL)) {
xbt_setset_set_remove(next_state->enabled_transitions, trans);
}
}
-
+
/* Fill the interleave set of the new state with all enabled transitions */
- xbt_setset_add(next_state->interleave, next_state->enabled_transitions);
+ xbt_setset_add(next_state->interleave,
+ next_state->enabled_transitions);
MC_UNSET_RAW_MEM;
/* Update Statistics */
- mc_stats->state_size += xbt_setset_set_size(next_state->enabled_transitions);
+ mc_stats->state_size +=
+ xbt_setset_set_size(next_state->enabled_transitions);
/* Let's loop again */
-
- /* The interleave set is empty or the maximum depth is reached, let's back-track */
- }else{
+
+ /* The interleave set is empty or the maximum depth is reached, let's back-track */
+ } else {
DEBUG0("There are no more actions to run");
-
+
MC_SET_RAW_MEM;
xbt_fifo_shift(mc_stack);
- MC_state_delete(current_state);
+ MC_state_delete(current_state);
/* Go backwards in the stack until we find a state with transitions in the interleave set */
- while(xbt_fifo_size(mc_stack) > 0 && (current_state = (mc_state_t)xbt_fifo_shift(mc_stack))){
- if(xbt_setset_set_size(current_state->interleave) == 0){
+ while (xbt_fifo_size(mc_stack) > 0
+ && (current_state = (mc_state_t) xbt_fifo_shift(mc_stack))) {
+ if (xbt_setset_set_size(current_state->interleave) == 0) {
MC_state_delete(current_state);
- }else{
+ } else {
xbt_fifo_unshift(mc_stack, current_state);
DEBUG1("Back-tracking to depth %d", xbt_fifo_size(mc_stack));
MC_replay(mc_stack);
MC_UNSET_RAW_MEM;
/* We are done, show the statistics and return */
MC_print_statistics(mc_stats);
-}
\ No newline at end of file
+}
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dpor, mc,
- "Logging specific to MC DPOR exploration");
+ "Logging specific to MC DPOR exploration");
/**
* \brief Initialize the DPOR exploration algorithm
mc_state_t initial_state = NULL;
mc_transition_t trans, trans_tmp = NULL;
xbt_setset_cursor_t cursor = NULL;
-
+
/* Create the initial state and push it into the exploration stack */
MC_SET_RAW_MEM;
initial_state = MC_state_new();
MC_UNSET_RAW_MEM;
/* Schedule all the processes to detect the transitions of the initial state */
- DEBUG0("**************************************************");
+ DEBUG0("**************************************************");
DEBUG0("Initial state");
- while(xbt_swag_size(simix_global->process_to_run)){
+ while (xbt_swag_size(simix_global->process_to_run)) {
MC_schedule_enabled_processes();
MC_execute_surf_actions();
}
initial_state->transitions);
/* Fill the interleave set of the initial state with an enabled process */
- trans = xbt_setset_set_choose(initial_state->enabled_transitions);
- if(trans){
- DEBUG1("Choosing process %s for next interleave", trans->process->name);
- xbt_setset_foreach(initial_state->enabled_transitions, cursor, trans_tmp){
- if(trans_tmp->process == trans->process)
- xbt_setset_set_insert(initial_state->interleave, trans_tmp);
+ trans = xbt_setset_set_choose(initial_state->enabled_transitions);
+ if (trans) {
+ DEBUG1("Choosing process %s for next interleave",
+ trans->process->name);
+ xbt_setset_foreach(initial_state->enabled_transitions, cursor,
+ trans_tmp) {
+ if (trans_tmp->process == trans->process)
+ xbt_setset_set_insert(initial_state->interleave, trans_tmp);
}
}
MC_UNSET_RAW_MEM;
/* Update Statistics */
- mc_stats->state_size += xbt_setset_set_size(initial_state->enabled_transitions);
+ mc_stats->state_size +=
+ xbt_setset_set_size(initial_state->enabled_transitions);
}
*/
void MC_dpor(void)
{
- mc_transition_t trans, trans_tmp = NULL;
+ mc_transition_t trans, trans_tmp = NULL;
mc_state_t next_state = NULL;
xbt_setset_cursor_t cursor = NULL;
-
- while(xbt_fifo_size(mc_stack) > 0){
-
+
+ while (xbt_fifo_size(mc_stack) > 0) {
+
DEBUG0("**************************************************");
/* FIXME: Think about what happen if there are no transitions but there are
some actions on the models. (ex. all the processes do a sleep(0) in a round). */
/* Get current state */
- mc_current_state = (mc_state_t) xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
-
+ mc_current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+
/* If there are transitions to execute and the maximun depth has not been reached
then perform one step of the exploration algorithm */
- if(xbt_setset_set_size(mc_current_state->interleave) > 0 && xbt_fifo_size(mc_stack) < MAX_DEPTH){
+ if (xbt_setset_set_size(mc_current_state->interleave) > 0
+ && xbt_fifo_size(mc_stack) < MAX_DEPTH) {
+
+ DEBUG4("Exploration detph=%d (state=%p)(%d interleave) (%d enabled)",
+ xbt_fifo_size(mc_stack), mc_current_state,
+ xbt_setset_set_size(mc_current_state->interleave),
+ xbt_setset_set_size(mc_current_state->enabled_transitions));
- DEBUG4("Exploration detph=%d (state=%p)(%d interleave) (%d enabled)", xbt_fifo_size(mc_stack),
- mc_current_state, xbt_setset_set_size(mc_current_state->interleave),
- xbt_setset_set_size(mc_current_state->enabled_transitions));
-
/* Update statistics */
mc_stats->visited_states++;
mc_stats->executed_transitions++;
-
+
/* Choose a transition to execute from the interleave set of the current
state, and create the data structures for the new expanded state in the
exploration stack. */
/* Add the transition in the done set of the current state */
xbt_setset_set_insert(mc_current_state->done, trans);
-
+
next_state = MC_state_new();
xbt_fifo_unshift(mc_stack, next_state);
-
+
/* Set it as the executed transition of the current state */
mc_current_state->executed_transition = trans;
MC_UNSET_RAW_MEM;
DEBUG1("Executing transition %s", trans->name);
SIMIX_process_schedule(trans->process);
MC_execute_surf_actions();
-
- while(xbt_swag_size(simix_global->process_to_run)){
+
+ while (xbt_swag_size(simix_global->process_to_run)) {
MC_schedule_enabled_processes();
MC_execute_surf_actions();
}
-
+
/* Calculate the enabled transitions set of the next state */
MC_SET_RAW_MEM;
- xbt_setset_foreach(mc_current_state->transitions, cursor, trans_tmp){
- if(trans_tmp->process != trans->process){
+ xbt_setset_foreach(mc_current_state->transitions, cursor, trans_tmp) {
+ if (trans_tmp->process != trans->process) {
xbt_setset_set_insert(next_state->transitions, trans_tmp);
}
}
-
- MC_trans_compute_enabled(next_state->enabled_transitions, next_state->transitions);
-
- /* Choose one transition to interleave from the enabled transition set */
+
+ MC_trans_compute_enabled(next_state->enabled_transitions,
+ next_state->transitions);
+
+ /* Choose one transition to interleave from the enabled transition set */
trans = xbt_setset_set_choose(next_state->enabled_transitions);
- if(trans){
- DEBUG1("Choosing process %s for next interleave", trans->process->name);
- xbt_setset_foreach(next_state->enabled_transitions, cursor, trans_tmp){
- if(trans_tmp->process == trans->process)
- xbt_setset_set_insert(next_state->interleave, trans_tmp);
+ if (trans) {
+ DEBUG1("Choosing process %s for next interleave",
+ trans->process->name);
+ xbt_setset_foreach(next_state->enabled_transitions, cursor,
+ trans_tmp) {
+ if (trans_tmp->process == trans->process)
+ xbt_setset_set_insert(next_state->interleave, trans_tmp);
}
}
MC_UNSET_RAW_MEM;
/* Update Statistics */
- mc_stats->state_size += xbt_setset_set_size(next_state->enabled_transitions);
+ mc_stats->state_size +=
+ xbt_setset_set_size(next_state->enabled_transitions);
/* Let's loop again */
-
- /* The interleave set is empty or the maximum depth is reached, let's back-track */
- }else{
+
+ /* The interleave set is empty or the maximum depth is reached, let's back-track */
+ } else {
DEBUG0("There are no more transitions to interleave.");
-
+
/* Check for deadlocks */
- xbt_setset_substract(mc_current_state->transitions, mc_current_state->done);
- if(xbt_setset_set_size(mc_current_state->transitions) > 0){
+ xbt_setset_substract(mc_current_state->transitions,
+ mc_current_state->done);
+ if (xbt_setset_set_size(mc_current_state->transitions) > 0) {
INFO0("**************************");
INFO0("*** DEAD-LOCK DETECTED ***");
INFO0("**************************");
INFO0("Locked transitions:");
- xbt_setset_foreach(mc_current_state->transitions, cursor, trans){
- INFO3("%s [src=%p, dst=%p]", trans->name, trans->wait.comm->src_proc,
- trans->wait.comm->dst_proc);
+ xbt_setset_foreach(mc_current_state->transitions, cursor, trans) {
+ INFO3("%s [src=%p, dst=%p]", trans->name,
+ trans->wait.comm->src_proc, trans->wait.comm->dst_proc);
}
INFO0("Counter-example execution trace:");
MC_dump_stack(mc_stack);
-
+
MC_print_statistics(mc_stats);
xbt_abort();
}
-
+
mc_transition_t q = NULL;
xbt_fifo_item_t item = NULL;
mc_state_t state = NULL;
/*
- INFO0("*********************************");
- MC_show_stack(mc_stack);*/
-
+ INFO0("*********************************");
+ MC_show_stack(mc_stack); */
+
/* Trash the current state, no longer needed */
MC_SET_RAW_MEM;
xbt_fifo_shift(mc_stack);
MC_state_delete(mc_current_state);
-
+
/* Traverse the stack backwards until a state with a non empty interleave
set is found, deleting all the states that have it empty in the way.
For each deleted state, check if the transition that has generated it
(from it's predecesor state), depends on any other previous transition
executed before it. If it does then add it to the interleave set of the
state that executed that previous transition. */
- while((mc_current_state = xbt_fifo_shift(mc_stack)) != NULL){
+ while ((mc_current_state = xbt_fifo_shift(mc_stack)) != NULL) {
q = mc_current_state->executed_transition;
- xbt_fifo_foreach(mc_stack, item, state, mc_state_t){
- if(MC_transition_depend(q, state->executed_transition)){
- xbt_setset_foreach(state->enabled_transitions, cursor, trans){
- if((trans->process == q->process) && !xbt_setset_set_belongs(state->done, trans)){
- DEBUG3("%s depend with %s at %p", q->name,
+ xbt_fifo_foreach(mc_stack, item, state, mc_state_t) {
+ if (MC_transition_depend(q, state->executed_transition)) {
+ xbt_setset_foreach(state->enabled_transitions, cursor, trans) {
+ if ((trans->process == q->process)
+ && !xbt_setset_set_belongs(state->done, trans)) {
+ DEBUG3("%s depend with %s at %p", q->name,
state->executed_transition->name, state);
- xbt_setset_foreach(state->enabled_transitions, cursor, trans){
- if(trans->process == q->process)
- xbt_setset_set_insert(state->interleave, trans);
+ xbt_setset_foreach(state->enabled_transitions, cursor,
+ trans) {
+ if (trans->process == q->process)
+ xbt_setset_set_insert(state->interleave, trans);
}
- /* FIXME: hack to make it work*/
+ /* FIXME: hack to make it work */
trans = q;
break;
}
}
- if(trans)
+ if (trans)
break;
}
}
- if(xbt_setset_set_size(mc_current_state->interleave) > 0){
+ if (xbt_setset_set_size(mc_current_state->interleave) > 0) {
/* We found a back-tracking point, let's loop */
xbt_fifo_unshift(mc_stack, mc_current_state);
DEBUG1("Back-tracking to depth %d", xbt_fifo_size(mc_stack));
MC_replay(mc_stack);
MC_UNSET_RAW_MEM;
break;
- }else{
+ } else {
MC_state_delete(mc_current_state);
- }
+ }
}
}
}
DEBUG0("We are done");
/* We are done, show the statistics and return */
MC_print_statistics(mc_stats);
-}
\ No newline at end of file
+}
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc,
- "Logging specific to MC (global)");
+ "Logging specific to MC (global)");
/* MC global data structures */
mc_snapshot_t initial_snapshot = NULL;
* \brief Initialize the model-checker data structures
*/
void MC_init(int method)
-{
+{
/* Check if MC is already initialized */
- if(initial_snapshot)
+ if (initial_snapshot)
return;
-
+
/* Initialize the data structures that must be persistent across every
iteration of the model-checker (in RAW memory) */
MC_SET_RAW_MEM;
-
+
/* Initialize statistics */
mc_stats = xbt_new0(s_mc_stats_t, 1);
mc_stats->state_size = 1;
-
+
/* Create exploration stack */
mc_stack = xbt_fifo_new();
/* Create the container for the sets */
mc_setset = xbt_setset_new(20);
-
- switch(method){
- case 0:
- MC_dfs_init();
- break;
- case 1:
- MC_dpor_init();
- break;
- default:
- break;
+
+ switch (method) {
+ case 0:
+ MC_dfs_init();
+ break;
+ case 1:
+ MC_dpor_init();
+ break;
+ default:
+ break;
}
-
+
/* Save the initial state */
MC_SET_RAW_MEM;
- initial_snapshot = xbt_new(s_mc_snapshot_t,1);
+ initial_snapshot = xbt_new(s_mc_snapshot_t, 1);
MC_take_snapshot(initial_snapshot);
MC_UNSET_RAW_MEM;
}
MC_init(method);
- switch(method){
- case 0:
- MC_dfs();
- break;
- case 1:
- MC_dpor();
- break;
- default:
- break;
+ switch (method) {
+ case 0:
+ MC_dfs();
+ break;
+ case 1:
+ MC_dpor();
+ break;
+ default:
+ break;
}
MC_exit(method);
void MC_exit(int method)
{
mc_state_t state;
-
- switch(method){
- case 0:
- //MC_dfs_exit();
- break;
- case 1:
- //MC_dpor_exit();
- break;
- default:
- break;
+
+ switch (method) {
+ case 0:
+ //MC_dfs_exit();
+ break;
+ case 1:
+ //MC_dpor_exit();
+ break;
+ default:
+ break;
}
-
+
/* Destroy MC data structures (in RAW memory) */
MC_SET_RAW_MEM;
xbt_free(mc_stats);
- while( (state = (mc_state_t)xbt_fifo_pop(mc_stack)) != NULL )
+ while ((state = (mc_state_t) xbt_fifo_pop(mc_stack)) != NULL)
MC_state_delete(state);
-
+
xbt_fifo_free(mc_stack);
xbt_setset_destroy(mc_setset);
MC_UNSET_RAW_MEM;
MC_restore_snapshot(initial_snapshot);
mc_replay_mode = TRUE;
-
+
MC_UNSET_RAW_MEM;
/* Traverse the stack from the initial state and re-execute the transitions */
- for(item = xbt_fifo_get_last_item(stack);
- item != xbt_fifo_get_first_item(stack);
- item = xbt_fifo_get_prev_item(item)){
+ for (item = xbt_fifo_get_last_item(stack);
+ item != xbt_fifo_get_first_item(stack);
+ item = xbt_fifo_get_prev_item(item)) {
mc_current_state = (mc_state_t) xbt_fifo_get_item_content(item);
trans = mc_current_state->executed_transition;
mc_state_t state;
MC_show_stack(stack);
-
+
MC_SET_RAW_MEM;
- while( (state = (mc_state_t)xbt_fifo_pop(stack)) != NULL )
+ while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
MC_state_delete(state);
MC_UNSET_RAW_MEM;
}
mc_transition_t trans;
xbt_fifo_item_t item;
- for(item=xbt_fifo_get_last_item(stack);
- (item?(state=(mc_state_t)(xbt_fifo_get_item_content(item))):(NULL));
- item=xbt_fifo_get_prev_item(item)){
+ for (item = xbt_fifo_get_last_item(stack);
+ (item ? (state = (mc_state_t) (xbt_fifo_get_item_content(item)))
+ : (NULL)); item = xbt_fifo_get_prev_item(item)) {
trans = state->executed_transition;
- if(trans){
- INFO1("%s", trans->name);
+ if (trans) {
+ INFO1("%s", trans->name);
}
}
}
*/
mc_state_t MC_state_new(void)
{
- mc_state_t state = NULL;
-
+ mc_state_t state = NULL;
+
state = xbt_new0(s_mc_state_t, 1);
state->created_transitions = xbt_setset_new_set(mc_setset);
state->transitions = xbt_setset_new_set(mc_setset);
state->executed_transition = NULL;
mc_stats->expanded_states++;
-
+
return state;
}
+
/**
* \brief Deletes a state data structure
* \param trans The state to be deleted
void MC_state_delete(mc_state_t state)
{
xbt_setset_cursor_t cursor;
- mc_transition_t trans;
-
- xbt_setset_foreach(state->created_transitions, cursor, trans){
+ mc_transition_t trans;
+
+ xbt_setset_foreach(state->created_transitions, cursor, trans) {
xbt_setset_elm_remove(mc_setset, trans);
MC_transition_delete(trans);
}
smx_action_t smx_action = NULL;
/* Execute all the actions in every model */
- xbt_dynar_foreach(model_list, iter, model){
- while ((action = xbt_swag_extract(model->states.running_action_set))){
+ xbt_dynar_foreach(model_list, iter, model) {
+ while ((action = xbt_swag_extract(model->states.running_action_set))) {
/* FIXME: timeouts are not calculated correctly */
- if(NOW >= action->max_duration){
+ if (NOW >= action->max_duration) {
surf_action_state_set(action, SURF_ACTION_DONE);
smx_action = action->data;
- DEBUG5("Resource [%s] (%d): Executing RUNNING action \"%s\" (%p) MaxDuration %lf",
- model->name, xbt_swag_size(model->states.running_action_set),
- smx_action->name, smx_action, action->max_duration);
-
- if(smx_action)
+ DEBUG5
+ ("Resource [%s] (%d): Executing RUNNING action \"%s\" (%p) MaxDuration %lf",
+ model->name, xbt_swag_size(model->states.running_action_set),
+ smx_action->name, smx_action, action->max_duration);
+
+ if (smx_action)
SIMIX_action_signal_all(smx_action);
}
}
/*FIXME: check if this is always empty or not */
while ((action = xbt_swag_extract(model->states.failed_action_set))) {
smx_action = action->data;
- DEBUG4("Resource [%s] (%d): Executing FAILED action \"%s\" (%p)",
- model->name, xbt_swag_size(model->states.running_action_set),
- smx_action->name, smx_action);
+ DEBUG4("Resource [%s] (%d): Executing FAILED action \"%s\" (%p)",
+ model->name, xbt_swag_size(model->states.running_action_set),
+ smx_action->name, smx_action);
if (smx_action)
- SIMIX_action_signal_all(smx_action);
+ SIMIX_action_signal_all(smx_action);
}
}
/* That's it, now go one step deeper into the model-checking process! */
- NOW += 0.5; /* FIXME: Check time increases*/
+ NOW += 0.5; /* FIXME: Check time increases */
}
/****************************** Statistics ************************************/
INFO1("Visited states = %lu", stats->visited_states);
INFO1("Executed transitions = %lu", stats->executed_transitions);
INFO1("Expanded / Visited = %lf",
- (double)stats->visited_states / stats->expanded_states);
+ (double) stats->visited_states / stats->expanded_states);
/*INFO1("Exploration coverage = %lf",
- (double)stats->expanded_states / stats->state_size);*/
+ (double)stats->expanded_states / stats->state_size); */
}
/************************* Assertion Checking *********************************/
void MC_assert(int prop)
{
- if(!prop){
+ if (!prop) {
INFO0("**************************");
INFO0("*** PROPERTY NOT VALID ***");
INFO0("**************************");
xbt_abort();
}
}
-
#include <unistd.h>
#define _GNU_SOURCE
-extern char *basename (__const char *__filename);
+extern char *basename(__const char *__filename);
-#define STD_HEAP_SIZE 20480000 /* Maximum size of the system's heap */
+#define STD_HEAP_SIZE 20480000 /* Maximum size of the system's heap */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
- "Logging specific to MC (memory)");
+ "Logging specific to MC (memory)");
/* Pointers to each of the heap regions to use */
-void *std_heap=NULL; /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
-void *raw_heap=NULL; /* memory persistent over the MC rollbacks. Only MC stuff should go there */
+void *std_heap = NULL; /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
+void *raw_heap = NULL; /* memory persistent over the MC rollbacks. Only MC stuff should go there */
/* Pointers to the beginning and end of the .data and .bss segment of libsimgrid */
/* They are initialized once at memory_init */
xbt_assert(std_heap != NULL);
/* Create the second region a page after the first one ends */
- raw_heap = mmalloc_attach(-1, (char *)(std_heap) + STD_HEAP_SIZE + getpagesize());
+ raw_heap =
+ mmalloc_attach(-1,
+ (char *) (std_heap) + STD_HEAP_SIZE + getpagesize());
xbt_assert(raw_heap != NULL);
MC_SET_RAW_MEM;
/* Get memory map */
memory_map_t maps;
maps = get_memory_map();
-
- for(i=0; i < maps->mapsize; i++){
-
- if(maps->regions[i].inode != 0){
-
+
+ for (i = 0; i < maps->mapsize; i++) {
+
+ if (maps->regions[i].inode != 0) {
+
tmp = xbt_strdup(maps->regions[i].pathname);
libname = basename(tmp);
-
+
#if 0
- if (maps->regions[i].perms & MAP_WRITE &&
- maps->regions[i].pathname[0] != '\0' && /* do not take anonymous segments: what are they? */
- strcmp("[heap]",maps->regions[i].pathname) && /* do not take standard heap: mmalloc saves it already */
- strcmp("[stack]",maps->regions[i].pathname) /* this is maestro's stack. No need to save it */
+ if (maps->regions[i].perms & MAP_WRITE && maps->regions[i].pathname[0] != '\0' && /* do not take anonymous segments: what are they? */
+ strcmp("[heap]", maps->regions[i].pathname) && /* do not take standard heap: mmalloc saves it already */
+ strcmp("[stack]", maps->regions[i].pathname) /* this is maestro's stack. No need to save it */
) {
/* FIXME: we should save the data of more segments, in a list of block to save */
}
#endif
/* for now, we only save the data of libsimgrid (FIXME) */
- if( strncmp("libsimgrid.so.", libname, 14) == 0 && maps->regions[i].perms & MAP_WRITE){
+ if (strncmp("libsimgrid.so.", libname, 14) == 0
+ && maps->regions[i].perms & MAP_WRITE) {
libsimgrid_data_addr_start = maps->regions[i].start_addr;
- libsimgrid_data_size = (size_t)((char *)maps->regions[i+1].start_addr - (char *)maps->regions[i].start_addr);
+ libsimgrid_data_size =
+ (size_t) ((char *) maps->regions[i + 1].start_addr -
+ (char *) maps->regions[i].start_addr);
xbt_free(tmp);
break;
- }
+ }
xbt_free(tmp);
}
}
-
- xbt_assert0(libsimgrid_data_addr_start != NULL,
- "Cannot determine libsimgrid's .data segment address");
-
+
+ xbt_assert0(libsimgrid_data_addr_start != NULL,
+ "Cannot determine libsimgrid's .data segment address");
+
MC_UNSET_RAW_MEM;
}
/* Finish the memory subsystem */
#include "xbt_modinter.h"
-void MC_memory_exit(void) {
+void MC_memory_exit(void)
+{
if (raw_heap)
mmalloc_detach(raw_heap);
}
/* an API to query about the status of a heap, we simply call mmstats and */
/* because I now how does structure looks like, then I redefine it here */
-struct mstats
- {
- size_t bytes_total; /* Total size of the heap. */
- size_t chunks_used; /* Chunks allocated by the user. */
- size_t bytes_used; /* Byte total of user-allocated chunks. */
- size_t chunks_free; /* Chunks in the free list. */
- size_t bytes_free; /* Byte total of chunks in the free list. */
- };
+struct mstats {
+ size_t bytes_total; /* Total size of the heap. */
+ size_t chunks_used; /* Chunks allocated by the user. */
+ size_t bytes_used; /* Byte total of user-allocated chunks. */
+ size_t chunks_free; /* Chunks in the free list. */
+ size_t bytes_free; /* Byte total of chunks in the free list. */
+};
extern struct mstats mmstats(void *);
/* Copy std_heap to "to_heap" allocating the required space for it */
size_t MC_save_heap(void **to_heap)
-{
+{
size_t heap_size = mmstats(std_heap).bytes_total;
-
+
*to_heap = calloc(heap_size, 1);
xbt_assert(*to_heap != NULL);
-
+
memcpy(*to_heap, std_heap, heap_size);
-
+
return heap_size;
}
/* Restore std_heap from "src_heap" */
void MC_restore_heap(void *src_heap, size_t size)
-{
+{
memcpy(std_heap, src_heap, size);
}
{
memcpy(libsimgrid_data_addr_start, src_data, size);
}
-
-
-
-
-
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans, mc,
- "Logging specific to MC transitions");
+ "Logging specific to MC transitions");
/* Creates a new iSend transition */
mc_transition_t MC_trans_isend_new(smx_rdv_t rdv)
trans->type = mc_isend;
trans->process = SIMIX_process_self();
trans->isend.rdv = rdv;
- trans->name = bprintf("[%s]\t iSend (%p)", trans->process->smx_host->name, trans);
+ trans->name =
+ bprintf("[%s]\t iSend (%p)", trans->process->smx_host->name, trans);
return trans;
}
trans->type = mc_irecv;
trans->process = SIMIX_process_self();
trans->irecv.rdv = rdv;
- trans->name = bprintf("[%s]\t iRecv (%p)", trans->process->smx_host->name, trans);
+ trans->name =
+ bprintf("[%s]\t iRecv (%p)", trans->process->smx_host->name, trans);
return trans;
}
trans->type = mc_wait;
trans->process = SIMIX_process_self();
trans->wait.comm = comm;
- trans->name = bprintf("[%s]\t Wait (%p)", trans->process->smx_host->name, trans);
+ trans->name =
+ bprintf("[%s]\t Wait (%p)", trans->process->smx_host->name, trans);
return trans;
}
trans->type = mc_test;
trans->process = SIMIX_process_self();
trans->test.comm = comm;
- trans->name = bprintf("[%s]\t Test (%p)", trans->process->smx_host->name, trans);
+ trans->name =
+ bprintf("[%s]\t Test (%p)", trans->process->smx_host->name, trans);
return trans;
}
trans->type = mc_waitany;
trans->process = SIMIX_process_self();
trans->waitany.comms = comms;
- trans->name = bprintf("[%s]\t WaitAny (%p)", trans->process->smx_host->name, trans);
+ trans->name =
+ bprintf("[%s]\t WaitAny (%p)", trans->process->smx_host->name,
+ trans);
return trans;
}
trans->type = mc_random;
trans->process = SIMIX_process_self();
trans->random.value = value;
- trans->name = bprintf("[%s]\t Random %d (%p)", trans->process->smx_host->name, value, trans);
+ trans->name =
+ bprintf("[%s]\t Random %d (%p)", trans->process->smx_host->name,
+ value, trans);
return trans;
}
*/
void MC_trans_intercept_isend(smx_rdv_t rdv)
{
- mc_transition_t trans=NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
trans = MC_trans_isend_new(rdv);
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
}
- SIMIX_process_yield();
+ SIMIX_process_yield();
}
/**
*/
void MC_trans_intercept_irecv(smx_rdv_t rdv)
{
- mc_transition_t trans=NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
trans = MC_trans_irecv_new(rdv);
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
*/
void MC_trans_intercept_wait(smx_comm_t comm)
{
- mc_transition_t trans=NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
trans = MC_trans_wait_new(comm);
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
*/
void MC_trans_intercept_test(smx_comm_t comm)
{
- mc_transition_t trans=NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
trans = MC_trans_test_new(comm);
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
MC_UNSET_RAW_MEM;
smx_comm_t comm = NULL;
mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
- xbt_dynar_foreach(comms, index, comm){
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ xbt_dynar_foreach(comms, index, comm) {
trans = MC_trans_wait_new(comm);
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
void MC_trans_intercept_random(int min, int max)
{
int i;
- mc_transition_t trans=NULL;
+ mc_transition_t trans = NULL;
mc_state_t current_state = NULL;
- if(!mc_replay_mode){
+ if (!mc_replay_mode) {
MC_SET_RAW_MEM;
- current_state = (mc_state_t)
- xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
- for(i=min; i <= max; i++){
+ current_state = (mc_state_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack));
+ for (i = min; i <= max; i++) {
trans = MC_trans_random_new(i);
xbt_setset_set_insert(current_state->created_transitions, trans);
xbt_setset_set_insert(current_state->transitions, trans);
}
/* Compute the subset of enabled transitions of the transition set */
-void MC_trans_compute_enabled(xbt_setset_set_t enabled, xbt_setset_set_t transitions)
+void MC_trans_compute_enabled(xbt_setset_set_t enabled,
+ xbt_setset_set_t transitions)
{
unsigned int index = 0;
smx_comm_t comm = NULL;
mc_transition_t trans = NULL;
xbt_setset_cursor_t cursor = NULL;
- xbt_setset_foreach(transitions, cursor, trans){
- switch(trans->type){
+ xbt_setset_foreach(transitions, cursor, trans) {
+ switch (trans->type) {
/* Wait transitions are enabled only if the communication has both a
sender and receiver */
- case mc_wait:
- if(trans->wait.comm->src_proc && trans->wait.comm->dst_proc){
- xbt_setset_set_insert(enabled, trans);
- DEBUG1("Transition %p is enabled for next state", trans);
- }
- break;
+ case mc_wait:
+ if (trans->wait.comm->src_proc && trans->wait.comm->dst_proc) {
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ }
+ break;
/* WaitAny transitions are enabled if any of it's communications has both
a sender and a receiver */
- case mc_waitany:
- xbt_dynar_foreach(trans->waitany.comms, index, comm){
- if(comm->src_proc && comm->dst_proc){
- xbt_setset_set_insert(enabled, trans);
- DEBUG1("Transition %p is enabled for next state", trans);
- break;
- }
+ case mc_waitany:
+ xbt_dynar_foreach(trans->waitany.comms, index, comm) {
+ if (comm->src_proc && comm->dst_proc) {
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ break;
}
- break;
+ }
+ break;
/* The rest of the transitions cannot be disabled */
- default:
- xbt_setset_set_insert(enabled, trans);
- DEBUG1("Transition %p is enabled for next state", trans);
- break;
- }
+ default:
+ xbt_setset_set_insert(enabled, trans);
+ DEBUG1("Transition %p is enabled for next state", trans);
+ break;
+ }
}
}
*/
int MC_transition_depend(mc_transition_t t1, mc_transition_t t2)
{
- if(t1->process == t2->process)
+ if (t1->process == t2->process)
return FALSE;
- if(t1->type != t2->type)
+ if (t1->type != t2->type)
return FALSE;
-
+
/* if(t1->type == mc_isend && t2->type == mc_irecv)
return FALSE;
if(t1->type == mc_irecv && t2->type == mc_isend)
return FALSE;*/
-
- if(t1->type == mc_random || t2->type == mc_random)
+
+ if (t1->type == mc_random || t2->type == mc_random)
return FALSE;
-
- if(t1->type == mc_isend && t2->type == mc_isend && t1->isend.rdv != t2->isend.rdv)
+
+ if (t1->type == mc_isend && t2->type == mc_isend
+ && t1->isend.rdv != t2->isend.rdv)
return FALSE;
- if(t1->type == mc_irecv && t2->type == mc_irecv && t1->irecv.rdv != t2->irecv.rdv)
+ if (t1->type == mc_irecv && t2->type == mc_irecv
+ && t1->irecv.rdv != t2->irecv.rdv)
return FALSE;
- if(t1->type == mc_wait && t2->type == mc_wait && t1->wait.comm == t2->wait.comm)
+ if (t1->type == mc_wait && t2->type == mc_wait
+ && t1->wait.comm == t2->wait.comm)
return FALSE;
-
- if(t1->type == mc_wait && t2->type == mc_wait
- && t1->wait.comm->src_buff != NULL
- && t1->wait.comm->dst_buff != NULL
- && t2->wait.comm->src_buff != NULL
- && t2->wait.comm->dst_buff != NULL
- && t1->wait.comm->dst_buff != t2->wait.comm->src_buff
- && t1->wait.comm->dst_buff != t2->wait.comm->dst_buff
- && t2->wait.comm->dst_buff != t1->wait.comm->src_buff)
+
+ if (t1->type == mc_wait && t2->type == mc_wait
+ && t1->wait.comm->src_buff != NULL
+ && t1->wait.comm->dst_buff != NULL
+ && t2->wait.comm->src_buff != NULL
+ && t2->wait.comm->dst_buff != NULL
+ && t1->wait.comm->dst_buff != t2->wait.comm->src_buff
+ && t1->wait.comm->dst_buff != t2->wait.comm->dst_buff
+ && t2->wait.comm->dst_buff != t1->wait.comm->src_buff)
return FALSE;
-
-
+
+
return TRUE;
-}
\ No newline at end of file
+}
memory_map_t get_memory_map(void)
{
- FILE *fp; /* File pointer to process's proc maps file */
- char *line = NULL; /* Temporal storage for each line that is readed */
- ssize_t read; /* Number of bytes readed */
- size_t n = 0; /* Amount of bytes to read by getline */
- memory_map_t ret = NULL; /* The memory map to return */
-
+ FILE *fp; /* File pointer to process's proc maps file */
+ char *line = NULL; /* Temporal storage for each line that is readed */
+ ssize_t read; /* Number of bytes readed */
+ size_t n = 0; /* Amount of bytes to read by getline */
+ memory_map_t ret = NULL; /* The memory map to return */
+
/* The following variables are used during the parsing of the file "maps" */
- s_map_region memreg; /* temporal map region used for creating the map */
+ s_map_region memreg; /* temporal map region used for creating the map */
char *lfields[6], *tok, *endptr;
int i;
-
+
/* Open the actual process's proc maps file and create the memory_map_t */
/* to be returned. */
- fp = fopen("/proc/self/maps","r");
+ fp = fopen("/proc/self/maps", "r");
+
+ xbt_assert0(fp,
+ "Cannot open /proc/self/maps to investigate the memory map of the process. Please report this bug.");
- xbt_assert0(fp,"Cannot open /proc/self/maps to investigate the memory map of the process. Please report this bug.");
-
- ret = xbt_new0(s_memory_map_t,1);
-
- /* Read one line at the time, parse it and add it to the memory map to be returned */
- while((read = getline(&line, &n, fp)) != -1) {
+ ret = xbt_new0(s_memory_map_t, 1);
+
+ /* Read one line at the time, parse it and add it to the memory map to be returned */
+ while ((read = getline(&line, &n, fp)) != -1) {
/* Wipeout the new line character */
line[read - 1] = '\0';
/* Tokenize the line using spaces as delimiters and store each token */
/* in lfields array. We expect 5 tokens/fields */
lfields[0] = strtok(line, " ");
-
- for(i=1; i < 6 && lfields[i - 1] != NULL; i++){
- lfields[i] = strtok(NULL, " ");
+
+ for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
+ lfields[i] = strtok(NULL, " ");
}
/* Check to see if we got the expected amount of columns */
- if(i < 6)
+ if (i < 6)
xbt_abort();
/* Ok we are good enough to try to get the info we need */
/* First get the start and the end address of the map */
- tok = strtok(lfields[0], "-");
- if(tok == NULL)
+ tok = strtok(lfields[0], "-");
+ if (tok == NULL)
xbt_abort();
-
- memreg.start_addr = (void *)strtoul(tok, &endptr, 16);
+
+ memreg.start_addr = (void *) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
-
+
tok = strtok(NULL, "-");
- if(tok == NULL)
+ if (tok == NULL)
xbt_abort();
-
- memreg.end_addr = (void *)strtoul(tok, &endptr, 16);
+
+ memreg.end_addr = (void *) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
-
+
/* Get the permissions flags */
- if(strlen(lfields[1]) < 4)
+ if (strlen(lfields[1]) < 4)
xbt_abort();
-
+
memreg.perms = 0;
-
- for(i=0; i<3; i++)
- if(lfields[1][i] != '-')
+
+ for (i = 0; i < 3; i++)
+ if (lfields[1][i] != '-')
memreg.perms |= 1 << i;
- if(lfields[1][4] == 'p')
+ if (lfields[1][4] == 'p')
memreg.perms |= MAP_PRIV;
-
+
else if (lfields[1][4] == 's')
- memreg.perms |= MAP_SHARED;
-
+ memreg.perms |= MAP_SHARED;
+
/* Get the offset value */
- memreg.offset = (void *)strtoul(lfields[2], &endptr, 16);
+ memreg.offset = (void *) strtoul(lfields[2], &endptr, 16);
/* Make sure that the entire string was an hex number */
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
-
+
/* Get the device major:minor bytes */
tok = strtok(lfields[3], ":");
- if(tok == NULL)
+ if (tok == NULL)
xbt_abort();
- memreg.dev_major = (char)strtoul(tok, &endptr, 16);
+ memreg.dev_major = (char) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
tok = strtok(NULL, ":");
- if(tok == NULL)
+ if (tok == NULL)
xbt_abort();
- memreg.dev_minor = (char)strtoul(tok, &endptr, 16);
+ memreg.dev_minor = (char) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
-
- /* Get the inode number and make sure that the entire string was a long int*/
+
+ /* Get the inode number and make sure that the entire string was a long int */
memreg.inode = strtoul(lfields[4], &endptr, 10);
- if(*endptr != '\0')
+ if (*endptr != '\0')
xbt_abort();
/* And finally get the pathname */
memreg.pathname = xbt_strdup(lfields[5]);
-
+
/* Create space for a new map region in the region's array and copy the */
/* parsed stuff from the temporal memreg variable */
- ret->regions = xbt_realloc(ret->regions, sizeof(memreg) * (ret->mapsize + 1));
- memcpy(ret->regions + ret->mapsize, &memreg, sizeof(memreg));
- ret->mapsize++;
+ ret->regions =
+ xbt_realloc(ret->regions, sizeof(memreg) * (ret->mapsize + 1));
+ memcpy(ret->regions + ret->mapsize, &memreg, sizeof(memreg));
+ ret->mapsize++;
}
-
- if(line)
+
+ if (line)
free(line);
-
+
return ret;
}
typedef struct s_mc_snapshot {
size_t heap_size;
size_t data_size;
- void* data;
- void* heap;
+ void *data;
+ void *heap;
} s_mc_snapshot_t, *mc_snapshot_t;
mc_random
} mc_trans_type_t;
-typedef struct s_mc_transition{
+typedef struct s_mc_transition {
XBT_SETSET_HEADERS;
- char* name;
+ char *name;
smx_process_t process;
mc_trans_type_t type;
union {
struct {
- smx_rdv_t rdv;
+ smx_rdv_t rdv;
} isend;
struct {
- smx_rdv_t rdv;
+ smx_rdv_t rdv;
} irecv;
struct {
void MC_trans_compute_enabled(xbt_setset_set_t, xbt_setset_set_t);
/******************************** States **************************************/
-typedef struct mc_state{
- xbt_setset_set_t created_transitions; /* created in this state */
- xbt_setset_set_t transitions; /* created in this state + inherited */
- xbt_setset_set_t enabled_transitions; /* they can be executed by the mc */
- xbt_setset_set_t interleave; /* the ones to be executed by the mc */
- xbt_setset_set_t done; /* already executed transitions */
- mc_transition_t executed_transition; /* last executed transition */
+typedef struct mc_state {
+ xbt_setset_set_t created_transitions; /* created in this state */
+ xbt_setset_set_t transitions; /* created in this state + inherited */
+ xbt_setset_set_t enabled_transitions; /* they can be executed by the mc */
+ xbt_setset_set_t interleave; /* the ones to be executed by the mc */
+ xbt_setset_set_t done; /* already executed transitions */
+ mc_transition_t executed_transition; /* last executed transition */
} s_mc_state_t, *mc_state_t;
extern xbt_fifo_t mc_stack;
void MC_state_delete(mc_state_t);
/****************************** Statistics ************************************/
-typedef struct mc_stats{
+typedef struct mc_stats {
unsigned long state_size;
unsigned long visited_states;
unsigned long expanded_states;
unsigned long executed_transitions;
-}s_mc_stats_t, *mc_stats_t;
+} s_mc_stats_t, *mc_stats_t;
extern mc_stats_t mc_stats;
#define MAP_WRITE 1 << 1
#define MAP_EXEC 1 << 2
#define MAP_SHARED 1 << 3
-#define MAP_PRIV 1 << 4
+#define MAP_PRIV 1 << 4
/* Each field is defined as documented in proc's manual page */
typedef struct s_map_region {
- void *start_addr; /* Start address of the map */
- void *end_addr; /* End address of the map */
- int perms; /* Set of permissions */
- void *offset; /* Offset in the file/whatever */
- char dev_major; /* Major of the device */
- char dev_minor; /* Minor of the device */
- unsigned long inode; /* Inode in the device */
- char *pathname; /* Path name of the mapped file */
+ void *start_addr; /* Start address of the map */
+ void *end_addr; /* End address of the map */
+ int perms; /* Set of permissions */
+ void *offset; /* Offset in the file/whatever */
+ char dev_major; /* Major of the device */
+ char dev_minor; /* Minor of the device */
+ unsigned long inode; /* Inode in the device */
+ char *pathname; /* Path name of the mapped file */
} s_map_region;
typedef struct s_memory_map {
- s_map_region *regions; /* Pointer to an array of regions */
- int mapsize; /* Number of regions in the memory */
+ s_map_region *regions; /* Pointer to an array of regions */
+ int mapsize; /* Number of regions in the memory */
} s_memory_map_t, *memory_map_t;
* \brief register functions bypassing the parser
*/
-void MSG_set_function(const char* host_id,const char *function_name,xbt_dynar_t arguments)
+void MSG_set_function(const char *host_id, const char *function_name,
+ xbt_dynar_t arguments)
{
- SIMIX_process_set_function(host_id,function_name,arguments,-1,-1);
+ SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
}
{
smx_host_t simix_h = NULL;
simix_h = SIMIX_host_get_by_name(name);
-
+
if (simix_h == NULL)
return NULL;
- return (m_host_t)SIMIX_host_get_data(simix_h);
+ return (m_host_t) SIMIX_host_get_data(simix_h);
}
/** \ingroup msg_easier_life
* and the routing table
*/
-void MSG_load_platform_script(const char *script_file) {
+void MSG_load_platform_script(const char *script_file)
+{
#ifdef HAVE_LUA
- lua_State *L = lua_open();
- luaL_openlibs(L);
+ lua_State *L = lua_open();
+ luaL_openlibs(L);
- if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
- printf("error: %s\n", lua_tostring(L, -1));
- return;
- }
+ if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
+ printf("error: %s\n", lua_tostring(L, -1));
+ return;
+ }
#else
- xbt_die("Lua is not available!! to call MSG_load_platform_script, lua should be available...");
+ xbt_die
+ ("Lua is not available!! to call MSG_load_platform_script, lua should be available...");
#endif
- return;
+ return;
}
void MSG_global_init(int *argc, char **argv)
{
#ifdef HAVE_TRACING
- TRACE_global_init (argc, argv);
+ TRACE_global_init(argc, argv);
#endif
xbt_getpid = MSG_process_self_PID;
else
#endif
while (SIMIX_solve(NULL, NULL) != -1.0);
-
+
return MSG_OK;
}
m_process_t p = NULL;
#ifdef HAVE_TRACING
- TRACE_surf_release ();
+ TRACE_surf_release();
#endif
while ((p = xbt_fifo_pop(msg_global->process_list))) {
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg,
- "Logging specific to MSG (gos)");
+ "Logging specific to MSG (gos)");
/** \ingroup msg_gos_functions
*
*/
MSG_error_t MSG_get_errno(void)
{
- return PROCESS_GET_ERRNO();
+ return PROCESS_GET_ERRNO();
}
/** \ingroup msg_gos_functions
*/
MSG_error_t MSG_task_execute(m_task_t task)
{
- simdata_task_t simdata = NULL;
- m_process_t self = MSG_process_self();
- e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
- CHECK_HOST();
+ simdata_task_t simdata = NULL;
+ m_process_t self = MSG_process_self();
+ e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
+ CHECK_HOST();
- simdata = task->simdata;
+ simdata = task->simdata;
- xbt_assert0(simdata->host_nb==0, "This is a parallel task. Go to hell.");
+ xbt_assert0(simdata->host_nb == 0,
+ "This is a parallel task. Go to hell.");
#ifdef HAVE_TRACING
- TRACE_msg_task_execute_start (task);
+ TRACE_msg_task_execute_start(task);
#endif
- xbt_assert1((!simdata->compute) && (task->simdata->refcount == 1),
- "This task is executed somewhere else. Go fix your code! %d", task->simdata->refcount);
+ xbt_assert1((!simdata->compute) && (task->simdata->refcount == 1),
+ "This task is executed somewhere else. Go fix your code! %d",
+ task->simdata->refcount);
- DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
+ DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
- if (simdata->computation_amount == 0) {
+ if (simdata->computation_amount == 0) {
#ifdef HAVE_TRACING
- TRACE_msg_task_execute_end (task);
+ TRACE_msg_task_execute_end(task);
#endif
- return MSG_OK;
- }
- simdata->refcount++;
- SIMIX_mutex_lock(simdata->mutex);
- simdata->compute =
- SIMIX_action_execute(SIMIX_host_self(), task->name,
- simdata->computation_amount);
- SIMIX_action_set_priority(simdata->compute, simdata->priority);
-
- /* changed to waiting action since we are always waiting one action (execute, communicate or sleep) */
- self->simdata->waiting_action = simdata->compute;
- SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
- do {
- SIMIX_cond_wait(simdata->cond, simdata->mutex);
- state = SIMIX_action_get_state(simdata->compute);
- } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
- SIMIX_unregister_action_to_condition(simdata->compute, simdata->cond);
- self->simdata->waiting_action = NULL;
-
- SIMIX_mutex_unlock(simdata->mutex);
- simdata->refcount--;
-
- if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->computation_amount = 0.0;
- simdata->comm = NULL;
- simdata->compute = NULL;
+ return MSG_OK;
+ }
+ simdata->refcount++;
+ SIMIX_mutex_lock(simdata->mutex);
+ simdata->compute =
+ SIMIX_action_execute(SIMIX_host_self(), task->name,
+ simdata->computation_amount);
+ SIMIX_action_set_priority(simdata->compute, simdata->priority);
+
+ /* changed to waiting action since we are always waiting one action (execute, communicate or sleep) */
+ self->simdata->waiting_action = simdata->compute;
+ SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
+ do {
+ SIMIX_cond_wait(simdata->cond, simdata->mutex);
+ state = SIMIX_action_get_state(simdata->compute);
+ } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
+ SIMIX_unregister_action_to_condition(simdata->compute, simdata->cond);
+ self->simdata->waiting_action = NULL;
+
+ SIMIX_mutex_unlock(simdata->mutex);
+ simdata->refcount--;
+
+ if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->computation_amount = 0.0;
+ simdata->comm = NULL;
+ simdata->compute = NULL;
#ifdef HAVE_TRACING
- TRACE_msg_task_execute_end (task);
+ TRACE_msg_task_execute_end(task);
#endif
- MSG_RETURN(MSG_OK);
- } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->comm = NULL;
- simdata->compute = NULL;
+ MSG_RETURN(MSG_OK);
+ } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->comm = NULL;
+ simdata->compute = NULL;
#ifdef HAVE_TRACING
- TRACE_msg_task_execute_end (task);
+ TRACE_msg_task_execute_end(task);
#endif
- MSG_RETURN(MSG_HOST_FAILURE);
- } else {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->comm = NULL;
- simdata->compute = NULL;
+ MSG_RETURN(MSG_HOST_FAILURE);
+ } else {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->comm = NULL;
+ simdata->compute = NULL;
#ifdef HAVE_TRACING
- TRACE_msg_task_execute_end (task);
+ TRACE_msg_task_execute_end(task);
#endif
- MSG_RETURN(MSG_TASK_CANCELLED);
- }
+ MSG_RETURN(MSG_TASK_CANCELLED);
+ }
}
/** \ingroup m_task_management
* \see m_task_t
* \return The new corresponding object.
*/
- m_task_t
+m_task_t
MSG_parallel_task_create(const char *name, int host_nb,
- const m_host_t * host_list,
- double *computation_amount,
- double *communication_amount, void *data)
-{
- int i;
- simdata_task_t simdata = xbt_new0(s_simdata_task_t, 1);
- m_task_t task = xbt_new0(s_m_task_t, 1);
- task->simdata = simdata;
-
- /* Task structure */
- task->name = xbt_strdup(name);
- task->data = data;
-
- /* Simulator Data */
- simdata->computation_amount = 0;
- simdata->message_size = 0;
- simdata->cond = SIMIX_cond_init();
- simdata->mutex = SIMIX_mutex_init();
- simdata->compute = NULL;
- simdata->comm = NULL;
- simdata->rate = -1.0;
- simdata->refcount = 1;
- simdata->sender = NULL;
- simdata->receiver = NULL;
- simdata->source = NULL;
-
- simdata->host_nb = host_nb;
- simdata->host_list = xbt_new0(smx_host_t, host_nb);
- simdata->comp_amount = computation_amount;
- simdata->comm_amount = communication_amount;
-
- for (i = 0; i < host_nb; i++)
- simdata->host_list[i] = host_list[i]->simdata->smx_host;
-
- return task;
+ const m_host_t * host_list,
+ double *computation_amount,
+ double *communication_amount, void *data)
+{
+ int i;
+ simdata_task_t simdata = xbt_new0(s_simdata_task_t, 1);
+ m_task_t task = xbt_new0(s_m_task_t, 1);
+ task->simdata = simdata;
+
+ /* Task structure */
+ task->name = xbt_strdup(name);
+ task->data = data;
+
+ /* Simulator Data */
+ simdata->computation_amount = 0;
+ simdata->message_size = 0;
+ simdata->cond = SIMIX_cond_init();
+ simdata->mutex = SIMIX_mutex_init();
+ simdata->compute = NULL;
+ simdata->comm = NULL;
+ simdata->rate = -1.0;
+ simdata->refcount = 1;
+ simdata->sender = NULL;
+ simdata->receiver = NULL;
+ simdata->source = NULL;
+
+ simdata->host_nb = host_nb;
+ simdata->host_list = xbt_new0(smx_host_t, host_nb);
+ simdata->comp_amount = computation_amount;
+ simdata->comm_amount = communication_amount;
+
+ for (i = 0; i < host_nb; i++)
+ simdata->host_list[i] = host_list[i]->simdata->smx_host;
+
+ return task;
}
MSG_error_t MSG_parallel_task_execute(m_task_t task)
{
- simdata_task_t simdata = NULL;
- m_process_t self = MSG_process_self();
- e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
- CHECK_HOST();
+ simdata_task_t simdata = NULL;
+ m_process_t self = MSG_process_self();
+ e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
+ CHECK_HOST();
- simdata = task->simdata;
+ simdata = task->simdata;
- xbt_assert0((!simdata->compute)
- && (task->simdata->refcount == 1),
- "This task is executed somewhere else. Go fix your code!");
+ xbt_assert0((!simdata->compute)
+ && (task->simdata->refcount == 1),
+ "This task is executed somewhere else. Go fix your code!");
- xbt_assert0(simdata->host_nb, "This is not a parallel task. Go to hell.");
+ xbt_assert0(simdata->host_nb,
+ "This is not a parallel task. Go to hell.");
- DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
+ DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name);
- simdata->refcount++;
+ simdata->refcount++;
- SIMIX_mutex_lock(simdata->mutex);
- simdata->compute =
- SIMIX_action_parallel_execute(task->name, simdata->host_nb,
- simdata->host_list, simdata->comp_amount,
- simdata->comm_amount, 1.0, -1.0);
+ SIMIX_mutex_lock(simdata->mutex);
+ simdata->compute =
+ SIMIX_action_parallel_execute(task->name, simdata->host_nb,
+ simdata->host_list,
+ simdata->comp_amount,
+ simdata->comm_amount, 1.0, -1.0);
- self->simdata->waiting_action = simdata->compute;
- SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
- do {
- SIMIX_cond_wait(simdata->cond, simdata->mutex);
- state = SIMIX_action_get_state(task->simdata->compute);
- } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
+ self->simdata->waiting_action = simdata->compute;
+ SIMIX_register_action_to_condition(simdata->compute, simdata->cond);
+ do {
+ SIMIX_cond_wait(simdata->cond, simdata->mutex);
+ state = SIMIX_action_get_state(task->simdata->compute);
+ } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
- SIMIX_unregister_action_to_condition(simdata->compute, simdata->cond);
- self->simdata->waiting_action = NULL;
+ SIMIX_unregister_action_to_condition(simdata->compute, simdata->cond);
+ self->simdata->waiting_action = NULL;
- SIMIX_mutex_unlock(simdata->mutex);
- simdata->refcount--;
+ SIMIX_mutex_unlock(simdata->mutex);
+ simdata->refcount--;
- if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->computation_amount = 0.0;
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_OK);
- } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_HOST_FAILURE);
- } else {
- /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
- SIMIX_action_destroy(task->simdata->compute);
- simdata->comm = NULL;
- simdata->compute = NULL;
- MSG_RETURN(MSG_TASK_CANCELLED);
- }
+ if (SIMIX_action_get_state(task->simdata->compute) == SURF_ACTION_DONE) {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->computation_amount = 0.0;
+ simdata->comm = NULL;
+ simdata->compute = NULL;
+ MSG_RETURN(MSG_OK);
+ } else if (SIMIX_host_get_state(SIMIX_host_self()) == 0) {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->comm = NULL;
+ simdata->compute = NULL;
+ MSG_RETURN(MSG_HOST_FAILURE);
+ } else {
+ /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */
+ SIMIX_action_destroy(task->simdata->compute);
+ simdata->comm = NULL;
+ simdata->compute = NULL;
+ MSG_RETURN(MSG_TASK_CANCELLED);
+ }
}
*/
MSG_error_t MSG_process_sleep(double nb_sec)
{
- smx_action_t act_sleep;
- m_process_t proc = MSG_process_self();
- e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
- smx_mutex_t mutex;
- smx_cond_t cond;
+ smx_action_t act_sleep;
+ m_process_t proc = MSG_process_self();
+ e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
+ smx_mutex_t mutex;
+ smx_cond_t cond;
#ifdef HAVE_TRACING
- TRACE_msg_process_sleep_in (MSG_process_self());
+ TRACE_msg_process_sleep_in(MSG_process_self());
#endif
- /* create action to sleep */
- act_sleep =
- SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->s_process),
- nb_sec);
-
- mutex = SIMIX_mutex_init();
- SIMIX_mutex_lock(mutex);
-
- /* create conditional and register action to it */
- cond = SIMIX_cond_init();
-
- proc->simdata->waiting_action = act_sleep;
- SIMIX_register_action_to_condition(act_sleep, cond);
- do {
- SIMIX_cond_wait(cond, mutex);
- state = SIMIX_action_get_state(act_sleep);
- } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
- proc->simdata->waiting_action = NULL;
- SIMIX_unregister_action_to_condition(act_sleep, cond);
- SIMIX_mutex_unlock(mutex);
-
- /* remove variables */
- SIMIX_cond_destroy(cond);
- SIMIX_mutex_destroy(mutex);
-
- if (SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
- if (SIMIX_host_get_state(SIMIX_host_self()) == SURF_RESOURCE_OFF) {
- SIMIX_action_destroy(act_sleep);
+ /* create action to sleep */
+ act_sleep =
+ SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->s_process),
+ nb_sec);
+
+ mutex = SIMIX_mutex_init();
+ SIMIX_mutex_lock(mutex);
+
+ /* create conditional and register action to it */
+ cond = SIMIX_cond_init();
+
+ proc->simdata->waiting_action = act_sleep;
+ SIMIX_register_action_to_condition(act_sleep, cond);
+ do {
+ SIMIX_cond_wait(cond, mutex);
+ state = SIMIX_action_get_state(act_sleep);
+ } while (state == SURF_ACTION_READY || state == SURF_ACTION_RUNNING);
+ proc->simdata->waiting_action = NULL;
+ SIMIX_unregister_action_to_condition(act_sleep, cond);
+ SIMIX_mutex_unlock(mutex);
+
+ /* remove variables */
+ SIMIX_cond_destroy(cond);
+ SIMIX_mutex_destroy(mutex);
+
+ if (SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
+ if (SIMIX_host_get_state(SIMIX_host_self()) == SURF_RESOURCE_OFF) {
+ SIMIX_action_destroy(act_sleep);
#ifdef HAVE_TRACING
- TRACE_msg_process_sleep_out (MSG_process_self());
+ TRACE_msg_process_sleep_out(MSG_process_self());
#endif
- MSG_RETURN(MSG_HOST_FAILURE);
- }
- } else {
- SIMIX_action_destroy(act_sleep);
+ MSG_RETURN(MSG_HOST_FAILURE);
+ }
+ } else {
+ SIMIX_action_destroy(act_sleep);
#ifdef HAVE_TRACING
- TRACE_msg_process_sleep_out (MSG_process_self());
+ TRACE_msg_process_sleep_out(MSG_process_self());
#endif
- MSG_RETURN(MSG_HOST_FAILURE);
- }
+ MSG_RETURN(MSG_HOST_FAILURE);
+ }
- SIMIX_action_destroy(act_sleep);
+ SIMIX_action_destroy(act_sleep);
#ifdef HAVE_TRACING
- TRACE_msg_process_sleep_out (MSG_process_self());
+ TRACE_msg_process_sleep_out(MSG_process_self());
#endif
- MSG_RETURN(MSG_OK);
+ MSG_RETURN(MSG_OK);
}
/** \ingroup msg_gos_functions
* \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
*/
- MSG_error_t
+MSG_error_t
MSG_task_get_from_host(m_task_t * task, m_channel_t channel, m_host_t host)
{
- return MSG_task_get_ext(task, channel, -1, host);
+ return MSG_task_get_ext(task, channel, -1, host);
}
/** \ingroup msg_gos_functions
*/
MSG_error_t MSG_task_get(m_task_t * task, m_channel_t channel)
{
- return MSG_task_get_with_timeout(task, channel, -1);
+ return MSG_task_get_with_timeout(task, channel, -1);
}
/** \ingroup msg_gos_functions
* \return #MSG_FATAL if \a task is equal to \c NULL, #MSG_WARNING
if \a *task is not equal to \c NULL, and #MSG_OK otherwise.
*/
- MSG_error_t
+MSG_error_t
MSG_task_get_with_timeout(m_task_t * task, m_channel_t channel,
- double max_duration)
+ double max_duration)
{
- return MSG_task_get_ext(task, channel, max_duration, NULL);
+ return MSG_task_get_ext(task, channel, max_duration, NULL);
}
/** \defgroup msg_gos_functions MSG Operating System Functions
* by an agent for handling some task.
*/
- MSG_error_t
+MSG_error_t
MSG_task_get_ext(m_task_t * task, m_channel_t channel, double timeout,
- m_host_t host)
+ m_host_t host)
{
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- return
- MSG_mailbox_get_task_ext(MSG_mailbox_get_by_channel
- (MSG_host_self(), channel), task, host, timeout);
+ return
+ MSG_mailbox_get_task_ext(MSG_mailbox_get_by_channel
+ (MSG_host_self(), channel), task, host,
+ timeout);
}
- MSG_error_t
-MSG_task_receive_from_host(m_task_t * task, const char *alias, m_host_t host)
+MSG_error_t
+MSG_task_receive_from_host(m_task_t * task, const char *alias,
+ m_host_t host)
{
- return MSG_task_receive_ext(task, alias, -1, host);
+ return MSG_task_receive_ext(task, alias, -1, host);
}
MSG_error_t MSG_task_receive(m_task_t * task, const char *alias)
{
- return MSG_task_receive_with_timeout(task, alias, -1);
+ return MSG_task_receive_with_timeout(task, alias, -1);
}
- MSG_error_t
+MSG_error_t
MSG_task_receive_with_timeout(m_task_t * task, const char *alias,
- double timeout)
+ double timeout)
{
- return MSG_task_receive_ext(task, alias, timeout, NULL);
+ return MSG_task_receive_ext(task, alias, timeout, NULL);
}
- MSG_error_t
+MSG_error_t
MSG_task_receive_ext(m_task_t * task, const char *alias, double timeout,
- m_host_t host)
+ m_host_t host)
{
- DEBUG1("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",alias);
- return MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task, host,
- timeout);
+ DEBUG1
+ ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'",
+ alias);
+ return MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task,
+ host, timeout);
}
/** \ingroup msg_gos_functions
channels fixed with MSG_set_channel_number().
* \return the msg_comm_t communication.
*/
-msg_comm_t MSG_task_isend(m_task_t task, const char *alias) {
- simdata_task_t t_simdata = NULL;
- m_process_t process = MSG_process_self();
- msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
+msg_comm_t MSG_task_isend(m_task_t task, const char *alias)
+{
+ simdata_task_t t_simdata = NULL;
+ m_process_t process = MSG_process_self();
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
- CHECK_HOST();
+ CHECK_HOST();
- /* FIXME: these functions are not tracable */
+ /* FIXME: these functions are not tracable */
- /* Prepare the task to send */
- t_simdata = task->simdata;
- t_simdata->sender = process;
- t_simdata->source = MSG_host_self();
+ /* Prepare the task to send */
+ t_simdata = task->simdata;
+ t_simdata->sender = process;
+ t_simdata->source = MSG_host_self();
- xbt_assert0(t_simdata->refcount == 1,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
+ xbt_assert0(t_simdata->refcount == 1,
+ "This task is still being used somewhere else. You cannot send it now. Go fix your code!");
- t_simdata->refcount++;
- msg_global->sent_msg++;
- process->simdata->waiting_task = task;
+ t_simdata->refcount++;
+ msg_global->sent_msg++;
+ process->simdata->waiting_task = task;
- /* Send it by calling SIMIX network layer */
+ /* Send it by calling SIMIX network layer */
- /* Kept for semantical compatibility with older implementation */
- if(mailbox->cond)
- SIMIX_cond_signal(mailbox->cond);
+ /* Kept for semantical compatibility with older implementation */
+ if (mailbox->cond)
+ SIMIX_cond_signal(mailbox->cond);
- return SIMIX_network_isend(mailbox->rdv, t_simdata->message_size, t_simdata->rate,
- task, sizeof(void*), &t_simdata->comm);
+ return SIMIX_network_isend(mailbox->rdv, t_simdata->message_size,
+ t_simdata->rate, task, sizeof(void *),
+ &t_simdata->comm);
}
/** \ingroup msg_gos_functions
number of channels fixed with MSG_set_channel_number().
* \return the msg_comm_t communication.
*/
-msg_comm_t MSG_task_irecv(m_task_t * task, const char *alias) {
- smx_comm_t comm;
- smx_rdv_t rdv = MSG_mailbox_get_by_alias(alias)->rdv;
- msg_mailbox_t mailbox=MSG_mailbox_get_by_alias(alias);
+msg_comm_t MSG_task_irecv(m_task_t * task, const char *alias)
+{
+ smx_comm_t comm;
+ smx_rdv_t rdv = MSG_mailbox_get_by_alias(alias)->rdv;
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
- CHECK_HOST();
+ CHECK_HOST();
- /* FIXME: these functions are not tracable */
+ /* FIXME: these functions are not tracable */
- memset(&comm,0,sizeof(comm));
+ memset(&comm, 0, sizeof(comm));
- /* Kept for compatibility with older implementation */
- xbt_assert1(!MSG_mailbox_get_cond(mailbox),
- "A process is already blocked on this channel %s",
- MSG_mailbox_get_alias(mailbox));
+ /* Kept for compatibility with older implementation */
+ xbt_assert1(!MSG_mailbox_get_cond(mailbox),
+ "A process is already blocked on this channel %s",
+ MSG_mailbox_get_alias(mailbox));
- /* Sanity check */
- xbt_assert0(task, "Null pointer for the task storage");
+ /* Sanity check */
+ xbt_assert0(task, "Null pointer for the task storage");
- if (*task)
- CRITICAL0("MSG_task_get() was asked to write in a non empty task struct.");
+ if (*task)
+ CRITICAL0
+ ("MSG_task_get() was asked to write in a non empty task struct.");
- /* Try to receive it by calling SIMIX network layer */
- return SIMIX_network_irecv(rdv, task, NULL);
+ /* Try to receive it by calling SIMIX network layer */
+ return SIMIX_network_irecv(rdv, task, NULL);
}
+
/** \ingroup msg_gos_functions
* \brief Test the status of a communication.
*
* FALSE: the communication is incompleted
* If the status is FALSE, don't forget to use MSG_process_sleep() after the test.
*/
-int MSG_comm_test(msg_comm_t comm) {
- return SIMIX_network_test(comm);
+int MSG_comm_test(msg_comm_t comm)
+{
+ return SIMIX_network_test(comm);
}
+
/** \ingroup msg_gos_functions
* \brief After received TRUE to MSG_comm_test(), the communication must be destroyed.
*
* It takes one parameter.
* \param comm the communication to destroy.
*/
-void MSG_comm_destroy(msg_comm_t comm) {
- if(!(comm->src_proc == SIMIX_process_self()))
- {
- m_task_t task;
- task = (m_task_t) SIMIX_communication_get_src_buf(comm);
- task->simdata->refcount--;
- }
- SIMIX_communication_destroy(comm);
+void MSG_comm_destroy(msg_comm_t comm)
+{
+ if (!(comm->src_proc == SIMIX_process_self())) {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+ SIMIX_communication_destroy(comm);
}
/** \ingroup msg_gos_functions
* \param timeout Wait until the communication terminates or the timeout occurs
* \return MSG_error_t
*/
-MSG_error_t MSG_comm_wait(msg_comm_t comm, double timeout) {
- xbt_ex_t e;
- MSG_error_t res = MSG_OK;
- TRY {
- SIMIX_network_wait(comm,timeout);
-
- if(!(comm->src_proc == SIMIX_process_self()))
- {
- m_task_t task;
- task = (m_task_t) SIMIX_communication_get_src_buf(comm);
- task->simdata->refcount--;
- }
-
- /* FIXME: these functions are not tracable */
- } CATCH(e){
- switch(e.category){
- case host_error:
- res = MSG_HOST_FAILURE;
- break;
- case network_error:
- res = MSG_TRANSFER_FAILURE;
- break;
- case timeout_error:
- res = MSG_TIMEOUT;
- break;
- default:
- xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
- }
- xbt_ex_free(e);
- }
- return res;
+MSG_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
+{
+ xbt_ex_t e;
+ MSG_error_t res = MSG_OK;
+ TRY {
+ SIMIX_network_wait(comm, timeout);
+
+ if (!(comm->src_proc == SIMIX_process_self())) {
+ m_task_t task;
+ task = (m_task_t) SIMIX_communication_get_src_buf(comm);
+ task->simdata->refcount--;
+ }
+
+ /* FIXME: these functions are not tracable */
+ }
+ CATCH(e) {
+ switch (e.category) {
+ case host_error:
+ res = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ res = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ res = MSG_TIMEOUT;
+ break;
+ default:
+ xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg));
+ }
+ xbt_ex_free(e);
+ }
+ return res;
}
/** \ingroup msg_gos_functions
* \param nb_elem is the size of the comm vector
* \param timeout for each call of MSG_comm_wait
*/
-void MSG_comm_waitall(msg_comm_t *comm,int nb_elem, double timeout) {
- int i=0;
- for(i=0; i<nb_elem; i++)
- {
- MSG_comm_wait(comm[i],timeout);
- }
+void MSG_comm_waitall(msg_comm_t * comm, int nb_elem, double timeout)
+{
+ int i = 0;
+ for (i = 0; i < nb_elem; i++) {
+ MSG_comm_wait(comm[i], timeout);
+ }
}
+
/** \ingroup msg_gos_functions
* \brief This function wait for the first completed communication
*
* \param comms a vector of communication
* \return the position of the completed communication from the xbt_dynar_t.
*/
-int MSG_comm_waitany(xbt_dynar_t comms) {
- return SIMIX_network_waitany(comms);
+int MSG_comm_waitany(xbt_dynar_t comms)
+{
+ return SIMIX_network_waitany(comms);
}
-m_task_t MSG_comm_get_task(msg_comm_t comm) {
- xbt_assert0(comm, "Invalid parameters");
- return (m_task_t) SIMIX_communication_get_src_buf(comm);
+m_task_t MSG_comm_get_task(msg_comm_t comm)
+{
+ xbt_assert0(comm, "Invalid parameters");
+ return (m_task_t) SIMIX_communication_get_src_buf(comm);
}
/** \ingroup msg_gos_functions
*/
MSG_error_t MSG_task_put(m_task_t task, m_host_t dest, m_channel_t channel)
{
- return MSG_task_put_with_timeout(task, dest, channel, -1.0);
+ return MSG_task_put_with_timeout(task, dest, channel, -1.0);
}
/** \ingroup msg_gos_functions
*
* \sa MSG_task_put
*/
- MSG_error_t
+MSG_error_t
MSG_task_put_bounded(m_task_t task, m_host_t dest, m_channel_t channel,
- double maxrate)
+ double maxrate)
{
- task->simdata->rate = maxrate;
- return MSG_task_put(task, dest, channel);
+ task->simdata->rate = maxrate;
+ return MSG_task_put(task, dest, channel);
}
/** \ingroup msg_gos_functions \brief Put a task on a channel of an
#MSG_TRANSFER_FAILURE if the transfer could not be properly done
(network failure, dest failure, timeout...)
*/
- MSG_error_t
-MSG_task_put_with_timeout(m_task_t task, m_host_t dest, m_channel_t channel,
- double timeout)
+MSG_error_t
+MSG_task_put_with_timeout(m_task_t task, m_host_t dest,
+ m_channel_t channel, double timeout)
{
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- return
- MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_channel(dest, channel),
- task, timeout);
+ return
+ MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_channel
+ (dest, channel), task, timeout);
}
MSG_error_t MSG_task_send(m_task_t task, const char *alias)
{
- DEBUG1("MSG_task_send: Trying to send a message on mailbox '%s'",alias);
- return MSG_task_send_with_timeout(task, alias, -1);
+ DEBUG1("MSG_task_send: Trying to send a message on mailbox '%s'", alias);
+ return MSG_task_send_with_timeout(task, alias, -1);
}
- MSG_error_t
+MSG_error_t
MSG_task_send_bounded(m_task_t task, const char *alias, double maxrate)
{
- task->simdata->rate = maxrate;
- return MSG_task_send(task, alias);
+ task->simdata->rate = maxrate;
+ return MSG_task_send(task, alias);
}
- MSG_error_t
-MSG_task_send_with_timeout(m_task_t task, const char *alias, double timeout)
+MSG_error_t
+MSG_task_send_with_timeout(m_task_t task, const char *alias,
+ double timeout)
{
- return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias), task,
- timeout);
+ return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias),
+ task, timeout);
}
int MSG_task_listen(const char *alias)
{
- CHECK_HOST();
+ CHECK_HOST();
- return !MSG_mailbox_is_empty(MSG_mailbox_get_by_alias(alias));
+ return !MSG_mailbox_is_empty(MSG_mailbox_get_by_alias(alias));
}
/** \ingroup msg_gos_functions
*/
int MSG_task_Iprobe(m_channel_t channel)
{
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- CHECK_HOST();
+ CHECK_HOST();
- return
- !MSG_mailbox_is_empty(MSG_mailbox_get_by_channel
- (MSG_host_self(), channel));
+ return
+ !MSG_mailbox_is_empty(MSG_mailbox_get_by_channel
+ (MSG_host_self(), channel));
}
/** \ingroup msg_gos_functions
*/
int MSG_task_probe_from_host(int channel, m_host_t host)
{
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- CHECK_HOST();
+ CHECK_HOST();
- return
- MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_channel
- (MSG_host_self(), channel),
- host);
+ return
+ MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_channel
+ (MSG_host_self(), channel),
+ host);
}
int MSG_task_listen_from_host(const char *alias, m_host_t host)
{
- CHECK_HOST();
+ CHECK_HOST();
- return
- MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias(alias),
- host);
+ return
+ MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias
+ (alias), host);
}
/** \ingroup msg_gos_functions
*/
int MSG_task_probe_from(m_channel_t channel)
{
- m_task_t task;
+ m_task_t task;
- CHECK_HOST();
+ CHECK_HOST();
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- if (NULL ==
- (task =
- MSG_mailbox_get_head(MSG_mailbox_get_by_channel
- (MSG_host_self(), channel))))
- return -1;
+ if (NULL ==
+ (task =
+ MSG_mailbox_get_head(MSG_mailbox_get_by_channel
+ (MSG_host_self(), channel))))
+ return -1;
- return MSG_process_get_PID(task->simdata->sender);
+ return MSG_process_get_PID(task->simdata->sender);
}
int MSG_task_listen_from(const char *alias)
{
- m_task_t task;
+ m_task_t task;
- CHECK_HOST();
+ CHECK_HOST();
- if (NULL == (task = MSG_mailbox_get_head(MSG_mailbox_get_by_alias(alias))))
- return -1;
+ if (NULL ==
+ (task = MSG_mailbox_get_head(MSG_mailbox_get_by_alias(alias))))
+ return -1;
- return MSG_process_get_PID(task->simdata->sender);
+ return MSG_process_get_PID(task->simdata->sender);
}
/** \ingroup msg_gos_functions
* \return #MSG_HOST_FAILURE if the host is shut down in the meantime
and #MSG_OK otherwise.
*/
- MSG_error_t
+MSG_error_t
MSG_channel_select_from(m_channel_t channel, double timeout, int *PID)
{
- m_host_t h = NULL;
- simdata_host_t h_simdata = NULL;
- m_task_t t;
- int first_time = 1;
- smx_cond_t cond;
- msg_mailbox_t mailbox;
+ m_host_t h = NULL;
+ simdata_host_t h_simdata = NULL;
+ m_task_t t;
+ int first_time = 1;
+ smx_cond_t cond;
+ msg_mailbox_t mailbox;
- xbt_assert1((channel >= 0)
- && (channel < msg_global->max_channel), "Invalid channel %d",
- channel);
+ xbt_assert1((channel >= 0)
+ && (channel < msg_global->max_channel), "Invalid channel %d",
+ channel);
- if (PID) {
- *PID = -1;
- }
+ if (PID) {
+ *PID = -1;
+ }
- if (timeout == 0.0) {
- *PID = MSG_task_probe_from(channel);
- MSG_RETURN(MSG_OK);
- } else {
- CHECK_HOST();
- h = MSG_host_self();
- h_simdata = h->simdata;
+ if (timeout == 0.0) {
+ *PID = MSG_task_probe_from(channel);
+ MSG_RETURN(MSG_OK);
+ } else {
+ CHECK_HOST();
+ h = MSG_host_self();
+ h_simdata = h->simdata;
- mailbox = MSG_mailbox_get_by_channel(MSG_host_self(), channel);
+ mailbox = MSG_mailbox_get_by_channel(MSG_host_self(), channel);
- while (MSG_mailbox_is_empty(mailbox)) {
- if (timeout > 0) {
- if (!first_time) {
- MSG_RETURN(MSG_OK);
- }
- }
+ while (MSG_mailbox_is_empty(mailbox)) {
+ if (timeout > 0) {
+ if (!first_time) {
+ MSG_RETURN(MSG_OK);
+ }
+ }
- SIMIX_mutex_lock(h_simdata->mutex);
+ SIMIX_mutex_lock(h_simdata->mutex);
- xbt_assert1(!MSG_mailbox_get_cond(mailbox),
- "A process is already blocked on this channel %d", channel);
+ xbt_assert1(!MSG_mailbox_get_cond(mailbox),
+ "A process is already blocked on this channel %d",
+ channel);
- cond = SIMIX_cond_init();
+ cond = SIMIX_cond_init();
- MSG_mailbox_set_cond(mailbox, cond);
+ MSG_mailbox_set_cond(mailbox, cond);
- if (timeout > 0) {
- SIMIX_cond_wait_timeout(cond, h_simdata->mutex, timeout);
- } else {
- SIMIX_cond_wait(cond, h_simdata->mutex);
- }
+ if (timeout > 0) {
+ SIMIX_cond_wait_timeout(cond, h_simdata->mutex, timeout);
+ } else {
+ SIMIX_cond_wait(cond, h_simdata->mutex);
+ }
- SIMIX_cond_destroy(cond);
- SIMIX_mutex_unlock(h_simdata->mutex);
+ SIMIX_cond_destroy(cond);
+ SIMIX_mutex_unlock(h_simdata->mutex);
- if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
- MSG_RETURN(MSG_HOST_FAILURE);
- }
+ if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
+ MSG_RETURN(MSG_HOST_FAILURE);
+ }
- MSG_mailbox_set_cond(mailbox, NULL);
- first_time = 0;
- }
+ MSG_mailbox_set_cond(mailbox, NULL);
+ first_time = 0;
+ }
- if (NULL == (t = MSG_mailbox_get_head(mailbox)))
- MSG_RETURN(MSG_OK);
+ if (NULL == (t = MSG_mailbox_get_head(mailbox)))
+ MSG_RETURN(MSG_OK);
- if (PID) {
- *PID = MSG_process_get_PID(t->simdata->sender);
- }
+ if (PID) {
+ *PID = MSG_process_get_PID(t->simdata->sender);
+ }
- MSG_RETURN(MSG_OK);
- }
+ MSG_RETURN(MSG_OK);
+ }
}
-MSG_error_t MSG_alias_select_from(const char *alias, double timeout, int *PID)
+MSG_error_t MSG_alias_select_from(const char *alias, double timeout,
+ int *PID)
{
- m_host_t h = NULL;
- simdata_host_t h_simdata = NULL;
- m_task_t t;
- int first_time = 1;
- smx_cond_t cond;
- msg_mailbox_t mailbox;
+ m_host_t h = NULL;
+ simdata_host_t h_simdata = NULL;
+ m_task_t t;
+ int first_time = 1;
+ smx_cond_t cond;
+ msg_mailbox_t mailbox;
- if (PID) {
- *PID = -1;
- }
+ if (PID) {
+ *PID = -1;
+ }
- if (timeout == 0.0) {
- *PID = MSG_task_listen_from(alias);
- MSG_RETURN(MSG_OK);
- } else {
- CHECK_HOST();
- h = MSG_host_self();
- h_simdata = h->simdata;
+ if (timeout == 0.0) {
+ *PID = MSG_task_listen_from(alias);
+ MSG_RETURN(MSG_OK);
+ } else {
+ CHECK_HOST();
+ h = MSG_host_self();
+ h_simdata = h->simdata;
- DEBUG2("Probing on alias %s (%s)", alias, h->name);
+ DEBUG2("Probing on alias %s (%s)", alias, h->name);
- mailbox = MSG_mailbox_get_by_alias(alias);
+ mailbox = MSG_mailbox_get_by_alias(alias);
- while (MSG_mailbox_is_empty(mailbox)) {
- if (timeout > 0) {
- if (!first_time) {
- MSG_RETURN(MSG_OK);
- }
- }
+ while (MSG_mailbox_is_empty(mailbox)) {
+ if (timeout > 0) {
+ if (!first_time) {
+ MSG_RETURN(MSG_OK);
+ }
+ }
- SIMIX_mutex_lock(h_simdata->mutex);
+ SIMIX_mutex_lock(h_simdata->mutex);
- xbt_assert1(!MSG_mailbox_get_cond(mailbox),
- "A process is already blocked on this alias %s", alias);
+ xbt_assert1(!MSG_mailbox_get_cond(mailbox),
+ "A process is already blocked on this alias %s", alias);
- cond = SIMIX_cond_init();
+ cond = SIMIX_cond_init();
- MSG_mailbox_set_cond(mailbox, cond);
+ MSG_mailbox_set_cond(mailbox, cond);
- if (timeout > 0) {
- SIMIX_cond_wait_timeout(cond, h_simdata->mutex, timeout);
- } else {
- SIMIX_cond_wait(cond, h_simdata->mutex);
- }
+ if (timeout > 0) {
+ SIMIX_cond_wait_timeout(cond, h_simdata->mutex, timeout);
+ } else {
+ SIMIX_cond_wait(cond, h_simdata->mutex);
+ }
- SIMIX_cond_destroy(cond);
- SIMIX_mutex_unlock(h_simdata->mutex);
+ SIMIX_cond_destroy(cond);
+ SIMIX_mutex_unlock(h_simdata->mutex);
- if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
- MSG_RETURN(MSG_HOST_FAILURE);
- }
+ if (SIMIX_host_get_state(h_simdata->smx_host) == 0) {
+ MSG_RETURN(MSG_HOST_FAILURE);
+ }
- MSG_mailbox_set_cond(mailbox, NULL);
- first_time = 0;
- }
+ MSG_mailbox_set_cond(mailbox, NULL);
+ first_time = 0;
+ }
- if (NULL == (t = MSG_mailbox_get_head(mailbox)))
- MSG_RETURN(MSG_OK);
+ if (NULL == (t = MSG_mailbox_get_head(mailbox)))
+ MSG_RETURN(MSG_OK);
- if (PID) {
- *PID = MSG_process_get_PID(t->simdata->sender);
- }
+ if (PID) {
+ *PID = MSG_process_get_PID(t->simdata->sender);
+ }
- MSG_RETURN(MSG_OK);
- }
+ MSG_RETURN(MSG_OK);
+ }
}
/* arg is a pointer to a simix process, we can get the msg process with the field data */
m_process_t proc = ((smx_process_t) arg)->data;
#ifdef HAVE_TRACING
- TRACE_msg_process_end (proc);
+ TRACE_msg_process_end(proc);
#endif
xbt_fifo_remove(msg_global->process_list, proc);
SIMIX_process_cleanup(arg);
xbt_dict_t properties)
{
m_host_t host = MSG_get_host_by_name(hostname);
- return (void *) MSG_process_create_with_environment(name, code, data, host,
- argc, argv, properties);
+ return (void *) MSG_process_create_with_environment(name, code, data,
+ host, argc, argv,
+ properties);
}
/** \ingroup m_process_management
void _MSG_process_kill_from_SIMIX(void *p)
{
#ifdef HAVE_TRACING
- TRACE_msg_process_kill ((m_process_t) p);
+ TRACE_msg_process_kill((m_process_t) p);
#endif
MSG_process_kill((m_process_t) p);
}
simdata_process_t p_simdata = process->simdata;
#ifdef HAVE_TRACING
- TRACE_msg_process_kill (process);
+ TRACE_msg_process_kill(process);
#endif
DEBUG3("Killing %s(%d) on %s",
process->name, p_simdata->PID, p_simdata->m_host->name);
if (p_simdata->waiting_task && p_simdata->waiting_task->simdata->comm) {
- SIMIX_communication_cancel(p_simdata->waiting_task->simdata->comm);
+ SIMIX_communication_cancel(p_simdata->waiting_task->simdata->comm);
}
-
+
if (p_simdata->waiting_action) {
DEBUG1("Canceling waiting task %s",
SIMIX_action_get_name(p_simdata->waiting_action));
SIMIX_action_cancel(p_simdata->waiting_action);
- }
-
+ }
+
xbt_fifo_remove(msg_global->process_list, process);
SIMIX_process_kill(process->simdata->s_process);
m_host_t now = process->simdata->m_host;
process->simdata->m_host = host;
#ifdef HAVE_TRACING
- TRACE_msg_process_change_host (process, now, host);
+ TRACE_msg_process_change_host(process, now, host);
#endif
SIMIX_process_change_host(process->simdata->s_process, now->name,
host->name);
CHECK_HOST();
#ifdef HAVE_TRACING
- TRACE_msg_process_suspend (process);
+ TRACE_msg_process_suspend(process);
#endif
SIMIX_process_suspend(process->simdata->s_process);
CHECK_HOST();
#ifdef HAVE_TRACING
- TRACE_msg_process_resume (process);
+ TRACE_msg_process_resume(process);
#endif
SIMIX_process_resume(process->simdata->s_process);
/*
* Initialization of the mailbox module.
*/
- void MSG_mailbox_mod_init(void);
+void MSG_mailbox_mod_init(void);
/*
* Terminaison of the mailbox module.
*/
- void MSG_mailbox_mod_exit(void);
+void MSG_mailbox_mod_exit(void);
/*! \brief MSG_mailbox_new - create a new mailbox.
* \return The newly created mailbox.
*/
XBT_PUBLIC(msg_mailbox_t)
- MSG_mailbox_new(const char *alias);
+ MSG_mailbox_new(const char *alias);
/*! \brief MSG_mailbox_create - create a new mailbox.
*
*
* \return The newly created mailbox.
*/
- msg_mailbox_t MSG_mailbox_create(const char *alias);
+msg_mailbox_t MSG_mailbox_create(const char *alias);
/* \brief MSG_mailbox_free - release a mailbox from the memory.
*
*
* \see MSG_mailbox_destroy.
*/
- void MSG_mailbox_free(void *mailbox);
+void MSG_mailbox_free(void *mailbox);
/* \brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
*
* or a new mailbox if the key does not match.
*/
XBT_PUBLIC(msg_mailbox_t)
- MSG_mailbox_get_by_alias(const char *alias);
+ MSG_mailbox_get_by_alias(const char *alias);
/* \brief MSG_mailbox_get_by_channel - get a mailbox of the specified host from its channel.
*
*
*/
XBT_PUBLIC(msg_mailbox_t)
- MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
+ MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel);
/*! \brief MSG_mailbox_get_alias - get the alias associated with the mailbox.
*
* \return The simix condition of the mailbox specified by the parameter mailbox.
*/
XBT_PUBLIC(smx_cond_t)
- MSG_mailbox_get_cond(msg_mailbox_t mailbox);
+ MSG_mailbox_get_cond(msg_mailbox_t mailbox);
/*! \brief MSG_mailbox_set_cond - set the simix condition of a mailbox.
*
* \param cond The new simix condition of the mailbox.
*
*/
-XBT_PUBLIC(void) MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond);
+XBT_PUBLIC(void) MSG_mailbox_set_cond(msg_mailbox_t mailbox,
+ smx_cond_t cond);
/*! \brief MSG_mailbox_is_empty - test if a mailbox is empty.
*
* \return The task at the head of the mailbox.
*/
XBT_PUBLIC(m_task_t)
- MSG_mailbox_get_head(msg_mailbox_t mailbox);
+ 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.
SG_END_DECL()
-#endif /* !SMX_MAILBOX_H */
+#endif /* !SMX_MAILBOX_H */
#include "xbt/str.h"
#include "xbt/dynar.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action,msg,"MSG actions for trace driven simulation");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg,
+ "MSG actions for trace driven simulation");
static xbt_dict_t action_funs;
static xbt_dict_t action_queues;
/* To split the file if a unique one is given (specific variable for the other case live in runner()) */
-static FILE *action_fp=NULL;
+static FILE *action_fp = NULL;
static char *action_line = NULL;
static size_t action_len = 0;
xbt_dict_remove(action_funs, action_name);
}
-static int MSG_action_runner(int argc, char *argv[]) {
- xbt_dynar_t evt=NULL;
+static int MSG_action_runner(int argc, char *argv[])
+{
+ xbt_dynar_t evt = NULL;
char *line = NULL;
size_t line_len = 0;
FILE *fp = NULL;
char *comment = NULL;
char *evtname = NULL;
ssize_t read;
- if (action_fp) { // A unique trace file
+ if (action_fp) { // A unique trace file
while ((evt = action_get_action(argv[0]))) {
msg_action_fun function =
(*function) (evt);
xbt_dynar_free(&evt);
}
- } else { // Should have got my trace file in argument
- xbt_assert1(argc>=2,
- "No '%s' agent function provided, no simulation-wide trace file provided to MSG_action_trace_run(), "
- "and no process-wide trace file provided in deployment file. Aborting.",argv[0]
- );
+ } else { // Should have got my trace file in argument
+ xbt_assert1(argc >= 2,
+ "No '%s' agent function provided, no simulation-wide trace file provided to MSG_action_trace_run(), "
+ "and no process-wide trace file provided in deployment file. Aborting.",
+ argv[0]
+ );
fp = fopen(argv[1], "r");
- xbt_assert2(fp != NULL, "Cannot open %s: %s", argv[1], strerror(errno));
+ xbt_assert2(fp != NULL, "Cannot open %s: %s", argv[1],
+ strerror(errno));
// Read lines and execute them until I reach the end of file
while ((read = getline(&line, &line_len, fp)) != -1) {
evt = xbt_str_split_quoted(line);
evtname = xbt_dynar_get_as(evt, 0, char *);
- if (!strcmp(argv[0],evtname)) {
+ if (!strcmp(argv[0], evtname)) {
msg_action_fun function =
xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
(*function) (evt);
} else {
- WARN1("Ignore trace element not for me: %s",xbt_str_join(evt," "));
+ WARN1("Ignore trace element not for me: %s",
+ xbt_str_join(evt, " "));
}
xbt_dynar_free(&evt);
}
MSG_function_register_default(MSG_action_runner);
}
-void _MSG_action_exit() {
+void _MSG_action_exit()
+{
xbt_dict_free(&action_queues);
xbt_dict_free(&action_funs);
}
-static xbt_dynar_t action_get_action(char *name) {
+static xbt_dynar_t action_get_action(char *name)
+{
ssize_t read;
- xbt_dynar_t evt=NULL;
+ xbt_dynar_t evt = NULL;
char *evtname = NULL;
- xbt_dynar_t myqueue = xbt_dict_get_or_null(action_queues,name);
- if (myqueue==NULL || xbt_dynar_length(myqueue)==0) { // nothing stored for me. Read the file further
+ xbt_dynar_t myqueue = xbt_dict_get_or_null(action_queues, name);
+ if (myqueue == NULL || xbt_dynar_length(myqueue) == 0) { // nothing stored for me. Read the file further
- if (action_fp==NULL) { // File closed now. There's nothing more to read. I'm out of here
+ if (action_fp == NULL) { // File closed now. There's nothing more to read. I'm out of here
goto todo_done;
}
-
// Read lines until I reach something for me (which breaks in loop body)
// or end of file reached
while ((read = getline(&action_line, &action_len, action_fp)) != -1) {
// if it's for me, I'm done
evtname = xbt_dynar_get_as(evt, 0, char *);
- if (!strcmp(name,evtname)) {
+ if (!strcmp(name, evtname)) {
return evt;
} else {
// Else, I have to store it for the relevant colleague
- xbt_dynar_t otherqueue = xbt_dict_get_or_null(action_queues,evtname);
- if (otherqueue == NULL) { // Damn. Create the queue of that guy
- otherqueue = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
- xbt_dict_set(action_queues ,evtname, otherqueue, NULL);
+ xbt_dynar_t otherqueue =
+ xbt_dict_get_or_null(action_queues, evtname);
+ if (otherqueue == NULL) { // Damn. Create the queue of that guy
+ otherqueue =
+ xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
+ xbt_dict_set(action_queues, evtname, otherqueue, NULL);
}
- xbt_dynar_push(otherqueue,&evt);
+ xbt_dynar_push(otherqueue, &evt);
}
}
- goto todo_done; // end of file reached while searching in vain for more work
+ goto todo_done; // end of file reached while searching in vain for more work
} else {
// Get something from my queue and return it
- xbt_dynar_shift(myqueue,&evt);
+ xbt_dynar_shift(myqueue, &evt);
return evt;
}
// I did all my actions for me in the file (either I closed the file, or a colleague did)
// Let's cleanup before leaving
- todo_done:
+todo_done:
if (myqueue != NULL) {
xbt_dynar_free(&myqueue);
- xbt_dict_remove(action_queues,name);
+ xbt_dict_remove(action_queues, name);
}
return NULL;
}
MSG_error_t MSG_action_trace_run(char *path)
{
MSG_error_t res;
- char *name;
- xbt_dynar_t todo;
- xbt_dict_cursor_t cursor;
+ char *name;
+ xbt_dynar_t todo;
+ xbt_dict_cursor_t cursor;
if (path) {
action_fp = fopen(path, "r");
- xbt_assert2(action_fp != NULL, "Cannot open %s: %s", path, strerror(errno));
+ xbt_assert2(action_fp != NULL, "Cannot open %s: %s", path,
+ strerror(errno));
}
res = MSG_main();
if (xbt_dict_size(action_queues)) {
- WARN0("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file.");
+ WARN0
+ ("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file.");
- xbt_dict_foreach(action_queues,cursor,name,todo) {
- WARN2("Still %lu actions for %s",xbt_dynar_length(todo),name);
+ xbt_dict_foreach(action_queues, cursor, name, todo) {
+ WARN2("Still %lu actions for %s", xbt_dynar_length(todo), name);
}
}
mailbox->cond = NULL;
mailbox->alias = alias ? xbt_strdup(alias) : NULL;
mailbox->rdv = SIMIX_rdv_create(alias);
-
+
return mailbox;
}
free(_mailbox->alias);
SIMIX_rdv_destroy(_mailbox->rdv);
-
+
free(_mailbox);
}
{
smx_comm_t comm = SIMIX_rdv_get_head(mailbox->rdv);
- if(!comm)
- return NULL;
-
- return (m_task_t)SIMIX_communication_get_data(comm);
+ if (!comm)
+ return NULL;
+
+ return (m_task_t) SIMIX_communication_get_data(comm);
}
int
-MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, m_host_t host)
+MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox,
+ m_host_t host)
{
- return SIMIX_rdv_get_count_waiting_comm (mailbox->rdv, host->simdata->smx_host);
+ return SIMIX_rdv_get_count_waiting_comm(mailbox->rdv,
+ host->simdata->smx_host);
}
void MSG_mailbox_set_cond(msg_mailbox_t mailbox, smx_cond_t cond)
return mailbox;
}
-msg_mailbox_t MSG_mailbox_get_by_channel(m_host_t host, m_channel_t channel)
+msg_mailbox_t MSG_mailbox_get_by_channel(m_host_t host,
+ m_channel_t channel)
{
xbt_assert0((host != NULL), "Invalid host");
xbt_assert1((channel >= 0)
}
MSG_error_t
-MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host,
- double timeout)
+MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task,
+ m_host_t host, double timeout)
{
xbt_ex_t e;
MSG_error_t ret = MSG_OK;
double start_time = 0;
#endif
/* We no longer support getting a task from a specific host */
- if (host) THROW_UNIMPLEMENTED;
+ if (host)
+ THROW_UNIMPLEMENTED;
CHECK_HOST();
#ifdef HAVE_TRACING
- TRACE_msg_task_get_start ();
+ TRACE_msg_task_get_start();
start_time = MSG_get_clock();
#endif
- memset(&comm,0,sizeof(comm));
+ memset(&comm, 0, sizeof(comm));
/* Kept for compatibility with older implementation */
xbt_assert1(!MSG_mailbox_get_cond(mailbox),
- "A process is already blocked on this channel %s",
+ "A process is already blocked on this channel %s",
MSG_mailbox_get_alias(mailbox));
/* Sanity check */
xbt_assert0(task, "Null pointer for the task storage");
if (*task)
- CRITICAL0("MSG_task_get() was asked to write in a non empty task struct.");
+ CRITICAL0
+ ("MSG_task_get() was asked to write in a non empty task struct.");
/* Try to receive it by calling SIMIX network layer */
- TRY{
+ TRY {
SIMIX_network_recv(mailbox->rdv, timeout, task, NULL, &comm);
//INFO2("Got task %s from %s",(*task)->name,mailbox->alias);
(*task)->simdata->refcount--;
}
- CATCH(e){
- switch(e.category){
- case host_error:
- ret = MSG_HOST_FAILURE;
- break;
- case network_error:
- ret = MSG_TRANSFER_FAILURE;
- break;
- case timeout_error:
- ret = MSG_TIMEOUT;
- break;
- default:
- xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
+ CATCH(e) {
+ switch (e.category) {
+ case host_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ ret = MSG_TIMEOUT;
+ break;
+ default:
+ xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg));
}
- xbt_ex_free(e);
+ xbt_ex_free(e);
}
if (ret != MSG_HOST_FAILURE &&
- ret != MSG_TRANSFER_FAILURE &&
- ret != MSG_TIMEOUT){
+ ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
#ifdef HAVE_TRACING
- TRACE_msg_task_get_end (start_time, *task);
+ TRACE_msg_task_get_end(start_time, *task);
#endif
}
- MSG_RETURN(ret);
+ MSG_RETURN(ret);
}
MSG_error_t
CHECK_HOST();
#ifdef HAVE_TRACING
- call_end = TRACE_msg_task_put_start (task); //must be after CHECK_HOST()
+ call_end = TRACE_msg_task_put_start(task); //must be after CHECK_HOST()
#endif
msg_global->sent_msg++;
process->simdata->waiting_task = task;
-
+
/* Try to send it by calling SIMIX network layer */
- TRY{
+ TRY {
/* Kept for semantical compatibility with older implementation */
- if(mailbox->cond)
+ if (mailbox->cond)
SIMIX_cond_signal(mailbox->cond);
- SIMIX_network_send(mailbox->rdv, t_simdata->message_size, t_simdata->rate,
- timeout, task, sizeof(void*), &t_simdata->comm, task);
+ SIMIX_network_send(mailbox->rdv, t_simdata->message_size,
+ t_simdata->rate, timeout, task, sizeof(void *),
+ &t_simdata->comm, task);
}
- CATCH(e){
- switch(e.category){
- case host_error:
- ret = MSG_HOST_FAILURE;
- break;
- case network_error:
- ret = MSG_TRANSFER_FAILURE;
- break;
- case timeout_error:
- ret = MSG_TIMEOUT;
- break;
- default:
- xbt_die(bprintf("Unhandled SIMIX network exception: %s",e.msg));
+ CATCH(e) {
+ switch (e.category) {
+ case host_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ ret = MSG_TIMEOUT;
+ break;
+ default:
+ xbt_die(bprintf("Unhandled SIMIX network exception: %s", e.msg));
}
xbt_ex_free(e);
process->simdata->waiting_task = NULL;
#ifdef HAVE_TRACING
- if (call_end) TRACE_msg_task_put_end ();
+ if (call_end)
+ TRACE_msg_task_put_end();
#endif
- MSG_RETURN(ret);
+ MSG_RETURN(ret);
}
/**************** datatypes **********************************/
/* this structure represents a mailbox */
- typedef struct s_msg_mailbox {
- char *alias; /* the key of the mailbox in the global dictionary */
- smx_cond_t cond; /* the condition on the mailbox */
- smx_rdv_t rdv; /* SIMIX rendez-vous point */
- } s_msg_mailbox_t;
-
- typedef struct simdata_host {
- smx_host_t smx_host; /* SURF modeling */
- struct s_msg_mailbox **mailboxes; /* mailboxes to store msg tasks of of the host */
- smx_mutex_t mutex; /* mutex to access the host */
- } s_simdata_host_t;
+typedef struct s_msg_mailbox {
+ char *alias; /* the key of the mailbox in the global dictionary */
+ smx_cond_t cond; /* the condition on the mailbox */
+ smx_rdv_t rdv; /* SIMIX rendez-vous point */
+} s_msg_mailbox_t;
+
+typedef struct simdata_host {
+ smx_host_t smx_host; /* SURF modeling */
+ struct s_msg_mailbox **mailboxes; /* mailboxes to store msg tasks of of the host */
+ smx_mutex_t mutex; /* mutex to access the host */
+} s_simdata_host_t;
/********************************* Task **************************************/
- typedef struct simdata_task {
- smx_action_t compute; /* SURF modeling of computation */
- smx_comm_t comm; /* SIMIX communication */
- double message_size; /* Data size */
- double computation_amount; /* Computation size */
- smx_cond_t cond;
- smx_mutex_t mutex; /* Task mutex */
- m_process_t sender;
- m_process_t receiver;
- m_host_t source;
- double priority;
- double rate;
- int refcount;
- int host_nb; /* ==0 if sequential task; parallel task if not */
+typedef struct simdata_task {
+ smx_action_t compute; /* SURF modeling of computation */
+ smx_comm_t comm; /* SIMIX communication */
+ double message_size; /* Data size */
+ double computation_amount; /* Computation size */
+ smx_cond_t cond;
+ smx_mutex_t mutex; /* Task mutex */
+ m_process_t sender;
+ m_process_t receiver;
+ m_host_t source;
+ double priority;
+ double rate;
+ int refcount;
+ int host_nb; /* ==0 if sequential task; parallel task if not */
/******* Parallel Tasks Only !!!! *******/
- smx_host_t *host_list;
- double *comp_amount;
- double *comm_amount;
- } s_simdata_task_t;
+ smx_host_t *host_list;
+ double *comp_amount;
+ double *comm_amount;
+} s_simdata_task_t;
/******************************* Process *************************************/
- typedef struct simdata_process {
- m_host_t m_host; /* the host on which the process is running */
- smx_process_t s_process;
- int PID; /* used for debugging purposes */
- int PPID; /* The parent PID */
- m_host_t put_host; /* used for debugging purposes */
- m_channel_t put_channel; /* used for debugging purposes */
- smx_action_t waiting_action;
- m_task_t waiting_task;
- int argc; /* arguments number if any */
- char **argv; /* arguments table if any */
- MSG_error_t last_errno; /* the last value returned by a MSG_function */
- } s_simdata_process_t;
-
- typedef struct process_arg {
- const char *name;
- xbt_main_func_t code;
- void *data;
- m_host_t m_host;
- int argc;
- char **argv;
- double kill_time;
- } s_process_arg_t, *process_arg_t;
+typedef struct simdata_process {
+ m_host_t m_host; /* the host on which the process is running */
+ smx_process_t s_process;
+ int PID; /* used for debugging purposes */
+ int PPID; /* The parent PID */
+ m_host_t put_host; /* used for debugging purposes */
+ m_channel_t put_channel; /* used for debugging purposes */
+ smx_action_t waiting_action;
+ m_task_t waiting_task;
+ int argc; /* arguments number if any */
+ char **argv; /* arguments table if any */
+ MSG_error_t last_errno; /* the last value returned by a MSG_function */
+} s_simdata_process_t;
+
+typedef struct process_arg {
+ const char *name;
+ xbt_main_func_t code;
+ void *data;
+ m_host_t m_host;
+ int argc;
+ char **argv;
+ double kill_time;
+} s_process_arg_t, *process_arg_t;
/************************** Global variables ********************************/
- typedef struct MSG_Global {
- xbt_fifo_t host;
- xbt_fifo_t process_list;
- int max_channel;
- int PID;
- int session;
- unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
- } s_MSG_Global_t, *MSG_Global_t;
+typedef struct MSG_Global {
+ xbt_fifo_t host;
+ xbt_fifo_t process_list;
+ int max_channel;
+ int PID;
+ int session;
+ unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
+} s_MSG_Global_t, *MSG_Global_t;
/*extern MSG_Global_t msg_global;*/
XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
#define CHECK_HOST() xbt_assert1(SIMIX_host_get_state(SIMIX_host_self())==1,\
"Host failed, you cannot call this function. (state=%d)",SIMIX_host_get_state(SIMIX_host_self()))
- m_host_t __MSG_host_create(smx_host_t workstation, void *data);
+m_host_t __MSG_host_create(smx_host_t workstation, void *data);
- void __MSG_host_destroy(m_host_t host);
+void __MSG_host_destroy(m_host_t host);
- void __MSG_display_process_status(void);
+void __MSG_display_process_status(void);
- void __MSG_process_cleanup(void *arg);
- void *_MSG_process_create_from_SIMIX(const char *name,
- xbt_main_func_t code, void *data,
- char *hostname, int argc,
- char **argv, xbt_dict_t properties);
- void _MSG_process_kill_from_SIMIX(void *p);
+void __MSG_process_cleanup(void *arg);
+void *_MSG_process_create_from_SIMIX(const char *name,
+ xbt_main_func_t code, void *data,
+ char *hostname, int argc,
+ char **argv, xbt_dict_t properties);
+void _MSG_process_kill_from_SIMIX(void *p);
- void _MSG_action_init(void);
- void _MSG_action_exit(void);
+void _MSG_action_init(void);
+void _MSG_action_exit(void);
SG_END_DECL()
#endif
* <em>message size</em> and some <em>private data</em>.
*/
-#ifdef HAVE_RUBY /* FIXME: KILLME */
+#ifdef HAVE_RUBY /* FIXME: KILLME */
XBT_LOG_EXTERNAL_CATEGORY(ruby);
#endif
simdata->comp_amount = NULL;
simdata->comm_amount = NULL;
#ifdef HAVE_TRACING
- TRACE_msg_task_create (task);
+ TRACE_msg_task_create(task);
#endif
return task;
* This function allows to associate a new pointer to
the user data associated of \a task.
*/
-void MSG_task_set_data(m_task_t task,void *data)
+void MSG_task_set_data(m_task_t task, void *data)
{
xbt_assert0((task != NULL), "Invalid parameter");
*
* This functions allows to associate a name to a task
*/
-void MSG_task_set_name(m_task_t task,const char* name)
+void MSG_task_set_name(m_task_t task, const char *name)
{
- xbt_assert0(task,"Invalid parameters");
- task->name = xbt_strdup(name);
+ xbt_assert0(task, "Invalid parameters");
+ task->name = xbt_strdup(name);
}
if (task->simdata->refcount > 0)
return MSG_OK;
#ifdef HAVE_TRACING
- TRACE_msg_task_destroy (task);
+ TRACE_msg_task_destroy(task);
#endif
if (task->name)
action = task->simdata->compute;
if (action)
SIMIX_action_destroy(action);
-
+
/* parallel tasks only */
if (task->simdata->host_list)
xbt_free(task->simdata->host_list);
* \brief set the computation amount needed to process a task #m_task_t.
*/
-void MSG_task_set_compute_duration(m_task_t task,double computation_amount)
+void MSG_task_set_compute_duration(m_task_t task,
+ double computation_amount)
{
- xbt_assert0(task,"Invalid parameter");
- task->simdata->computation_amount = computation_amount;
+ xbt_assert0(task, "Invalid parameter");
+ task->simdata->computation_amount = computation_amount;
}
+
/** \ingroup m_task_management
* \brief Returns the remaining computation amount of a task #m_task_t.
*
{
xbt_assert0((task != NULL)
&& (task->simdata != NULL), "Invalid parameter");
- DEBUG1("calling SIMIX_communication_get_remains(%p)", task->simdata->comm);
+ DEBUG1("calling SIMIX_communication_get_remains(%p)",
+ task->simdata->comm);
return SIMIX_communication_get_remains(task->simdata->comm);
}
*/
int MSG_task_is_latency_bounded(m_task_t task)
{
- xbt_assert0((task != NULL)
- && (task->simdata != NULL), "Invalid parameter");
- DEBUG1("calling SIMIX_communication_is_latency_bounded(%p)", task->simdata->comm);
- return SIMIX_communication_is_latency_bounded(task->simdata->comm);
+ xbt_assert0((task != NULL)
+ && (task->simdata != NULL), "Invalid parameter");
+ DEBUG1("calling SIMIX_communication_is_latency_bounded(%p)",
+ task->simdata->comm);
+ return SIMIX_communication_is_latency_bounded(task->simdata->comm);
}
#endif
SIMIX_action_set_priority(task->simdata->compute,
task->simdata->priority);
}
-
-
# else
# define tcp_close( s ) close( s )
# endif
-#endif /* windows or unix ? */
+#endif /* windows or unix ? */
/****
**** File handling
/* use internal functions when OS provided ones are borken */
#if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF)
- extern int portable_snprintf(char *str, size_t str_m, const char *fmt,
- /*args */ ...);
- extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
- va_list ap);
+extern int portable_snprintf(char *str, size_t str_m, const char *fmt,
+ /*args */ ...);
+extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+ va_list ap);
#define snprintf portable_snprintf
#define vsnprintf portable_vsnprintf
#endif
/* prototype of GNU functions */
#if (defined(__GNUC__) && !defined(__cplusplus))
- extern int asprintf(char **ptr, const char *fmt, /*args */ ...);
- extern int vasprintf(char **ptr, const char *fmt, va_list ap);
+extern int asprintf(char **ptr, const char *fmt, /*args */ ...);
+extern int vasprintf(char **ptr, const char *fmt, va_list ap);
#endif
- extern int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args */
- ...);
- extern int vasnprintf(char **ptr, size_t str_m, const char *fmt,
- va_list ap);
+extern int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args */
+ ...);
+extern int vasnprintf(char **ptr, size_t str_m, const char *fmt,
+ va_list ap);
/*
* That's needed to protect solaris's printf from ever seing NULL associated to a %s format
/****
**** Some debugging functions. Can't we find a better place for this??
****/
- void hexa_print(const char *name, unsigned char *data, int size);
- const char *hexa_str(unsigned char *data, int size, int downside);
+void hexa_print(const char *name, unsigned char *data, int size);
+const char *hexa_str(unsigned char *data, int size, int downside);
-#endif /* GRAS_PORTABLE_H */
+#endif /* GRAS_PORTABLE_H */
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 316 "xbt/set.c"
+#line 321 "xbt/set.c"
#include "xbt.h"
#include "xbt/ex.h"
THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
key, elm->name);
if (strcmp(elm->name, elm->data))
- THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key, elm->name);
+ THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key,
+ elm->name);
fflush(stdout);
}
xbt_test_assert0(elm, "Dude ! Got a null elm during traversal!");
xbt_test_log3("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data);
xbt_test_assert2(!strcmp(elm->name, elm->data),
- "Key(%s) != value(%s). Abording", elm->name, elm->data);
+ "Key(%s) != value(%s). Abording", elm->name,
+ elm->data);
}
}
xbt_test_add1("Search %s (expected not to be found)", data);
TRY {
xbt_set_get_by_name(set, data);
- THROW1(unknown_error, 0, "Found something which shouldn't be there (%s)",
- data);
+ THROW1(unknown_error, 0,
+ "Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *dax_text;
-/* Validating XML processor for /home/mquinson/Code/simgrid/src/simdag/dax.dtd.
- * Generated 2010/10/01 22:34:14.
+/* Validating XML processor for /home/alegrand/Work/SimGrid/simgrid-git/src/simdag/dax.dtd.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
/* XML processor/application API for src/simdag/dax.dtd.
- * Generated 2010/10/01 22:34:16.
+ * Generated 2010/10/11 11:35:08.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
-/* Validating XML processor for /home/mquinson/Code/simgrid/src/simdag/dax.dtd.
- * Generated 2010/10/01 22:34:14.
+/* Validating XML processor for /home/alegrand/Work/SimGrid/simgrid-git/src/simdag/dax.dtd.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
double start_time;
double finish_time;
surf_action_t surf_action;
- unsigned short watch_points; /* bit field xor()ed with masks */
+ unsigned short watch_points; /* bit field xor()ed with masks */
int fifo_checked; /* used by SD_task_just_done to make sure we evaluate
the task only once */
double rate;
#ifdef HAVE_TRACING
- char *category; /* sd task category for instrumentation */
+ char *category; /* sd task category for instrumentation */
#endif
} s_SD_task_t;
SD_link_t __SD_link_create(void *surf_link, void *data);
void __SD_link_destroy(void *link);
-SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data);
+SD_workstation_t __SD_workstation_create(void *surf_workstation,
+ void *data);
void __SD_workstation_destroy(void *workstation);
int __SD_workstation_is_busy(SD_workstation_t workstation);
static XBT_INLINE int __SD_task_is_scheduled_or_runnable(SD_task_t task)
{
return task->state_set == sd_global->scheduled_task_set ||
- task->state_set == sd_global->runnable_task_set;
+ task->state_set == sd_global->runnable_task_set;
}
/* Returns whether the given task is scheduled or runnable. */
static XBT_INLINE int __SD_task_is_schedulable_or_done(SD_task_t task)
{
return task->state_set == sd_global->schedulable_task_set ||
- task->state_set == sd_global->done_task_set;
+ task->state_set == sd_global->done_task_set;
}
/* Returns whether the state of the given task is SD_NOT_SCHEDULED. */
static XBT_INLINE int __SD_task_is_runnable_or_in_fifo(SD_task_t task)
{
return task->state_set == sd_global->runnable_task_set ||
- task->state_set == sd_global->in_fifo_task_set;
+ task->state_set == sd_global->in_fifo_task_set;
}
/* Returns whether the state of the given task is SD_RUNNING. */
#include "xbt/misc.h"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd,"Parsing DAX files");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
#undef CLEANUP
#include "dax_dtd.h"
/* Parsing helpers */
-static void dax_parse_error(char *msg) {
+static void dax_parse_error(char *msg)
+{
fprintf(stderr, "Parse error on line %d: %s\n", dax_lineno, msg);
abort();
}
-static double dax_parse_double(const char *string) {
+
+static double dax_parse_double(const char *string)
+{
int ret = 0;
double value;
dax_parse_error(bprintf("%s is not a double", string));
return value;
}
-static int dax_parse_int(const char *string) {
+
+static int dax_parse_int(const char *string)
+{
int ret = 0;
int value;
/* Ensure that transfer tasks have unique names even though a file is used
* several times */
-void uniq_transfer_task_name(SD_task_t task){
- SD_task_t child, parent;
- xbt_dynar_t children, parents;
- char *new_name;
+void uniq_transfer_task_name(SD_task_t task)
+{
+ SD_task_t child, parent;
+ xbt_dynar_t children, parents;
+ char *new_name;
- children = SD_task_get_children(task);
- parents = SD_task_get_parents(task);
+ children = SD_task_get_children(task);
+ parents = SD_task_get_parents(task);
- xbt_dynar_get_cpy(children,0,&child);
- xbt_dynar_get_cpy(parents,0,&parent);
+ xbt_dynar_get_cpy(children, 0, &child);
+ xbt_dynar_get_cpy(parents, 0, &parent);
- new_name = bprintf("%s_%s_%s",
- SD_task_get_name(parent),
- SD_task_get_name(task),
- SD_task_get_name(child));
+ new_name = bprintf("%s_%s_%s",
+ SD_task_get_name(parent),
+ SD_task_get_name(task), SD_task_get_name(child));
- SD_task_set_name (task, new_name);
+ SD_task_set_name(task, new_name);
- xbt_dynar_free_container(&children);
- xbt_dynar_free_container(&parents);
- free(new_name);
+ xbt_dynar_free_container(&children);
+ xbt_dynar_free_container(&parents);
+ free(new_name);
}
static xbt_dict_t jobs;
static xbt_dict_t files;
static SD_task_t current_job;
-static SD_task_t root_task,end_task;
+static SD_task_t root_task, end_task;
-static void dump_res() {
+static void dump_res()
+{
unsigned int cursor;
SD_task_t task;
- xbt_dynar_foreach(result,cursor,task) {
- INFO1("Task %d",cursor);
+ xbt_dynar_foreach(result, cursor, task) {
+ INFO1("Task %d", cursor);
SD_task_dump(task);
}
}
-static void dax_task_free(void*task){
- SD_task_t t=task;
+static void dax_task_free(void *task)
+{
+ SD_task_t t = task;
SD_task_destroy(t);
}
* See https://confluence.pegasus.isi.edu/display/pegasus/WorkflowGenerator
* for more details.
*/
-xbt_dynar_t SD_daxload(const char*filename) {
+xbt_dynar_t SD_daxload(const char *filename)
+{
xbt_dict_cursor_t cursor;
SD_task_t file;
char *name;
- FILE* in_file = fopen(filename,"r");
+ FILE *in_file = fopen(filename, "r");
xbt_assert1(in_file, "Unable to open \"%s\"\n", filename);
input_buffer = dax__create_buffer(in_file, 10);
dax__switch_to_buffer(input_buffer);
dax_lineno = 1;
- result = xbt_dynar_new(sizeof(SD_task_t),dax_task_free);
- files=xbt_dict_new();
- jobs=xbt_dict_new();
- root_task = SD_task_create_comp_seq("root",NULL,0);
+ result = xbt_dynar_new(sizeof(SD_task_t), dax_task_free);
+ files = xbt_dict_new();
+ jobs = xbt_dict_new();
+ root_task = SD_task_create_comp_seq("root", NULL, 0);
/* by design the root task is always SCHEDULABLE */
__SD_task_set_state(root_task, SD_SCHEDULABLE);
- xbt_dynar_push(result,&root_task);
- end_task = SD_task_create_comp_seq("end",NULL,0);
+ xbt_dynar_push(result, &root_task);
+ end_task = SD_task_create_comp_seq("end", NULL, 0);
- xbt_assert2(!dax_lex(),"Parse error in %s: %s",filename,dax__parse_err_msg());
+ xbt_assert2(!dax_lex(), "Parse error in %s: %s", filename,
+ dax__parse_err_msg());
dax__delete_buffer(input_buffer);
fclose(in_file);
xbt_dict_free(&jobs);
* Files not consumed in the system are said to be consumed by end task (bottom of DAG).
*/
- xbt_dict_foreach(files,cursor,name,file) {
- unsigned int cpt1,cpt2;
+ xbt_dict_foreach(files, cursor, name, file) {
+ unsigned int cpt1, cpt2;
SD_task_t newfile = NULL;
- SD_dependency_t depbefore,depafter;
+ SD_dependency_t depbefore, depafter;
if (xbt_dynar_length(file->tasks_before) == 0) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,root_task,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, root_task, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);
}
} else if (xbt_dynar_length(file->tasks_after) == 0) {
- xbt_dynar_foreach(file->tasks_before,cpt2,depbefore) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,end_task);
- xbt_dynar_push(result,&newfile);
+ xbt_dynar_foreach(file->tasks_before, cpt2, depbefore) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, end_task);
+ xbt_dynar_push(result, &newfile);
}
} else {
- xbt_dynar_foreach(file->tasks_before,cpt1,depbefore) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
+ xbt_dynar_foreach(file->tasks_before, cpt1, depbefore) {
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
if (depbefore->src == depafter->dst) {
- WARN2("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
- file->name,depbefore->src->name);
+ WARN2
+ ("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
+ file->name, depbefore->src->name);
}
- newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
+ newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);
}
}
}
}
/* Push end task last */
- xbt_dynar_push(result,&end_task);
+ xbt_dynar_push(result, &end_task);
/* Free previous copy of the files */
xbt_dict_free(&files);
unsigned int cpt;
- xbt_dynar_foreach(result,cpt,file) {
- if (SD_task_get_kind(file)==SD_TASK_COMM_E2E){
- uniq_transfer_task_name(file);
- }
+ xbt_dynar_foreach(result, cpt, file) {
+ if (SD_task_get_kind(file) == SD_TASK_COMM_E2E) {
+ uniq_transfer_task_name(file);
+ }
}
return result;
}
-void STag_dax__adag(void) {
+void STag_dax__adag(void)
+{
double version = dax_parse_double(A_dax__adag_version);
- xbt_assert1((version == 2.1), "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file",version);
+ xbt_assert1((version == 2.1),
+ "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file",
+ version);
}
-void STag_dax__job(void) {
+
+void STag_dax__job(void)
+{
double runtime = dax_parse_double(A_dax__job_runtime);
- char *name=bprintf("%s@%s",A_dax__job_id,A_dax__job_name);
- runtime*=4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
+ char *name = bprintf("%s@%s", A_dax__job_id, A_dax__job_name);
+ runtime *= 4200000000.; /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
// INFO3("See <job id=%s runtime=%s %.0f>",A_dax__job_id,A_dax__job_runtime,runtime);
- current_job = SD_task_create_comp_seq(name,NULL,runtime);
- xbt_dict_set(jobs,A_dax__job_id,current_job,NULL);
+ current_job = SD_task_create_comp_seq(name, NULL, runtime);
+ xbt_dict_set(jobs, A_dax__job_id, current_job, NULL);
free(name);
- xbt_dynar_push(result,¤t_job);
+ xbt_dynar_push(result, ¤t_job);
}
-void STag_dax__uses(void) {
+
+void STag_dax__uses(void)
+{
SD_task_t file;
double size = dax_parse_double(A_dax__uses_size);
int is_input = (A_dax__uses_link == A_dax__uses_link_input);
// INFO2("See <uses file=%s %s>",A_dax__uses_file,(is_input?"in":"out"));
- file = xbt_dict_get_or_null(files,A_dax__uses_file);
- if (file==NULL) {
- file = SD_task_create_comm_e2e(A_dax__uses_file,NULL,size);
- xbt_dict_set(files,A_dax__uses_file,file,&dax_task_free);
+ file = xbt_dict_get_or_null(files, A_dax__uses_file);
+ if (file == NULL) {
+ file = SD_task_create_comm_e2e(A_dax__uses_file, NULL, size);
+ xbt_dict_set(files, A_dax__uses_file, file, &dax_task_free);
} else {
- if (SD_task_get_amount(file)!=size) {
+ if (SD_task_get_amount(file) != size) {
WARN3("Ignoring file %s size redefinition from %.0f to %.0f",
- A_dax__uses_file,SD_task_get_amount(file),size);
+ A_dax__uses_file, SD_task_get_amount(file), size);
}
}
if (is_input) {
- SD_task_dependency_add(NULL,NULL,file,current_job);
+ SD_task_dependency_add(NULL, NULL, file, current_job);
} else {
- SD_task_dependency_add(NULL,NULL,current_job,file);
- if (xbt_dynar_length(file->tasks_before)>1) {
- WARN1("File %s created at more than one location...",file->name);
+ SD_task_dependency_add(NULL, NULL, current_job, file);
+ if (xbt_dynar_length(file->tasks_before) > 1) {
+ WARN1("File %s created at more than one location...", file->name);
}
}
}
+
static SD_task_t current_child;
-void STag_dax__child(void) {
- current_child = xbt_dict_get_or_null(jobs,A_dax__child_ref);
- if (current_child==NULL)
- dax_parse_error(bprintf("Asked to add dependencies to the non-existent %s task",A_dax__child_ref));
+void STag_dax__child(void)
+{
+ current_child = xbt_dict_get_or_null(jobs, A_dax__child_ref);
+ if (current_child == NULL)
+ dax_parse_error(bprintf
+ ("Asked to add dependencies to the non-existent %s task",
+ A_dax__child_ref));
}
-void ETag_dax__child(void) {
- current_child=NULL;
+
+void ETag_dax__child(void)
+{
+ current_child = NULL;
}
-void STag_dax__parent(void) {
- SD_task_t parent = xbt_dict_get_or_null(jobs,A_dax__parent_ref);
+
+void STag_dax__parent(void)
+{
+ SD_task_t parent = xbt_dict_get_or_null(jobs, A_dax__parent_ref);
if (parent == NULL)
- dax_parse_error(bprintf("Asked to add a dependency from %s to %s, but %s does not exist",
- current_child->name,A_dax__parent_ref,A_dax__parent_ref));
- SD_task_dependency_add(NULL,NULL,parent,current_child);
- DEBUG2("Control-flow dependency from %s to %s", current_child->name,parent->name);
+ dax_parse_error(bprintf
+ ("Asked to add a dependency from %s to %s, but %s does not exist",
+ current_child->name, A_dax__parent_ref,
+ A_dax__parent_ref));
+ SD_task_dependency_add(NULL, NULL, parent, current_child);
+ DEBUG2("Control-flow dependency from %s to %s", current_child->name,
+ parent->name);
}
-void ETag_dax__adag(void) {
+
+void ETag_dax__adag(void)
+{
// INFO0("See </adag>");
}
-void ETag_dax__job(void) {
+
+void ETag_dax__job(void)
+{
current_job = NULL;
// INFO0("See </job>");
}
-void ETag_dax__parent(void) {
+
+void ETag_dax__parent(void)
+{
// INFO0("See </parent>");
}
-void ETag_dax__uses(void) {
+
+void ETag_dax__uses(void)
+{
// INFO0("See </uses>");
}
#include "xbt/misc.h"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd,"Parsing DOT files");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd, "Parsing DOT files");
#undef CLEANUP
#include <cgraph.h>
-void dot_add_task(Agnode_t *dag_node) ;
-void dot_add_input_dependencies(SD_task_t current_job, Agedge_t *edge) ;
-void dot_add_output_dependencies(SD_task_t current_job, Agedge_t *edge) ;
-xbt_dynar_t SD_dotload_FILE(FILE* in_file);
+void dot_add_task(Agnode_t * dag_node);
+void dot_add_input_dependencies(SD_task_t current_job, Agedge_t * edge);
+void dot_add_output_dependencies(SD_task_t current_job, Agedge_t * edge);
+xbt_dynar_t SD_dotload_FILE(FILE * in_file);
-static double dot_parse_double(const char *string) {
- if (string == NULL) return -1;
- int ret = 0;
- double value = -1;
+static double dot_parse_double(const char *string)
+{
+ if (string == NULL)
+ return -1;
+ int ret = 0;
+ double value = -1;
- ret = sscanf(string, "%lg", &value);
- if (ret != 1)
- WARN1("%s is not a double", string);
- return value;
+ ret = sscanf(string, "%lg", &value);
+ if (ret != 1)
+ WARN1("%s is not a double", string);
+ return value;
}
-static int dot_parse_int(const char *string) {
- if (string == NULL) return -10;
- int ret = 0;
- int value;
+static int dot_parse_int(const char *string)
+{
+ if (string == NULL)
+ return -10;
+ int ret = 0;
+ int value;
- ret = sscanf(string, "%d", &value);
- if (ret != 1)
- WARN1("%s is not an integer", string);
- return value;
+ ret = sscanf(string, "%d", &value);
+ if (ret != 1)
+ WARN1("%s is not an integer", string);
+ return value;
}
static xbt_dynar_t result;
static xbt_dict_t jobs;
static xbt_dict_t files;
-static SD_task_t root_task,end_task;
-static Agraph_t * dag_dot;
+static SD_task_t root_task, end_task;
+static Agraph_t *dag_dot;
-static void dump_res() {
- unsigned int cursor;
- SD_task_t task;
- xbt_dynar_foreach(result,cursor,task) {
- INFO1("Task %d",cursor);
- SD_task_dump(task);
- }
+static void dump_res()
+{
+ unsigned int cursor;
+ SD_task_t task;
+ xbt_dynar_foreach(result, cursor, task) {
+ INFO1("Task %d", cursor);
+ SD_task_dump(task);
+ }
}
-static void dot_task_free(void*task){
- SD_task_t t=task;
- SD_task_destroy(t);
+static void dot_task_free(void *task)
+{
+ SD_task_t t = task;
+ SD_task_destroy(t);
}
/** @brief loads a DOT file describing a DAG
* (the amount of data transfer in bit).
* if they aren't here, there choose to be equal to zero.
*/
-xbt_dynar_t SD_dotload(const char*filename){
- FILE* in_file = fopen(filename,"r");
- xbt_assert1(in_file, "Unable to open \"%s\"\n", filename);
- SD_dotload_FILE(in_file);
- fclose(in_file);
- return result;
+xbt_dynar_t SD_dotload(const char *filename)
+{
+ FILE *in_file = fopen(filename, "r");
+ xbt_assert1(in_file, "Unable to open \"%s\"\n", filename);
+ SD_dotload_FILE(in_file);
+ fclose(in_file);
+ return result;
}
-xbt_dynar_t SD_dotload_FILE(FILE* in_file){
- xbt_assert0(in_file, "Unable to use a null file descriptor\n");
- dag_dot = agread(in_file,NIL(Agdisc_t*));
+xbt_dynar_t SD_dotload_FILE(FILE * in_file)
+{
+ xbt_assert0(in_file, "Unable to use a null file descriptor\n");
+ dag_dot = agread(in_file, NIL(Agdisc_t *));
- result = xbt_dynar_new(sizeof(SD_task_t),dot_task_free);
- files=xbt_dict_new();
- jobs=xbt_dict_new();
- root_task = SD_task_create_comp_seq("root",NULL,0);
- /* by design the root task is always SCHEDULABLE */
- __SD_task_set_state(root_task, SD_SCHEDULABLE);
+ result = xbt_dynar_new(sizeof(SD_task_t), dot_task_free);
+ files = xbt_dict_new();
+ jobs = xbt_dict_new();
+ root_task = SD_task_create_comp_seq("root", NULL, 0);
+ /* by design the root task is always SCHEDULABLE */
+ __SD_task_set_state(root_task, SD_SCHEDULABLE);
- xbt_dict_set(jobs,"root",root_task,NULL);
- xbt_dynar_push(result,&root_task);
- end_task = SD_task_create_comp_seq("end",NULL,0);
- xbt_dict_set(jobs,"end",end_task,NULL);
+ xbt_dict_set(jobs, "root", root_task, NULL);
+ xbt_dynar_push(result, &root_task);
+ end_task = SD_task_create_comp_seq("end", NULL, 0);
+ xbt_dict_set(jobs, "end", end_task, NULL);
- Agnode_t *dag_node = NULL;
- for (dag_node = agfstnode(dag_dot); dag_node; dag_node = agnxtnode(dag_dot,dag_node)){
- dot_add_task(dag_node);
- }
- agclose(dag_dot);
- xbt_dict_free(&jobs);
+ Agnode_t *dag_node = NULL;
+ for (dag_node = agfstnode(dag_dot); dag_node;
+ dag_node = agnxtnode(dag_dot, dag_node)) {
+ dot_add_task(dag_node);
+ }
+ agclose(dag_dot);
+ xbt_dict_free(&jobs);
- /* And now, post-process the files.
- * We want a file task per pair of computation tasks exchanging the file. Duplicate on need
- * Files not produced in the system are said to be produced by root task (top of DAG).
- * Files not consumed in the system are said to be consumed by end task (bottom of DAG).
- */
- xbt_dict_cursor_t cursor;
- SD_task_t file;
- char *name;
- xbt_dict_foreach(files,cursor,name,file) {
- unsigned int cpt1,cpt2;
- SD_task_t newfile = NULL;
- SD_dependency_t depbefore,depafter;
- if (xbt_dynar_length(file->tasks_before) == 0) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,root_task,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
- }
- } else if (xbt_dynar_length(file->tasks_after) == 0) {
- xbt_dynar_foreach(file->tasks_before,cpt2,depbefore) {
- SD_task_t newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,end_task);
- xbt_dynar_push(result,&newfile);
- }
- } else {
- xbt_dynar_foreach(file->tasks_before,cpt1,depbefore) {
- xbt_dynar_foreach(file->tasks_after,cpt2,depafter) {
- if (depbefore->src == depafter->dst) {
- WARN2("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
- file->name,depbefore->src->name);
- }
- newfile = SD_task_create_comm_e2e(file->name,NULL,file->amount);
- SD_task_dependency_add(NULL,NULL,depbefore->src,newfile);
- SD_task_dependency_add(NULL,NULL,newfile,depafter->dst);
- xbt_dynar_push(result,&newfile);
- }
- }
+ /* And now, post-process the files.
+ * We want a file task per pair of computation tasks exchanging the file. Duplicate on need
+ * Files not produced in the system are said to be produced by root task (top of DAG).
+ * Files not consumed in the system are said to be consumed by end task (bottom of DAG).
+ */
+ xbt_dict_cursor_t cursor;
+ SD_task_t file;
+ char *name;
+ xbt_dict_foreach(files, cursor, name, file) {
+ unsigned int cpt1, cpt2;
+ SD_task_t newfile = NULL;
+ SD_dependency_t depbefore, depafter;
+ if (xbt_dynar_length(file->tasks_before) == 0) {
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, root_task, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);
+ }
+ } else if (xbt_dynar_length(file->tasks_after) == 0) {
+ xbt_dynar_foreach(file->tasks_before, cpt2, depbefore) {
+ SD_task_t newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, end_task);
+ xbt_dynar_push(result, &newfile);
+ }
+ } else {
+ xbt_dynar_foreach(file->tasks_before, cpt1, depbefore) {
+ xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
+ if (depbefore->src == depafter->dst) {
+ WARN2
+ ("File %s is produced and consumed by task %s. This loop dependency will prevent the execution of the task.",
+ file->name, depbefore->src->name);
+ }
+ newfile =
+ SD_task_create_comm_e2e(file->name, NULL, file->amount);
+ SD_task_dependency_add(NULL, NULL, depbefore->src, newfile);
+ SD_task_dependency_add(NULL, NULL, newfile, depafter->dst);
+ xbt_dynar_push(result, &newfile);
}
+ }
}
+ }
- /* Push end task last */
- xbt_dynar_push(result,&end_task);
+ /* Push end task last */
+ xbt_dynar_push(result, &end_task);
- /* Free previous copy of the files */
- xbt_dict_free(&files);
+ /* Free previous copy of the files */
+ xbt_dict_free(&files);
- return result;
+ return result;
}
/* dot_add_task create a sd_task and all transfers required for this
* task. The execution time of the task is given by the attribute size.
* The unit of size is the Flop.*/
-void dot_add_task(Agnode_t *dag_node) {
- char *name = agnameof(dag_node);
- SD_task_t current_job;
- double runtime = dot_parse_double(agget(dag_node,(char*)"size"));
- long performer = (long)dot_parse_int((char *) agget(dag_node,(char*)"performer"));
- INFO3("See <job id=%s runtime=%s %.0f>",name,agget(dag_node,(char*)"size"),runtime);
- current_job = xbt_dict_get_or_null(jobs,name);
- if (current_job == NULL) {
- current_job = SD_task_create_comp_seq(name,(void*)performer,runtime);
- xbt_dict_set(jobs,name,current_job,NULL);
- xbt_dynar_push(result,¤t_job);
- }
- Agedge_t *e;
- int count = 0;
- for (e = agfstin(dag_dot,dag_node); e; e = agnxtin(dag_dot,e)) {
- dot_add_input_dependencies(current_job,e);
- count++;
- }
- if (count==0 && current_job != root_task){
- SD_task_dependency_add(NULL,NULL,root_task,current_job);
- }
- count = 0;
- for (e = agfstout(dag_dot,dag_node); e; e = agnxtout(dag_dot,e)) {
- dot_add_output_dependencies(current_job,e);
- count++;
- }
- if (count==0 && current_job != end_task){
- SD_task_dependency_add(NULL,NULL,current_job,end_task);
- }
+void dot_add_task(Agnode_t * dag_node)
+{
+ char *name = agnameof(dag_node);
+ SD_task_t current_job;
+ double runtime = dot_parse_double(agget(dag_node, (char *) "size"));
+ long performer =
+ (long) dot_parse_int((char *) agget(dag_node, (char *) "performer"));
+ INFO3("See <job id=%s runtime=%s %.0f>", name,
+ agget(dag_node, (char *) "size"), runtime);
+ current_job = xbt_dict_get_or_null(jobs, name);
+ if (current_job == NULL) {
+ current_job =
+ SD_task_create_comp_seq(name, (void *) performer, runtime);
+ xbt_dict_set(jobs, name, current_job, NULL);
+ xbt_dynar_push(result, ¤t_job);
+ }
+ Agedge_t *e;
+ int count = 0;
+ for (e = agfstin(dag_dot, dag_node); e; e = agnxtin(dag_dot, e)) {
+ dot_add_input_dependencies(current_job, e);
+ count++;
+ }
+ if (count == 0 && current_job != root_task) {
+ SD_task_dependency_add(NULL, NULL, root_task, current_job);
+ }
+ count = 0;
+ for (e = agfstout(dag_dot, dag_node); e; e = agnxtout(dag_dot, e)) {
+ dot_add_output_dependencies(current_job, e);
+ count++;
+ }
+ if (count == 0 && current_job != end_task) {
+ SD_task_dependency_add(NULL, NULL, current_job, end_task);
+ }
}
/* dot_add_output_dependencies create the dependencies between a task
* and a transfers. This is given by the edges in the dot file.
* The amount of data transfers is given by the attribute size on the
* edge. */
-void dot_add_input_dependencies(SD_task_t current_job, Agedge_t *edge) {
- SD_task_t file;
+void dot_add_input_dependencies(SD_task_t current_job, Agedge_t * edge)
+{
+ SD_task_t file;
- char name[80];
- sprintf(name ,"%s->%s",agnameof(agtail(edge)) ,agnameof(aghead(edge)));
- double size = dot_parse_double(agget(edge,(char*)"size"));
- INFO2("size : %e, get size : %s",size,agget(edge,(char*)"size"));
- //int sender = dot_parse_int(agget(edge,(char*)"sender"));
- //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
- if(size >0){
- file = xbt_dict_get_or_null(files,name);
- if (file==NULL) {
- file = SD_task_create_comm_e2e(name,NULL,size);
- xbt_dict_set(files,name,file,&dot_task_free);
- } else {
- if (SD_task_get_amount(file)!=size) {
- WARN3("Ignoring file %s size redefinition from %.0f to %.0f",
- name,SD_task_get_amount(file),size);
- }
- }
- SD_task_dependency_add(NULL,NULL,file,current_job);
- }else{
- file = xbt_dict_get_or_null(jobs,agnameof(agtail(edge)));
- if (file != NULL){
- SD_task_dependency_add(NULL,NULL,file,current_job);
+ char name[80];
+ sprintf(name, "%s->%s", agnameof(agtail(edge)), agnameof(aghead(edge)));
+ double size = dot_parse_double(agget(edge, (char *) "size"));
+ INFO2("size : %e, get size : %s", size, agget(edge, (char *) "size"));
+ //int sender = dot_parse_int(agget(edge,(char*)"sender"));
+ //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
+ if (size > 0) {
+ file = xbt_dict_get_or_null(files, name);
+ if (file == NULL) {
+ file = SD_task_create_comm_e2e(name, NULL, size);
+ xbt_dict_set(files, name, file, &dot_task_free);
+ } else {
+ if (SD_task_get_amount(file) != size) {
+ WARN3("Ignoring file %s size redefinition from %.0f to %.0f",
+ name, SD_task_get_amount(file), size);
}
}
+ SD_task_dependency_add(NULL, NULL, file, current_job);
+ } else {
+ file = xbt_dict_get_or_null(jobs, agnameof(agtail(edge)));
+ if (file != NULL) {
+ SD_task_dependency_add(NULL, NULL, file, current_job);
+ }
+ }
}
/* dot_add_output_dependencies create the dependencies between a
* transfers and a task. This is given by the edges in the dot file.
* The amount of data transfers is given by the attribute size on the
* edge. */
-void dot_add_output_dependencies(SD_task_t current_job, Agedge_t *edge) {
- SD_task_t file;
- char name[80];
- sprintf(name ,"%s->%s",agnameof(agtail(edge)) ,agnameof(aghead(edge)));
- double size = dot_parse_double(agget(edge,(char*)"size"));
- INFO2("size : %e, get size : %s",size,agget(edge,(char*)"size"));
- //int sender = dot_parse_int(agget(edge,(char*)"sender"));
- //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
+void dot_add_output_dependencies(SD_task_t current_job, Agedge_t * edge)
+{
+ SD_task_t file;
+ char name[80];
+ sprintf(name, "%s->%s", agnameof(agtail(edge)), agnameof(aghead(edge)));
+ double size = dot_parse_double(agget(edge, (char *) "size"));
+ INFO2("size : %e, get size : %s", size, agget(edge, (char *) "size"));
+ //int sender = dot_parse_int(agget(edge,(char*)"sender"));
+ //int reciever = dot_parse_int(agget(edge,(char*)"reciever"));
- //INFO2("See <uses file=%s %s>",A_dot__uses_file,(is_input?"in":"out"));
- if(size >0){
- file = xbt_dict_get_or_null(files,name);
- if (file==NULL) {
- file = SD_task_create_comm_e2e(name,NULL,size);
- xbt_dict_set(files,name,file,&dot_task_free);
- } else {
- if (SD_task_get_amount(file)!=size) {
- WARN3("Ignoring file %s size redefinition from %.0f to %.0f",
- name,SD_task_get_amount(file),size);
- }
- }
- SD_task_dependency_add(NULL,NULL,current_job,file);
- if (xbt_dynar_length(file->tasks_before)>1) {
- WARN1("File %s created at more than one location...",file->name);
- }
- }else{
- file = xbt_dict_get_or_null(jobs,agnameof(aghead(edge)));
- if (file != NULL){
- SD_task_dependency_add(NULL,NULL,current_job,file);
+ //INFO2("See <uses file=%s %s>",A_dot__uses_file,(is_input?"in":"out"));
+ if (size > 0) {
+ file = xbt_dict_get_or_null(files, name);
+ if (file == NULL) {
+ file = SD_task_create_comm_e2e(name, NULL, size);
+ xbt_dict_set(files, name, file, &dot_task_free);
+ } else {
+ if (SD_task_get_amount(file) != size) {
+ WARN3("Ignoring file %s size redefinition from %.0f to %.0f",
+ name, SD_task_get_amount(file), size);
}
}
+ SD_task_dependency_add(NULL, NULL, current_job, file);
+ if (xbt_dynar_length(file->tasks_before) > 1) {
+ WARN1("File %s created at more than one location...", file->name);
+ }
+ } else {
+ file = xbt_dict_get_or_null(jobs, agnameof(aghead(edge)));
+ if (file != NULL) {
+ SD_task_dependency_add(NULL, NULL, current_job, file);
+ }
+ }
}
-
void SD_init(int *argc, char **argv)
{
#ifdef HAVE_TRACING
- TRACE_global_init (argc, argv);
+ TRACE_global_init(argc, argv);
#endif
s_SD_task_t task;
sd_global->watch_point_reached = 0;
sd_global->not_scheduled_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->schedulable_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->scheduled_task_set =
xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->runnable_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->in_fifo_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->running_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->done_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->failed_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->task_number = 0;
surf_init(argc, argv);
- xbt_cfg_setdefault_string(_surf_cfg_set, "workstation/model", "ptask_L07");
+ xbt_cfg_setdefault_string(_surf_cfg_set, "workstation/model",
+ "ptask_L07");
}
/**
xbt_swag_free(sd_global->failed_task_set);
sd_global->not_scheduled_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->schedulable_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->scheduled_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->runnable_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->in_fifo_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->running_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->done_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->failed_task_set =
- xbt_swag_new(xbt_swag_offset(task, state_hookup));
+ xbt_swag_new(xbt_swag_offset(task, state_hookup));
sd_global->task_number = 0;
} else {
WARN0("SD_application_reinit called before initialization of SimDag");
__SD_workstation_create(surf_workstation, NULL);
}
- xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor, name, surf_link) {
+ xbt_dict_foreach(surf_model_resource_set(surf_network_model), cursor,
+ name, surf_link) {
__SD_link_create(surf_link, NULL);
}
SD_workstation_get_number(), SD_link_get_number());
#ifdef HAVE_TRACING
- TRACE_surf_save_onelink ();
+ TRACE_surf_save_onelink();
#endif
}
/* explore the runnable tasks */
xbt_swag_foreach_safe(task, task_safe, sd_global->runnable_task_set) {
VERB1("Executing task '%s'", SD_task_get_name(task));
- if (__SD_task_try_to_run(task) && !xbt_dynar_member(changed_tasks, &task))
+ if (__SD_task_try_to_run(task)
+ && !xbt_dynar_member(changed_tasks, &task))
xbt_dynar_push(changed_tasks, &task);
}
xbt_dynar_foreach(model_list, iter, model) {
while ((action = xbt_swag_extract(model->states.done_action_set))) {
task = action->data;
- task->start_time = surf_workstation_model->action_get_start_time(task->surf_action);
+ task->start_time =
+ surf_workstation_model->
+ action_get_start_time(task->surf_action);
task->finish_time = surf_get_clock();
VERB1("Task '%s' done", SD_task_get_name(task));
DEBUG0("Calling __SD_task_just_done");
xbt_dynar_push(changed_tasks, &task);
/* remove the dependencies after this task */
- xbt_dynar_foreach(task->tasks_after, depcnt, dependency){
- dst = dependency->dst;
- if (dst->unsatisfied_dependencies>0)
- dst->unsatisfied_dependencies--;
- if (dst->is_not_ready>0)
- dst->is_not_ready--;
-
- if (!(dst->unsatisfied_dependencies)){
- if (__SD_task_is_scheduled(dst))
- __SD_task_set_state(dst, SD_RUNNABLE);
- else
- __SD_task_set_state(dst, SD_SCHEDULABLE);
+ xbt_dynar_foreach(task->tasks_after, depcnt, dependency) {
+ dst = dependency->dst;
+ if (dst->unsatisfied_dependencies > 0)
+ dst->unsatisfied_dependencies--;
+ if (dst->is_not_ready > 0)
+ dst->is_not_ready--;
+
+ if (!(dst->unsatisfied_dependencies)) {
+ if (__SD_task_is_scheduled(dst))
+ __SD_task_set_state(dst, SD_RUNNABLE);
+ else
+ __SD_task_set_state(dst, SD_SCHEDULABLE);
}
- if (SD_task_get_kind(dst) == SD_TASK_COMM_E2E){
- SD_dependency_t comm_dep;
- SD_task_t comm_dst;
- xbt_dynar_get_cpy(dst->tasks_after, 0, &comm_dep);
- comm_dst = comm_dep->dst;
- if (__SD_task_is_not_scheduled(comm_dst) &&
- comm_dst->is_not_ready>0){
- comm_dst->is_not_ready--;
-
- if (!(comm_dst->is_not_ready)){
- __SD_task_set_state(comm_dst, SD_SCHEDULABLE);
- }
- }
+ if (SD_task_get_kind(dst) == SD_TASK_COMM_E2E) {
+ SD_dependency_t comm_dep;
+ SD_task_t comm_dst;
+ xbt_dynar_get_cpy(dst->tasks_after, 0, &comm_dep);
+ comm_dst = comm_dep->dst;
+ if (__SD_task_is_not_scheduled(comm_dst) &&
+ comm_dst->is_not_ready > 0) {
+ comm_dst->is_not_ready--;
+
+ if (!(comm_dst->is_not_ready)) {
+ __SD_task_set_state(comm_dst, SD_SCHEDULABLE);
+ }
+ }
}
/* is dst runnable now? */
- if (__SD_task_is_runnable(dst) && !sd_global->watch_point_reached) {
+ if (__SD_task_is_runnable(dst)
+ && !sd_global->watch_point_reached) {
VERB1("Executing task '%s'", SD_task_get_name(dst));
if (__SD_task_try_to_run(dst) &&
!xbt_dynar_member(changed_tasks, &task))
/* let's see which tasks have just failed */
while ((action = xbt_swag_extract(model->states.failed_action_set))) {
task = action->data;
- task->start_time = surf_workstation_model->action_get_start_time(task->surf_action);
+ task->start_time =
+ surf_workstation_model->
+ action_get_start_time(task->surf_action);
task->finish_time = surf_get_clock();
VERB1("Task '%s' failed", SD_task_get_name(task));
__SD_task_set_state(task, SD_FAILED);
void SD_exit(void)
{
#ifdef HAVE_TRACING
- TRACE_surf_release ();
+ TRACE_surf_release();
#endif
if (SD_INITIALISED()) {
DEBUG0("Destroying workstation and link dictionaries...");
* \bried load script file
*/
-void SD_load_environment_script(const char* script_file)
+void SD_load_environment_script(const char *script_file)
{
#ifdef HAVE_LUA
- lua_State *L = lua_open();
- luaL_openlibs(L);
+ lua_State *L = lua_open();
+ luaL_openlibs(L);
- if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
- printf("error: %s\n", lua_tostring(L, -1));
- return;
- }
+ if (luaL_loadfile(L, script_file) || lua_pcall(L, 0, 0, 0)) {
+ printf("error: %s\n", lua_tostring(L, -1));
+ return;
+ }
#else
- xbt_die("Lua is not available!! to call SD_load_environment_script, lua should be available...");
+ xbt_die
+ ("Lua is not available!! to call SD_load_environment_script, lua should be available...");
#endif
- return;
+ return;
}
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
return surf_workstation_model->extension.workstation.
- get_link_bandwidth(link->surf_link);
+ get_link_bandwidth(link->surf_link);
}
/**
SD_CHECK_INIT_DONE();
xbt_assert0(link != NULL, "Invalid parameter");
return surf_workstation_model->extension.workstation.
- get_link_latency(link->surf_link);
+ get_link_latency(link->surf_link);
}
/**
/* dependencies */
task->tasks_before = xbt_dynar_new(sizeof(SD_dependency_t), NULL);
task->tasks_after = xbt_dynar_new(sizeof(SD_dependency_t), NULL);
- task->unsatisfied_dependencies=0;
- task->is_not_ready=0;
+ task->unsatisfied_dependencies = 0;
+ task->is_not_ready = 0;
/* scheduling parameters */
task->workstation_nb = 0;
sd_global->task_number++;
#ifdef HAVE_TRACING
- TRACE_sd_task_create (task);
+ TRACE_sd_task_create(task);
#endif
return task;
case SD_RUNNING:
task->state_set = sd_global->running_task_set;
task->start_time =
- surf_workstation_model->action_get_start_time(task->surf_action);
+ surf_workstation_model->action_get_start_time(task->surf_action);
break;
case SD_DONE:
task->state_set = sd_global->done_task_set;
task->finish_time =
- surf_workstation_model->action_get_finish_time(task->surf_action);
+ surf_workstation_model->action_get_finish_time(task->surf_action);
task->remains = 0;
break;
case SD_FAILED:
}
/** @brief Allows to change the name of a task */
-void SD_task_set_name(SD_task_t task, const char *name) {
+void SD_task_set_name(SD_task_t task, const char *name)
+{
xbt_free(task->name);
task->name = xbt_strdup(name);
}
xbt_assert0(task != NULL, "Invalid parameter");
parents = xbt_dynar_new(sizeof(SD_task_t), NULL);
- xbt_dynar_foreach(task->tasks_before, i, dep){
+ xbt_dynar_foreach(task->tasks_before, i, dep) {
xbt_dynar_push(parents, &(dep->src));
}
return parents;
xbt_assert0(task != NULL, "Invalid parameter");
children = xbt_dynar_new(sizeof(SD_task_t), NULL);
- xbt_dynar_foreach(task->tasks_after, i, dep){
+ xbt_dynar_foreach(task->tasks_after, i, dep) {
xbt_dynar_push(children, &(dep->dst));
}
return children;
SD_CHECK_INIT_DONE();
xbt_assert0(task != NULL, "Invalid parameter");
// xbt_assert1( task->state_set != sd_global->scheduled_task_set,
- // "Unscheduled task %s", task->name);
+ // "Unscheduled task %s", task->name);
return task->workstation_nb;
}
* Only call this on already scheduled tasks!
* \param task a task
*/
-SD_workstation_t* SD_task_get_workstation_list(SD_task_t task)
+SD_workstation_t *SD_task_get_workstation_list(SD_task_t task)
{
SD_CHECK_INIT_DONE();
xbt_assert0(task != NULL, "Invalid parameter");
//xbt_assert1( task->state_set != sd_global->scheduled_task_set,
- // "Unscheduled task %s", task->name);
+ // "Unscheduled task %s", task->name);
return task->workstation_list;
}
return task->remains;
}
-int SD_task_get_kind(SD_task_t task) {
+int SD_task_get_kind(SD_task_t task)
+{
return task->kind;
}
SD_dependency_t dependency;
char *statename;
- INFO1("Displaying task %s",SD_task_get_name(task));
- statename=bprintf("%s %s %s %s %s %s %s %s",
- (task->state&SD_NOT_SCHEDULED?"not scheduled":""),
- (task->state&SD_SCHEDULABLE?"schedulable":""),
- (task->state&SD_SCHEDULED?"scheduled":""),
- (task->state&SD_RUNNABLE?"runnable":"not runnable"),
- (task->state&SD_IN_FIFO?"in fifo":""),
- (task->state&SD_RUNNING?"running":""),
- (task->state&SD_DONE?"done":""),
- (task->state&SD_FAILED?"failed":""));
- INFO1(" - state: %s",statename);
+ INFO1("Displaying task %s", SD_task_get_name(task));
+ statename = bprintf("%s %s %s %s %s %s %s %s",
+ (task->state & SD_NOT_SCHEDULED ? "not scheduled" :
+ ""),
+ (task->state & SD_SCHEDULABLE ? "schedulable" : ""),
+ (task->state & SD_SCHEDULED ? "scheduled" : ""),
+ (task->state & SD_RUNNABLE ? "runnable" :
+ "not runnable"),
+ (task->state & SD_IN_FIFO ? "in fifo" : ""),
+ (task->state & SD_RUNNING ? "running" : ""),
+ (task->state & SD_DONE ? "done" : ""),
+ (task->state & SD_FAILED ? "failed" : ""));
+ INFO1(" - state: %s", statename);
free(statename);
- if (task->kind!=0) {
- switch(task->kind){
+ if (task->kind != 0) {
+ switch (task->kind) {
case SD_TASK_COMM_E2E:
INFO0(" - kind: end-to-end communication");
break;
INFO0(" - kind: sequential computation");
break;
default:
- INFO1(" - (unknown kind %d)",task->kind);
+ INFO1(" - (unknown kind %d)", task->kind);
}
}
- INFO1(" - amount: %.0f",SD_task_get_amount(task));
+ INFO1(" - amount: %.0f", SD_task_get_amount(task));
INFO1(" - Dependencies to satisfy: %d", task->unsatisfied_dependencies);
if (xbt_dynar_length(task->tasks_before)) {
INFO0(" - pre-dependencies:");
- xbt_dynar_foreach(task->tasks_before,counter,dependency) {
- INFO1(" %s",SD_task_get_name(dependency->src));
+ xbt_dynar_foreach(task->tasks_before, counter, dependency) {
+ INFO1(" %s", SD_task_get_name(dependency->src));
}
}
if (xbt_dynar_length(task->tasks_after)) {
INFO0(" - post-dependencies:");
- xbt_dynar_foreach(task->tasks_after,counter,dependency) {
- INFO1(" %s",SD_task_get_name(dependency->dst));
+ xbt_dynar_foreach(task->tasks_after, counter, dependency) {
+ INFO1(" %s", SD_task_get_name(dependency->dst));
}
}
}
+
/** @brief Dumps the task in dotty formalism into the FILE* passed as second argument */
-void SD_task_dotty(SD_task_t task,void* out) {
+void SD_task_dotty(SD_task_t task, void *out)
+{
unsigned int counter;
SD_dependency_t dependency;
- fprintf(out, " T%p [label=\"%.20s\"",task, task->name);
- switch(task->kind){
- case SD_TASK_COMM_E2E:
- fprintf(out,", shape=box");
- break;
- case SD_TASK_COMP_SEQ:
- fprintf(out,", shape=circle");
- break;
- default:
- xbt_die("Unknown task type!");
+ fprintf(out, " T%p [label=\"%.20s\"", task, task->name);
+ switch (task->kind) {
+ case SD_TASK_COMM_E2E:
+ fprintf(out, ", shape=box");
+ break;
+ case SD_TASK_COMP_SEQ:
+ fprintf(out, ", shape=circle");
+ break;
+ default:
+ xbt_die("Unknown task type!");
}
- fprintf(out,"];\n");
- xbt_dynar_foreach(task->tasks_before,counter,dependency) {
- fprintf(out," T%p -> T%p;\n",dependency->src, dependency->dst);
+ fprintf(out, "];\n");
+ xbt_dynar_foreach(task->tasks_before, counter, dependency) {
+ fprintf(out, " T%p -> T%p;\n", dependency->src, dependency->dst);
}
}
"Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED or SD_RUNNABLE",
SD_task_get_name(dst));
- DEBUG2("SD_task_dependency_add: src = %s, dst = %s", SD_task_get_name(src),
- SD_task_get_name(dst));
+ DEBUG2("SD_task_dependency_add: src = %s, dst = %s",
+ SD_task_get_name(src), SD_task_get_name(dst));
for (i = 0; i < length && !found; i++) {
xbt_dynar_get_cpy(dynar, i, &dependency);
found = (dependency->dst == dst);
dependency = xbt_new(s_SD_dependency_t, 1);
- dependency->name = xbt_strdup(name); /* xbt_strdup is cleaver enough to deal with NULL args itself */
+ dependency->name = xbt_strdup(name); /* xbt_strdup is cleaver enough to deal with NULL args itself */
dependency->data = data;
dependency->src = src;
dependency->dst = dst;
/* if the task was runnable, then dst->tasks_before is not empty anymore,
so we must go back to state SD_SCHEDULED */
if (__SD_task_is_runnable(dst)) {
- DEBUG1("SD_task_dependency_add: %s was runnable and becomes scheduled!",
- SD_task_get_name(dst));
+ DEBUG1
+ ("SD_task_dependency_add: %s was runnable and becomes scheduled!",
+ SD_task_get_name(dst));
__SD_task_set_state(dst, SD_SCHEDULED);
}
SD_dependency_t dependency;
SD_CHECK_INIT_DONE();
- xbt_assert0(src != NULL || dst != NULL, "Invalid parameter: both src and dst are NULL");
+ xbt_assert0(src != NULL
+ || dst != NULL,
+ "Invalid parameter: both src and dst are NULL");
if (src) {
if (dst) {
- xbt_dynar_foreach(src->tasks_after,counter,dependency) {
+ xbt_dynar_foreach(src->tasks_after, counter, dependency) {
if (dependency->dst == dst)
return 1;
}
/* if the task was scheduled and dst->tasks_before is empty now, we can make it runnable */
- if (dst->unsatisfied_dependencies == 0){
- if (__SD_task_is_scheduled(dst))
- __SD_task_set_state(dst, SD_RUNNABLE);
- else
- __SD_task_set_state(dst, SD_SCHEDULABLE);
- }
+ if (dst->unsatisfied_dependencies == 0) {
+ if (__SD_task_is_scheduled(dst))
+ __SD_task_set_state(dst, SD_RUNNABLE);
+ else
+ __SD_task_set_state(dst, SD_SCHEDULABLE);
+ }
- if (dst->is_not_ready == 0)
- __SD_task_set_state(dst, SD_SCHEDULABLE);
+ if (dst->is_not_ready == 0)
+ __SD_task_set_state(dst, SD_SCHEDULABLE);
/* __SD_print_dependencies(src);
__SD_print_dependencies(dst); */
static void __SD_print_watch_points(SD_task_t task)
{
static const int state_masks[] =
- { SD_SCHEDULABLE, SD_SCHEDULED, SD_RUNNING, SD_RUNNABLE, SD_DONE, SD_FAILED };
+ { SD_SCHEDULABLE, SD_SCHEDULED, SD_RUNNING, SD_RUNNABLE, SD_DONE,
+ SD_FAILED
+ };
static const char *state_names[] =
- { "schedulable", "scheduled", "running", "runnable", "done", "failed" };
+ { "schedulable", "scheduled", "running", "runnable", "done",
+ "failed"
+ };
int i;
INFO2("Task '%s' watch points (%x): ", SD_task_get_name(task),
*/
double SD_task_get_execution_time(SD_task_t task,
int workstation_nb,
- const SD_workstation_t * workstation_list,
+ const SD_workstation_t *
+ workstation_list,
const double *computation_amount,
const double *communication_amount)
{
double time, max_time = 0.0;
int i, j;
SD_CHECK_INIT_DONE();
- xbt_assert0(task != NULL && workstation_nb > 0 && workstation_list != NULL,
- "Invalid parameter");
+ xbt_assert0(task != NULL && workstation_nb > 0
+ && workstation_list != NULL, "Invalid parameter");
/* the task execution time is the maximum execution time of the parallel tasks */
if (computation_amount != NULL)
time =
SD_workstation_get_computation_time(workstation_list[i],
- computation_amount[i]);
+ computation_amount[i]);
if (communication_amount != NULL)
for (j = 0; j < workstation_nb; j++) {
time +=
SD_route_get_communication_time(workstation_list[i],
- workstation_list[j],
- communication_amount[i *
- workstation_nb +
- j]);
+ workstation_list[j],
+ communication_amount[i *
+ workstation_nb
+ + j]);
}
if (time > max_time) {
}
return max_time;
}
-static XBT_INLINE void SD_task_do_schedule(SD_task_t task) {
+
+static XBT_INLINE void SD_task_do_schedule(SD_task_t task)
+{
SD_CHECK_INIT_DONE();
- if (!__SD_task_is_not_scheduled(task) && !__SD_task_is_schedulable(task) )
- THROW1(arg_error, 0, "Task '%s' has already been scheduled",
- SD_task_get_name(task));
+ if (!__SD_task_is_not_scheduled(task) && !__SD_task_is_schedulable(task))
+ THROW1(arg_error, 0, "Task '%s' has already been scheduled",
+ SD_task_get_name(task));
- /* update the task state */
+ /* update the task state */
if (task->unsatisfied_dependencies == 0)
__SD_task_set_state(task, SD_RUNNABLE);
else
if (computation_amount) {
task->computation_amount = xbt_new(double, workstation_count);
memcpy(task->computation_amount, computation_amount,
- sizeof(double) * workstation_count);
+ sizeof(double) * workstation_count);
} else {
task->computation_amount = NULL;
}
if (communication_amount) {
task->communication_amount = xbt_new(double, communication_nb);
memcpy(task->communication_amount, communication_amount,
- sizeof(double) * communication_nb);
+ sizeof(double) * communication_nb);
} else {
task->communication_amount = NULL;
}
SD_task_do_schedule(task);
}
+
/**
* \brief Unschedules a task
*
"Task %s: the state must be SD_SCHEDULED, SD_RUNNABLE, SD_RUNNING or SD_FAILED",
SD_task_get_name(task));
- if (__SD_task_is_scheduled_or_runnable(task) /* if the task is scheduled or runnable */
- && task->kind == SD_TASK_NOT_TYPED) /* Don't free scheduling data for typed tasks */
+ if (__SD_task_is_scheduled_or_runnable(task) /* if the task is scheduled or runnable */
+ &&task->kind == SD_TASK_NOT_TYPED) /* Don't free scheduling data for typed tasks */
__SD_task_destroy_scheduling_data(task);
if (__SD_task_is_running(task)) /* the task should become SD_FAILED */
surf_workstation_model->action_cancel(task->surf_action);
else {
- if (task->unsatisfied_dependencies == 0)
- __SD_task_set_state(task, SD_SCHEDULABLE);
- else
- __SD_task_set_state(task, SD_NOT_SCHEDULED);
+ if (task->unsatisfied_dependencies == 0)
+ __SD_task_set_state(task, SD_SCHEDULABLE);
+ else
+ __SD_task_set_state(task, SD_NOT_SCHEDULED);
}
task->remains = task->amount;
task->start_time = -1.0;
static void __SD_task_destroy_scheduling_data(SD_task_t task)
{
SD_CHECK_INIT_DONE();
- if (!__SD_task_is_scheduled_or_runnable(task) && !__SD_task_is_in_fifo(task))
+ if (!__SD_task_is_scheduled_or_runnable(task)
+ && !__SD_task_is_in_fifo(task))
THROW1(arg_error, 0,
"Task '%s' must be SD_SCHEDULED, SD_RUNNABLE or SD_IN_FIFO",
SD_task_get_name(task));
"Task '%s' is not runnable or in a fifo! Task state: %d",
SD_task_get_name(task), SD_task_get_state(task));
xbt_assert1(task->workstation_list != NULL,
- "Task '%s': workstation_list is NULL!", SD_task_get_name(task));
+ "Task '%s': workstation_list is NULL!",
+ SD_task_get_name(task));
#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
task->surf_action = NULL;
- if ((task->workstation_nb == 1) && (cost_or_zero(task->communication_amount,0) == 0.0)) {
+ if ((task->workstation_nb == 1)
+ && (cost_or_zero(task->communication_amount, 0) == 0.0)) {
task->surf_action =
- surf_workstation_model->extension.
- workstation.execute(surf_workstations[0], cost_or_zero(task->computation_amount,0));
+ surf_workstation_model->extension.
+ workstation.execute(surf_workstations[0],
+ cost_or_zero(task->computation_amount, 0));
} else if ((task->workstation_nb == 1)
- && (cost_or_zero(task->computation_amount,0) == 0.0)) {
+ && (cost_or_zero(task->computation_amount, 0) == 0.0)) {
task->surf_action =
- surf_workstation_model->extension.
- workstation.communicate(surf_workstations[0], surf_workstations[0],
- cost_or_zero(task->communication_amount,0), task->rate);
+ surf_workstation_model->extension.
+ workstation.communicate(surf_workstations[0], surf_workstations[0],
+ cost_or_zero(task->communication_amount,
+ 0), task->rate);
} else if ((task->workstation_nb == 2)
- && (cost_or_zero(task->computation_amount,0) == 0.0)
- && (cost_or_zero(task->computation_amount,1) == 0.0)) {
+ && (cost_or_zero(task->computation_amount, 0) == 0.0)
+ && (cost_or_zero(task->computation_amount, 1) == 0.0)) {
int nb = 0;
double value = 0.0;
for (i = 0; i < task->workstation_nb * task->workstation_nb; i++) {
- if (cost_or_zero(task->communication_amount,i) > 0.0) {
+ if (cost_or_zero(task->communication_amount, i) > 0.0) {
nb++;
- value = cost_or_zero(task->communication_amount,i);
+ value = cost_or_zero(task->communication_amount, i);
}
}
if (nb == 1) {
task->surf_action =
- surf_workstation_model->extension.
- workstation.communicate(surf_workstations[0], surf_workstations[1],
- value, task->rate);
+ surf_workstation_model->extension.
+ workstation.communicate(surf_workstations[0],
+ surf_workstations[1], value, task->rate);
}
}
#undef cost_or_zero
sizeof(double) * task->workstation_nb * task->workstation_nb);
task->surf_action =
- surf_workstation_model->extension.
- workstation.execute_parallel_task(task->workstation_nb,
- surf_workstations, computation_amount,
- communication_amount, task->amount,
- task->rate);
+ surf_workstation_model->extension.
+ workstation.execute_parallel_task(task->workstation_nb,
+ surf_workstations,
+ computation_amount,
+ communication_amount,
+ task->amount, task->rate);
} else {
xbt_free(surf_workstations);
}
DEBUG1("surf_action = %p", task->surf_action);
#ifdef HAVE_TRACING
- if (task->category) TRACE_surf_action(task->surf_action, task->category);
+ if (task->category)
+ TRACE_surf_action(task->surf_action, task->category);
#endif
__SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */
for (i = 0; i < task->workstation_nb; i++) {
- can_start = can_start &&
- !__SD_workstation_is_busy(task->workstation_list[i]);
+ can_start = can_start &&
+ !__SD_workstation_is_busy(task->workstation_list[i]);
}
DEBUG2("Task '%s' can start: %d", SD_task_get_name(task), can_start);
workstation = task->workstation_list[i];
if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
DEBUG2("Pushing task '%s' in the fifo of workstation '%s'",
- SD_task_get_name(task), SD_workstation_get_name(workstation));
+ SD_task_get_name(task),
+ SD_workstation_get_name(workstation));
xbt_fifo_push(workstation->task_fifo, task);
}
}
"The task must be running! Task state: %d",
SD_task_get_state(task));
xbt_assert1(task->workstation_list != NULL,
- "Task '%s': workstation_list is NULL!", SD_task_get_name(task));
+ "Task '%s': workstation_list is NULL!",
+ SD_task_get_name(task));
candidates = xbt_new(SD_task_t, 8);
DEBUG0("Getting candidate in fifo");
candidate =
- xbt_fifo_get_item_content(xbt_fifo_get_first_item
- (workstation->task_fifo));
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item
+ (workstation->task_fifo));
if (candidate != NULL) {
DEBUG1("Candidate: '%s'", SD_task_get_name(candidate));
if (candidate_nb == candidate_capacity) {
candidate_capacity *= 2;
candidates =
- xbt_realloc(candidates, sizeof(SD_task_t) * candidate_capacity);
+ xbt_realloc(candidates,
+ sizeof(SD_task_t) * candidate_capacity);
}
/* register the candidate */
/* I can start on this workstation if the workstation is shared
or if I am the first task in the fifo */
- can_start = workstation->access_mode == SD_WORKSTATION_SHARED_ACCESS ||
- candidate ==
- xbt_fifo_get_item_content(xbt_fifo_get_first_item
- (workstation->task_fifo));
+ can_start = workstation->access_mode == SD_WORKSTATION_SHARED_ACCESS
+ || candidate ==
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item
+ (workstation->task_fifo));
}
DEBUG2("Candidate '%s' can start: %d", SD_task_get_name(candidate),
if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
candidate = xbt_fifo_shift(workstation->task_fifo); /* the return value is stored just for debugging */
DEBUG1("Head of the fifo: '%s'",
- (candidate != NULL) ? SD_task_get_name(candidate) : "NULL");
+ (candidate !=
+ NULL) ? SD_task_get_name(candidate) : "NULL");
xbt_assert0(candidate == candidates[i],
"Error in __SD_task_just_done: bad first task in the fifo");
}
__SD_task_really_run(candidate);
DEBUG4
- ("Calling __SD_task_is_running: task '%s', state set: %p, running_task_set: %p, is running: %d",
- SD_task_get_name(candidate), candidate->state_set,
- sd_global->running_task_set, __SD_task_is_running(candidate));
+ ("Calling __SD_task_is_running: task '%s', state set: %p, running_task_set: %p, is running: %d",
+ SD_task_get_name(candidate), candidate->state_set,
+ sd_global->running_task_set, __SD_task_is_running(candidate));
xbt_assert2(__SD_task_is_running(candidate),
- "Bad state of task '%s': %d", SD_task_get_name(candidate),
+ "Bad state of task '%s': %d",
+ SD_task_get_name(candidate),
SD_task_get_state(candidate));
DEBUG0("Okay, the task is running.");
SD_CHECK_INIT_DONE();
xbt_assert0(task != NULL, "Invalid parameter");
if (task->surf_action)
- return surf_workstation_model->action_get_start_time(task->surf_action);
+ return surf_workstation_model->
+ action_get_start_time(task->surf_action);
else
return task->start_time;
}
xbt_assert0(task != NULL, "Invalid parameter");
if (task->surf_action) /* should never happen as actions are destroyed right after their completion */
- return surf_workstation_model->action_get_finish_time(task->surf_action);
+ return surf_workstation_model->
+ action_get_finish_time(task->surf_action);
else
return task->finish_time;
}
/* if the task was scheduled or runnable we have to free the scheduling parameters */
if (__SD_task_is_scheduled_or_runnable(task))
__SD_task_destroy_scheduling_data(task);
- xbt_swag_remove(task,task->state_set);
+ xbt_swag_remove(task, task->state_set);
if (task->name != NULL)
xbt_free(task->name);
xbt_free(task->computation_amount);
#ifdef HAVE_TRACING
- TRACE_sd_task_destroy (task);
+ TRACE_sd_task_destroy(task);
#endif
xbt_dynar_free(&task->tasks_before);
}
-static XBT_INLINE SD_task_t SD_task_create_sized(const char*name,void*data,double amount,int ws_count) {
- SD_task_t task = SD_task_create(name,data,amount);
- task->communication_amount = xbt_new0(double,ws_count*ws_count);
- task->computation_amount = xbt_new0(double,ws_count);
+static XBT_INLINE SD_task_t SD_task_create_sized(const char *name,
+ void *data, double amount,
+ int ws_count)
+{
+ SD_task_t task = SD_task_create(name, data, amount);
+ task->communication_amount = xbt_new0(double, ws_count * ws_count);
+ task->computation_amount = xbt_new0(double, ws_count);
task->workstation_nb = ws_count;
- task->workstation_list = xbt_new0(SD_workstation_t,ws_count);
+ task->workstation_list = xbt_new0(SD_workstation_t, ws_count);
return task;
}
+
/** @brief create a end-to-end communication task that can then be auto-scheduled
*
* Auto-scheduling mean that the task can be used with SD_task_schedulev(). This
* A end-to-end communication must be scheduled on 2 hosts, and the amount
* specified at creation is sent from hosts[0] to hosts[1].
*/
-SD_task_t SD_task_create_comm_e2e(const char*name, void *data, double amount) {
- SD_task_t res = SD_task_create_sized(name,data,amount,2);
+SD_task_t SD_task_create_comm_e2e(const char *name, void *data,
+ double amount)
+{
+ SD_task_t res = SD_task_create_sized(name, data, amount, 2);
res->communication_amount[2] = amount;
- res->kind=SD_TASK_COMM_E2E;
+ res->kind = SD_TASK_COMM_E2E;
return res;
}
+
/** @brief create a sequential computation task that can then be auto-scheduled
*
* Auto-scheduling mean that the task can be used with SD_task_schedulev(). This
* A sequential computation must be scheduled on 1 host, and the amount
* specified at creation to be run on hosts[0].
*/
-SD_task_t SD_task_create_comp_seq(const char*name, void *data, double amount) {
- SD_task_t res = SD_task_create_sized(name,data,amount,1);
- res->computation_amount[0]=amount;
- res->kind=SD_TASK_COMP_SEQ;
+SD_task_t SD_task_create_comp_seq(const char *name, void *data,
+ double amount)
+{
+ SD_task_t res = SD_task_create_sized(name, data, amount, 1);
+ res->computation_amount[0] = amount;
+ res->kind = SD_TASK_COMP_SEQ;
return res;
}
* - parallel tasks with no internal communication (one kind per speedup model such as amdal)
* - idem+ internal communication. Task type not enough since we cannot store comm cost alongside to comp one)
*/
-void SD_task_schedulev(SD_task_t task, int count, const SD_workstation_t*list) {
+void SD_task_schedulev(SD_task_t task, int count,
+ const SD_workstation_t * list)
+{
int i;
SD_dependency_t dep;
unsigned int cpt;
- xbt_assert1(task->kind != 0,"Task %s is not typed. Cannot automatically schedule it.",SD_task_get_name(task));
- switch(task->kind) {
+ xbt_assert1(task->kind != 0,
+ "Task %s is not typed. Cannot automatically schedule it.",
+ SD_task_get_name(task));
+ switch (task->kind) {
case SD_TASK_COMM_E2E:
case SD_TASK_COMP_SEQ:
- xbt_assert(task->workstation_nb==count);
- for (i=0;i<count;i++)
- task->workstation_list[i]=list[i];
+ xbt_assert(task->workstation_nb == count);
+ for (i = 0; i < count; i++)
+ task->workstation_list[i] = list[i];
SD_task_do_schedule(task);
break;
default:
xbt_die(bprintf("Kind of task %s not supported by SD_task_schedulev()",
- SD_task_get_name(task)));
+ SD_task_get_name(task)));
}
if (task->kind == SD_TASK_COMM_E2E) {
VERB4("Schedule comm task %s between %s -> %s. It costs %.f bytes",
- SD_task_get_name(task),
- SD_workstation_get_name(task->workstation_list[0]),SD_workstation_get_name(task->workstation_list[1]),
- task->communication_amount[2]);
+ SD_task_get_name(task),
+ SD_workstation_get_name(task->workstation_list[0]),
+ SD_workstation_get_name(task->workstation_list[1]),
+ task->communication_amount[2]);
}
/* Iterate over all childs and parent being COMM_E2E to say where I am located (and start them if runnable) */
if (task->kind == SD_TASK_COMP_SEQ) {
VERB3("Schedule computation task %s on %s. It costs %.f flops",
- SD_task_get_name(task),SD_workstation_get_name(task->workstation_list[0]),
- task->computation_amount[0]);
+ SD_task_get_name(task),
+ SD_workstation_get_name(task->workstation_list[0]),
+ task->computation_amount[0]);
- xbt_dynar_foreach(task->tasks_before,cpt,dep) {
+ xbt_dynar_foreach(task->tasks_before, cpt, dep) {
SD_task_t before = dep->src;
if (before->kind == SD_TASK_COMM_E2E) {
before->workstation_list[1] = task->workstation_list[0];
if (before->workstation_list[0] &&
- (__SD_task_is_schedulable(before) || __SD_task_is_not_scheduled(before))) {
+ (__SD_task_is_schedulable(before)
+ || __SD_task_is_not_scheduled(before))) {
SD_task_do_schedule(before);
- VERB4("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
- SD_task_get_name(before),
- SD_workstation_get_name(before->workstation_list[0]),SD_workstation_get_name(before->workstation_list[1]),
- before->communication_amount[2]);
+ VERB4
+ ("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
+ SD_task_get_name(before),
+ SD_workstation_get_name(before->workstation_list[0]),
+ SD_workstation_get_name(before->workstation_list[1]),
+ before->communication_amount[2]);
}
}
}
- xbt_dynar_foreach(task->tasks_after,cpt,dep) {
+ xbt_dynar_foreach(task->tasks_after, cpt, dep) {
SD_task_t after = dep->dst;
if (after->kind == SD_TASK_COMM_E2E) {
after->workstation_list[0] = task->workstation_list[0];
//J-N : Why did you comment on these line (this comment add a bug I think)?
- if (after->workstation_list[1] && (__SD_task_is_not_scheduled(after) ||
- __SD_task_is_schedulable(after))) {
+ if (after->workstation_list[1]
+ && (__SD_task_is_not_scheduled(after)
+ || __SD_task_is_schedulable(after))) {
SD_task_do_schedule(after);
- VERB4("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
- SD_task_get_name(after),
- SD_workstation_get_name(after->workstation_list[0]),SD_workstation_get_name(after->workstation_list[1]),
- after->communication_amount[2]);
+ VERB4
+ ("Auto-Schedule comm task %s between %s -> %s. It costs %.f bytes",
+ SD_task_get_name(after),
+ SD_workstation_get_name(after->workstation_list[0]),
+ SD_workstation_get_name(after->workstation_list[1]),
+ after->communication_amount[2]);
}
}
}
}
}
+
/** @brief autoschedule a task on a list of workstations
*
* This function is very similar to SD_task_schedulev(),
* but takes the list of workstations to schedule onto as separate parameters.
* It builds a proper vector of workstations and then call SD_task_schedulev()
*/
-void SD_task_schedulel(SD_task_t task, int count, ...) {
+void SD_task_schedulel(SD_task_t task, int count, ...)
+{
va_list ap;
- SD_workstation_t *list=xbt_new(SD_workstation_t,count);
+ SD_workstation_t *list = xbt_new(SD_workstation_t, count);
int i;
- va_start(ap,count);
- for (i=0;i<count;i++) {
- list[i] = va_arg(ap,SD_workstation_t);
+ va_start(ap, count);
+ for (i = 0; i < count; i++) {
+ list[i] = va_arg(ap, SD_workstation_t);
}
va_end(ap);
- SD_task_schedulev(task,count,list);
+ SD_task_schedulev(task, count, list);
free(list);
}
/* Creates a workstation and registers it in SD.
*/
-SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data)
+SD_workstation_t __SD_workstation_create(void *surf_workstation,
+ void *data)
{
SD_workstation_t workstation;
if (sd_global->workstation_list == NULL) { /* this is the first time the function is called */
sd_global->workstation_list =
- xbt_new(SD_workstation_t, sd_global->workstation_count);
+ xbt_new(SD_workstation_t, sd_global->workstation_count);
i = 0;
xbt_dict_foreach(sd_global->workstations, cursor, key, data) {
SD_CHECK_INIT_DONE();
xbt_assert0((workstation != NULL), "Invalid parameters");
- return surf_workstation_model->extension.workstation.get_properties(workstation->surf_workstation);
+ return surf_workstation_model->extension.
+ workstation.get_properties(workstation->surf_workstation);
}
* \return a new array of \ref SD_link_t representating the route between these two workstations
* \see SD_route_get_size(), SD_link_t
*/
-const SD_link_t *SD_route_get_list(SD_workstation_t src, SD_workstation_t dst)
+const SD_link_t *SD_route_get_list(SD_workstation_t src,
+ SD_workstation_t dst)
{
void *surf_src;
void *surf_dst;
surf_src = src->surf_workstation;
surf_dst = dst->surf_workstation;
- surf_route = surf_workstation_model->extension.workstation.get_route(surf_src,surf_dst);
+ surf_route =
+ surf_workstation_model->extension.workstation.get_route(surf_src,
+ surf_dst);
xbt_dynar_foreach(surf_route, cpt, surf_link) {
link_name = surf_resource_name(surf_link);
sd_global->recyclable_route[cpt] =
- xbt_dict_get(sd_global->links, link_name);
+ xbt_dict_get(sd_global->links, link_name);
}
return sd_global->recyclable_route;
}
int SD_route_get_size(SD_workstation_t src, SD_workstation_t dst)
{
SD_CHECK_INIT_DONE();
- return xbt_dynar_length(surf_workstation_model->extension.workstation.get_route(
- src->surf_workstation,dst->surf_workstation));
+ return xbt_dynar_length(surf_workstation_model->extension.
+ workstation.get_route(src->surf_workstation,
+ dst->surf_workstation));
}
/**
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return surf_workstation_model->extension.workstation.
- get_speed(workstation->surf_workstation, 1.0);
+ get_speed(workstation->surf_workstation, 1.0);
}
/**
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return surf_workstation_model->extension.
- workstation.get_available_speed(workstation->surf_workstation);
+ workstation.get_available_speed(workstation->surf_workstation);
}
/**
*
* \see SD_workstation_set_access_mode(), e_SD_workstation_access_mode_t
*/
-e_SD_workstation_access_mode_t SD_workstation_get_access_mode(SD_workstation_t
- workstation)
+e_SD_workstation_access_mode_t
+SD_workstation_get_access_mode(SD_workstation_t workstation)
{
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
}
/* Returns whether a task can start now on a workstation.
- *//*
- int __SD_workstation_can_start(SD_workstation_t workstation, SD_task_t task) {
- SD_CHECK_INIT_DONE();
- xbt_assert0(workstation != NULL && task != NULL, "Invalid parameter");
+ *//*
+ int __SD_workstation_can_start(SD_workstation_t workstation, SD_task_t task) {
+ SD_CHECK_INIT_DONE();
+ xbt_assert0(workstation != NULL && task != NULL, "Invalid parameter");
- return !__SD_workstation_is_busy(workstation) &&
- (xbt_fifo_size(workstation->task_fifo) == 0) || xbt_fifo_get_first_item(workstation->task_fifo) == task);
- }
- */
+ return !__SD_workstation_is_busy(workstation) &&
+ (xbt_fifo_size(workstation->task_fifo) == 0) || xbt_fifo_get_first_item(workstation->task_fifo) == task);
+ }
+ */
/* Returns whether a workstation is busy. A workstation is busy is it is
* in sequential mode and a task is running on it or the fifo is not empty.
xbt_assert0(workstation != NULL, "Invalid parameter");
DEBUG4
- ("Workstation '%s' access mode: '%s', current task: %s, fifo size: %d",
- SD_workstation_get_name(workstation),
- (workstation->access_mode ==
- SD_WORKSTATION_SHARED_ACCESS) ? "SHARED" : "FIFO",
- (workstation->current_task ? SD_task_get_name(workstation->current_task)
- : "none"),
- (workstation->task_fifo ? xbt_fifo_size(workstation->task_fifo) : 0));
+ ("Workstation '%s' access mode: '%s', current task: %s, fifo size: %d",
+ SD_workstation_get_name(workstation),
+ (workstation->access_mode ==
+ SD_WORKSTATION_SHARED_ACCESS) ? "SHARED" : "FIFO",
+ (workstation->current_task ?
+ SD_task_get_name(workstation->current_task)
+ : "none"),
+ (workstation->task_fifo ? xbt_fifo_size(workstation->task_fifo) :
+ 0));
return workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS &&
- (workstation->current_task != NULL
- || xbt_fifo_size(workstation->task_fifo) > 0);
+ (workstation->current_task != NULL
+ || xbt_fifo_size(workstation->task_fifo) > 0);
}
/* Destroys a workstation.
{
SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
- xbt_assert0(workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS,
- "Access mode must be set to SD_WORKSTATION_SEQUENTIAL_ACCESS"
- " to use this function");
-
+ xbt_assert0(workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS,
+ "Access mode must be set to SD_WORKSTATION_SEQUENTIAL_ACCESS"
+ " to use this function");
+
return (workstation->current_task);
}
xbt_test_suite_push(suite, "int", test_dynar_int, "Dynars of integers");
xbt_test_suite_push(suite, "double", test_dynar_double, "Dynars of doubles");
xbt_test_suite_push(suite, "string", test_dynar_string, "Dynars of strings");
- xbt_test_suite_push(suite, "synchronized int", test_dynar_sync_int, "Synchronized dynars of integers");
+ xbt_test_suite_push(suite, "synchronized int", test_dynar_sync_int, "Synchronized dynars of integers");
/* SGU: END FILE */
/* SGU: BEGIN FILE xbt/dict.c */
suite = xbt_test_suite_by_name("dict","Dict data container");
- xbt_test_suite_push(suite, "basic", test_dict_basic, "Basic usage: change, retrieve, traverse");
+ xbt_test_suite_push(suite, "basic", test_dict_basic, "Basic usage: change, retrieve, traverse");
xbt_test_suite_push(suite, "remove", test_dict_remove, "Removing some values");
xbt_test_suite_push(suite, "nulldata", test_dict_nulldata, "NULL data management");
xbt_test_suite_push(suite, "dicti", test_dict_scalar, "Scalar data and key management");
/* SGU: BEGIN FILE xbt/xbt_str.c */
suite = xbt_test_suite_by_name("xbt_str","String Handling");
- xbt_test_suite_push(suite, "xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted");
- xbt_test_suite_push(suite, "xbt_str_split_str", test_split_str, "test the function xbt_str_split_str");
+ xbt_test_suite_push(suite, "xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted");
+ xbt_test_suite_push(suite, "xbt_str_split_str", test_split_str, "test the function xbt_str_split_str");
/* SGU: END FILE */
/* SGU: BEGIN FILE xbt/xbt_strbuff.c */
suite = xbt_test_suite_by_name("xbt_strbuff","String Buffers");
- xbt_test_suite_push(suite, "xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute");
+ xbt_test_suite_push(suite, "xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute");
/* SGU: END FILE */
/* SGU: BEGIN FILE xbt/xbt_sha.c */
@ingroup m_datatypes_management_details */
typedef struct s_smx_host {
char *name; /**< @brief host name if any */
- void *host; /* SURF modeling */
+ void *host; /* SURF modeling */
xbt_swag_t process_list;
void *data; /**< @brief user data */
} s_smx_host_t;
/** @brief Process datatype
@ingroup m_datatypes_management_details @{ */
- typedef struct s_smx_process {
- s_xbt_swag_hookup_t process_hookup;
- s_xbt_swag_hookup_t synchro_hookup; /* process_to_run or mutex->sleeping and co */
- s_xbt_swag_hookup_t host_proc_hookup;
- s_xbt_swag_hookup_t destroy_hookup;
-
- char *name; /**< @brief process name if any */
- smx_host_t smx_host; /* the host on which the process is running */
- smx_context_t context; /* the context that executes the scheduler function */
- ex_ctx_t *exception;
- int blocked : 1;
- int suspended : 1;
- int iwannadie : 1;
- smx_mutex_t mutex; /* mutex on which the process is blocked */
- smx_cond_t cond; /* cond on which the process is blocked */
- smx_sem_t sem; /* semaphore on which the process is blocked */
- smx_action_t waiting_action;
- xbt_dict_t properties;
- void *data; /* kept for compatibility, it should be replaced with moddata */
-
- } s_smx_process_t;
+typedef struct s_smx_process {
+ s_xbt_swag_hookup_t process_hookup;
+ s_xbt_swag_hookup_t synchro_hookup; /* process_to_run or mutex->sleeping and co */
+ s_xbt_swag_hookup_t host_proc_hookup;
+ s_xbt_swag_hookup_t destroy_hookup;
+
+ char *name; /**< @brief process name if any */
+ smx_host_t smx_host; /* the host on which the process is running */
+ smx_context_t context; /* the context that executes the scheduler function */
+ ex_ctx_t *exception;
+ int blocked:1;
+ int suspended:1;
+ int iwannadie:1;
+ smx_mutex_t mutex; /* mutex on which the process is blocked */
+ smx_cond_t cond; /* cond on which the process is blocked */
+ smx_sem_t sem; /* semaphore on which the process is blocked */
+ smx_action_t waiting_action;
+ xbt_dict_t properties;
+ void *data; /* kept for compatibility, it should be replaced with moddata */
+
+} s_smx_process_t;
/** @} */
typedef struct s_smx_process_arg {
char *name;
smx_mutex_t read;
smx_mutex_t write;
- xbt_fifo_t comm_fifo;
+ xbt_fifo_t comm_fifo;
void *data;
} s_smx_rvpoint_t;
typedef struct s_smx_comm {
- smx_comm_type_t type; /* Type of the communication (comm_send,comm_recv) */
- smx_rdv_t rdv; /* Rendez-vous where the comm is queued */
- smx_sem_t sem; /* Semaphore associated to the surf simulation */
- int refcount; /* Number of processes involved in the cond */
+ smx_comm_type_t type; /* Type of the communication (comm_send,comm_recv) */
+ smx_rdv_t rdv; /* Rendez-vous where the comm is queued */
+ smx_sem_t sem; /* Semaphore associated to the surf simulation */
+ int refcount; /* Number of processes involved in the cond */
/* Surf action data */
smx_process_t src_proc;
size_t src_buff_size;
size_t *dst_buff_size;
char copied;
-
- void *data; /* User data associated to communication */
+
+ void *data; /* User data associated to communication */
} s_smx_comm_t;
void SIMIX_network_copy_data(smx_comm_t comm);
smx_comm_t SIMIX_communication_new(smx_comm_type_t type);
static XBT_INLINE void SIMIX_communication_use(smx_comm_t comm);
-static XBT_INLINE void SIMIX_communication_wait_for_completion(smx_comm_t comm, double timeout);
+static XBT_INLINE void SIMIX_communication_wait_for_completion(smx_comm_t
+ comm,
+ double
+ timeout);
static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_comm_t comm);
static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_comm_t comm);
/********************************* Action *************************************/
-typedef enum {ready, ongoing, done, failed} smx_action_state_t;
+typedef enum { ready, ongoing, done, failed } smx_action_state_t;
/** @brief Action datatype
@ingroup m_datatypes_management_details */
typedef struct s_smx_action {
char *name; /**< @brief action name if any */
- xbt_fifo_t cond_list; /*< conditional variables that must be signaled when the action finish. */
- xbt_fifo_t sem_list; /*< semaphores that must be signaled when the action finish. */
+ xbt_fifo_t cond_list; /*< conditional variables that must be signaled when the action finish. */
+ xbt_fifo_t sem_list; /*< semaphores that must be signaled when the action finish. */
void *data; /**< @brief user data */
int refcount; /**< @brief reference counter */
surf_action_t surf_action; /* SURF modeling of computation */
smx_host_t source;
#ifdef HAVE_TRACING
- long long int counter; /* simix action unique identifier for instrumentation */
- char *category; /* simix action category for instrumentation */
+ long long int counter; /* simix action unique identifier for instrumentation */
+ char *category; /* simix action category for instrumentation */
#endif
} s_smx_action_t;
get_state(SIMIX_host_self()->host)==SURF_RESOURCE_ON,\
"Host failed, you cannot call this function.")
-smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
+smx_host_t __SIMIX_host_create(const char *name, void *workstation,
+ void *data);
void __SIMIX_host_destroy(void *host);
void __SIMIX_cond_wait(smx_cond_t cond);
void __SIMIX_cond_display_actions(smx_cond_t cond);
/* 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_f_pvoid_t, void*);
-typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
+typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
+ (xbt_main_func_t, int, char **, void_f_pvoid_t, void *);
+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);
/* Initializes a context factory from the name specified by the parameter name.
* If the factory cannot be found, an exception is raised.
*/
-void SIMIX_context_init_factory_by_name(smx_context_factory_t * factory, const char *name);
+void SIMIX_context_init_factory_by_name(smx_context_factory_t * factory,
+ const char *name);
/* All factories init */
void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory);
* \param cleanup_func the function to call when the context stops
* \param cleanup_arg the argument of the cleanup_func function
*/
-static XBT_INLINE smx_context_t SIMIX_context_new(xbt_main_func_t code, int argc,
- char** argv,
- void_f_pvoid_t cleanup_func,
- void* cleanup_arg) {
+static XBT_INLINE smx_context_t SIMIX_context_new(xbt_main_func_t code,
+ int argc, char **argv,
+ void_f_pvoid_t
+ cleanup_func,
+ void *cleanup_arg)
+{
return (*(simix_global->context_factory->create_context))
- (code, argc, argv, cleanup_func, cleanup_arg);
+ (code, argc, argv, cleanup_func, cleanup_arg);
}
/**
* \param context the context to destroy
* Argument must be stopped first -- runs in maestro context
*/
-static XBT_INLINE void SIMIX_context_free(smx_context_t context) {
+static XBT_INLINE void SIMIX_context_free(smx_context_t context)
+{
(*(simix_global->context_factory->free)) (context);
}
* \brief stops the execution of a context
* \param context to stop
*/
-static XBT_INLINE void SIMIX_context_stop(smx_context_t context) {
+static XBT_INLINE void SIMIX_context_stop(smx_context_t context)
+{
(*(simix_global->context_factory->stop)) (context);
}
* \return A new SIMIX action
* */
smx_action_t SIMIX_action_communicate(smx_host_t sender,
- smx_host_t receiver, const char *name,
- double size, double rate)
+ smx_host_t receiver,
+ const char *name, double size,
+ double rate)
{
smx_action_t act;
/* check if the host is active */
- if (surf_workstation_model->extension.workstation.get_state(sender->host) !=
- SURF_RESOURCE_ON) {
- THROW1(network_error, 0, "Host %s failed, you cannot call this function",
- sender->name);
+ if (surf_workstation_model->extension.
+ workstation.get_state(sender->host) != SURF_RESOURCE_ON) {
+ THROW1(network_error, 0,
+ "Host %s failed, you cannot call this function", sender->name);
}
if (surf_workstation_model->extension.workstation.
get_state(receiver->host) != SURF_RESOURCE_ON) {
- THROW1(network_error, 0, "Host %s failed, you cannot call this function",
+ THROW1(network_error, 0,
+ "Host %s failed, you cannot call this function",
receiver->name);
}
#endif
act->surf_action =
- surf_workstation_model->extension.workstation.communicate(sender->host,
- receiver->host,
- size, rate);
+ surf_workstation_model->extension.workstation.
+ communicate(sender->host, receiver->host, size, rate);
surf_workstation_model->action_data_set(act->surf_action, act);
DEBUG1("Create communicate action %p", act);
smx_action_t act;
/* check if the host is active */
- if (surf_workstation_model->extension.workstation.get_state(host->host) !=
- SURF_RESOURCE_ON) {
+ if (surf_workstation_model->extension.
+ workstation.get_state(host->host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
/* set execute */
act->surf_action =
- surf_workstation_model->extension.workstation.execute(host->host, amount);
+ surf_workstation_model->extension.workstation.execute(host->host,
+ amount);
surf_workstation_model->action_data_set(act->surf_action, act);
DEBUG1("Create execute action %p", act);
#ifdef HAVE_TRACING
- TRACE_smx_action_execute (act);
- TRACE_surf_action (act->surf_action, act->category);
+ TRACE_smx_action_execute(act);
+ TRACE_surf_action(act->surf_action, act->category);
#endif
return act;
}
smx_action_t act;
/* check if the host is active */
- if (surf_workstation_model->extension.workstation.get_state(host->host) !=
- SURF_RESOURCE_ON) {
+ if (surf_workstation_model->extension.
+ workstation.get_state(host->host) != SURF_RESOURCE_ON) {
THROW1(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
#endif
act->surf_action =
- surf_workstation_model->extension.workstation.sleep(host->host, duration);
+ surf_workstation_model->extension.workstation.sleep(host->host,
+ duration);
surf_workstation_model->action_data_set(act->surf_action, act);
* \param action The SIMIX action
* \param priority The new priority
*/
-XBT_INLINE void SIMIX_action_set_priority(smx_action_t action, double priority)
+XBT_INLINE void SIMIX_action_set_priority(smx_action_t action,
+ double priority)
{
xbt_assert0((action != NULL), "Invalid parameter");
if (action->surf_action)
action->surf_action->model_type->action_unref(action->surf_action);
#ifdef HAVE_TRACING
- TRACE_smx_action_destroy (action);
+ TRACE_smx_action_destroy(action);
#endif
xbt_free(action);
return 1;
* \param action SIMIX action
* \param cond SIMIX cond
*/
-void SIMIX_register_action_to_condition(smx_action_t action, smx_cond_t cond)
+void SIMIX_register_action_to_condition(smx_action_t action,
+ smx_cond_t cond)
{
xbt_assert0((action != NULL) && (cond != NULL), "Invalid parameters");
DEBUG2("Register action %p to cond %p", action, cond);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_cond_display_actions(cond);
xbt_fifo_push(cond->actions, action);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_cond_display_actions(cond);
DEBUG2("Register condition %p to action %p", cond, action);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_action_display_conditions(action);
xbt_fifo_push(action->cond_list, cond);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_action_display_conditions(action);
}
{
xbt_assert0((action != NULL) && (cond != NULL), "Invalid parameters");
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_cond_display_actions(cond);
xbt_fifo_remove_all(cond->actions, action);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_cond_display_actions(cond);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_action_display_conditions(action);
xbt_fifo_remove_all(action->cond_list, cond);
- if(XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
+ if (XBT_LOG_ISENABLED(simix_action, xbt_log_priority_debug))
__SIMIX_action_display_conditions(action);
}
+
/**
* \brief Link an action to a semaphore
*
* When the action terminates, the semaphore gets signaled automatically.
*/
-XBT_INLINE void SIMIX_register_action_to_semaphore(smx_action_t action, smx_sem_t sem) {
+XBT_INLINE void SIMIX_register_action_to_semaphore(smx_action_t action,
+ smx_sem_t sem)
+{
- DEBUG2("Register action %p to semaphore %p (and otherwise)", action, sem);
+ DEBUG2("Register action %p to semaphore %p (and otherwise)", action,
+ sem);
xbt_fifo_push(sem->actions, action);
xbt_fifo_push(action->sem_list, sem);
}
+
/**
* \brief Unset an action to a semaphore.
*
* Destroys the "links" from the semaphore to this action.
*/
XBT_INLINE void SIMIX_unregister_action_to_semaphore(smx_action_t action,
- smx_sem_t sem)
+ smx_sem_t sem)
{
xbt_fifo_remove_all(sem->actions, action);
xbt_fifo_remove_all(action->sem_list, sem);
workstation_list[i] = host_list[i]->host;
act->surf_action =
- surf_workstation_model->extension.workstation.
- execute_parallel_task(host_nb, workstation_list, computation_amount,
- communication_amount, amount, rate);
+ surf_workstation_model->extension.workstation.
+ execute_parallel_task(host_nb, workstation_list, computation_amount,
+ communication_amount, amount, rate);
surf_workstation_model->action_data_set(act->surf_action, act);
return act;
}
-XBT_INLINE e_surf_action_state_t SIMIX_action_get_state(smx_action_t action)
+XBT_INLINE e_surf_action_state_t SIMIX_action_get_state(smx_action_t
+ action)
{
xbt_assert0((action != NULL), "Invalid parameter");
return surf_workstation_model->action_state_get(action->surf_action);
DEBUG1("Actions for condition %p", cond);
xbt_fifo_foreach(cond->actions, item, action, smx_action_t)
- DEBUG2("\t %p [%s]", action, action->name);
+ DEBUG2("\t %p [%s]", action, action->name);
}
void __SIMIX_action_display_conditions(smx_action_t action)
DEBUG1("Conditions for action %p", action);
xbt_fifo_foreach(action->cond_list, item, cond, smx_cond_t)
- DEBUG1("\t %p", cond);
+ DEBUG1("\t %p", cond);
}
XBT_INLINE char *SIMIX_action_get_name(smx_action_t action)
xbt_assert0((action != NULL), "Invalid parameter");
return action->name;
}
+
/** @brief Change the name of the action. Warning, the string you provide is not strdup()ed */
-XBT_INLINE void SIMIX_action_set_name(smx_action_t action,char *name)
+XBT_INLINE void SIMIX_action_set_name(smx_action_t action, char *name)
{
xbt_free(action->name);
action->name = name;
}
/** @brief broadcast any condition and release any semaphore including this action */
-void SIMIX_action_signal_all(smx_action_t action){
+void SIMIX_action_signal_all(smx_action_t action)
+{
smx_cond_t cond;
smx_sem_t sem;
#endif
#ifdef HAVE_RUBY
- void SIMIX_ctx_ruby_factory_init(smx_context_factory_t *factory);
-#endif
+void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory);
+#endif
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_context, simix, "Context switching mecanism");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_context, simix,
+ "Context switching mecanism");
const char *xbt_ctx_factory_to_use = NULL;
void SIMIX_context_mod_init(void)
{
if (!simix_global->context_factory) {
- /* select context factory to use to create the context(depends of the macro definitions) */
+ /* select context factory to use to create the context(depends of the macro definitions) */
if (xbt_ctx_factory_to_use) {
SIMIX_context_select_factory(xbt_ctx_factory_to_use);
} else {
#ifdef CONTEXT_THREADS
- /* context switch based os thread */
- SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
+ /* context switch based os thread */
+ SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
#elif defined(CONTEXT_UCONTEXT)
- /* context switch based ucontext */
- SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
+ /* context switch based ucontext */
+ SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
#elif defined(_XBT_WIN32)
- /* context switch based windows */
+ /* context switch based windows */
#else
- /* context switch is not allowed on Windows */
+ /* context switch is not allowed on Windows */
#error ERROR [__FILE__, line __LINE__]: no context based implementation specified.
#endif
}
{
if (simix_global->context_factory) {
smx_pfn_context_factory_finalize_t finalize_factory;
-
+
/* finalize the context factory */
finalize_factory = simix_global->context_factory->finalize;
(*finalize_factory) (&simix_global->context_factory);
/* if a context factory is already instantiated and it is different from the
newly selected one, then kill all the processes, exit the context module
and initialize the new factory.
- */
-
+ */
+
if (simix_global->context_factory != NULL) {
- if (strcmp(simix_global->context_factory->name, name)){
+ if (strcmp(simix_global->context_factory->name, name)) {
SIMIX_process_killall();
-
+
/* kill maestro process */
SIMIX_context_free(simix_global->maestro_process->context);
- free(simix_global->maestro_process);
+ free(simix_global->maestro_process);
simix_global->maestro_process = NULL;
SIMIX_context_mod_exit();
- }
- else
+ } else
/* the same context factory is requested return directly */
return 0;
}
-
+
/* init the desired factory */
SIMIX_context_init_factory_by_name(&simix_global->context_factory, name);
- SIMIX_create_maestro_process ();
+ SIMIX_create_maestro_process();
+
-
return 0;
}
void SIMIX_context_init_factory_by_name(smx_context_factory_t * factory,
const char *name)
{
-
+
if (!strcmp(name, "java"))
-#ifdef HAVE_JAVA
+#ifdef HAVE_JAVA
SIMIX_ctx_java_factory_init(factory);
#else
- THROW0(not_found_error, 0, "Factory 'Java' does not exist: Java support was not compiled in the SimGrid library");
-#endif /* HAVE_JAVA */
-
+ THROW0(not_found_error, 0,
+ "Factory 'Java' does not exist: Java support was not compiled in the SimGrid library");
+#endif /* HAVE_JAVA */
+
else if (!strcmp(name, "thread"))
#ifdef CONTEXT_THREADS
SIMIX_ctx_thread_factory_init(factory);
#else
- THROW0(not_found_error, 0, "Factory 'thread' does not exist: thread support was not compiled in the SimGrid library");
-#endif /* CONTEXT_THREADS */
-
- else if (!strcmp(name, "sysv"))
- #if !defined(_XBT_WIN32) && !defined(CONTEXT_THREADS)
- SIMIX_ctx_sysv_factory_init(factory);
- #else
- THROW0(not_found_error, 0, "Factory 'sysv' does not exist: no System V thread support under Windows");
- #endif
- else if (!strcmp(name, "lua"))
+ THROW0(not_found_error, 0,
+ "Factory 'thread' does not exist: thread support was not compiled in the SimGrid library");
+#endif /* CONTEXT_THREADS */
+
+ else if (!strcmp(name, "sysv"))
+#if !defined(_XBT_WIN32) && !defined(CONTEXT_THREADS)
+ SIMIX_ctx_sysv_factory_init(factory);
+#else
+ THROW0(not_found_error, 0,
+ "Factory 'sysv' does not exist: no System V thread support under Windows");
+#endif
+ else if (!strcmp(name, "lua"))
#ifdef HAVE_LUA
- SIMIX_ctx_lua_factory_init(factory);
+ SIMIX_ctx_lua_factory_init(factory);
#else
- THROW0(not_found_error, 0, "Factory 'lua' does not exist: Lua support was not compiled in the SimGrid library");
-#endif /* HAVE_LUA */
+ THROW0(not_found_error, 0,
+ "Factory 'lua' does not exist: Lua support was not compiled in the SimGrid library");
+#endif /* HAVE_LUA */
- else if (!strcmp(name,"ruby"))
+ else if (!strcmp(name, "ruby"))
#ifdef HAVE_RUBY
SIMIX_ctx_ruby_factory_init(factory);
#else
- THROW0(not_found_error, 0, "Factory 'ruby' does not exist: Ruby support was not compiled in the SimGrid library");
+ THROW0(not_found_error, 0,
+ "Factory 'ruby' does not exist: Ruby support was not compiled in the SimGrid library");
#endif
else
THROW1(not_found_error, 0, "Factory '%s' does not exist", name);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(bindings);
-void smx_ctx_base_factory_init(smx_context_factory_t * factory) {
+void smx_ctx_base_factory_init(smx_context_factory_t * factory)
+{
/* instantiate the context factory */
*factory = xbt_new0(s_smx_context_factory_t, 1);
(*factory)->name = "base context factory";
}
-int smx_ctx_base_factory_finalize(smx_context_factory_t * factory) {
+int smx_ctx_base_factory_finalize(smx_context_factory_t * factory)
+{
free(*factory);
*factory = NULL;
return 0;
smx_context_t
smx_ctx_base_factory_create_context_sized(size_t size,
- xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg)
+ xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg)
{
smx_context_t context = xbt_malloc0(size);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
- if(code){
+ if (code) {
context->cleanup_func = cleanup_func;
context->cleanup_arg = cleanup_arg;
context->argc = argc;
context->argv = argv;
context->code = code;
}
-
+
return context;
}
-void smx_ctx_base_free(smx_context_t context) {
+void smx_ctx_base_free(smx_context_t context)
+{
int i;
if (context) {
/* free structure */
free(context);
}
-}
+}
-void smx_ctx_base_stop(smx_context_t context) {
+void smx_ctx_base_stop(smx_context_t context)
+{
if (context->cleanup_func)
(*(context->cleanup_func)) (context->cleanup_arg);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jmsg, bindings, "MSG for Java(TM)");
static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
static void smx_ctx_java_free(smx_context_t context);
static void smx_ctx_java_start(smx_context_t context);
}
static smx_context_t
-smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg)
+smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg)
{
smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
- if(code){
+ if (code) {
context->super.cleanup_func = cleanup_func;
context->super.cleanup_arg = cleanup_arg;
context->jprocess = (jobject) code;
jprocess_start(((smx_ctx_java_t) context)->jprocess,
get_current_thread_env());
}
-
+
return (smx_context_t) context;
}
}
smx_ctx_base_free(context);
-}
+}
static void smx_ctx_java_stop(smx_context_t context)
{
ctx_java = (smx_ctx_java_t) context;
- /*FIXME: is this really necessary?*/
+ /*FIXME: is this really necessary? */
if (simix_global->current_process->iwannadie) {
/* The maestro call xbt_context_stop() with an exit code set to one */
if (ctx_java->jprocess) {
}
// FIXME: inline those functions
-static void
-smx_ctx_java_resume(smx_context_t new_context)
+static void smx_ctx_java_resume(smx_context_t new_context)
{
jprocess_schedule(new_context);
}
SG_BEGIN_DECL()
typedef struct s_smx_ctx_java {
- s_smx_ctx_base_t super; /* Fields of super implementation */
- jobject jprocess; /* the java process instance binded with the msg process structure */
- JNIEnv *jenv; /* jni interface pointer associated to this thread */
+ s_smx_ctx_base_t super; /* Fields of super implementation */
+ jobject jprocess; /* the java process instance binded with the msg process structure */
+ JNIEnv *jenv; /* jni interface pointer associated to this thread */
} s_smx_ctx_java_t, *smx_ctx_java_t;
SG_END_DECL()
-#endif /* !_XBT_CONTEXT_JAVA_H */
+#endif /* !_XBT_CONTEXT_JAVA_H */
*/
lua_State *simgrid_lua_state;
-void SIMIX_ctx_lua_factory_init(smx_context_factory_t *factory) {
+void SIMIX_ctx_lua_factory_init(smx_context_factory_t * factory)
+{
}
#ifdef KILLME
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(lua);
-static smx_context_t
-smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+static smx_context_t
+smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func, void *cleanup_arg);
-static int smx_ctx_lua_factory_finalize(smx_context_factory_t *factory);
+static int smx_ctx_lua_factory_finalize(smx_context_factory_t * factory);
static void smx_ctx_lua_free(smx_context_t context);
static void smx_ctx_lua_stop(smx_context_t context);
static void smx_ctx_lua_resume(smx_context_t new_context);
-void SIMIX_ctx_lua_factory_init(smx_context_factory_t *factory) {
+void SIMIX_ctx_lua_factory_init(smx_context_factory_t * factory)
+{
smx_ctx_base_factory_init(factory);
(*factory)->create_context = smx_ctx_lua_create_context;
- /* don't override (*factory)->finalize */;
+ /* don't override (*factory)->finalize */ ;
(*factory)->free = smx_ctx_sysv_free;
(*factory)->stop = smx_ctx_sysv_stop;
(*factory)->suspend = smx_ctx_sysv_suspend;
INFO0("Lua Factory created");
}
-static smx_context_t
-smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg) {
+static smx_context_t
+smx_ctx_lua_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func, void *cleanup_arg)
+{
return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t),
- code,argc,argv,cleanup_func,cleanup_arg);
+ code, argc, argv, cleanup_func,
+ cleanup_arg);
}
+
#if KILLME
-static void smx_ctx_lua_free(smx_context_t context) {
+static void smx_ctx_lua_free(smx_context_t context)
+{
- if (context){
- DEBUG1("smx_ctx_lua_free_context(%p)",context);
+ if (context) {
+ DEBUG1("smx_ctx_lua_free_context(%p)", context);
}
smx_ctx_sysv_free(context);
}
-static void smx_ctx_lua_stop(smx_context_t pcontext) {
- DEBUG1("Stopping '%s' (nothing to do)",pcontext->argv[0]);
+static void smx_ctx_lua_stop(smx_context_t pcontext)
+{
+ DEBUG1("Stopping '%s' (nothing to do)", pcontext->argv[0]);
smx_ctx_sysv_stop(pcontext);
}
-static void smx_ctx_lua_suspend(smx_context_t pcontext) {
- smx_ctx_lua_t context = (smx_ctx_lua_t)pcontext;
- DEBUG1("Suspending '%s' (using sysv facilities)",context->super.super.argv[0]);
+static void smx_ctx_lua_suspend(smx_context_t pcontext)
+{
+ smx_ctx_lua_t context = (smx_ctx_lua_t) pcontext;
+ DEBUG1("Suspending '%s' (using sysv facilities)",
+ context->super.super.argv[0]);
smx_ctx_sysv_suspend(pcontext);
DEBUG0("Back from call yielding");
}
-static void
-smx_ctx_lua_resume(smx_context_t new_context) {
- smx_ctx_lua_t context = (smx_ctx_lua_t)new_context;
- DEBUG1("Resuming %s",context->super.super.argv[0]);
+static void smx_ctx_lua_resume(smx_context_t new_context)
+{
+ smx_ctx_lua_t context = (smx_ctx_lua_t) new_context;
+ DEBUG1("Resuming %s", context->super.super.argv[0]);
smx_ctx_sysv_resume(new_context);
}
#endif
concepts must implement */
/* 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 begining -- OOP in C :/ */
typedef struct s_smx_context {
smx_context_t
smx_ctx_base_factory_create_context_sized(size_t size,
- xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+ xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
void smx_ctx_base_free(smx_context_t context);
void smx_ctx_base_stop(smx_context_t context);
SG_END_DECL()
-#endif /* !_XBT_CONTEXT_PRIVATE_H */
-
-
+#endif /* !_XBT_CONTEXT_PRIVATE_H */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby);
static smx_context_t
-smx_ctx_ruby_create_context(xbt_main_func_t code,int argc,char** argv,
- void_f_pvoid_t cleanup_func,void *cleanup_arg);
+smx_ctx_ruby_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
static void smx_ctx_ruby_stop(smx_context_t context);
static void smx_ctx_ruby_suspend(smx_context_t context);
static void smx_ctx_ruby_resume(smx_context_t new_context);
-static void smx_ctx_ruby_wrapper(void);
+static void smx_ctx_ruby_wrapper(void);
-void SIMIX_ctx_ruby_factory_init(smx_context_factory_t *factory) {
+void SIMIX_ctx_ruby_factory_init(smx_context_factory_t * factory)
+{
smx_ctx_base_factory_init(factory);
(*factory)->create_context = smx_ctx_ruby_create_context;
ruby_init_loadpath();
}
-static smx_context_t
-smx_ctx_ruby_create_context(xbt_main_func_t code,int argc,char** argv,
- void_f_pvoid_t cleanup_func,void* cleanup_arg) {
+static smx_context_t
+smx_ctx_ruby_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func, void *cleanup_arg)
+{
- smx_ctx_ruby_t context = (smx_ctx_ruby_t)smx_ctx_base_factory_create_context_sized
- (sizeof(s_smx_ctx_ruby_t), code,argc,argv,cleanup_func,cleanup_arg);
+ smx_ctx_ruby_t context = (smx_ctx_ruby_t)
+ smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_ruby_t),
+ code, argc, argv,
+ cleanup_func, cleanup_arg);
/* if the user provided a function for the process , then use it
Otherwise it's the context for maestro */
if (code) {
- context->process = (VALUE)code;
+ context->process = (VALUE) code;
- DEBUG1("smx_ctx_ruby_create_context(%s)...Done",argv[0]);
+ DEBUG1("smx_ctx_ruby_create_context(%s)...Done", argv[0]);
}
return (smx_context_t) context;
}
-static void smx_ctx_ruby_stop(smx_context_t context) {
+static void smx_ctx_ruby_stop(smx_context_t context)
+{
DEBUG0("smx_ctx_ruby_stop()");
VALUE process = Qnil;
- smx_ctx_ruby_t ctx_ruby,current;
+ smx_ctx_ruby_t ctx_ruby, current;
smx_ctx_base_stop(context);
ctx_ruby = (smx_ctx_ruby_t) context;
-
- if ( simix_global->current_process->iwannadie ) {
- if( ctx_ruby->process ) {
-
+
+ if (simix_global->current_process->iwannadie) {
+ if (ctx_ruby->process) {
+
//if the Ruby Process still Alive ,let's Schedule it
- if ( rb_process_isAlive( ctx_ruby->process ) ) {
+ if (rb_process_isAlive(ctx_ruby->process)) {
- current = (smx_ctx_ruby_t)simix_global->current_process->context;
+ current = (smx_ctx_ruby_t) simix_global->current_process->context;
rb_process_schedule(current->process);
process = ctx_ruby->process;
// interupt/kill The Ruby Process
}
} else {
- if (ctx_ruby->process)
- ctx_ruby->process = Qnil;
+ if (ctx_ruby->process)
+ ctx_ruby->process = Qnil;
}
}
-static void smx_ctx_ruby_suspend(smx_context_t context) {
+static void smx_ctx_ruby_suspend(smx_context_t context)
+{
- DEBUG1("smx_ctx_ruby_suspend(%s)",context->argv[0]);
- smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) context;
- if (ctx_ruby->process)
- rb_process_unschedule(ctx_ruby->process);
+ DEBUG1("smx_ctx_ruby_suspend(%s)", context->argv[0]);
+ smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) context;
+ if (ctx_ruby->process)
+ rb_process_unschedule(ctx_ruby->process);
}
-static void smx_ctx_ruby_resume(smx_context_t new_context) {
+static void smx_ctx_ruby_resume(smx_context_t new_context)
+{
DEBUG1("smx_ctx_ruby_resume(%s)",
- (new_context->argc?new_context->argv[0]:"maestro"));
+ (new_context->argc ? new_context->argv[0] : "maestro"));
smx_ctx_ruby_t ctx_ruby = (smx_ctx_ruby_t) new_context;
rb_process_schedule(ctx_ruby->process);
#ifdef HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
-#endif /* HAVE_VALGRIND_VALGRIND_H */
+#endif /* HAVE_VALGRIND_VALGRIND_H */
#ifdef _XBT_WIN32
- #include "win32_ucontext.h"
- #include "win32_ucontext.c"
+#include "win32_ucontext.h"
+#include "win32_ucontext.c"
#else
- #include "ucontext.h"
+#include "ucontext.h"
#endif
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
-static smx_context_t
-smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+static smx_context_t
+smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
static void smx_ctx_sysv_wrapper(void);
-void SIMIX_ctx_sysv_factory_init(smx_context_factory_t *factory) {
+void SIMIX_ctx_sysv_factory_init(smx_context_factory_t * factory)
+{
smx_ctx_base_factory_init(factory);
}
smx_context_t
-smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg) {
-
- smx_ctx_sysv_t context = (smx_ctx_sysv_t)smx_ctx_base_factory_create_context_sized
- (size, code,argc,argv,cleanup_func,cleanup_arg);
+smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code,
+ int argc, char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg)
+{
+
+ smx_ctx_sysv_t context =
+ (smx_ctx_sysv_t) smx_ctx_base_factory_create_context_sized(size,
+ code,
+ argc,
+ argv,
+ cleanup_func,
+ cleanup_arg);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
- if(code){
+ if (code) {
xbt_assert2(getcontext(&(context->uc)) == 0,
- "Error in context saving: %d (%s)", errno, strerror(errno));
+ "Error in context saving: %d (%s)", errno,
+ strerror(errno));
context->uc.uc_link = NULL;
#ifdef HAVE_VALGRIND_VALGRIND_H
context->valgrind_stack_id =
VALGRIND_STACK_REGISTER(context->uc.uc_stack.ss_sp,
- ((char *) context->uc.uc_stack.ss_sp) +
- context->uc.uc_stack.ss_size);
-#endif /* HAVE_VALGRIND_VALGRIND_H */
+ ((char *) context->uc.uc_stack.ss_sp) +
+ context->uc.uc_stack.ss_size);
+#endif /* HAVE_VALGRIND_VALGRIND_H */
- makecontext(&((smx_ctx_sysv_t)context)->uc, smx_ctx_sysv_wrapper, 0);
+ makecontext(&((smx_ctx_sysv_t) context)->uc, smx_ctx_sysv_wrapper, 0);
}
- return (smx_context_t)context;
+ return (smx_context_t) context;
}
static smx_context_t
-smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg) {
+smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_f_pvoid_t cleanup_func, void *cleanup_arg)
+{
return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t),
- code,argc,argv,cleanup_func,cleanup_arg);
+ code, argc, argv, cleanup_func,
+ cleanup_arg);
}
-void smx_ctx_sysv_free(smx_context_t context) {
+void smx_ctx_sysv_free(smx_context_t context)
+{
- if (context){
+ if (context) {
#ifdef HAVE_VALGRIND_VALGRIND_H
- VALGRIND_STACK_DEREGISTER(((smx_ctx_sysv_t) context)->valgrind_stack_id);
-#endif /* HAVE_VALGRIND_VALGRIND_H */
+ VALGRIND_STACK_DEREGISTER(((smx_ctx_sysv_t)
+ context)->valgrind_stack_id);
+#endif /* HAVE_VALGRIND_VALGRIND_H */
}
smx_ctx_base_free(context);
}
-void smx_ctx_sysv_stop(smx_context_t context) {
+void smx_ctx_sysv_stop(smx_context_t context)
+{
smx_ctx_base_stop(context);
smx_ctx_sysv_suspend(context);
}
-void smx_ctx_sysv_wrapper() {
+void smx_ctx_sysv_wrapper()
+{
/*FIXME: I would like to avoid accessing simix_global to get the current
- context by passing it as an argument of the wrapper function. The problem
- is that this function is called from smx_ctx_sysv_start, and uses
- makecontext for calling it, and the stupid posix specification states that
- all the arguments of the function should be int(32 bits), making it useless
- in 64-bit architectures where pointers are 64 bit long.
+ context by passing it as an argument of the wrapper function. The problem
+ is that this function is called from smx_ctx_sysv_start, and uses
+ makecontext for calling it, and the stupid posix specification states that
+ all the arguments of the function should be int(32 bits), making it useless
+ in 64-bit architectures where pointers are 64 bit long.
*/
- smx_ctx_sysv_t context =
- (smx_ctx_sysv_t)simix_global->current_process->context;
+ smx_ctx_sysv_t context =
+ (smx_ctx_sysv_t) simix_global->current_process->context;
(context->super.code) (context->super.argc, context->super.argv);
- smx_ctx_sysv_stop((smx_context_t)context);
+ smx_ctx_sysv_stop((smx_context_t) context);
}
-void smx_ctx_sysv_suspend(smx_context_t context) {
- ucontext_t maestro_ctx = ((smx_ctx_sysv_t)simix_global->maestro_process->context)->uc;
+void smx_ctx_sysv_suspend(smx_context_t context)
+{
+ ucontext_t maestro_ctx =
+ ((smx_ctx_sysv_t) simix_global->maestro_process->context)->uc;
int rv = swapcontext(&((smx_ctx_sysv_t) context)->uc, &maestro_ctx);
xbt_assert0((rv == 0), "Context swapping failure");
}
-void smx_ctx_sysv_resume(smx_context_t new_context) {
- smx_ctx_sysv_t maestro = (smx_ctx_sysv_t)simix_global->maestro_process->context;
+void smx_ctx_sysv_resume(smx_context_t new_context)
+{
+ smx_ctx_sysv_t maestro =
+ (smx_ctx_sysv_t) simix_global->maestro_process->context;
- int rv = swapcontext(&(maestro->uc), &((smx_ctx_sysv_t)new_context)->uc);
+ int rv =
+ swapcontext(&(maestro->uc), &((smx_ctx_sysv_t) new_context)->uc);
xbt_assert0((rv == 0), "Context swapping failure");
}
/* lower this if you want to reduce the memory consumption */
-#ifndef CONTEXT_STACK_SIZE /* allow lua to override this */
+#ifndef CONTEXT_STACK_SIZE /* allow lua to override this */
#define CONTEXT_STACK_SIZE 128*1024
-#endif /*CONTEXT_STACK_SIZE */
-
+#endif /*CONTEXT_STACK_SIZE */
#include "context_sysv_config.h" /* loads context system definitions */
#ifdef _XBT_WIN32
-#include <win32_ucontext.h> /* context relative declarations */
+#include <win32_ucontext.h> /* context relative declarations */
#else
#include <ucontext.h> /* context relative declarations */
#endif
unsigned int valgrind_stack_id; /* the valgrind stack id */
#endif
char stack[CONTEXT_STACK_SIZE]; /* the thread stack size */
-} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;smx_context_t
+} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
+smx_context_t
smx_ctx_sysv_create_context_sized(size_t structure_size,
- xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+ xbt_main_func_t code, int argc,
+ char **argv, void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
void smx_ctx_sysv_free(smx_context_t context);
void smx_ctx_sysv_stop(smx_context_t context);
void smx_ctx_sysv_suspend(smx_context_t context);
void smx_ctx_sysv_resume(smx_context_t new_context);
SG_END_DECL()
-#endif /* !_XBT_CONTEXT_SYSV_PRIVATE_H */
-
-
+#endif /* !_XBT_CONTEXT_SYSV_PRIVATE_H */
} s_smx_ctx_thread_t, *smx_ctx_thread_t;
static smx_context_t
-smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg);
+smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg);
static void smx_ctx_thread_free(smx_context_t context);
static void smx_ctx_thread_stop(smx_context_t context);
static void *smx_ctx_thread_wrapper(void *param);
-void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory) {
+void SIMIX_ctx_thread_factory_init(smx_context_factory_t * factory)
+{
smx_ctx_base_factory_init(factory);
(*factory)->name = "ctx_thread_factory";
}
-static smx_context_t
-smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, char** argv,
- void_f_pvoid_t cleanup_func, void* cleanup_arg)
+static smx_context_t
+smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc,
+ char **argv,
+ void_f_pvoid_t cleanup_func,
+ void *cleanup_arg)
{
- smx_ctx_thread_t context = (smx_ctx_thread_t)smx_ctx_base_factory_create_context_sized
- (sizeof(s_smx_ctx_thread_t), code,argc,argv,cleanup_func,cleanup_arg);
+ smx_ctx_thread_t context = (smx_ctx_thread_t)
+ smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_thread_t),
+ code, argc, argv,
+ cleanup_func, cleanup_arg);
/* If the user provided a function for the process then use it
otherwise is the context for maestro */
- if(code){
+ if (code) {
context->begin = xbt_os_sem_init(0);
context->end = xbt_os_sem_init(0);
/* NOTE: The first argument to xbt_os_thread_create used to be the process *
* name, but now the name is stored at SIMIX level, so we pass a null */
context->thread =
- xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, context);
+ xbt_os_thread_create(NULL, smx_ctx_thread_wrapper, context);
/* wait the starting of the newly created process */
xbt_os_sem_acquire(context->end);
}
-
- return (smx_context_t)context;
+
+ return (smx_context_t) context;
}
static void smx_ctx_thread_free(smx_context_t pcontext)
{
- smx_ctx_thread_t context = (smx_ctx_thread_t)pcontext;
+ smx_ctx_thread_t context = (smx_ctx_thread_t) pcontext;
- /* check if this is the context of maestro (it doesn't has a real thread) */
+ /* check if this is the context of maestro (it doesn't has a real thread) */
if (context->thread) {
/* wait about the thread terminason */
xbt_os_thread_join(context->thread, NULL);
-
+
/* destroy the synchronisation objects */
xbt_os_sem_destroy(context->begin);
xbt_os_sem_destroy(context->end);
}
-
+
smx_ctx_base_free(pcontext);
}
static void smx_ctx_thread_stop(smx_context_t pcontext)
{
- smx_ctx_thread_t context = (smx_ctx_thread_t)pcontext;
-
+ smx_ctx_thread_t context = (smx_ctx_thread_t) pcontext;
+
/* please no debug here: our procdata was already free'd */
smx_ctx_base_stop(pcontext);
/* exit */
/* We should provide return value in case other wants it */
- xbt_os_thread_exit(NULL);
+ xbt_os_thread_exit(NULL);
}
static void *smx_ctx_thread_wrapper(void *param)
(context->super.code) (context->super.argc, context->super.argv);
- smx_ctx_thread_stop((smx_context_t)context);
+ smx_ctx_thread_stop((smx_context_t) context);
return NULL;
}
-static void smx_ctx_thread_suspend(smx_context_t context) {
+static void smx_ctx_thread_suspend(smx_context_t context)
+{
xbt_os_sem_release(((smx_ctx_thread_t) context)->end);
xbt_os_sem_acquire(((smx_ctx_thread_t) context)->begin);
}
-static void smx_ctx_thread_resume(smx_context_t new_context) {
+static void smx_ctx_thread_resume(smx_context_t new_context)
+{
xbt_os_sem_release(((smx_ctx_thread_t) new_context)->begin);
xbt_os_sem_acquire(((smx_ctx_thread_t) new_context)->end);
}
surf_timer_model->extension.timer.set(start_time, (void *)
&SIMIX_process_create, arg);
- } else { // start_time <= SIMIX_get_clock()
+ } else { // start_time <= SIMIX_get_clock()
DEBUG2("Starting Process %s(%s) right now", parse_argv[0], parse_host);
if (simix_global->create_process_function)
process =
- (*simix_global->create_process_function) (parse_argv[0], parse_code,
- NULL, parse_host,
- parse_argc, parse_argv,
- /*the props */
- current_property_set);
+ (*simix_global->create_process_function) (parse_argv[0],
+ parse_code, NULL,
+ parse_host, parse_argc,
+ parse_argv,
+ /*the props */
+ current_property_set);
else
process = SIMIX_process_create(parse_argv[0], parse_code, NULL, parse_host, parse_argc, parse_argv, /*the props */
current_property_set);
return;
}
if (kill_time > SIMIX_get_clock()) {
- if (simix_global->kill_process_function)
- surf_timer_model->extension.timer.set(start_time, (void *)
+ if (simix_global->kill_process_function)
+ surf_timer_model->extension.timer.set(start_time, (void *)
simix_global->kill_process_function,
process);
- else
- surf_timer_model->extension.timer.set(kill_time, (void *)
+ else
+ surf_timer_model->extension.timer.set(kill_time, (void *)
&SIMIX_process_kill,
(void *) process);
}
surfxml_add_callback(STag_surfxml_process_cb_list, parse_process_init);
surfxml_add_callback(ETag_surfxml_argument_cb_list, parse_argument);
surfxml_add_callback(STag_surfxml_prop_cb_list, parse_properties);
- surfxml_add_callback(ETag_surfxml_process_cb_list, parse_process_finalize);
+ surfxml_add_callback(ETag_surfxml_process_cb_list,
+ parse_process_finalize);
surf_parse_open(file);
parse_status = surf_parse();
* \param name the reference name of the function.
* \param code the function
*/
-XBT_INLINE void SIMIX_function_register(const char *name, xbt_main_func_t code)
+XBT_INLINE void SIMIX_function_register(const char *name,
+ xbt_main_func_t code)
{
xbt_assert0(simix_global,
"SIMIX_global_init has to be called before SIMIX_function_register.");
* \brief Bypass the parser, get arguments, and set function to each process
*/
-void SIMIX_process_set_function(const char* process_host,const char *process_function,xbt_dynar_t arguments,double process_start_time,double process_kill_time)
+void SIMIX_process_set_function(const char *process_host,
+ const char *process_function,
+ xbt_dynar_t arguments,
+ double process_start_time,
+ double process_kill_time)
{
unsigned int i;
char *arg;
xbt_assert1(SIMIX_host_get_by_name(parse_host),
"Host '%s' unknown", parse_host);
parse_code = SIMIX_get_registered_function(process_function);
- xbt_assert1(parse_code, "Function '%s' unknown",
- process_function);
+ xbt_assert1(parse_code, "Function '%s' unknown", process_function);
parse_argc = 0;
parse_argv = NULL;
current_property_set = xbt_dict_new();
/* add arguments */
- xbt_dynar_foreach(arguments,i,arg)
- {
- parse_argc++;
- parse_argv = xbt_realloc(parse_argv, (parse_argc) * sizeof(char *));
- parse_argv[(parse_argc) - 1] = xbt_strdup(arg);
+ xbt_dynar_foreach(arguments, i, arg) {
+ parse_argc++;
+ parse_argv = xbt_realloc(parse_argv, (parse_argc) * sizeof(char *));
+ parse_argv[(parse_argc) - 1] = xbt_strdup(arg);
}
/*finalize */
DEBUG1("PARSE TIME: %lg", (end - start));
#ifdef HAVE_TRACING
- TRACE_surf_save_onelink ();
+ TRACE_surf_save_onelink();
#endif
xbt_dict_foreach(surf_model_resource_set(surf_workstation_model), cursor,
simix_global->host = xbt_dict_new();
simix_global->process_to_run =
- xbt_swag_new(xbt_swag_offset(proc, synchro_hookup));
+ xbt_swag_new(xbt_swag_offset(proc, synchro_hookup));
simix_global->process_list =
- xbt_swag_new(xbt_swag_offset(proc, process_hookup));
+ xbt_swag_new(xbt_swag_offset(proc, process_hookup));
simix_global->process_to_destroy =
- xbt_swag_new(xbt_swag_offset(proc, destroy_hookup));
+ xbt_swag_new(xbt_swag_offset(proc, destroy_hookup));
simix_global->current_process = NULL;
simix_global->maestro_process = NULL;
smx_action_t act;
int nbprocess = xbt_swag_size(simix_global->process_list);
- INFO1("%d processes are still running, waiting for something.", nbprocess);
+ INFO1("%d processes are still running, waiting for something.",
+ nbprocess);
/* List the process and their state */
INFO0
- ("Legend of the following listing: \"<process> on <host>: <status>.\"");
+ ("Legend of the following listing: \"<process> on <host>: <status>.\"");
xbt_swag_foreach(process, simix_global->process_list) {
char *who, *who2;
if (process->mutex) {
who2 =
- bprintf("%s Blocked on mutex %p", who,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- process->mutex : (void *) 0xdead);
+ bprintf("%s Blocked on mutex %p", who,
+ (XBT_LOG_ISENABLED
+ (simix_kernel,
+ xbt_log_priority_verbose)) ? process->mutex : (void *)
+ 0xdead);
free(who);
who = who2;
} else if (process->cond) {
who2 =
- bprintf
- ("%s Blocked on condition %p; Waiting for the following actions:",
- who,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- process->cond : (void *) 0xdead);
+ bprintf
+ ("%s Blocked on condition %p; Waiting for the following actions:",
+ who,
+ (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
+ process->cond : (void *) 0xdead);
free(who);
who = who2;
xbt_fifo_foreach(process->cond->actions, item, act, smx_action_t) {
who2 =
- bprintf("%s '%s'(%p)", who, act->name,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose))
- ? act : (void *) 0xdead);
+ bprintf("%s '%s'(%p)", who, act->name,
+ (XBT_LOG_ISENABLED
+ (simix_kernel, xbt_log_priority_verbose))
+ ? act : (void *) 0xdead);
free(who);
who = who2;
}
} else if (process->sem) {
who2 =
- bprintf
- ("%s Blocked on semaphore %p; Waiting for the following actions:",
- who,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
- process->sem : (void *) 0xdead);
+ bprintf
+ ("%s Blocked on semaphore %p; Waiting for the following actions:",
+ who,
+ (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose)) ?
+ process->sem : (void *) 0xdead);
free(who);
who = who2;
xbt_fifo_foreach(process->sem->actions, item, act, smx_action_t) {
who2 =
- bprintf("%s '%s'(%p)", who, act->name,
- (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_verbose))
- ? act : (void *) 0xdead);
+ bprintf("%s '%s'(%p)", who, act->name,
+ (XBT_LOG_ISENABLED
+ (simix_kernel, xbt_log_priority_verbose))
+ ? act : (void *) 0xdead);
free(who);
who = who2;
}
} else {
who2 =
- bprintf
- ("%s Blocked in an unknown status (please report this bug)", who);
+ bprintf
+ ("%s Blocked in an unknown status (please report this bug)",
+ who);
free(who);
who = who2;
}
int actions_on_system = 0;
SIMIX_process_empty_trash();
- if (XBT_LOG_ISENABLED(simix_kernel,xbt_log_priority_debug) &&
+ if (XBT_LOG_ISENABLED(simix_kernel, xbt_log_priority_debug) &&
xbt_swag_size(simix_global->process_to_run) && (elapsed_time > 0)) {
DEBUG0("**************************************************");
}
smx_process_arg_t args = arg;
DEBUG2("Launching %s on %s", args->name, args->hostname);
process =
- (*simix_global->create_process_function) (args->name, args->code,
- args->data,
- args->hostname,
- args->argc, args->argv,
- args->properties);
+ (*simix_global->create_process_function) (args->name,
+ args->code,
+ args->data,
+ args->hostname,
+ args->argc,
+ args->argv,
+ args->properties);
/* verify if process has been created */
if (!process) {
xbt_free(args);
while ((action = xbt_swag_extract(model->states.done_action_set))) {
smx_action = action->data;
if (smx_action) {
- SIMIX_action_signal_all(smx_action);
+ SIMIX_action_signal_all(smx_action);
}
}
}
* \param function Create process function
*
*/
-XBT_INLINE void SIMIX_function_register_process_create(smx_creation_func_t function)
+XBT_INLINE void SIMIX_function_register_process_create(smx_creation_func_t
+ function)
{
xbt_assert0((simix_global->create_process_function == NULL),
"Data already set");
* \param function Kill process function
*
*/
-XBT_INLINE void SIMIX_function_register_process_kill(void_f_pvoid_t function)
+XBT_INLINE void SIMIX_function_register_process_kill(void_f_pvoid_t
+ function)
{
xbt_assert0((simix_global->kill_process_function == NULL),
"Data already set");
* \param function cleanup process function
*
*/
-XBT_INLINE void SIMIX_function_register_process_cleanup(void_f_pvoid_t function)
+XBT_INLINE void SIMIX_function_register_process_cleanup(void_f_pvoid_t
+ function)
{
simix_global->cleanup_process_function = function;
}
smx_host->name = xbt_strdup(name);
smx_host->data = data;
smx_host->host = workstation;
- smx_host->process_list = xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
+ smx_host->process_list =
+ xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
/* Update global variables */
- xbt_dict_set(simix_global->host, smx_host->name, smx_host, &__SIMIX_host_destroy);
+ xbt_dict_set(simix_global->host, smx_host->name, smx_host,
+ &__SIMIX_host_destroy);
return smx_host;
}
/* Clean Simulator data */
if (xbt_swag_size(host->process_list) != 0) {
- char *msg = bprintf("Shutting down host %s, but it's not empty:", host->name);
+ char *msg =
+ bprintf("Shutting down host %s, but it's not empty:", host->name);
char *tmp;
smx_process_t process = NULL;
int i = 0;
xbt_dict_foreach(simix_global->host, c, name, h)
- res[i++] = h;
+ res[i++] = h;
return res;
}
XBT_INLINE smx_host_t SIMIX_host_get_by_name(const char *name)
{
xbt_assert0(((simix_global != NULL)
- && (simix_global->host != NULL)), "Environment not set yet");
+ && (simix_global->host != NULL)),
+ "Environment not set yet");
return xbt_dict_get_or_null(simix_global->host, name);
}
{
xbt_assert0((host != NULL), "Invalid parameters (simix host is NULL)");
- return surf_workstation_model->extension.workstation.get_properties(host->host);
+ return surf_workstation_model->extension.
+ workstation.get_properties(host->host);
}
/******************************************************************************/
/* Rendez-Vous Points */
-/******************************************************************************/
+/******************************************************************************/
/**
* \brief Creates a new rendez-vous point
*/
void SIMIX_rdv_destroy(smx_rdv_t rdv)
{
- if(rdv->name)
+ if (rdv->name)
xbt_free(rdv->name);
SIMIX_mutex_destroy(rdv->read);
SIMIX_mutex_destroy(rdv->write);
xbt_fifo_remove(rdv->comm_fifo, comm);
comm->rdv = NULL;
}
-
+
/**
* \brief Checks if there is a communication request 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 request if found, NULL otherwise.
*/
-smx_comm_t SIMIX_rdv_get_request(smx_rdv_t rdv, smx_comm_type_t type) {
- smx_comm_t comm = (smx_comm_t)xbt_fifo_get_item_content(
- xbt_fifo_get_first_item(rdv->comm_fifo));
+smx_comm_t SIMIX_rdv_get_request(smx_rdv_t rdv, smx_comm_type_t type)
+{
+ smx_comm_t comm = (smx_comm_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
- if(comm && comm->type == type){
+ if (comm && comm->type == type) {
DEBUG0("Communication request found!");
xbt_fifo_shift(rdv->comm_fifo);
SIMIX_communication_use(comm);
* \param host The host to be counted
* \return The number of comm request pending in the rdv
*/
-int
-SIMIX_rdv_get_count_waiting_comm(smx_rdv_t rdv, smx_host_t host)
+int SIMIX_rdv_get_count_waiting_comm(smx_rdv_t rdv, smx_host_t host)
{
smx_comm_t comm = NULL;
xbt_fifo_item_t item = NULL;
*/
XBT_INLINE smx_comm_t SIMIX_rdv_get_head(smx_rdv_t rdv)
{
- return (smx_comm_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
+ return (smx_comm_t)
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo));
}
/** @brief adds some API-related data to the rendez-vous point */
-XBT_INLINE void SIMIX_rdv_set_data(smx_rdv_t rdv,void *data) {
- rdv->data=data;
+XBT_INLINE void SIMIX_rdv_set_data(smx_rdv_t rdv, void *data)
+{
+ rdv->data = data;
}
+
/** @brief gets API-related data from the rendez-vous point */
-XBT_INLINE void *SIMIX_rdv_get_data(smx_rdv_t rdv) {
+XBT_INLINE void *SIMIX_rdv_get_data(smx_rdv_t rdv)
+{
return rdv->data;
}
/******************************************************************************/
/* Communication Requests */
-/******************************************************************************/
+/******************************************************************************/
/**
* \brief Creates a new communication request
* \param type The type of communication (comm_send, comm_recv)
* \return The new communication request
- */
+ */
smx_comm_t SIMIX_communication_new(smx_comm_type_t type)
{
/* alloc structures */
comm->type = type;
comm->sem = SIMIX_sem_init(0);
comm->refcount = 1;
-
+
return comm;
}
*/
void SIMIX_communication_destroy(smx_comm_t comm)
{
- VERB2("Destroy communication %p; refcount initially %d",comm,comm->refcount);
+ VERB2("Destroy communication %p; refcount initially %d", comm,
+ comm->refcount);
#ifdef HAVE_LATENCY_BOUND_TRACKING
//save is latency limited flag to use afterwards
if (latency_limited_dict == NULL) {
- latency_limited_dict = xbt_dict_new();
+ latency_limited_dict = xbt_dict_new();
}
- if (comm->act){
- DEBUG2("adding key %p with latency limited value %d to the dict", comm, SIMIX_action_is_latency_bounded(comm->act));
- xbt_dicti_set(latency_limited_dict, (uintptr_t)comm, SIMIX_action_is_latency_bounded(comm->act));
+ if (comm->act) {
+ DEBUG2("adding key %p with latency limited value %d to the dict", comm,
+ SIMIX_action_is_latency_bounded(comm->act));
+ xbt_dicti_set(latency_limited_dict, (uintptr_t) comm,
+ SIMIX_action_is_latency_bounded(comm->act));
}
#endif
comm->refcount--;
- if(comm->refcount > 0)
+ if (comm->refcount > 0)
return;
- if(comm->sem){
+ if (comm->sem) {
SIMIX_sem_destroy(comm->sem);
comm->sem = NULL;
}
-
- if(comm->act){
+
+ if (comm->act) {
SIMIX_action_destroy(comm->act);
comm->act = NULL;
}
- if(comm->src_timeout){
+ if (comm->src_timeout) {
SIMIX_action_destroy(comm->src_timeout);
comm->src_timeout = NULL;
}
- if(comm->dst_timeout){
- SIMIX_action_destroy(comm->dst_timeout);
- comm->dst_timeout = NULL;
- }
+ if (comm->dst_timeout) {
+ SIMIX_action_destroy(comm->dst_timeout);
+ comm->dst_timeout = NULL;
+ }
static XBT_INLINE void SIMIX_communication_start(smx_comm_t comm)
{
/* If both the sender and the receiver are already there, start the communication */
- if(comm->src_proc && comm->dst_proc){
+ if (comm->src_proc && comm->dst_proc) {
DEBUG1("Starting communication %p", comm);
- comm->act = SIMIX_action_communicate(comm->src_proc->smx_host,
- comm->dst_proc->smx_host, NULL,
+ comm->act = SIMIX_action_communicate(comm->src_proc->smx_host,
+ comm->dst_proc->smx_host, NULL,
comm->task_size, comm->rate);
#ifdef HAVE_TRACING
- TRACE_smx_action_communicate (comm->act, comm->src_proc);
- TRACE_surf_action (comm->act->surf_action, comm->act->category);
+ TRACE_smx_action_communicate(comm->act, comm->src_proc);
+ TRACE_surf_action(comm->act->surf_action, comm->act->category);
#endif
/* If any of the process is suspend, create the action but stop its execution,
it will be restarted when the sender process resume */
- if(SIMIX_process_is_suspended(comm->src_proc) ||
- SIMIX_process_is_suspended(comm->dst_proc)) {
+ if (SIMIX_process_is_suspended(comm->src_proc) ||
+ SIMIX_process_is_suspended(comm->dst_proc)) {
SIMIX_action_suspend(comm->act);
}
-
+
/* Add the communication as user data of the action */
comm->act->data = comm;
/* Make sure that everyone sleeping on that semaphore is awake, and that nobody will ever block on it */
SIMIX_sem_release_forever(comm->sem);
-
+
/* Check for errors other than timeouts */
- if (!SIMIX_host_get_state(SIMIX_host_self())){
- if(comm->rdv)
+ if (!SIMIX_host_get_state(SIMIX_host_self())) {
+ if (comm->rdv)
SIMIX_rdv_remove(comm->rdv, comm);
- SIMIX_communication_destroy(comm);
+ SIMIX_communication_destroy(comm);
THROW0(host_error, 0, "Host failed");
- } else if (SIMIX_action_get_state(comm->act) == SURF_ACTION_FAILED){
+ } else if (SIMIX_action_get_state(comm->act) == SURF_ACTION_FAILED) {
SIMIX_communication_destroy(comm);
THROW0(network_error, 0, "Link failure");
- } else if (!SIMIX_host_get_state(SIMIX_process_get_host(comm->dst_proc)) ||
- !SIMIX_host_get_state(SIMIX_process_get_host(comm->src_proc))) {
+ } else if (!SIMIX_host_get_state(SIMIX_process_get_host(comm->dst_proc))
+ ||
+ !SIMIX_host_get_state(SIMIX_process_get_host(comm->src_proc)))
+ {
/* We test both src&dst because we dunno who we are today, and we already tested myself above.
* So, at the end, we test the remote peer only
* Moreover, we have to test it because if the remote peer fails, the action comm->act is not done nor failed.
}
/* Copy network data */
- SIMIX_network_copy_data(comm);
+ SIMIX_network_copy_data(comm);
SIMIX_communication_destroy(comm);
}
* - timeout_error if communication reached the timeout specified (either because of local peer or remote peer)
* - network_error if network failed or remote peer failed
*/
-static XBT_INLINE void SIMIX_communication_wait_for_completion(smx_comm_t comm, double timeout)
+static XBT_INLINE void SIMIX_communication_wait_for_completion(smx_comm_t
+ comm,
+ double
+ timeout)
{
smx_action_t act_sleep = NULL;
int src_timeout = 0;
int dst_timeout = 0;
DEBUG1("Waiting for the completion of communication %p", comm);
-
+
if (timeout >= 0) {
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), timeout);
- if(SIMIX_process_self()==comm->src_proc)
- comm->src_timeout = act_sleep;
- else
- comm->dst_timeout = act_sleep;
- SIMIX_action_set_name(act_sleep,bprintf("Timeout for comm %p and wait on semaphore %p (max_duration:%f)", comm, comm->sem,timeout));
+ if (SIMIX_process_self() == comm->src_proc)
+ comm->src_timeout = act_sleep;
+ else
+ comm->dst_timeout = act_sleep;
+ SIMIX_action_set_name(act_sleep,
+ bprintf
+ ("Timeout for comm %p and wait on semaphore %p (max_duration:%f)",
+ comm, comm->sem, timeout));
SIMIX_register_action_to_semaphore(act_sleep, comm->sem);
SIMIX_process_self()->waiting_action = act_sleep;
SIMIX_sem_block_onto(comm->sem);
}
/* Check for timeouts */
- if ((src_timeout = ((comm->src_timeout) && (SIMIX_action_get_state(comm->src_timeout) == SURF_ACTION_DONE))) ||
- (dst_timeout = ((comm->dst_timeout) && (SIMIX_action_get_state(comm->dst_timeout) == SURF_ACTION_DONE))) ) {
- /* Somebody did a timeout! */
- if (src_timeout) DEBUG1("Communication timeout from the src! %p", comm);
- if (dst_timeout) DEBUG1("Communication timeout from the dst! %p", comm);
-
- if(comm->act && SIMIX_action_get_state(comm->act) == SURF_ACTION_RUNNING)
+ if ((src_timeout = ((comm->src_timeout)
+ && (SIMIX_action_get_state(comm->src_timeout) ==
+ SURF_ACTION_DONE)))
+ || (dst_timeout = ((comm->dst_timeout)
+ && (SIMIX_action_get_state(comm->dst_timeout) ==
+ SURF_ACTION_DONE)))) {
+ /* Somebody did a timeout! */
+ if (src_timeout)
+ DEBUG1("Communication timeout from the src! %p", comm);
+ if (dst_timeout)
+ DEBUG1("Communication timeout from the dst! %p", comm);
+
+ if (comm->act
+ && SIMIX_action_get_state(comm->act) == SURF_ACTION_RUNNING)
SIMIX_communication_cancel(comm);
else if (comm->rdv)
SIMIX_rdv_remove(comm->rdv, comm);
SIMIX_sem_release_forever(comm->sem);
SIMIX_communication_destroy(comm);
- THROW1(timeout_error, 0, "Communication timeouted because of %s",src_timeout?"the source":"the destination");
+ THROW1(timeout_error, 0, "Communication timeouted because of %s",
+ src_timeout ? "the source" : "the destination");
}
DEBUG1("Communication %p complete!", comm);
{
DEBUG1("calling SIMIX_action_get_remains(%p)", comm->act);
return SIMIX_action_get_remains(comm->act);
-}
+}
#ifdef HAVE_LATENCY_BOUND_TRACKING
/**
uintptr_t key = 0;
uintptr_t data = 0;
xbt_dict_cursor_t cursor;
- xbt_dict_foreach(latency_limited_dict,cursor,key,data) {
- DEBUG2("comparing key=%p with comm=%p", (void*)key, (void*)comm);
- if((void*)comm == (void*)key){
- DEBUG2("key %p found, return value latency limited value %d", (void*)key, (int)data);
- return (int)data;
- }
+ xbt_dict_foreach(latency_limited_dict, cursor, key, data) {
+ DEBUG2("comparing key=%p with comm=%p", (void *) key, (void *) comm);
+ if ((void *) comm == (void *) key) {
+ DEBUG2("key %p found, return value latency limited value %d",
+ (void *) key, (int) data);
+ return (int) data;
+ }
}
DEBUG1("calling SIMIX_action_is_latency_bounded(%p)", comm->act);
/******************************************************************************/
/* SIMIX_network_copy_data callbacks */
/******************************************************************************/
-static void (*SIMIX_network_copy_data_callback)(smx_comm_t, size_t) = &SIMIX_network_copy_pointer_callback;
+static void (*SIMIX_network_copy_data_callback) (smx_comm_t, size_t) =
+ &SIMIX_network_copy_pointer_callback;
-void SIMIX_network_set_copy_data_callback(void (*callback)(smx_comm_t, size_t)) {
+void
+SIMIX_network_set_copy_data_callback(void (*callback) (smx_comm_t, size_t))
+{
SIMIX_network_copy_data_callback = callback;
}
-void SIMIX_network_copy_pointer_callback(smx_comm_t comm, size_t buff_size) {
- xbt_assert1((buff_size == sizeof(void*)), "Cannot copy %zu bytes: must be sizeof(void*)",buff_size);
- *(void**)(comm->dst_buff) = comm->src_buff;
+void SIMIX_network_copy_pointer_callback(smx_comm_t comm, size_t buff_size)
+{
+ xbt_assert1((buff_size == sizeof(void *)),
+ "Cannot copy %zu bytes: must be sizeof(void*)", buff_size);
+ *(void **) (comm->dst_buff) = comm->src_buff;
}
-void SIMIX_network_copy_buffer_callback(smx_comm_t comm, size_t buff_size) {
+void SIMIX_network_copy_buffer_callback(smx_comm_t comm, size_t buff_size)
+{
memcpy(comm->dst_buff, comm->src_buff, buff_size);
}
uintptr_t casted_size = 0;
uintptr_t amount = 0;
/* If there is no data to be copy then return */
- if(!comm->src_buff || !comm->dst_buff || comm->copied == 1)
+ if (!comm->src_buff || !comm->dst_buff || comm->copied == 1)
return;
DEBUG6("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)",
- comm,
- comm->src_proc->smx_host->name, comm->src_buff,
- comm->dst_proc->smx_host->name, comm->dst_buff,
- buff_size);
+ comm,
+ comm->src_proc->smx_host->name, comm->src_buff,
+ comm->dst_proc->smx_host->name, comm->dst_buff, buff_size);
/* Copy at most dst_buff_size bytes of the message to receiver's buffer */
if (comm->dst_buff_size)
- buff_size = MIN(buff_size,*(comm->dst_buff_size));
-
+ buff_size = MIN(buff_size, *(comm->dst_buff_size));
+
/* Update the receiver's buffer size to the copied amount */
if (comm->dst_buff_size)
*comm->dst_buff_size = buff_size;
- if(buff_size == 0)
+ if (buff_size == 0)
return;
- (*SIMIX_network_copy_data_callback)(comm, buff_size);
+ (*SIMIX_network_copy_data_callback) (comm, buff_size);
/* Set the copied flag so we copy data only once */
- /* (this function might be called from both communication ends)*/
+ /* (this function might be called from both communication ends) */
comm->copied = 1;
-
+
/* pimple to display the message sizes */
{
if (msg_sizes == NULL)
amount = xbt_dicti_get(msg_sizes, casted_size);
amount++;
- xbt_dicti_set(msg_sizes,casted_size, amount);
+ xbt_dicti_set(msg_sizes, casted_size, amount);
}
}
+
#include "xbt.h"
/* pimple to display the message sizes */
-void SIMIX_message_sizes_output(const char *filename) {
+void SIMIX_message_sizes_output(const char *filename)
+{
uintptr_t key = 0;
uintptr_t data = 0;
xbt_dict_cursor_t cursor;
- FILE * out = NULL;
- out = fopen(filename,"w");
- xbt_assert1(out,"Cannot open file %s",filename);
+ FILE *out = NULL;
+ out = fopen(filename, "w");
+ xbt_assert1(out, "Cannot open file %s", filename);
- xbt_dict_foreach(msg_sizes,cursor,key,data) {
- fprintf(out,"%zu %zu\n",key,data);
+ xbt_dict_foreach(msg_sizes, cursor, key, data) {
+ fprintf(out, "%zu %zu\n", key, data);
}
fclose(out);
}
{
return comm->src_buff;
}
+
XBT_PUBLIC(void *) SIMIX_communication_get_dst_buf(smx_comm_t comm)
{
return comm->dst_buff;
}
+
XBT_PUBLIC(size_t) SIMIX_communication_get_src_buf_size(smx_comm_t comm)
{
return comm->src_buff_size;
}
+
XBT_PUBLIC(size_t) SIMIX_communication_get_dst_buf_size(smx_comm_t comm)
{
return *(comm->dst_buff_size);
* - timeout_error if communication reached the timeout specified
* - network_error if network failed or peer issued a timeout
*/
-XBT_INLINE void SIMIX_network_send(smx_rdv_t rdv, double task_size, double rate,
- double timeout, void *src_buff, size_t src_buff_size,
- smx_comm_t *comm_ref, void *data)
+XBT_INLINE void SIMIX_network_send(smx_rdv_t rdv, double task_size,
+ double rate, double timeout,
+ void *src_buff, size_t src_buff_size,
+ smx_comm_t * comm_ref, void *data)
{
- *comm_ref = SIMIX_network_isend(rdv,task_size,rate,src_buff,src_buff_size,data);
- SIMIX_network_wait(*comm_ref,timeout);
+ *comm_ref =
+ SIMIX_network_isend(rdv, task_size, rate, src_buff, src_buff_size,
+ data);
+ SIMIX_network_wait(*comm_ref, timeout);
}
/**
* - timeout_error if communication reached the timeout specified
* - network_error if network failed or peer issued a timeout
*/
-XBT_INLINE void SIMIX_network_recv(smx_rdv_t rdv, double timeout, void *dst_buff,
- size_t *dst_buff_size, smx_comm_t *comm_ref)
+XBT_INLINE void SIMIX_network_recv(smx_rdv_t rdv, double timeout,
+ void *dst_buff, size_t * dst_buff_size,
+ smx_comm_t * comm_ref)
{
- *comm_ref = (smx_comm_t) SIMIX_network_irecv(rdv,dst_buff,dst_buff_size);
- SIMIX_network_wait(*comm_ref,timeout);
+ *comm_ref =
+ (smx_comm_t) SIMIX_network_irecv(rdv, dst_buff, dst_buff_size);
+ SIMIX_network_wait(*comm_ref, timeout);
}
/******************************************************************************/
/* Asynchronous Communication */
/******************************************************************************/
-smx_comm_t SIMIX_network_isend(smx_rdv_t rdv, double task_size, double rate,
- void *src_buff, size_t src_buff_size, void *data)
+smx_comm_t SIMIX_network_isend(smx_rdv_t rdv, double task_size,
+ double rate, void *src_buff,
+ size_t src_buff_size, void *data)
{
smx_comm_t comm;
- /*If running in model-checking mode then intercept the communication action*/
- #ifdef HAVE_MC
- if (_surf_do_model_check)
- MC_trans_intercept_isend(rdv);
- #endif
+ /*If running in model-checking mode then intercept the communication action */
+#ifdef HAVE_MC
+ if (_surf_do_model_check)
+ MC_trans_intercept_isend(rdv);
+#endif
/* Look for communication request matching our needs.
If it is not found then create it and push it into the rendez-vous point */
comm = SIMIX_rdv_get_request(rdv, comm_recv);
- if(!comm){
+ if (!comm) {
comm = SIMIX_communication_new(comm_send);
SIMIX_rdv_push(rdv, comm);
}
comm->src_buff = src_buff;
comm->src_buff_size = src_buff_size;
comm->data = data;
-
+
SIMIX_communication_start(comm);
return comm;
}
-smx_comm_t SIMIX_network_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size)
+smx_comm_t SIMIX_network_irecv(smx_rdv_t rdv, void *dst_buff,
+ size_t * dst_buff_size)
{
smx_comm_t comm;
- /*If running in model-checking mode then intercept the communication action*/
+ /*If running in model-checking mode then intercept the communication action */
#ifdef HAVE_MC
if (_surf_do_model_check)
MC_trans_intercept_irecv(rdv);
*/
comm = SIMIX_rdv_get_request(rdv, comm_send);
- if(!comm){
+ if (!comm) {
comm = SIMIX_communication_new(comm_recv);
SIMIX_rdv_push(rdv, comm);
}
comm->dst_proc = SIMIX_process_self();
comm->dst_buff = dst_buff;
comm->dst_buff_size = dst_buff_size;
-
+
SIMIX_communication_start(comm);
return comm;
}
/** @brief blocks until the communication terminates or the timeout occurs */
XBT_INLINE void SIMIX_network_wait(smx_comm_t comm, double timeout)
{
- /*If running in model-checking mode then intercept the communication action*/
+ /*If running in model-checking mode then intercept the communication action */
#ifdef HAVE_MC
if (_surf_do_model_check)
MC_trans_intercept_wait(comm);
/** @Returns whether the (asynchronous) communication is done yet or not */
XBT_INLINE int SIMIX_network_test(smx_comm_t comm)
{
- /*If running in model-checking mode then intercept the communication action*/
+ /*If running in model-checking mode then intercept the communication action */
#ifdef HAVE_MC
if (_surf_do_model_check)
MC_trans_intercept_test(comm);
#endif
/* Copy data if the communication is done */
- if(comm->sem && !SIMIX_sem_would_block(comm->sem)){
+ if (comm->sem && !SIMIX_sem_would_block(comm->sem)) {
/* Copy network data */
SIMIX_network_copy_data(comm);
return TRUE;
*/
unsigned int SIMIX_network_waitany(xbt_dynar_t comms)
{
- xbt_dynar_t sems = xbt_dynar_new(sizeof(smx_sem_t),NULL);
- unsigned int cursor, found_comm=-1;
- smx_comm_t comm,comm_finished=NULL;
+ xbt_dynar_t sems = xbt_dynar_new(sizeof(smx_sem_t), NULL);
+ unsigned int cursor, found_comm = -1;
+ smx_comm_t comm, comm_finished = NULL;
- /*If running in model-checking mode then intercept the communication action*/
+ /*If running in model-checking mode then intercept the communication action */
#ifdef HAVE_MC
if (_surf_do_model_check)
MC_trans_intercept_waitany(comms);
#endif
- xbt_dynar_foreach(comms,cursor,comm)
- xbt_dynar_push(sems,&(comm->sem));
+ xbt_dynar_foreach(comms, cursor, comm)
+ xbt_dynar_push(sems, &(comm->sem));
DEBUG1("Waiting for the completion of communication set %p", comms);
found_comm = SIMIX_sem_acquire_any(sems);
xbt_dynar_free_container(&sems);
- xbt_assert0(found_comm!=-1,"Cannot find which communication finished");
- xbt_dynar_get_cpy(comms,found_comm,&comm_finished);
+ xbt_assert0(found_comm != -1,
+ "Cannot find which communication finished");
+ xbt_dynar_get_cpy(comms, found_comm, &comm_finished);
- DEBUG2("Communication %p of communication set %p finished", comm_finished, comms);
+ DEBUG2("Communication %p of communication set %p finished",
+ comm_finished, comms);
/* let the regular code deal with the communication end (errors checking and cleanup).
* A bit of useless work will be done, but that's good for source factorization */
DEBUG2("Start process %s on host %s", name, hostname);
if (!SIMIX_host_get_state(host)) {
- WARN2("Cannot launch process '%s' on failed host '%s'", name, hostname);
+ WARN2("Cannot launch process '%s' on failed host '%s'", name,
+ hostname);
return NULL;
}
process = xbt_new0(s_smx_process_t, 1);
*/
void SIMIX_process_kill(smx_process_t process)
{
- DEBUG2("Killing process %s on %s", process->name, process->smx_host->name);
+ DEBUG2("Killing process %s on %s", process->name,
+ process->smx_host->name);
process->iwannadie = 1;
if (process->cond)
xbt_swag_remove(process, process->cond->sleeping);
if (process->waiting_action) {
- SIMIX_unregister_action_to_condition(process->waiting_action, process->cond);
+ SIMIX_unregister_action_to_condition(process->waiting_action,
+ process->cond);
SIMIX_action_destroy(process->waiting_action);
}
xbt_fifo_remove(process->sem->sleeping, process);
if (process->waiting_action) {
- SIMIX_unregister_action_to_semaphore(process->waiting_action, process->sem);
+ SIMIX_unregister_action_to_semaphore(process->waiting_action,
+ process->sem);
SIMIX_action_destroy(process->waiting_action);
}
}
} else {
DEBUG4("%s(%p) here! killing %s(%p)",
- simix_global->current_process->name,simix_global->current_process,
- process->name,process);
+ simix_global->current_process->name,
+ simix_global->current_process, process->name, process);
/* Cleanup if it were waiting for something */
if (process->mutex) {
xbt_swag_remove(process, process->cond->sleeping);
if (process->waiting_action) {
- SIMIX_unregister_action_to_condition(process->waiting_action, process->cond);
+ SIMIX_unregister_action_to_condition(process->waiting_action,
+ process->cond);
SIMIX_action_destroy(process->waiting_action);
}
process->cond = NULL;
xbt_fifo_remove(process->sem->sleeping, process);
if (process->waiting_action) {
- SIMIX_unregister_action_to_semaphore(process->waiting_action, process->sem);
- SIMIX_action_destroy(process->waiting_action);
+ SIMIX_unregister_action_to_semaphore(process->waiting_action,
+ process->sem);
+ SIMIX_action_destroy(process->waiting_action);
}
process->sem = NULL;
}
*/
XBT_INLINE smx_process_t SIMIX_process_self(void)
{
- if(simix_global)
- return simix_global->current_process;
- return NULL;
+ if (simix_global)
+ return simix_global->current_process;
+ return NULL;
}
/**
void SIMIX_process_schedule(smx_process_t new_process)
{
- xbt_assert0(simix_global->current_process == simix_global->maestro_process,
- "This function can only be called from maestro context");
+ xbt_assert0(simix_global->current_process ==
+ simix_global->maestro_process,
+ "This function can only be called from maestro context");
DEBUG1("Scheduling context: '%s'", new_process->name);
/* update the current process */
DEBUG1("Wait condition %p", cond);
/* If there is a mutex unlock it */
- if(mutex != NULL){
+ if (mutex != NULL) {
cond->mutex = mutex;
SIMIX_mutex_unlock(mutex);
}
-
+
/* Always create an action null in case there is a host failure */
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), -1);
- SIMIX_action_set_name(act_sleep,bprintf("Wait condition %p", cond));
+ SIMIX_action_set_name(act_sleep, bprintf("Wait condition %p", cond));
SIMIX_process_self()->waiting_action = act_sleep;
SIMIX_register_action_to_condition(act_sleep, cond);
__SIMIX_cond_wait(cond);
SIMIX_action_destroy(act_sleep);
/* get the mutex again if necessary */
- if(mutex != NULL)
+ if (mutex != NULL)
SIMIX_mutex_lock(cond->mutex);
return;
DEBUG1("Timed wait condition %p", cond);
/* If there is a mutex unlock it */
- if(mutex != NULL){
+ if (mutex != NULL) {
cond->mutex = mutex;
SIMIX_mutex_unlock(mutex);
}
if (max_duration >= 0) {
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), max_duration);
- SIMIX_action_set_name(act_sleep,bprintf("Timed wait condition %p (max_duration:%f)", cond,max_duration));
+ SIMIX_action_set_name(act_sleep,
+ bprintf
+ ("Timed wait condition %p (max_duration:%f)",
+ cond, max_duration));
SIMIX_register_action_to_condition(act_sleep, cond);
SIMIX_process_self()->waiting_action = act_sleep;
__SIMIX_cond_wait(cond);
SIMIX_unregister_action_to_condition(act_sleep, cond);
if (SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
SIMIX_action_destroy(act_sleep);
- THROW1(timeout_error, 0, "Condition timeout after %f",max_duration);
+ THROW1(timeout_error, 0, "Condition timeout after %f", max_duration);
} else {
SIMIX_action_destroy(act_sleep);
}
} else
- SIMIX_cond_wait(cond,NULL);
+ SIMIX_cond_wait(cond, NULL);
/* get the mutex again if necessary */
- if(mutex != NULL)
+ if (mutex != NULL)
SIMIX_mutex_lock(cond->mutex);
}
/* ************************** Semaphores ************************************** */
#define SMX_SEM_NOLIMIT 99999
/** @brief Initialize a semaphore */
-smx_sem_t SIMIX_sem_init(int capacity) {
+smx_sem_t SIMIX_sem_init(int capacity)
+{
smx_sem_t sem = xbt_new0(s_smx_sem_t, 1);
sem->sleeping = xbt_fifo_new();
sem->capacity = capacity;
return sem;
}
+
/** @brief Destroys a semaphore */
-void SIMIX_sem_destroy(smx_sem_t sem) {
+void SIMIX_sem_destroy(smx_sem_t sem)
+{
smx_action_t action = NULL;
DEBUG1("Destroy semaphore %p", sem);
if (sem == NULL)
return;
xbt_assert0(xbt_fifo_size(sem->sleeping) == 0,
- "Cannot destroy semaphore since someone is still using it");
+ "Cannot destroy semaphore since someone is still using it");
xbt_fifo_free(sem->sleeping);
DEBUG1("%d actions registered", xbt_fifo_size(sem->actions));
- while((action=xbt_fifo_pop(sem->actions)))
+ while ((action = xbt_fifo_pop(sem->actions)))
SIMIX_unregister_action_to_semaphore(action, sem);
xbt_fifo_free(sem->actions);
* The first locked process on this semaphore is unlocked.
* If no one was blocked, the semaphore capacity is increased by 1.
* */
-void SIMIX_sem_release(smx_sem_t sem) {
+void SIMIX_sem_release(smx_sem_t sem)
+{
smx_process_t proc;
if (sem->capacity != SMX_SEM_NOLIMIT) {
xbt_swag_insert(proc, simix_global->process_to_run);
}
}
+
/** @brief make sure the semaphore will never be blocking again
*
* This function is not really in the semaphore spirit. It makes
*
* There is no way to reset the semaphore to a more regular state afterward.
* */
-void SIMIX_sem_release_forever(smx_sem_t sem) {
+void SIMIX_sem_release_forever(smx_sem_t sem)
+{
smx_process_t proc;
sem->capacity = SMX_SEM_NOLIMIT;
* do not attach a dummy action beforehand. SIMIX_sem_acquire does all these
* things for you so you it may be preferable to use.
*/
-void SIMIX_sem_block_onto(smx_sem_t sem) {
+void SIMIX_sem_block_onto(smx_sem_t sem)
+{
smx_process_t self = SIMIX_process_self();
/* process status */
self->sem = sem;
- xbt_fifo_push (sem->sleeping, self);
+ xbt_fifo_push(sem->sleeping, self);
SIMIX_process_yield();
self->sem = NULL;
while (self->suspended)
}
/** @brief Returns true if acquiring this semaphore would block */
-XBT_INLINE int SIMIX_sem_would_block(smx_sem_t sem) {
- return (sem->capacity<=0);
+XBT_INLINE int SIMIX_sem_would_block(smx_sem_t sem)
+{
+ return (sem->capacity <= 0);
}
/** @brief Returns the current capacity of the semaphore
*
* If it's negative, that's the amount of processes locked on the semaphore
*/
-int SIMIX_sem_get_capacity(smx_sem_t sem){
+int SIMIX_sem_get_capacity(smx_sem_t sem)
+{
return sem->capacity;
}
* If capacity==0, locks the current process
* until someone call SIMIX_sem_release() on this semaphore
*/
-void SIMIX_sem_acquire(smx_sem_t sem) {
- SIMIX_sem_acquire_timeout (sem, -1);
+void SIMIX_sem_acquire(smx_sem_t sem)
+{
+ SIMIX_sem_acquire_timeout(sem, -1);
}
/**
*
* Same behavior of #SIMIX_sem_acquire, but waits a maximum time and throws an timeout_error if it happens.
*/
-void SIMIX_sem_acquire_timeout(smx_sem_t sem, double max_duration) {
+void SIMIX_sem_acquire_timeout(smx_sem_t sem, double max_duration)
+{
smx_action_t act_sleep;
DEBUG2("Wait semaphore %p (timeout:%f)", sem, max_duration);
if (sem->capacity == SMX_SEM_NOLIMIT) {
DEBUG1("semaphore %p wide open", sem);
- return; /* don't even decrease it if wide open */
+ return; /* don't even decrease it if wide open */
}
/* If capacity sufficient, decrease it */
- if (sem->capacity>0) {
+ if (sem->capacity > 0) {
DEBUG1("semaphore %p has enough capacity", sem);
sem->capacity--;
return;
/* Always create an action null in case there is a host failure */
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), max_duration);
- SIMIX_action_set_name(act_sleep,bprintf("Locked in semaphore %p (max_duration:%f)", sem, max_duration));
+ SIMIX_action_set_name(act_sleep,
+ bprintf("Locked in semaphore %p (max_duration:%f)",
+ sem, max_duration));
SIMIX_process_self()->waiting_action = act_sleep;
SIMIX_register_action_to_semaphore(act_sleep, sem);
SIMIX_sem_block_onto(sem);
SIMIX_process_self()->waiting_action = NULL;
SIMIX_unregister_action_to_semaphore(act_sleep, sem);
- if (max_duration >= 0 && SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
+ if (max_duration >= 0
+ && SIMIX_action_get_state(act_sleep) == SURF_ACTION_DONE) {
SIMIX_action_destroy(act_sleep);
- THROW1(timeout_error, 0, "Semaphore acquire timeouted after %f",max_duration);
+ THROW1(timeout_error, 0, "Semaphore acquire timeouted after %f",
+ max_duration);
} else {
if (sem->capacity != SMX_SEM_NOLIMIT) {
/* Take the released token */
}
DEBUG1("End of Wait on semaphore %p", sem);
}
+
/**
* \brief Blocks on a set of semaphore
*
*
* \return the rank in the dynar of the semaphore which just got locked from the set
*/
-unsigned int SIMIX_sem_acquire_any(xbt_dynar_t sems) {
+unsigned int SIMIX_sem_acquire_any(xbt_dynar_t sems)
+{
smx_sem_t sem;
- unsigned int counter,result=-1;
+ unsigned int counter, result = -1;
smx_action_t act_sleep;
smx_process_t self = SIMIX_process_self();
xbt_assert0(xbt_dynar_length(sems),
- "I refuse to commit sucide by locking on an **empty** set of semaphores!!");
- DEBUG2("Wait on semaphore set %p (containing %ld semaphores)", sems,xbt_dynar_length(sems));
+ "I refuse to commit sucide by locking on an **empty** set of semaphores!!");
+ DEBUG2("Wait on semaphore set %p (containing %ld semaphores)", sems,
+ xbt_dynar_length(sems));
- xbt_dynar_foreach(sems,counter,sem) {
+ xbt_dynar_foreach(sems, counter, sem) {
if (!SIMIX_sem_would_block(sem)) {
- DEBUG1("Semaphore %p wouldn't block; get it without waiting",sem);
+ DEBUG1("Semaphore %p wouldn't block; get it without waiting", sem);
SIMIX_sem_acquire(sem);
return counter;
}
/* Always create an action null in case there is a host failure */
act_sleep = SIMIX_action_sleep(SIMIX_host_self(), -1);
- SIMIX_action_set_name(act_sleep,bprintf("Locked in semaphore %p", sem));
+ SIMIX_action_set_name(act_sleep, bprintf("Locked in semaphore %p", sem));
self->waiting_action = act_sleep;
- SIMIX_register_action_to_semaphore(act_sleep, xbt_dynar_get_as(sems,0,smx_sem_t));
+ SIMIX_register_action_to_semaphore(act_sleep,
+ xbt_dynar_get_as(sems, 0, smx_sem_t));
/* Get listed as member of all the provided semaphores */
- self->sem = (smx_sem_t)sems; /* FIXME: we pass a pointer to dynar where a pointer to sem is expected...*/
- xbt_dynar_foreach(sems,counter,sem) {
+ self->sem = (smx_sem_t) sems; /* FIXME: we pass a pointer to dynar where a pointer to sem is expected... */
+ xbt_dynar_foreach(sems, counter, sem) {
xbt_fifo_push(sem->sleeping, self);
}
SIMIX_process_yield();
SIMIX_process_yield();
/* at least one of the semaphore unsuspended us -- great, let's search the first one (and get out of the others) */
- xbt_dynar_foreach(sems,counter,sem) {
+ xbt_dynar_foreach(sems, counter, sem) {
if (!xbt_fifo_remove(sem->sleeping, self) && result == -1) {
if (sem->capacity != SMX_SEM_NOLIMIT) {
/* Take the released token */
result = counter;
}
}
- xbt_assert0(result!=-1,"Cannot find which semaphore unlocked me!");
+ xbt_assert0(result != -1, "Cannot find which semaphore unlocked me!");
/* Destroy the waiting action */
self->waiting_action = NULL;
- SIMIX_unregister_action_to_semaphore(act_sleep, xbt_dynar_get_as(sems,0,smx_sem_t));
+ SIMIX_unregister_action_to_semaphore(act_sleep,
+ xbt_dynar_get_as(sems, 0,
+ smx_sem_t));
SIMIX_action_destroy(act_sleep);
return result;
}
#include "instr/private.h"
struct s_smpi_process_data;
-typedef struct s_smpi_process_data* smpi_process_data_t;
+typedef struct s_smpi_process_data *smpi_process_data_t;
#define PERSISTENT 0x0
#define NON_PERSISTENT 0x1
#define RECV 0x2
typedef struct s_smpi_mpi_request {
- void* buf;
+ void *buf;
size_t size;
int src;
int dst;
#endif
} s_smpi_mpi_request_t;
-void smpi_process_init(int* argc, char*** argv);
+void smpi_process_init(int *argc, char ***argv);
void smpi_process_destroy(void);
smpi_process_data_t smpi_process_data(void);
xbt_os_timer_t smpi_process_timer(void);
void smpi_process_simulated_start(void);
double smpi_process_simulated_elapsed(void);
-void print_request(const char* message, MPI_Request request);
+void print_request(const char *message, MPI_Request request);
void smpi_process_post_send(MPI_Comm comm, MPI_Request request);
void smpi_process_post_recv(MPI_Request request);
size_t smpi_datatype_size(MPI_Datatype datatype);
MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
MPI_Aint smpi_datatype_ub(MPI_Datatype datatype);
-int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint * extent);
-int smpi_datatype_copy(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype);
+int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
+ MPI_Aint * extent);
+int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount,
+ MPI_Datatype recvtype);
-MPI_Op smpi_op_new(MPI_User_function* function, int commute);
+MPI_Op smpi_op_new(MPI_User_function * function, int commute);
void smpi_op_destroy(MPI_Op op);
-void smpi_op_apply(MPI_Op op, void* invec, void* inoutvec, int* len, MPI_Datatype* datatype);
+void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
+ MPI_Datatype * datatype);
MPI_Group smpi_group_new(int size);
void smpi_group_destroy(MPI_Group group);
int smpi_comm_size(MPI_Comm comm);
int smpi_comm_rank(MPI_Comm comm);
-MPI_Request smpi_mpi_send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-MPI_Request smpi_mpi_recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm);
void smpi_mpi_start(MPI_Request request);
-void smpi_mpi_startall(int count, MPI_Request* requests);
-void smpi_mpi_request_free(MPI_Request* request);
-MPI_Request smpi_isend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-MPI_Request smpi_mpi_isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-MPI_Request smpi_irecv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
-MPI_Request smpi_mpi_irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
-void smpi_mpi_recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
-void smpi_mpi_send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
-void smpi_mpi_sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
-int smpi_mpi_test(MPI_Request* request, MPI_Status* status);
-int smpi_mpi_testany(int count, MPI_Request requests[], int* index, MPI_Status* status);
-int smpi_mpi_get_count(MPI_Status* status, MPI_Datatype datatype);
-void smpi_mpi_wait(MPI_Request* request, MPI_Status* status);
-int smpi_mpi_waitany(int count, MPI_Request requests[], MPI_Status* status);
-void smpi_mpi_waitall(int count, MPI_Request requests[], MPI_Status status[]);
-int smpi_mpi_waitsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]);
-void smpi_mpi_bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
+void smpi_mpi_startall(int count, MPI_Request * requests);
+void smpi_mpi_request_free(MPI_Request * request);
+MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm);
+MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm);
+MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm);
+void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
+ int tag, MPI_Comm comm, MPI_Status * status);
+void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
+ int tag, MPI_Comm comm);
+void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ int dst, int sendtag, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status);
+int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
+int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
+ MPI_Status * status);
+int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
+void smpi_mpi_wait(MPI_Request * request, MPI_Status * status);
+int smpi_mpi_waitany(int count, MPI_Request requests[],
+ MPI_Status * status);
+void smpi_mpi_waitall(int count, MPI_Request requests[],
+ MPI_Status status[]);
+int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
+ MPI_Status status[]);
+void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm);
void smpi_mpi_barrier(MPI_Comm comm);
-void smpi_mpi_gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-void smpi_mpi_gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm);
-void smpi_mpi_allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-void smpi_mpi_allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm);
-void smpi_mpi_scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-void smpi_mpi_scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
-void smpi_mpi_reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-void smpi_mpi_allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-void smpi_mpi_scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
-
-void nary_tree_bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, int arity);
+void smpi_mpi_gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm);
+void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts, int *displs,
+ MPI_Datatype recvtype, int root, MPI_Comm comm);
+void smpi_mpi_allgather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, MPI_Comm comm);
+void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm);
+void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
+ MPI_Datatype sendtype, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int root, MPI_Comm comm);
+void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm);
+void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
+void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
+
+void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm, int arity);
void nary_tree_barrier(MPI_Comm comm, int arity);
-int smpi_coll_tuned_alltoall_bruck(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-int smpi_coll_tuned_alltoall_pairwise(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
-int smpi_coll_basic_alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm);
+int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype,
+ void *recvbuf, int recvcount,
+ MPI_Datatype recvtype,
+ MPI_Comm comm);
+int smpi_coll_tuned_alltoall_pairwise(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm);
+int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
+ int *senddisps, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts,
+ int *recvdisps, MPI_Datatype recvtype,
+ MPI_Comm comm);
// utilities
void smpi_bench_destroy(void);
-void smpi_bench_begin(int rank, const char* mpi_call);
-void smpi_bench_end(int rank, const char* mpi_call);
+void smpi_bench_begin(int rank, const char *mpi_call);
+void smpi_bench_end(int rank, const char *mpi_call);
#endif
#include <stdio.h>
#include <mpi.h>
-int main (int argc, char **argv) {
+int main(int argc, char **argv)
+{
int size, rank;
- int root=0;
+ int root = 0;
int value = 1;
- int sum=-99;
+ int sum = -99;
double start_timer;
printf("rank %d has value %d\n", rank, value);
MPI_Reduce(&value, &sum, 1, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
- if ( rank == root) {
- printf("On root: sum=%d\n",sum);
- printf("Elapsed time=%lf s\n", MPI_Wtime()-start_timer);
+ if (rank == root) {
+ printf("On root: sum=%d\n", sum);
+ printf("Elapsed time=%lf s\n", MPI_Wtime() - start_timer);
}
MPI_Finalize();
return 0;
XBT_LOG_EXTERNAL_CATEGORY(smpi_sender);
XBT_LOG_EXTERNAL_CATEGORY(smpi_util);
-void smpi_process_init(int* argc, char*** argv) {
+void smpi_process_init(int *argc, char ***argv)
+{
int index;
smpi_process_data_t data;
smx_process_t proc;
DEBUG2("<%d> New process in the game: %p", index, proc);
}
-void smpi_process_destroy(void) {
+void smpi_process_destroy(void)
+{
int index = smpi_process_index();
DEBUG1("<%d> Process left the game", index);
}
-static MPI_Request build_request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) {
+static MPI_Request build_request(void *buf, int count,
+ MPI_Datatype datatype, int src, int dst,
+ int tag, MPI_Comm comm, unsigned flags)
+{
MPI_Request request;
request = xbt_new(s_smpi_mpi_request_t, 1);
}
/* MPI Low level calls */
-MPI_Request smpi_mpi_send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
- MPI_Request request = build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag, comm, PERSISTENT | SEND);
+MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
+ comm, PERSISTENT | SEND);
return request;
}
-MPI_Request smpi_mpi_recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) {
- MPI_Request request = build_request(buf, count, datatype, src, smpi_comm_rank(comm), tag, comm, PERSISTENT | RECV);
+MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, src, smpi_comm_rank(comm), tag,
+ comm, PERSISTENT | RECV);
return request;
}
-void smpi_mpi_start(MPI_Request request) {
- xbt_assert0(request->complete == 0, "Cannot start a non-finished communication");
- if((request->flags & RECV) == RECV) {
+void smpi_mpi_start(MPI_Request request)
+{
+ xbt_assert0(request->complete == 0,
+ "Cannot start a non-finished communication");
+ if ((request->flags & RECV) == RECV) {
smpi_process_post_recv(request);
print_request("New recv", request);
- request->pair = SIMIX_network_irecv(request->rdv, request->buf, &request->size);
+ request->pair =
+ SIMIX_network_irecv(request->rdv, request->buf, &request->size);
} else {
- smpi_process_post_send(request->comm, request); // FIXME
+ smpi_process_post_send(request->comm, request); // FIXME
print_request("New send", request);
- request->pair = SIMIX_network_isend(request->rdv, request->size, -1.0, request->buf, request->size, NULL);
+ request->pair =
+ SIMIX_network_isend(request->rdv, request->size, -1.0,
+ request->buf, request->size, NULL);
}
}
-void smpi_mpi_startall(int count, MPI_Request* requests) {
+void smpi_mpi_startall(int count, MPI_Request * requests)
+{
int i;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
smpi_mpi_start(requests[i]);
}
}
-void smpi_mpi_request_free(MPI_Request* request) {
+void smpi_mpi_request_free(MPI_Request * request)
+{
xbt_free(*request);
*request = MPI_REQUEST_NULL;
}
-MPI_Request smpi_isend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
- MPI_Request request = build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag, comm, NON_PERSISTENT | SEND);
+MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, smpi_comm_rank(comm), dst, tag,
+ comm, NON_PERSISTENT | SEND);
return request;
}
-MPI_Request smpi_mpi_isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
- MPI_Request request = smpi_isend_init(buf, count, datatype, dst, tag, comm);
+MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
+ int dst, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ smpi_isend_init(buf, count, datatype, dst, tag, comm);
smpi_mpi_start(request);
return request;
}
-MPI_Request smpi_irecv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) {
- MPI_Request request = build_request(buf, count, datatype, src, smpi_comm_rank(comm), tag, comm, NON_PERSISTENT | RECV);
+MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ build_request(buf, count, datatype, src, smpi_comm_rank(comm), tag,
+ comm, NON_PERSISTENT | RECV);
return request;
}
-MPI_Request smpi_mpi_irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) {
- MPI_Request request = smpi_irecv_init(buf, count, datatype, src, tag, comm);
+MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
+ int src, int tag, MPI_Comm comm)
+{
+ MPI_Request request =
+ smpi_irecv_init(buf, count, datatype, src, tag, comm);
smpi_mpi_start(request);
return request;
}
-void smpi_mpi_recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status) {
+void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
+ int tag, MPI_Comm comm, MPI_Status * status)
+{
MPI_Request request;
request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
smpi_mpi_wait(&request, status);
}
-void smpi_mpi_send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
+void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
+ int tag, MPI_Comm comm)
+{
MPI_Request request;
request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
smpi_mpi_wait(&request, MPI_STATUS_IGNORE);
}
-void smpi_mpi_sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status) {
+void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ int dst, int sendtag, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status)
+{
MPI_Request requests[2];
MPI_Status stats[2];
- requests[0] = smpi_isend_init(sendbuf, sendcount, sendtype, dst, sendtag, comm);
- requests[1] = smpi_irecv_init(recvbuf, recvcount, recvtype, src, recvtag, comm);
+ requests[0] =
+ smpi_isend_init(sendbuf, sendcount, sendtype, dst, sendtag, comm);
+ requests[1] =
+ smpi_irecv_init(recvbuf, recvcount, recvtype, src, recvtag, comm);
smpi_mpi_startall(2, requests);
smpi_mpi_waitall(2, requests, stats);
- if(status != MPI_STATUS_IGNORE) {
+ if (status != MPI_STATUS_IGNORE) {
// Copy receive status
memcpy(status, &stats[1], sizeof(MPI_Status));
}
}
-int smpi_mpi_get_count(MPI_Status* status, MPI_Datatype datatype) {
- return status->count / smpi_datatype_size(datatype);
+int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype)
+{
+ return status->count / smpi_datatype_size(datatype);
}
-static void finish_wait(MPI_Request* request, MPI_Status* status) {
- if(status != MPI_STATUS_IGNORE) {
+static void finish_wait(MPI_Request * request, MPI_Status * status)
+{
+ if (status != MPI_STATUS_IGNORE) {
status->MPI_SOURCE = (*request)->src;
status->MPI_TAG = (*request)->tag;
status->MPI_ERROR = MPI_SUCCESS;
status->count = SIMIX_communication_get_dst_buf_size((*request)->pair);
}
print_request("finishing wait", *request);
- if((*request)->complete == 1) {
+ if ((*request)->complete == 1) {
SIMIX_rdv_destroy((*request)->rdv);
} else {
(*request)->match->complete = 1;
(*request)->match->match = MPI_REQUEST_NULL;
}
- if(((*request)->flags & NON_PERSISTENT) == NON_PERSISTENT) {
+ if (((*request)->flags & NON_PERSISTENT) == NON_PERSISTENT) {
smpi_mpi_request_free(request);
} else {
(*request)->rdv = NULL;
}
}
-int smpi_mpi_test(MPI_Request* request, MPI_Status* status) {
+int smpi_mpi_test(MPI_Request * request, MPI_Status * status)
+{
int flag = (*request)->complete;
- if(flag) {
+ if (flag) {
smpi_mpi_wait(request, status);
}
return flag;
}
-int smpi_mpi_testany(int count, MPI_Request requests[], int* index, MPI_Status* status) {
+int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
+ MPI_Status * status)
+{
int i, flag;
*index = MPI_UNDEFINED;
flag = 0;
- for(i = 0; i < count; i++) {
- if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
+ for (i = 0; i < count; i++) {
+ if (requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
smpi_mpi_wait(&requests[i], status);
*index = i;
flag = 1;
return flag;
}
-void smpi_mpi_wait(MPI_Request* request, MPI_Status* status) {
+void smpi_mpi_wait(MPI_Request * request, MPI_Status * status)
+{
print_request("wait", *request);
SIMIX_network_wait((*request)->pair, -1.0);
finish_wait(request, status);
}
-int smpi_mpi_waitany(int count, MPI_Request requests[], MPI_Status* status) {
+int smpi_mpi_waitany(int count, MPI_Request requests[],
+ MPI_Status * status)
+{
xbt_dynar_t comms;
int i, size, index;
- int* map;
+ int *map;
index = MPI_UNDEFINED;
- if(count > 0) {
+ if (count > 0) {
// First check for already completed requests
- for(i = 0; i < count; i++) {
- if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
+ for (i = 0; i < count; i++) {
+ if (requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
index = i;
smpi_mpi_wait(&requests[index], status);
break;
}
}
- if(index == MPI_UNDEFINED) {
+ if (index == MPI_UNDEFINED) {
// Otherwise, wait for a request to complete
comms = xbt_dynar_new(sizeof(smx_comm_t), NULL);
map = xbt_new(int, count);
size = 0;
DEBUG0("Wait for one of");
- for(i = 0; i < count; i++) {
- if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete == 0) {
+ for (i = 0; i < count; i++) {
+ if (requests[i] != MPI_REQUEST_NULL && requests[i]->complete == 0) {
print_request(" ", requests[i]);
xbt_dynar_push(comms, &requests[i]->pair);
map[size] = i;
size++;
}
}
- if(size > 0) {
+ if (size > 0) {
index = SIMIX_network_waitany(comms);
index = map[index];
finish_wait(&requests[index], status);
return index;
}
-void smpi_mpi_waitall(int count, MPI_Request requests[], MPI_Status status[]) {
+void smpi_mpi_waitall(int count, MPI_Request requests[],
+ MPI_Status status[])
+{
int index;
MPI_Status stat;
- while(count > 0) {
+ while (count > 0) {
index = smpi_mpi_waitany(count, requests, &stat);
- if(index == MPI_UNDEFINED) {
+ if (index == MPI_UNDEFINED) {
break;
}
- if(status != MPI_STATUS_IGNORE) {
+ if (status != MPI_STATUS_IGNORE) {
memcpy(&status[index], &stat, sizeof(stat));
}
// FIXME: check this -v
}
}
-int smpi_mpi_waitsome(int incount, MPI_Request requests[], int* indices, MPI_Status status[]) {
+int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
+ MPI_Status status[])
+{
int i, count;
count = 0;
- for(i = 0; i < incount; i++) {
- if(requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
- smpi_mpi_wait(&requests[i], status != MPI_STATUS_IGNORE ? &status[i] : MPI_STATUS_IGNORE);
+ for (i = 0; i < incount; i++) {
+ if (requests[i] != MPI_REQUEST_NULL && requests[i]->complete) {
+ smpi_mpi_wait(&requests[i],
+ status !=
+ MPI_STATUS_IGNORE ? &status[i] : MPI_STATUS_IGNORE);
indices[count] = i;
count++;
}
return count;
}
-void smpi_mpi_bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) {
+void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm)
+{
// arity=2: a binary tree, arity=4 seem to be a good setting (see P2P-MPI))
nary_tree_bcast(buf, count, datatype, root, comm, 4);
}
-void smpi_mpi_barrier(MPI_Comm comm) {
+void smpi_mpi_barrier(MPI_Comm comm)
+{
// arity=2: a binary tree, arity=4 seem to be a good setting (see P2P-MPI))
nary_tree_barrier(comm, 4);
}
-void smpi_mpi_gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+void smpi_mpi_gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, src, index, sendsize, recvsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
- if(rank != root) {
+ if (rank != root) {
// Send buffer to root
smpi_mpi_send(sendbuf, sendcount, sendtype, root, system_tag, comm);
} else {
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
// Local copy from root
- memcpy(&((char*)recvbuf)[root * recvcount * recvsize], sendbuf, sendcount * sendsize * sizeof(char));
+ memcpy(&((char *) recvbuf)[root * recvcount * recvsize], sendbuf,
+ sendcount * sendsize * sizeof(char));
// Receive buffers from senders
requests = xbt_new(MPI_Request, size - 1);
index = 0;
- for(src = 0; src < size; src++) {
- if(src != root) {
- requests[index] = smpi_irecv_init(&((char*)recvbuf)[src * recvcount * recvsize], recvcount, recvtype, src, system_tag, comm);
+ for (src = 0; src < size; src++) {
+ if (src != root) {
+ requests[index] = smpi_irecv_init(&((char *) recvbuf)
+ [src * recvcount * recvsize],
+ recvcount, recvtype, src,
+ system_tag, comm);
index++;
}
}
}
}
-void smpi_mpi_gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts, int *displs,
+ MPI_Datatype recvtype, int root, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, src, index, sendsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
- if(rank != root) {
+ if (rank != root) {
// Send buffer to root
smpi_mpi_send(sendbuf, sendcount, sendtype, root, system_tag, comm);
} else {
sendsize = smpi_datatype_size(sendtype);
// Local copy from root
- memcpy(&((char*)recvbuf)[displs[root]], sendbuf, sendcount * sendsize * sizeof(char));
+ memcpy(&((char *) recvbuf)[displs[root]], sendbuf,
+ sendcount * sendsize * sizeof(char));
// Receive buffers from senders
requests = xbt_new(MPI_Request, size - 1);
index = 0;
- for(src = 0; src < size; src++) {
- if(src != root) {
- requests[index] = smpi_irecv_init(&((char*)recvbuf)[displs[src]], recvcounts[src], recvtype, src, system_tag, comm);
+ for (src = 0; src < size; src++) {
+ if (src != root) {
+ requests[index] =
+ smpi_irecv_init(&((char *) recvbuf)[displs[src]],
+ recvcounts[src], recvtype, src, system_tag,
+ comm);
index++;
}
}
}
}
-void smpi_mpi_allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+void smpi_mpi_allgather(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, other, index, sendsize, recvsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
// Local copy from self
- memcpy(&((char*)recvbuf)[rank * recvcount * recvsize], sendbuf, sendcount * sendsize * sizeof(char));
+ memcpy(&((char *) recvbuf)[rank * recvcount * recvsize], sendbuf,
+ sendcount * sendsize * sizeof(char));
// Send/Recv buffers to/from others;
requests = xbt_new(MPI_Request, 2 * (size - 1));
index = 0;
- for(other = 0; other < size; other++) {
- if(other != rank) {
- requests[index] = smpi_isend_init(sendbuf, sendcount, sendtype, other, system_tag, comm);
+ for (other = 0; other < size; other++) {
+ if (other != rank) {
+ requests[index] =
+ smpi_isend_init(sendbuf, sendcount, sendtype, other, system_tag,
+ comm);
index++;
- requests[index] = smpi_irecv_init(&((char*)recvbuf)[other * recvcount * recvsize], recvcount, recvtype, other, system_tag, comm);
+ requests[index] = smpi_irecv_init(&((char *) recvbuf)
+ [other * recvcount * recvsize],
+ recvcount, recvtype, other,
+ system_tag, comm);
index++;
}
}
xbt_free(requests);
}
-void smpi_mpi_allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm) {
+void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int *recvcounts, int *displs,
+ MPI_Datatype recvtype, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, other, index, sendsize, recvsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
// Local copy from self
- memcpy(&((char*)recvbuf)[displs[rank]], sendbuf, sendcount * sendsize * sizeof(char));
+ memcpy(&((char *) recvbuf)[displs[rank]], sendbuf,
+ sendcount * sendsize * sizeof(char));
// Send buffers to others;
requests = xbt_new(MPI_Request, 2 * (size - 1));
index = 0;
- for(other = 0; other < size; other++) {
- if(other != rank) {
- requests[index] = smpi_isend_init(sendbuf, sendcount, sendtype, other, system_tag, comm);
+ for (other = 0; other < size; other++) {
+ if (other != rank) {
+ requests[index] =
+ smpi_isend_init(sendbuf, sendcount, sendtype, other, system_tag,
+ comm);
index++;
- requests[index] = smpi_irecv_init(&((char*)recvbuf)[displs[other]], recvcounts[other], recvtype, other, system_tag, comm);
+ requests[index] =
+ smpi_irecv_init(&((char *) recvbuf)[displs[other]],
+ recvcounts[other], recvtype, other, system_tag,
+ comm);
index++;
}
}
xbt_free(requests);
}
-void smpi_mpi_scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, dst, index, sendsize, recvsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
- if(rank != root) {
+ if (rank != root) {
// Recv buffer from root
- smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
+ smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm,
+ MPI_STATUS_IGNORE);
} else {
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
// Local copy from root
- memcpy(recvbuf, &((char*)sendbuf)[root * sendcount * sendsize], recvcount * recvsize * sizeof(char));
+ memcpy(recvbuf, &((char *) sendbuf)[root * sendcount * sendsize],
+ recvcount * recvsize * sizeof(char));
// Send buffers to receivers
requests = xbt_new(MPI_Request, size - 1);
index = 0;
- for(dst = 0; dst < size; dst++) {
- if(dst != root) {
- requests[index] = smpi_isend_init(&((char*)sendbuf)[dst * sendcount * sendsize], sendcount, sendtype, dst, system_tag, comm);
+ for (dst = 0; dst < size; dst++) {
+ if (dst != root) {
+ requests[index] = smpi_isend_init(&((char *) sendbuf)
+ [dst * sendcount * sendsize],
+ sendcount, sendtype, dst,
+ system_tag, comm);
index++;
}
}
}
}
-void smpi_mpi_scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
+ MPI_Datatype sendtype, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int root, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, dst, index, sendsize, recvsize;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
- if(rank != root) {
+ if (rank != root) {
// Recv buffer from root
- smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
+ smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm,
+ MPI_STATUS_IGNORE);
} else {
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
// Local copy from root
- memcpy(recvbuf, &((char*)sendbuf)[displs[root]], recvcount * recvsize * sizeof(char));
+ memcpy(recvbuf, &((char *) sendbuf)[displs[root]],
+ recvcount * recvsize * sizeof(char));
// Send buffers to receivers
requests = xbt_new(MPI_Request, size - 1);
index = 0;
- for(dst = 0; dst < size; dst++) {
- if(dst != root) {
- requests[index] = smpi_isend_init(&((char*)sendbuf)[displs[dst]], sendcounts[dst], sendtype, dst, system_tag, comm);
+ for (dst = 0; dst < size; dst++) {
+ if (dst != root) {
+ requests[index] =
+ smpi_isend_init(&((char *) sendbuf)[displs[dst]],
+ sendcounts[dst], sendtype, dst, system_tag,
+ comm);
index++;
}
}
}
}
-void smpi_mpi_reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) {
+void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root,
+ MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, src, index, datasize;
- MPI_Request* requests;
- void** tmpbufs;
+ MPI_Request *requests;
+ void **tmpbufs;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
- if(rank != root) {
+ if (rank != root) {
// Send buffer to root
smpi_mpi_send(sendbuf, count, datatype, root, system_tag, comm);
} else {
// Receive buffers from senders
//TODO: make a MPI_barrier here ?
requests = xbt_new(MPI_Request, size - 1);
- tmpbufs = xbt_new(void*, size - 1);
+ tmpbufs = xbt_new(void *, size - 1);
index = 0;
- for(src = 0; src < size; src++) {
- if(src != root) {
+ for (src = 0; src < size; src++) {
+ if (src != root) {
tmpbufs[index] = xbt_malloc(count * datasize);
- requests[index] = smpi_irecv_init(tmpbufs[index], count, datatype, src, system_tag, comm);
+ requests[index] =
+ smpi_irecv_init(tmpbufs[index], count, datatype, src,
+ system_tag, comm);
index++;
}
}
// Wait for completion of irecv's.
smpi_mpi_startall(size - 1, requests);
- for(src = 0; src < size - 1; src++) {
+ for (src = 0; src < size - 1; src++) {
index = smpi_mpi_waitany(size - 1, requests, MPI_STATUS_IGNORE);
- if(index == MPI_UNDEFINED) {
+ if (index == MPI_UNDEFINED) {
break;
}
smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
}
- for(index = 0; index < size - 1; index++) {
+ for (index = 0; index < size - 1; index++) {
xbt_free(tmpbufs[index]);
}
xbt_free(tmpbufs);
}
}
-void smpi_mpi_allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
+void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+{
smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
smpi_mpi_bcast(recvbuf, count, datatype, 0, comm);
*/
}
-void smpi_mpi_scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
+void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+{
int system_tag = 666;
int rank, size, other, index, datasize;
int total;
- MPI_Request* requests;
- void** tmpbufs;
+ MPI_Request *requests;
+ void **tmpbufs;
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
// Send/Recv buffers to/from others;
total = rank + (size - (rank + 1));
requests = xbt_new(MPI_Request, total);
- tmpbufs = xbt_new(void*, rank);
+ tmpbufs = xbt_new(void *, rank);
index = 0;
- for(other = 0; other < rank; other++) {
+ for (other = 0; other < rank; other++) {
tmpbufs[index] = xbt_malloc(count * datasize);
- requests[index] = smpi_irecv_init(tmpbufs[index], count, datatype, other, system_tag, comm);
+ requests[index] =
+ smpi_irecv_init(tmpbufs[index], count, datatype, other, system_tag,
+ comm);
index++;
}
- for(other = rank + 1; other < size; other++) {
- requests[index] = smpi_isend_init(sendbuf, count, datatype, other, system_tag, comm);
+ for (other = rank + 1; other < size; other++) {
+ requests[index] =
+ smpi_isend_init(sendbuf, count, datatype, other, system_tag, comm);
index++;
}
// Wait for completion of all comms.
smpi_mpi_startall(size - 1, requests);
- for(other = 0; other < total; other++) {
+ for (other = 0; other < total; other++) {
index = smpi_mpi_waitany(size - 1, requests, MPI_STATUS_IGNORE);
- if(index == MPI_UNDEFINED) {
+ if (index == MPI_UNDEFINED) {
break;
}
- if(index < rank) {
+ if (index < rank) {
// #Request is below rank: it's a irecv
smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
}
}
- for(index = 0; index < size - 1; index++) {
+ for (index = 0; index < size - 1; index++) {
xbt_free(tmpbufs[index]);
}
xbt_free(tmpbufs);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi,
"Logging specific to SMPI (benchmarking)");
-xbt_dict_t allocs = NULL; /* Allocated on first use */
-xbt_dict_t samples = NULL; /* Allocated on first use */
+xbt_dict_t allocs = NULL; /* Allocated on first use */
+xbt_dict_t samples = NULL; /* Allocated on first use */
typedef struct {
- int count;
- char data[];
+ int count;
+ char data[];
} shared_data_t;
typedef struct {
- double time;
- int count;
- int max;
- int started;
+ double time;
+ int count;
+ int max;
+ int started;
} local_data_t;
-void smpi_bench_destroy(void) {
- if (allocs) {
- xbt_dict_free(&allocs);
- }
- if (samples) {
- xbt_dict_free(&samples);
- }
+void smpi_bench_destroy(void)
+{
+ if (allocs) {
+ xbt_dict_free(&allocs);
+ }
+ if (samples) {
+ xbt_dict_free(&samples);
+ }
}
-static void smpi_execute_flops(double flops) {
+static void smpi_execute_flops(double flops)
+{
smx_host_t host;
smx_action_t action;
smx_mutex_t mutex;
action = SIMIX_action_execute(host, "computation", flops);
SIMIX_mutex_lock(mutex);
SIMIX_register_action_to_condition(action, cond);
- for(state = SIMIX_action_get_state(action);
- state == SURF_ACTION_READY ||
- state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)) {
+ for (state = SIMIX_action_get_state(action);
+ state == SURF_ACTION_READY ||
+ state == SURF_ACTION_RUNNING;
+ state = SIMIX_action_get_state(action)) {
SIMIX_cond_wait(cond, mutex);
}
SIMIX_unregister_action_to_condition(action, cond);
SIMIX_mutex_destroy(mutex);
}
-static void smpi_execute(double duration) {
- if(duration >= xbt_cfg_get_double(_surf_cfg_set, "smpi/cpu_threshold")) {
+static void smpi_execute(double duration)
+{
+ if (duration >= xbt_cfg_get_double(_surf_cfg_set, "smpi/cpu_threshold")) {
DEBUG1("Sleep for %f to handle real computation time", duration);
- smpi_execute_flops(duration * xbt_cfg_get_double(_surf_cfg_set, "smpi/running_power"));
+ smpi_execute_flops(duration *
+ xbt_cfg_get_double(_surf_cfg_set,
+ "smpi/running_power"));
}
}
-void smpi_bench_begin(int rank, const char* mpi_call) {
- if(mpi_call && rank >= 0 && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
- INFO3("SMPE: ts=%f rank=%d type=end et=%s", SIMIX_get_clock(), rank, mpi_call);
+void smpi_bench_begin(int rank, const char *mpi_call)
+{
+ if (mpi_call && rank >= 0
+ && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
+ INFO3("SMPE: ts=%f rank=%d type=end et=%s", SIMIX_get_clock(), rank,
+ mpi_call);
}
xbt_os_timer_start(smpi_process_timer());
}
-void smpi_bench_end(int rank, const char* mpi_call) {
+void smpi_bench_end(int rank, const char *mpi_call)
+{
xbt_os_timer_t timer = smpi_process_timer();
xbt_os_timer_stop(timer);
smpi_execute(xbt_os_timer_elapsed(timer));
- if(mpi_call && rank >= 0 && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
- INFO3("SMPE: ts=%f rank=%d type=begin et=%s", SIMIX_get_clock(), rank, mpi_call);
+ if (mpi_call && rank >= 0
+ && xbt_cfg_get_int(_surf_cfg_set, "smpi/log_events")) {
+ INFO3("SMPE: ts=%f rank=%d type=begin et=%s", SIMIX_get_clock(), rank,
+ mpi_call);
}
}
-unsigned int smpi_sleep(unsigned int secs) {
- smpi_execute((double)secs);
- return secs;
+unsigned int smpi_sleep(unsigned int secs)
+{
+ smpi_execute((double) secs);
+ return secs;
}
-int smpi_gettimeofday(struct timeval* tv, struct timezone* tz) {
- double now = SIMIX_get_clock();
+int smpi_gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ double now = SIMIX_get_clock();
- if(tv) {
- tv->tv_sec = (time_t)now;
- tv->tv_usec = (suseconds_t)(now * 1e6);
- }
- return 0;
+ if (tv) {
+ tv->tv_sec = (time_t) now;
+ tv->tv_usec = (suseconds_t) (now * 1e6);
+ }
+ return 0;
}
-static char* sample_location(int global, const char* file, int line) {
- if(global) {
- return bprintf("%s:%d", file, line);
- } else {
- return bprintf("%s:%d:%d", file, line, smpi_process_index());
- }
+static char *sample_location(int global, const char *file, int line)
+{
+ if (global) {
+ return bprintf("%s:%d", file, line);
+ } else {
+ return bprintf("%s:%d:%d", file, line, smpi_process_index());
+ }
}
-void smpi_sample_1(int global, const char* file, int line, int max) {
- char* loc = sample_location(global, file, line);
- local_data_t* data;
-
- smpi_bench_end(-1, NULL); /* Take time from previous MPI call into account */
- if (!samples) {
- samples = xbt_dict_new();
- }
- data = xbt_dict_get_or_null(samples, loc);
- if (!data) {
- data = (local_data_t*)xbt_new(local_data_t, 1);
- data->time = 0.0;
- data->count = 0;
- data->max = max;
- data->started = 0;
- xbt_dict_set(samples, loc, data, &free);
- }
- free(loc);
+void smpi_sample_1(int global, const char *file, int line, int max)
+{
+ char *loc = sample_location(global, file, line);
+ local_data_t *data;
+
+ smpi_bench_end(-1, NULL); /* Take time from previous MPI call into account */
+ if (!samples) {
+ samples = xbt_dict_new();
+ }
+ data = xbt_dict_get_or_null(samples, loc);
+ if (!data) {
+ data = (local_data_t *) xbt_new(local_data_t, 1);
+ data->time = 0.0;
+ data->count = 0;
+ data->max = max;
+ data->started = 0;
+ xbt_dict_set(samples, loc, data, &free);
+ }
+ free(loc);
}
-int smpi_sample_2(int global, const char* file, int line) {
- char* loc = sample_location(global, file, line);
- local_data_t* data;
-
- xbt_assert0(samples, "You did something very inconsistent, didn't you?");
- data = xbt_dict_get_or_null(samples, loc);
- if (!data) {
- xbt_assert0(data, "Please, do thing in order");
- }
- if (!data->started) {
- if (data->count < data->max) {
- data->started = 1;
- data->count++;
- } else {
- DEBUG1("Perform some wait of %f", data->time / (double)data->count);
- smpi_execute(data->time / (double)data->count);
- }
- } else {
- data->started = 0;
- }
- free(loc);
- smpi_bench_begin(-1, NULL);
- smpi_process_simulated_start();
- return data->started;
+int smpi_sample_2(int global, const char *file, int line)
+{
+ char *loc = sample_location(global, file, line);
+ local_data_t *data;
+
+ xbt_assert0(samples, "You did something very inconsistent, didn't you?");
+ data = xbt_dict_get_or_null(samples, loc);
+ if (!data) {
+ xbt_assert0(data, "Please, do thing in order");
+ }
+ if (!data->started) {
+ if (data->count < data->max) {
+ data->started = 1;
+ data->count++;
+ } else {
+ DEBUG1("Perform some wait of %f", data->time / (double) data->count);
+ smpi_execute(data->time / (double) data->count);
+ }
+ } else {
+ data->started = 0;
+ }
+ free(loc);
+ smpi_bench_begin(-1, NULL);
+ smpi_process_simulated_start();
+ return data->started;
}
-void smpi_sample_3(int global, const char* file, int line) {
- char* loc = sample_location(global, file, line);
- local_data_t* data;
-
- xbt_assert0(samples, "You did something very inconsistent, didn't you?");
- data = xbt_dict_get_or_null(samples, loc);
- if (!data || !data->started || data->count >= data->max) {
- xbt_assert0(data, "Please, do thing in order");
- }
- smpi_bench_end(-1, NULL);
- data->time += smpi_process_simulated_elapsed();
- DEBUG2("Average mean after %d steps is %f", data->count, data->time / (double)data->count);
+void smpi_sample_3(int global, const char *file, int line)
+{
+ char *loc = sample_location(global, file, line);
+ local_data_t *data;
+
+ xbt_assert0(samples, "You did something very inconsistent, didn't you?");
+ data = xbt_dict_get_or_null(samples, loc);
+ if (!data || !data->started || data->count >= data->max) {
+ xbt_assert0(data, "Please, do thing in order");
+ }
+ smpi_bench_end(-1, NULL);
+ data->time += smpi_process_simulated_elapsed();
+ DEBUG2("Average mean after %d steps is %f", data->count,
+ data->time / (double) data->count);
}
-void smpi_sample_flops(double flops) {
- smpi_execute_flops(flops);
+void smpi_sample_flops(double flops)
+{
+ smpi_execute_flops(flops);
}
-void* smpi_shared_malloc(size_t size, const char* file, int line) {
- char* loc = bprintf("%s:%d:%zu", file, line, size);
- shared_data_t* data;
-
- if (!allocs) {
- allocs = xbt_dict_new();
- }
- data = xbt_dict_get_or_null(allocs, loc);
- if (!data) {
- data = (shared_data_t*)xbt_malloc0(sizeof(int) + size);
- data->count = 1;
- xbt_dict_set(allocs, loc, data, &free);
- } else {
- data->count++;
- }
- free(loc);
- return data->data;
+void *smpi_shared_malloc(size_t size, const char *file, int line)
+{
+ char *loc = bprintf("%s:%d:%zu", file, line, size);
+ shared_data_t *data;
+
+ if (!allocs) {
+ allocs = xbt_dict_new();
+ }
+ data = xbt_dict_get_or_null(allocs, loc);
+ if (!data) {
+ data = (shared_data_t *) xbt_malloc0(sizeof(int) + size);
+ data->count = 1;
+ xbt_dict_set(allocs, loc, data, &free);
+ } else {
+ data->count++;
+ }
+ free(loc);
+ return data->data;
}
-void smpi_shared_free(void* ptr) {
- shared_data_t* data = (shared_data_t*)((int*)ptr - 1);
- char* loc;
-
- if (!allocs) {
- WARN0("Cannot free: nothing was allocated");
- return;
- }
- loc = xbt_dict_get_key(allocs, data);
- if (!loc) {
- WARN1("Cannot free: %p was not shared-allocated by SMPI", ptr);
- return;
- }
- data->count--;
- if (data->count <= 0) {
- xbt_dict_remove(allocs, loc);
- }
+void smpi_shared_free(void *ptr)
+{
+ shared_data_t *data = (shared_data_t *) ((int *) ptr - 1);
+ char *loc;
+
+ if (!allocs) {
+ WARN0("Cannot free: nothing was allocated");
+ return;
+ }
+ loc = xbt_dict_get_key(allocs, data);
+ if (!loc) {
+ WARN1("Cannot free: %p was not shared-allocated by SMPI", ptr);
+ return;
+ }
+ data->count--;
+ if (data->count <= 0) {
+ xbt_dict_remove(allocs, loc);
+ }
}
struct s_proc_tree {
int PROCTREE_A;
int numChildren;
- int * child;
+ int *child;
int parent;
int me;
int root;
int isRoot;
};
-typedef struct s_proc_tree * proc_tree_t;
+typedef struct s_proc_tree *proc_tree_t;
/**
* alloc and init
**/
-static proc_tree_t alloc_tree(int arity) {
+static proc_tree_t alloc_tree(int arity)
+{
proc_tree_t tree;
int i;
tree->isRoot = 0;
tree->numChildren = 0;
tree->child = xbt_new(int, arity);
- for(i = 0; i < arity; i++) {
+ for (i = 0; i < arity; i++) {
tree->child[i] = -1;
}
tree->root = -1;
/**
* free
**/
-static void free_tree(proc_tree_t tree) {
- xbt_free(tree->child );
+static void free_tree(proc_tree_t tree)
+{
+ xbt_free(tree->child);
xbt_free(tree);
}
* @param index the rank of the calling process
* @param extent the total number of processes
**/
-static void build_tree(int index, int extent, proc_tree_t* tree) {
+static void build_tree(int index, int extent, proc_tree_t * tree)
+{
int places = (*tree)->PROCTREE_A * index;
int i, ch, pr;
(*tree)->me = index;
- (*tree)->root = 0 ;
- for(i = 1; i <= (*tree)->PROCTREE_A; i++) {
+ (*tree)->root = 0;
+ for (i = 1; i <= (*tree)->PROCTREE_A; i++) {
++places;
ch = (*tree)->PROCTREE_A * index + i + (*tree)->root;
ch %= extent;
- if(places < extent) {
+ if (places < extent) {
(*tree)->child[i - 1] = ch;
(*tree)->numChildren++;
}
}
- if(index == (*tree)->root) {
+ if (index == (*tree)->root) {
(*tree)->isRoot = 1;
} else {
(*tree)->isRoot = 0;
/**
* bcast
**/
-static void tree_bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, proc_tree_t tree) {
- int system_tag = 999; // used negative int but smpi_create_request() declares this illegal (to be checked)
+static void tree_bcast(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm, proc_tree_t tree)
+{
+ int system_tag = 999; // used negative int but smpi_create_request() declares this illegal (to be checked)
int rank, i;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
/* wait for data from my parent in the tree */
- if(!tree->isRoot) {
+ if (!tree->isRoot) {
DEBUG3("<%d> tree_bcast(): i am not root: recv from %d, tag=%d)",
rank, tree->parent, system_tag + rank);
- smpi_mpi_recv(buf, count, datatype, tree->parent, system_tag + rank, comm, MPI_STATUS_IGNORE);
+ smpi_mpi_recv(buf, count, datatype, tree->parent, system_tag + rank,
+ comm, MPI_STATUS_IGNORE);
}
requests = xbt_new(MPI_Request, tree->numChildren);
- DEBUG2("<%d> creates %d requests (1 per child)", rank, tree->numChildren);
+ DEBUG2("<%d> creates %d requests (1 per child)", rank,
+ tree->numChildren);
/* iniates sends to ranks lower in the tree */
- for(i = 0; i < tree->numChildren; i++) {
- if(tree->child[i] == -1) {
+ for (i = 0; i < tree->numChildren; i++) {
+ if (tree->child[i] == -1) {
requests[i] = MPI_REQUEST_NULL;
} else {
- DEBUG3("<%d> send to <%d>, tag=%d", rank, tree->child[i], system_tag + tree->child[i]);
- requests[i] = smpi_isend_init(buf, count, datatype, tree->child[i], system_tag + tree->child[i], comm);
+ DEBUG3("<%d> send to <%d>, tag=%d", rank, tree->child[i],
+ system_tag + tree->child[i]);
+ requests[i] =
+ smpi_isend_init(buf, count, datatype, tree->child[i],
+ system_tag + tree->child[i], comm);
}
}
smpi_mpi_startall(tree->numChildren, requests);
/**
* anti-bcast
**/
-static void tree_antibcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, proc_tree_t tree) {
- int system_tag = 999; // used negative int but smpi_create_request() declares this illegal (to be checked)
+static void tree_antibcast(void *buf, int count, MPI_Datatype datatype,
+ int root, MPI_Comm comm, proc_tree_t tree)
+{
+ int system_tag = 999; // used negative int but smpi_create_request() declares this illegal (to be checked)
int rank, i;
- MPI_Request* requests;
+ MPI_Request *requests;
rank = smpi_comm_rank(comm);
// everyone sends to its parent, except root.
- if(!tree->isRoot) {
+ if (!tree->isRoot) {
DEBUG3("<%d> tree_antibcast(): i am not root: send to %d, tag=%d)",
rank, tree->parent, system_tag + rank);
- smpi_mpi_send(buf, count, datatype, tree->parent, system_tag + rank, comm);
+ smpi_mpi_send(buf, count, datatype, tree->parent, system_tag + rank,
+ comm);
}
//every one receives as many messages as it has children
requests = xbt_new(MPI_Request, tree->numChildren);
- DEBUG2("<%d> creates %d requests (1 per child)", rank, tree->numChildren);
- for(i = 0; i < tree->numChildren; i++) {
- if(tree->child[i] == -1) {
+ DEBUG2("<%d> creates %d requests (1 per child)", rank,
+ tree->numChildren);
+ for (i = 0; i < tree->numChildren; i++) {
+ if (tree->child[i] == -1) {
requests[i] = MPI_REQUEST_NULL;
} else {
- DEBUG3("<%d> recv from <%d>, tag=%d", rank, tree->child[i], system_tag + tree->child[i]);
- requests[i] = smpi_irecv_init(buf, count, datatype, tree->child[i], system_tag + tree->child[i], comm);
+ DEBUG3("<%d> recv from <%d>, tag=%d", rank, tree->child[i],
+ system_tag + tree->child[i]);
+ requests[i] =
+ smpi_irecv_init(buf, count, datatype, tree->child[i],
+ system_tag + tree->child[i], comm);
}
}
smpi_mpi_startall(tree->numChildren, requests);
/**
* bcast with a binary, ternary, or whatever tree ..
**/
-void nary_tree_bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, int arity) {
+void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm, int arity)
+{
proc_tree_t tree = alloc_tree(arity);
int rank, size;
/**
* barrier with a binary, ternary, or whatever tree ..
**/
-void nary_tree_barrier(MPI_Comm comm, int arity) {
- proc_tree_t tree = alloc_tree( arity );
+void nary_tree_barrier(MPI_Comm comm, int arity)
+{
+ proc_tree_t tree = alloc_tree(arity);
int rank, size;
- char dummy='$';
+ char dummy = '$';
rank = smpi_comm_rank(comm);
size = smpi_comm_size(comm);
*
* Openmpi calls this routine when the message size sent to each rank < 2000 bytes and size < 12
**/
-int smpi_coll_tuned_alltoall_bruck(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int system_tag = 777;
int i, rank, size, err, count;
MPI_Aint lb;
MPI_Aint sendextent = 0;
MPI_Aint recvextent = 0;
- MPI_Request* requests;
+ MPI_Request *requests;
// FIXME: check implementation
rank = smpi_comm_rank(comm);
err = smpi_datatype_extent(sendtype, &lb, &sendextent);
err = smpi_datatype_extent(recvtype, &lb, &recvextent);
/* Local copy from self */
- err = smpi_datatype_copy(&((char*)sendbuf)[rank * sendextent], sendcount, sendtype, &((char*)recvbuf)[rank * recvextent], recvcount, recvtype);
- if(err == MPI_SUCCESS && size > 1) {
+ err =
+ smpi_datatype_copy(&((char *) sendbuf)[rank * sendextent], sendcount,
+ sendtype, &((char *) recvbuf)[rank * recvextent],
+ recvcount, recvtype);
+ if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
requests = xbt_new(MPI_Request, 2 * (size - 1));
count = 0;
/* Create all receives that will be posted first */
- for(i = 0; i < size; ++i) {
- if(i == rank) {
- DEBUG3("<%d> skip request creation [src = %d, recvcount = %d]", rank, i, recvcount);
+ for (i = 0; i < size; ++i) {
+ if (i == rank) {
+ DEBUG3("<%d> skip request creation [src = %d, recvcount = %d]",
+ rank, i, recvcount);
continue;
}
- requests[count] = smpi_irecv_init(&((char*)recvbuf)[i * recvextent], recvcount, recvtype, i, system_tag, comm);
+ requests[count] =
+ smpi_irecv_init(&((char *) recvbuf)[i * recvextent], recvcount,
+ recvtype, i, system_tag, comm);
count++;
}
/* Now create all sends */
- for(i = 0; i < size; ++i) {
- if(i == rank) {
- DEBUG3("<%d> skip request creation [dst = %d, sendcount = %d]", rank, i, sendcount);
+ for (i = 0; i < size; ++i) {
+ if (i == rank) {
+ DEBUG3("<%d> skip request creation [dst = %d, sendcount = %d]",
+ rank, i, sendcount);
continue;
}
- requests[count] = smpi_isend_init(&((char*)sendbuf)[i * sendextent], sendcount, sendtype, i, system_tag, comm);
+ requests[count] =
+ smpi_isend_init(&((char *) sendbuf)[i * sendextent], sendcount,
+ sendtype, i, system_tag, comm);
count++;
}
- /* Wait for them all.*/
+ /* Wait for them all. */
smpi_mpi_startall(count, requests);
DEBUG2("<%d> wait for %d requests", rank, count);
smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
/**
* Alltoall basic_linear
**/
-int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype,
+ void *recvbuf, int recvcount,
+ MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int system_tag = 888;
int i, rank, size, err, count;
MPI_Aint lb;
sendinc *= sendcount;
recvinc *= recvcount;
/* simple optimization */
- err = smpi_datatype_copy(&((char*)sendbuf)[rank * sendinc], sendcount, sendtype, &((char*)recvbuf)[rank * recvinc], recvcount, recvtype);
- if(err == MPI_SUCCESS && size > 1) {
+ err =
+ smpi_datatype_copy(&((char *) sendbuf)[rank * sendinc], sendcount,
+ sendtype, &((char *) recvbuf)[rank * recvinc],
+ recvcount, recvtype);
+ if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
requests = xbt_new(MPI_Request, 2 * (size - 1));
/* Post all receives first -- a simple optimization */
count = 0;
- for(i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
- requests[count] = smpi_irecv_init(&((char*)recvbuf)[i * recvinc], recvcount, recvtype, i, system_tag, comm);
+ for (i = (rank + 1) % size; i != rank; i = (i + 1) % size) {
+ requests[count] =
+ smpi_irecv_init(&((char *) recvbuf)[i * recvinc], recvcount,
+ recvtype, i, system_tag, comm);
count++;
}
/* Now post all sends in reverse order
* when messages actually arrive in the order in which they were posted.
* TODO: check the previous assertion
*/
- for(i = (rank + size - 1) % size; i != rank; i = (i + size - 1) % size ) {
- requests[count] = smpi_isend_init(&((char*)sendbuf)[i * sendinc], sendcount, sendtype, i, system_tag, comm);
+ for (i = (rank + size - 1) % size; i != rank;
+ i = (i + size - 1) % size) {
+ requests[count] =
+ smpi_isend_init(&((char *) sendbuf)[i * sendinc], sendcount,
+ sendtype, i, system_tag, comm);
count++;
}
- /* Wait for them all.*/
+ /* Wait for them all. */
smpi_mpi_startall(count, requests);
DEBUG2("<%d> wait for %d requests", rank, count);
smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
* ....
* Openmpi calls this routine when the message size sent to each rank is greater than 3000 bytes
**/
-int smpi_coll_tuned_alltoall_pairwise(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+int smpi_coll_tuned_alltoall_pairwise(void *sendbuf, int sendcount,
+ MPI_Datatype sendtype, void *recvbuf,
+ int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int system_tag = 999;
int rank, size, step, sendto, recvfrom, sendsize, recvsize;
sendsize = smpi_datatype_size(sendtype);
recvsize = smpi_datatype_size(recvtype);
/* Perform pairwise exchange - starting from 1 so the local copy is last */
- for(step = 1; step < size + 1; step++) {
+ for (step = 1; step < size + 1; step++) {
/* who do we talk to in this step? */
- sendto = (rank+step)%size;
- recvfrom = (rank+size-step)%size;
+ sendto = (rank + step) % size;
+ recvfrom = (rank + size - step) % size;
/* send and receive */
- smpi_mpi_sendrecv(&((char*)sendbuf)[sendto * sendsize * sendcount], sendcount, sendtype, sendto, system_tag, &((char*)recvbuf)[recvfrom * recvsize * recvcount], recvcount, recvtype, recvfrom, system_tag, comm, MPI_STATUS_IGNORE);
+ smpi_mpi_sendrecv(&((char *) sendbuf)[sendto * sendsize * sendcount],
+ sendcount, sendtype, sendto, system_tag,
+ &((char *) recvbuf)[recvfrom * recvsize * recvcount],
+ recvcount, recvtype, recvfrom, system_tag, comm,
+ MPI_STATUS_IGNORE);
}
return MPI_SUCCESS;
}
-int smpi_coll_basic_alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm) {
+int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
+ int *senddisps, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts,
+ int *recvdisps, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int system_tag = 889;
int i, rank, size, err, count;
MPI_Aint lb;
MPI_Aint sendextent = 0;
MPI_Aint recvextent = 0;
- MPI_Request* requests;
+ MPI_Request *requests;
/* Initialize. */
rank = smpi_comm_rank(comm);
err = smpi_datatype_extent(sendtype, &lb, &sendextent);
err = smpi_datatype_extent(recvtype, &lb, &recvextent);
/* Local copy from self */
- err = smpi_datatype_copy(&((char*)sendbuf)[senddisps[rank] * sendextent], sendcounts[rank], sendtype, &((char*)recvbuf)[recvdisps[rank] * recvextent], recvcounts[rank], recvtype);
- if(err == MPI_SUCCESS && size > 1) {
+ err =
+ smpi_datatype_copy(&((char *) sendbuf)[senddisps[rank] * sendextent],
+ sendcounts[rank], sendtype,
+ &((char *) recvbuf)[recvdisps[rank] * recvextent],
+ recvcounts[rank], recvtype);
+ if (err == MPI_SUCCESS && size > 1) {
/* Initiate all send/recv to/from others. */
requests = xbt_new(MPI_Request, 2 * (size - 1));
count = 0;
/* Create all receives that will be posted first */
- for(i = 0; i < size; ++i) {
- if(i == rank || recvcounts[i] == 0) {
- DEBUG3("<%d> skip request creation [src = %d, recvcounts[src] = %d]", rank, i, recvcounts[i]);
+ for (i = 0; i < size; ++i) {
+ if (i == rank || recvcounts[i] == 0) {
+ DEBUG3
+ ("<%d> skip request creation [src = %d, recvcounts[src] = %d]",
+ rank, i, recvcounts[i]);
continue;
}
- requests[count] = smpi_irecv_init(&((char*)recvbuf)[recvdisps[i] * recvextent], recvcounts[i], recvtype, i, system_tag, comm);
+ requests[count] =
+ smpi_irecv_init(&((char *) recvbuf)[recvdisps[i] * recvextent],
+ recvcounts[i], recvtype, i, system_tag, comm);
count++;
}
/* Now create all sends */
- for(i = 0; i < size; ++i) {
- if(i == rank || sendcounts[i] == 0) {
- DEBUG3("<%d> skip request creation [dst = %d, sendcounts[dst] = %d]", rank, i, sendcounts[i]);
+ for (i = 0; i < size; ++i) {
+ if (i == rank || sendcounts[i] == 0) {
+ DEBUG3
+ ("<%d> skip request creation [dst = %d, sendcounts[dst] = %d]",
+ rank, i, sendcounts[i]);
continue;
}
- requests[count] = smpi_isend_init(&((char*)sendbuf)[senddisps[i] * sendextent], sendcounts[i], sendtype, i, system_tag, comm);
+ requests[count] =
+ smpi_isend_init(&((char *) sendbuf)[senddisps[i] * sendextent],
+ sendcounts[i], sendtype, i, system_tag, comm);
count++;
}
- /* Wait for them all.*/
+ /* Wait for them all. */
smpi_mpi_startall(count, requests);
DEBUG2("<%d> wait for %d requests", rank, count);
smpi_mpi_waitall(count, requests, MPI_STATUS_IGNORE);
MPI_Group group;
} s_smpi_mpi_communicator_t;
-MPI_Comm smpi_comm_new(MPI_Group group) {
+MPI_Comm smpi_comm_new(MPI_Group group)
+{
MPI_Comm comm;
comm = xbt_new(s_smpi_mpi_communicator_t, 1);
return comm;
}
-void smpi_comm_destroy(MPI_Comm comm) {
+void smpi_comm_destroy(MPI_Comm comm)
+{
smpi_group_destroy(comm->group);
xbt_free(comm);
}
-MPI_Group smpi_comm_group(MPI_Comm comm) {
+MPI_Group smpi_comm_group(MPI_Comm comm)
+{
return comm->group;
}
-int smpi_comm_size(MPI_Comm comm) {
+int smpi_comm_size(MPI_Comm comm)
+{
return smpi_group_size(smpi_comm_group(comm));
}
-int smpi_comm_rank(MPI_Comm comm) {
+int smpi_comm_rank(MPI_Comm comm)
+{
return smpi_group_rank(smpi_comm_group(comm), smpi_process_index());
}
MPI_Comm comm_self;
} s_smpi_process_data_t;
-static smpi_process_data_t* process_data = NULL;
+static smpi_process_data_t *process_data = NULL;
static int process_count = 0;
MPI_Comm MPI_COMM_WORLD = MPI_COMM_NULL;
-smpi_process_data_t smpi_process_data(void) {
+smpi_process_data_t smpi_process_data(void)
+{
return SIMIX_process_get_data(SIMIX_process_self());
}
-smpi_process_data_t smpi_process_remote_data(int index) {
+smpi_process_data_t smpi_process_remote_data(int index)
+{
return process_data[index];
}
-int smpi_process_count(void) {
+int smpi_process_count(void)
+{
return process_count;
}
-int smpi_process_index(void) {
+int smpi_process_index(void)
+{
smpi_process_data_t data = smpi_process_data();
return data->index;
}
-xbt_os_timer_t smpi_process_timer(void) {
+xbt_os_timer_t smpi_process_timer(void)
+{
smpi_process_data_t data = smpi_process_data();
return data->timer;
}
-void smpi_process_simulated_start(void) {
+void smpi_process_simulated_start(void)
+{
smpi_process_data_t data = smpi_process_data();
- data->simulated = SIMIX_get_clock();
+ data->simulated = SIMIX_get_clock();
}
-double smpi_process_simulated_elapsed(void) {
+double smpi_process_simulated_elapsed(void)
+{
smpi_process_data_t data = smpi_process_data();
return SIMIX_get_clock() - data->simulated;
}
-MPI_Comm smpi_process_comm_self(void) {
+MPI_Comm smpi_process_comm_self(void)
+{
smpi_process_data_t data = smpi_process_data();
return data->comm_self;
}
-void print_request(const char* message, MPI_Request request) {
- char* req = bprintf("[buf = %p, size = %zu, src = %d, dst = %d, tag= %d, complete = %d, flags = %u]",
- request->buf, request->size, request->src, request->dst, request->tag, request->complete, request->flags);
+void print_request(const char *message, MPI_Request request)
+{
+ char *req =
+ bprintf
+ ("[buf = %p, size = %zu, src = %d, dst = %d, tag= %d, complete = %d, flags = %u]",
+ request->buf, request->size, request->src, request->dst,
+ request->tag, request->complete, request->flags);
DEBUG5("%s (request %p with rdv %p and match %p) %s",
message, request, request->rdv, request->match, req);
free(req);
}
-void smpi_process_post_send(MPI_Comm comm, MPI_Request request) {
+void smpi_process_post_send(MPI_Comm comm, MPI_Request request)
+{
int index = smpi_group_index(smpi_comm_group(comm), request->dst);
smpi_process_data_t data = smpi_process_remote_data(index);
xbt_fifo_item_t item;
print_request("Isend", request);
xbt_fifo_foreach(data->pending_recv, item, req, MPI_Request) {
- if(req->comm == request->comm
- && (req->src == MPI_ANY_SOURCE || req->src == request->src)
- && (req->tag == MPI_ANY_TAG || req->tag == request->tag)){
+ if (req->comm == request->comm
+ && (req->src == MPI_ANY_SOURCE || req->src == request->src)
+ && (req->tag == MPI_ANY_TAG || req->tag == request->tag)) {
print_request("Match found", req);
xbt_fifo_remove_item(data->pending_recv, item);
/* Materialize the *_ANY_* fields from corresponding irecv request */
xbt_fifo_push(data->pending_sent, request);
}
-void smpi_process_post_recv(MPI_Request request) {
+void smpi_process_post_recv(MPI_Request request)
+{
smpi_process_data_t data = smpi_process_data();
xbt_fifo_item_t item;
MPI_Request req;
print_request("Irecv", request);
xbt_fifo_foreach(data->pending_sent, item, req, MPI_Request) {
- if(req->comm == request->comm
- && (request->src == MPI_ANY_SOURCE || req->src == request->src)
- && (request->tag == MPI_ANY_TAG || req->tag == request->tag)){
+ if (req->comm == request->comm
+ && (request->src == MPI_ANY_SOURCE || req->src == request->src)
+ && (request->tag == MPI_ANY_TAG || req->tag == request->tag)) {
print_request("Match found", req);
xbt_fifo_remove_item(data->pending_sent, item);
/* Materialize the *_ANY_* fields from the irecv request */
xbt_fifo_push(data->pending_recv, request);
}
-void smpi_global_init(void) {
+void smpi_global_init(void)
+{
int i;
MPI_Group group;
- SIMIX_network_set_copy_data_callback(&SIMIX_network_copy_buffer_callback);
+ SIMIX_network_set_copy_data_callback
+ (&SIMIX_network_copy_buffer_callback);
process_count = SIMIX_process_count();
process_data = xbt_new(smpi_process_data_t, process_count);
- for(i = 0; i < process_count; i++) {
+ for (i = 0; i < process_count; i++) {
process_data[i] = xbt_new(s_smpi_process_data_t, 1);
process_data[i]->index = i;
process_data[i]->pending_sent = xbt_fifo_new();
}
group = smpi_group_new(process_count);
MPI_COMM_WORLD = smpi_comm_new(group);
- for(i = 0; i < process_count; i++) {
+ for (i = 0; i < process_count; i++) {
smpi_group_set_mapping(group, i, i);
}
}
-void smpi_global_destroy(void) {
+void smpi_global_destroy(void)
+{
int count = smpi_process_count();
int i;
smpi_bench_destroy();
smpi_comm_destroy(MPI_COMM_WORLD);
MPI_COMM_WORLD = MPI_COMM_NULL;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
smpi_comm_destroy(process_data[i]->comm_self);
xbt_os_timer_free(process_data[i]->timer);
xbt_fifo_free(process_data[i]->pending_recv);
double default_reference_speed = 20000.0;
xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
"Power of the host running the simulation (in flop/s). Used to bench the operations.",
- xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL, NULL);
+ xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
+ NULL);
int default_display_timing = 0;
xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
"Boolean indicating whether we should display the timing after simulation.",
- xbt_cfgelm_int, &default_display_timing, 1, 1, NULL, NULL);
+ xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
+ NULL);
int default_display_smpe = 0;
xbt_cfg_register(&_surf_cfg_set, "smpi/log_events",
"Boolean indicating whether we should display simulated time spent in MPI calls.",
- xbt_cfgelm_int, &default_display_smpe, 1, 1, NULL, NULL);
+ xbt_cfgelm_int, &default_display_smpe, 1, 1, NULL,
+ NULL);
double default_threshold = 1e-6;
xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
"Minimal computation time (in seconds) not discarded.",
- xbt_cfgelm_double, &default_threshold, 1, 1, NULL, NULL);
+ xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
+ NULL);
#ifdef HAVE_TRACING
- TRACE_global_init (&argc, argv);
+ TRACE_global_init(&argc, argv);
#endif
SIMIX_global_init(&argc, argv);
#ifdef HAVE_TRACING
- TRACE_smpi_start ();
+ TRACE_smpi_start();
#endif
// parse the platform file: get the host list
SIMIX_message_sizes_output("toto.txt");
#ifdef HAVE_TRACING
- TRACE_smpi_release ();
+ TRACE_smpi_release();
#endif
SIMIX_clean();
typedef struct s_smpi_mpi_group {
int size;
- int* rank_to_index_map;
- int* index_to_rank_map;
+ int *rank_to_index_map;
+ int *index_to_rank_map;
int refcount;
} s_smpi_mpi_group_t;
static s_smpi_mpi_group_t mpi_MPI_GROUP_EMPTY = {
- 0, /* size */
- NULL, /* rank_to_index_map */
- NULL, /* index_to_rank_map */
- 1, /* refcount: start > 0 so that this group never gets freed */
+ 0, /* size */
+ NULL, /* rank_to_index_map */
+ NULL, /* index_to_rank_map */
+ 1, /* refcount: start > 0 so that this group never gets freed */
};
+
MPI_Group MPI_GROUP_EMPTY = &mpi_MPI_GROUP_EMPTY;
-MPI_Group smpi_group_new(int size) {
+MPI_Group smpi_group_new(int size)
+{
MPI_Group group;
int i, count;
group->rank_to_index_map = xbt_new(int, size);
group->index_to_rank_map = xbt_new(int, count);
group->refcount = 0;
- for(i = 0; i < size; i++) {
+ for (i = 0; i < size; i++) {
group->rank_to_index_map[i] = MPI_UNDEFINED;
}
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
group->index_to_rank_map[i] = MPI_UNDEFINED;
}
return group;
}
-void smpi_group_destroy(MPI_Group group) {
- if(smpi_group_unuse(group) <= 0) {
+void smpi_group_destroy(MPI_Group group)
+{
+ if (smpi_group_unuse(group) <= 0) {
xbt_free(group->rank_to_index_map);
xbt_free(group->index_to_rank_map);
xbt_free(group);
}
}
-void smpi_group_set_mapping(MPI_Group group, int index, int rank) {
- if(rank < group->size && index < smpi_process_count()) {
+void smpi_group_set_mapping(MPI_Group group, int index, int rank)
+{
+ if (rank < group->size && index < smpi_process_count()) {
group->rank_to_index_map[rank] = index;
group->index_to_rank_map[index] = rank;
}
}
-int smpi_group_index(MPI_Group group, int rank) {
+int smpi_group_index(MPI_Group group, int rank)
+{
int index = MPI_UNDEFINED;
- if(rank < group->size) {
+ if (rank < group->size) {
index = group->rank_to_index_map[rank];
}
return index;
}
-int smpi_group_rank(MPI_Group group, int index) {
+int smpi_group_rank(MPI_Group group, int index)
+{
int rank = MPI_UNDEFINED;
- if(index < smpi_process_count()) {
+ if (index < smpi_process_count()) {
rank = group->index_to_rank_map[index];
}
return rank;
}
-int smpi_group_use(MPI_Group group) {
+int smpi_group_use(MPI_Group group)
+{
group->refcount++;
return group->refcount;
}
-int smpi_group_unuse(MPI_Group group) {
+int smpi_group_unuse(MPI_Group group)
+{
group->refcount--;
return group->refcount;
}
-int smpi_group_size(MPI_Group group) {
+int smpi_group_size(MPI_Group group)
+{
return group->size;
}
-int smpi_group_compare(MPI_Group group1, MPI_Group group2) {
+int smpi_group_compare(MPI_Group group1, MPI_Group group2)
+{
int result;
int i, index, rank, size;
result = MPI_IDENT;
- if(smpi_group_size(group1) != smpi_group_size(group2)) {
+ if (smpi_group_size(group1) != smpi_group_size(group2)) {
result = MPI_UNEQUAL;
} else {
size = smpi_group_size(group2);
- for(i = 0; i < size; i++) {
+ for (i = 0; i < size; i++) {
index = smpi_group_index(group1, i);
rank = smpi_group_rank(group2, index);
- if(rank == MPI_UNDEFINED) {
+ if (rank == MPI_UNDEFINED) {
result = MPI_UNEQUAL;
break;
}
- if(rank != i) {
+ if (rank != i) {
result = MPI_SIMILAR;
}
}
/* MPI User level calls */
-int MPI_Init(int* argc, char*** argv) {
+int MPI_Init(int *argc, char ***argv)
+{
smpi_process_init(argc, argv);
#ifdef HAVE_TRACING
TRACE_smpi_init(smpi_process_index());
return MPI_SUCCESS;
}
-int MPI_Finalize(void) {
+int MPI_Finalize(void)
+{
smpi_bench_end(-1, NULL);
#ifdef HAVE_TRACING
TRACE_smpi_finalize(smpi_process_index());
return MPI_SUCCESS;
}
-int MPI_Init_thread(int* argc, char*** argv, int required, int* provided) {
- if(provided != NULL) {
+int MPI_Init_thread(int *argc, char ***argv, int required, int *provided)
+{
+ if (provided != NULL) {
*provided = MPI_THREAD_MULTIPLE;
}
return MPI_Init(argc, argv);
}
-int MPI_Query_thread(int* provided) {
+int MPI_Query_thread(int *provided)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(provided == NULL) {
+ if (provided == NULL) {
retval = MPI_ERR_ARG;
} else {
*provided = MPI_THREAD_MULTIPLE;
return retval;
}
-int MPI_Is_thread_main(int* flag) {
+int MPI_Is_thread_main(int *flag)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(flag == NULL) {
+ if (flag == NULL) {
retval = MPI_ERR_ARG;
} else {
*flag = smpi_process_index() == 0;
return retval;
}
-int MPI_Abort(MPI_Comm comm, int errorcode) {
+int MPI_Abort(MPI_Comm comm, int errorcode)
+{
smpi_bench_end(-1, NULL);
smpi_process_destroy();
// FIXME: should kill all processes in comm instead
return MPI_SUCCESS;
}
-double MPI_Wtime(void) {
+double MPI_Wtime(void)
+{
double time;
smpi_bench_end(-1, NULL);
return time;
}
-int MPI_Address(void *location, MPI_Aint *address) {
+int MPI_Address(void *location, MPI_Aint * address)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(!address) {
+ if (!address) {
retval = MPI_ERR_ARG;
} else {
- *address = (MPI_Aint)location;
+ *address = (MPI_Aint) location;
}
smpi_bench_begin(-1, NULL);
return retval;
}
-int MPI_Type_free(MPI_Datatype* datatype) {
+int MPI_Type_free(MPI_Datatype * datatype)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(!datatype) {
+ if (!datatype) {
retval = MPI_ERR_ARG;
} else {
// FIXME: always fail for now
return retval;
}
-int MPI_Type_size(MPI_Datatype datatype, int* size) {
+int MPI_Type_size(MPI_Datatype datatype, int *size)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(datatype == MPI_DATATYPE_NULL) {
+ if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(size == NULL) {
+ } else if (size == NULL) {
retval = MPI_ERR_ARG;
} else {
- *size = (int)smpi_datatype_size(datatype);
+ *size = (int) smpi_datatype_size(datatype);
retval = MPI_SUCCESS;
}
smpi_bench_begin(-1, NULL);
return retval;
}
-int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent) {
+int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb,
+ MPI_Aint * extent)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(datatype == MPI_DATATYPE_NULL) {
+ if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(lb == NULL || extent == NULL) {
+ } else if (lb == NULL || extent == NULL) {
retval = MPI_ERR_ARG;
} else {
retval = smpi_datatype_extent(datatype, lb, extent);
return retval;
}
-int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint* extent) {
+int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
+{
int retval;
MPI_Aint dummy;
smpi_bench_end(-1, NULL);
- if(datatype == MPI_DATATYPE_NULL) {
+ if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(extent == NULL) {
+ } else if (extent == NULL) {
retval = MPI_ERR_ARG;
} else {
retval = smpi_datatype_extent(datatype, &dummy, extent);
return retval;
}
-int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp) {
+int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(datatype == MPI_DATATYPE_NULL) {
+ if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(disp == NULL) {
+ } else if (disp == NULL) {
retval = MPI_ERR_ARG;
} else {
*disp = smpi_datatype_lb(datatype);
return retval;
}
-int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp) {
+int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(datatype == MPI_DATATYPE_NULL) {
+ if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(disp == NULL) {
+ } else if (disp == NULL) {
retval = MPI_ERR_ARG;
} else {
*disp = smpi_datatype_ub(datatype);
return retval;
}
-int MPI_Op_create(MPI_User_function* function, int commute, MPI_Op* op) {
+int MPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(function == NULL || op == NULL) {
+ if (function == NULL || op == NULL) {
retval = MPI_ERR_ARG;
} else {
*op = smpi_op_new(function, commute);
return retval;
}
-int MPI_Op_free(MPI_Op* op) {
+int MPI_Op_free(MPI_Op * op)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(op == NULL) {
+ if (op == NULL) {
retval = MPI_ERR_ARG;
- } else if(*op == MPI_OP_NULL) {
+ } else if (*op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else {
smpi_op_destroy(*op);
return retval;
}
-int MPI_Group_free(MPI_Group *group) {
+int MPI_Group_free(MPI_Group * group)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(group == NULL) {
+ if (group == NULL) {
retval = MPI_ERR_ARG;
} else {
smpi_group_destroy(*group);
return retval;
}
-int MPI_Group_size(MPI_Group group, int* size) {
+int MPI_Group_size(MPI_Group group, int *size)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(size == NULL) {
+ } else if (size == NULL) {
retval = MPI_ERR_ARG;
} else {
*size = smpi_group_size(group);
return retval;
}
-int MPI_Group_rank(MPI_Group group, int* rank) {
+int MPI_Group_rank(MPI_Group group, int *rank)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(rank == NULL) {
+ } else if (rank == NULL) {
retval = MPI_ERR_ARG;
} else {
*rank = smpi_group_rank(group, smpi_process_index());
return retval;
}
-int MPI_Group_translate_ranks (MPI_Group group1, int n, int* ranks1, MPI_Group group2, int* ranks2) {
+int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
+ MPI_Group group2, int *ranks2)
+{
int retval, i, index;
smpi_bench_end(-1, NULL);
- if(group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
+ if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
} else {
- for(i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
index = smpi_group_index(group1, ranks1[i]);
ranks2[i] = smpi_group_rank(group2, index);
}
return retval;
}
-int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int* result) {
+int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
+ if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(result == NULL) {
+ } else if (result == NULL) {
retval = MPI_ERR_ARG;
} else {
*result = smpi_group_compare(group1, group2);
return retval;
}
-int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup) {
+int MPI_Group_union(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup)
+{
int retval, i, proc1, proc2, size, size2;
smpi_bench_end(-1, NULL);
- if(group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
+ if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
size = smpi_group_size(group1);
size2 = smpi_group_size(group2);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc2 = smpi_group_index(group2, i);
proc1 = smpi_group_rank(group1, proc2);
- if(proc1 == MPI_UNDEFINED) {
+ if (proc1 == MPI_UNDEFINED) {
size++;
}
}
- if(size == 0) {
+ if (size == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
*newgroup = smpi_group_new(size);
size2 = smpi_group_size(group1);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc1 = smpi_group_index(group1, i);
smpi_group_set_mapping(*newgroup, proc1, i);
}
- for(i = size2; i < size; i++) {
+ for (i = size2; i < size; i++) {
proc2 = smpi_group_index(group2, i - size2);
smpi_group_set_mapping(*newgroup, proc2, i);
}
return retval;
}
-int MPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup) {
- int retval, i, proc1, proc2, size, size2;
+int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup)
+{
+ int retval, i, proc1, proc2, size, size2;
smpi_bench_end(-1, NULL);
- if(group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
+ if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
size = smpi_group_size(group1);
size2 = smpi_group_size(group2);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc2 = smpi_group_index(group2, i);
proc1 = smpi_group_rank(group1, proc2);
- if(proc1 == MPI_UNDEFINED) {
+ if (proc1 == MPI_UNDEFINED) {
size--;
}
}
- if(size == 0) {
+ if (size == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
*newgroup = smpi_group_new(size);
size2 = smpi_group_size(group1);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc1 = smpi_group_index(group1, i);
proc2 = smpi_group_rank(group2, proc1);
- if(proc2 != MPI_UNDEFINED) {
+ if (proc2 != MPI_UNDEFINED) {
smpi_group_set_mapping(*newgroup, proc1, i);
}
}
return retval;
}
-int MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup) {
+int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
+ MPI_Group * newgroup)
+{
int retval, i, proc1, proc2, size, size2;
smpi_bench_end(-1, NULL);
- if(group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
+ if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
size = size2 = smpi_group_size(group1);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc1 = smpi_group_index(group1, i);
proc2 = smpi_group_rank(group2, proc1);
- if(proc2 != MPI_UNDEFINED) {
+ if (proc2 != MPI_UNDEFINED) {
size--;
}
}
- if(size == 0) {
+ if (size == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
*newgroup = smpi_group_new(size);
- for(i = 0; i < size2; i++) {
+ for (i = 0; i < size2; i++) {
proc1 = smpi_group_index(group1, i);
proc2 = smpi_group_rank(group2, proc1);
- if(proc2 == MPI_UNDEFINED) {
+ if (proc2 == MPI_UNDEFINED) {
smpi_group_set_mapping(*newgroup, proc1, i);
}
}
return retval;
}
-int MPI_Group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup) {
+int MPI_Group_incl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup)
+{
int retval, i, index;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(n == 0) {
+ if (n == 0) {
*newgroup = MPI_GROUP_EMPTY;
- } else if(n == smpi_group_size(group)) {
+ } else if (n == smpi_group_size(group)) {
*newgroup = group;
} else {
*newgroup = smpi_group_new(n);
- for(i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
index = smpi_group_index(group, ranks[i]);
smpi_group_set_mapping(*newgroup, index, i);
}
return retval;
}
-int MPI_Group_excl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup) {
+int MPI_Group_excl(MPI_Group group, int n, int *ranks,
+ MPI_Group * newgroup)
+{
int retval, i, size, rank, index;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(n == 0) {
+ if (n == 0) {
*newgroup = group;
- } else if(n == smpi_group_size(group)) {
+ } else if (n == smpi_group_size(group)) {
*newgroup = MPI_GROUP_EMPTY;
} else {
size = smpi_group_size(group) - n;
*newgroup = smpi_group_new(size);
rank = 0;
- while(rank < size) {
- for(i = 0; i < n; i++) {
- if(ranks[i] == rank) {
+ while (rank < size) {
+ for (i = 0; i < n; i++) {
+ if (ranks[i] == rank) {
break;
}
}
- if(i >= n) {
+ if (i >= n) {
index = smpi_group_index(group, rank);
smpi_group_set_mapping(*newgroup, index, rank);
rank++;
return retval;
}
-int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup) {
+int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
+ MPI_Group * newgroup)
+{
int retval, i, j, rank, size, index;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(n == 0) {
+ if (n == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
size = 0;
- for(i = 0; i < n; i++) {
- for(rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */) {
+ for (i = 0; i < n; i++) {
+ for (rank = ranges[i][0]; /* First */
+ rank >= 0 && rank <= ranges[i][1]; /* Last */
+ rank += ranges[i][2] /* Stride */ ) {
size++;
}
}
- if(size == smpi_group_size(group)) {
+ if (size == smpi_group_size(group)) {
*newgroup = group;
} else {
*newgroup = smpi_group_new(size);
j = 0;
- for(i = 0; i < n; i++) {
- for(rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */) {
+ for (i = 0; i < n; i++) {
+ for (rank = ranges[i][0]; /* First */
+ rank >= 0 && rank <= ranges[i][1]; /* Last */
+ rank += ranges[i][2] /* Stride */ ) {
index = smpi_group_index(group, rank);
smpi_group_set_mapping(*newgroup, index, j);
j++;
return retval;
}
-int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup) {
+int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
+ MPI_Group * newgroup)
+{
int retval, i, newrank, rank, size, index, add;
smpi_bench_end(-1, NULL);
- if(group == MPI_GROUP_NULL) {
+ if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newgroup == NULL) {
+ } else if (newgroup == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(n == 0) {
+ if (n == 0) {
*newgroup = group;
} else {
size = smpi_group_size(group);
- for(i = 0; i < n; i++) {
- for(rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */) {
+ for (i = 0; i < n; i++) {
+ for (rank = ranges[i][0]; /* First */
+ rank >= 0 && rank <= ranges[i][1]; /* Last */
+ rank += ranges[i][2] /* Stride */ ) {
size--;
}
}
- if(size == 0) {
+ if (size == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
*newgroup = smpi_group_new(size);
newrank = 0;
- while(newrank < size) {
- for(i = 0; i < n; i++) {
+ while (newrank < size) {
+ for (i = 0; i < n; i++) {
add = 1;
- for(rank = ranges[i][0]; /* First */
- rank >= 0 && rank <= ranges[i][1]; /* Last */
- rank += ranges[i][2] /* Stride */) {
- if(rank == newrank) {
+ for (rank = ranges[i][0]; /* First */
+ rank >= 0 && rank <= ranges[i][1]; /* Last */
+ rank += ranges[i][2] /* Stride */ ) {
+ if (rank == newrank) {
add = 0;
break;
}
}
- if(add == 1) {
+ if (add == 1) {
index = smpi_group_index(group, newrank);
smpi_group_set_mapping(*newgroup, index, newrank);
}
return retval;
}
-int MPI_Comm_rank(MPI_Comm comm, int* rank) {
+int MPI_Comm_rank(MPI_Comm comm, int *rank)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else {
*rank = smpi_comm_rank(comm);
return retval;
}
-int MPI_Comm_size(MPI_Comm comm, int* size) {
+int MPI_Comm_size(MPI_Comm comm, int *size)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(size == NULL) {
+ } else if (size == NULL) {
retval = MPI_ERR_ARG;
} else {
*size = smpi_comm_size(comm);
return retval;
}
-int MPI_Comm_group(MPI_Comm comm, MPI_Group* group) {
+int MPI_Comm_group(MPI_Comm comm, MPI_Group * group)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(group == NULL) {
+ } else if (group == NULL) {
retval = MPI_ERR_ARG;
} else {
*group = smpi_comm_group(comm);
return retval;
}
-int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result) {
+int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
+ if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(result == NULL) {
+ } else if (result == NULL) {
retval = MPI_ERR_ARG;
} else {
- if(comm1 == comm2) { /* Same communicators means same groups */
+ if (comm1 == comm2) { /* Same communicators means same groups */
*result = MPI_IDENT;
} else {
- *result = smpi_group_compare(smpi_comm_group(comm1), smpi_comm_group(comm2));
- if(*result == MPI_IDENT) {
+ *result =
+ smpi_group_compare(smpi_comm_group(comm1),
+ smpi_comm_group(comm2));
+ if (*result == MPI_IDENT) {
*result = MPI_CONGRUENT;
}
}
return retval;
}
-int MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm) {
+int MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(newcomm == NULL) {
+ } else if (newcomm == NULL) {
retval = MPI_ERR_ARG;
} else {
*newcomm = smpi_comm_new(smpi_comm_group(comm));
return retval;
}
-int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm) {
+int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(group == MPI_GROUP_NULL) {
+ } else if (group == MPI_GROUP_NULL) {
retval = MPI_ERR_GROUP;
- } else if(newcomm == NULL) {
+ } else if (newcomm == NULL) {
retval = MPI_ERR_ARG;
} else {
*newcomm = smpi_comm_new(group);
return retval;
}
-int MPI_Comm_free(MPI_Comm* comm) {
+int MPI_Comm_free(MPI_Comm * comm)
+{
int retval;
smpi_bench_end(-1, NULL);
- if(comm == NULL) {
+ if (comm == NULL) {
retval = MPI_ERR_ARG;
- } else if(*comm == MPI_COMM_NULL) {
+ } else if (*comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else {
smpi_comm_destroy(*comm);
return retval;
}
-int MPI_Send_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
+int MPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
+ int tag, MPI_Comm comm, MPI_Request * request)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Send_init");
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
return retval;
}
-int MPI_Recv_init(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request) {
+int MPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
+ int tag, MPI_Comm comm, MPI_Request * request)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Recv_init");
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
return retval;
}
-int MPI_Start(MPI_Request* request) {
+int MPI_Start(MPI_Request * request)
+{
int retval;
MPI_Comm comm = (*request)->comm;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Start");
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else {
smpi_mpi_start(*request);
return retval;
}
-int MPI_Startall(int count, MPI_Request* requests) {
+int MPI_Startall(int count, MPI_Request * requests)
+{
int retval;
- MPI_Comm comm = count > 0 && requests ? requests[0]->comm : MPI_COMM_NULL;
+ MPI_Comm comm = count > 0
+ && requests ? requests[0]->comm : MPI_COMM_NULL;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Startall");
- if(requests == NULL) {
+ if (requests == NULL) {
retval = MPI_ERR_ARG;
} else {
smpi_mpi_startall(count, requests);
return retval;
}
-int MPI_Request_free(MPI_Request* request) {
+int MPI_Request_free(MPI_Request * request)
+{
int retval;
MPI_Comm comm = (*request)->comm;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Request_free");
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else {
smpi_mpi_request_free(request);
return retval;
}
-int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request) {
+int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
+ int tag, MPI_Comm comm, MPI_Request * request)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Irecv");
#ifdef HAVE_TRACING
int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
- TRACE_smpi_ptp_in (rank, src_traced, rank, __FUNCTION__);
+ TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
#endif
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, src_traced, rank, __FUNCTION__);
+ TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
(*request)->recv = 1;
#endif
smpi_bench_begin(rank, "Irecv");
return retval;
}
-int MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
+int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
+ int tag, MPI_Comm comm, MPI_Request * request)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Isend");
#ifdef HAVE_TRACING
int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
- TRACE_smpi_ptp_in (rank, rank, dst_traced, __FUNCTION__);
- TRACE_smpi_send (rank, rank, dst_traced);
+ TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
+ TRACE_smpi_send(rank, rank, dst_traced);
#endif
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
} else if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, rank, dst_traced, __FUNCTION__);
+ TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
(*request)->send = 1;
#endif
smpi_bench_begin(rank, "Isend");
return retval;
}
-int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status) {
+int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
+ MPI_Comm comm, MPI_Status * status)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Recv");
#ifdef HAVE_TRACING
int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
- TRACE_smpi_ptp_in (rank, src_traced, rank, __FUNCTION__);
+ TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, src_traced, rank, __FUNCTION__);
- TRACE_smpi_recv (rank, src_traced, rank);
+ TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
+ TRACE_smpi_recv(rank, src_traced, rank);
#endif
smpi_bench_begin(rank, "Recv");
return retval;
}
-int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
+int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
+ MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Send");
#ifdef HAVE_TRACING
int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
- TRACE_smpi_ptp_in (rank, rank, dst_traced, __FUNCTION__);
- TRACE_smpi_send (rank, rank, dst_traced);
+ TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
+ TRACE_smpi_send(rank, rank, dst_traced);
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, rank, dst_traced, __FUNCTION__);
+ TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Send");
return retval;
}
-int MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status) {
+int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ int dst, int sendtag, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
#ifdef HAVE_TRACING
int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
- TRACE_smpi_ptp_in (rank, src_traced, dst_traced, __FUNCTION__);
- TRACE_smpi_send (rank, rank, dst_traced);
- TRACE_smpi_send (rank, src_traced, rank);
+ TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
+ TRACE_smpi_send(rank, rank, dst_traced);
+ TRACE_smpi_send(rank, src_traced, rank);
#endif
if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if (sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
} else {
- smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src, recvtag, comm, status);
+ smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
+ recvcount, recvtype, src, recvtag, comm, status);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, src_traced, dst_traced, __FUNCTION__);
- TRACE_smpi_recv (rank, rank, dst_traced);
- TRACE_smpi_recv (rank, src_traced, rank);
+ TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
+ TRACE_smpi_recv(rank, rank, dst_traced);
+ TRACE_smpi_recv(rank, src_traced, rank);
#endif
smpi_bench_begin(rank, "Sendrecv");
return retval;
}
-int MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag, MPI_Comm comm, MPI_Status* status) {
+int MPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
+ int dst, int sendtag, int src, int recvtag,
+ MPI_Comm comm, MPI_Status * status)
+{
//TODO: suboptimal implementation
- void* recvbuf;
+ void *recvbuf;
int retval, size;
size = smpi_datatype_size(datatype) * count;
recvbuf = xbt_new(char, size);
- retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
+ retval =
+ MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
+ datatype, src, recvtag, comm, status);
memcpy(buf, recvbuf, size * sizeof(char));
xbt_free(recvbuf);
return retval;
}
-int MPI_Test(MPI_Request* request, int* flag, MPI_Status* status) {
+int MPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
+{
int retval;
int rank = request && (*request)->comm != MPI_COMM_NULL
- ? smpi_comm_rank((*request)->comm)
- : -1;
+ ? smpi_comm_rank((*request)->comm)
+ : -1;
smpi_bench_end(rank, "Test");
- if(request == NULL || flag == NULL) {
+ if (request == NULL || flag == NULL) {
retval = MPI_ERR_ARG;
- } else if(*request == MPI_REQUEST_NULL) {
+ } else if (*request == MPI_REQUEST_NULL) {
retval = MPI_ERR_REQUEST;
} else {
*flag = smpi_mpi_test(request, status);
return retval;
}
-int MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status) {
+int MPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
+ MPI_Status * status)
+{
int retval;
- smpi_bench_end(-1, NULL); //FIXME
- if(index == NULL || flag == NULL) {
+ smpi_bench_end(-1, NULL); //FIXME
+ if (index == NULL || flag == NULL) {
retval = MPI_ERR_ARG;
} else {
*flag = smpi_mpi_testany(count, requests, index, status);
return retval;
}
-int MPI_Wait(MPI_Request* request, MPI_Status* status) {
+int MPI_Wait(MPI_Request * request, MPI_Status * status)
+{
int retval;
int rank = request && (*request)->comm != MPI_COMM_NULL
- ? smpi_comm_rank((*request)->comm)
- : -1;
+ ? smpi_comm_rank((*request)->comm)
+ : -1;
smpi_bench_end(rank, "Wait");
#ifdef HAVE_TRACING
MPI_Group group = smpi_comm_group((*request)->comm);
- int src_traced = smpi_group_rank (group , (*request)->src);
- int dst_traced = smpi_group_rank (group , (*request)->dst);
+ int src_traced = smpi_group_rank(group, (*request)->src);
+ int dst_traced = smpi_group_rank(group, (*request)->dst);
int is_wait_for_receive = (*request)->recv;
- TRACE_smpi_ptp_in (rank, src_traced, dst_traced, __FUNCTION__);
+ TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
#endif
- if(request == NULL) {
+ if (request == NULL) {
retval = MPI_ERR_ARG;
- } else if(*request == MPI_REQUEST_NULL) {
+ } else if (*request == MPI_REQUEST_NULL) {
retval = MPI_ERR_REQUEST;
} else {
smpi_mpi_wait(request, status);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_ptp_out (rank, src_traced, dst_traced, __FUNCTION__);
- if (is_wait_for_receive){
- TRACE_smpi_recv (rank, src_traced, dst_traced);
+ TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
+ if (is_wait_for_receive) {
+ TRACE_smpi_recv(rank, src_traced, dst_traced);
}
#endif
smpi_bench_begin(rank, "Wait");
return retval;
}
-int MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status) {
+int MPI_Waitany(int count, MPI_Request requests[], int *index,
+ MPI_Status * status)
+{
int retval;
- smpi_bench_end(-1, NULL); //FIXME
+ smpi_bench_end(-1, NULL); //FIXME
#ifdef HAVE_TRACING
//save requests information for tracing
int i;
- xbt_dynar_t srcs = xbt_dynar_new (sizeof(int), xbt_free);
- xbt_dynar_t dsts = xbt_dynar_new (sizeof(int), xbt_free);
- xbt_dynar_t recvs = xbt_dynar_new (sizeof(int), xbt_free);
- for (i = 0; i < count; i++){
- MPI_Request req = requests[i]; //already received requests are no longer valid
- if (req){
+ xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), xbt_free);
+ xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), xbt_free);
+ xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), xbt_free);
+ for (i = 0; i < count; i++) {
+ MPI_Request req = requests[i]; //already received requests are no longer valid
+ if (req) {
int *asrc = xbt_new(int, 1);
int *adst = xbt_new(int, 1);
int *arecv = xbt_new(int, 1);
*asrc = req->src;
*adst = req->dst;
*arecv = req->recv;
- xbt_dynar_insert_at (srcs, i, asrc);
- xbt_dynar_insert_at (dsts, i, adst);
- xbt_dynar_insert_at (recvs, i, arecv);
- }else{
+ xbt_dynar_insert_at(srcs, i, asrc);
+ xbt_dynar_insert_at(dsts, i, adst);
+ xbt_dynar_insert_at(recvs, i, arecv);
+ } else {
int *t = xbt_new(int, 1);
- xbt_dynar_insert_at (srcs, i, t);
- xbt_dynar_insert_at (dsts, i, t);
- xbt_dynar_insert_at (recvs, i, t);
+ xbt_dynar_insert_at(srcs, i, t);
+ xbt_dynar_insert_at(dsts, i, t);
+ xbt_dynar_insert_at(recvs, i, t);
}
}
}
MPI_Comm comm = (req)->comm;
int rank_traced = smpi_comm_rank(comm);
- TRACE_smpi_ptp_in (rank_traced, -1, -1, __FUNCTION__);
+ TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
#endif
- if(index == NULL) {
+ if (index == NULL) {
retval = MPI_ERR_ARG;
} else {
*index = smpi_mpi_waitany(count, requests, status);
}
#ifdef HAVE_TRACING
int src_traced, dst_traced, is_wait_for_receive;
- xbt_dynar_get_cpy (srcs, *index, &src_traced);
- xbt_dynar_get_cpy (dsts, *index, &dst_traced);
- xbt_dynar_get_cpy (recvs, *index, &is_wait_for_receive);
- if (is_wait_for_receive){
- TRACE_smpi_recv (rank_traced, src_traced, dst_traced);
+ xbt_dynar_get_cpy(srcs, *index, &src_traced);
+ xbt_dynar_get_cpy(dsts, *index, &dst_traced);
+ xbt_dynar_get_cpy(recvs, *index, &is_wait_for_receive);
+ if (is_wait_for_receive) {
+ TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
}
- TRACE_smpi_ptp_out (rank_traced, src_traced, dst_traced, __FUNCTION__);
+ TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
//clean-up of dynars
- xbt_free (srcs);
- xbt_free (dsts);
- xbt_free (recvs);
+ xbt_free(srcs);
+ xbt_free(dsts);
+ xbt_free(recvs);
#endif
smpi_bench_begin(-1, NULL);
return retval;
}
-int MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]) {
+int MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
+{
- smpi_bench_end(-1, NULL); //FIXME
+ smpi_bench_end(-1, NULL); //FIXME
#ifdef HAVE_TRACING
//save information from requests
int i;
- xbt_dynar_t srcs = xbt_dynar_new (sizeof(int), xbt_free);
- xbt_dynar_t dsts = xbt_dynar_new (sizeof(int), xbt_free);
- xbt_dynar_t recvs = xbt_dynar_new (sizeof(int), xbt_free);
- for (i = 0; i < count; i++){
- MPI_Request req = requests[i]; //all req should be valid in Waitall
+ xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), xbt_free);
+ xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), xbt_free);
+ xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), xbt_free);
+ for (i = 0; i < count; i++) {
+ MPI_Request req = requests[i]; //all req should be valid in Waitall
int *asrc = xbt_new(int, 1);
int *adst = xbt_new(int, 1);
int *arecv = xbt_new(int, 1);
*asrc = req->src;
*adst = req->dst;
*arecv = req->recv;
- xbt_dynar_insert_at (srcs, i, asrc);
- xbt_dynar_insert_at (dsts, i, adst);
- xbt_dynar_insert_at (recvs, i, arecv);
+ xbt_dynar_insert_at(srcs, i, asrc);
+ xbt_dynar_insert_at(dsts, i, adst);
+ xbt_dynar_insert_at(recvs, i, arecv);
}
// find my rank inside one of MPI_Comm's of the requests
}
MPI_Comm comm = (req)->comm;
int rank_traced = smpi_comm_rank(comm);
- TRACE_smpi_ptp_in (rank_traced, -1, -1, __FUNCTION__);
+ TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
#endif
smpi_mpi_waitall(count, requests, status);
#ifdef HAVE_TRACING
- for (i = 0; i < count; i++){
+ for (i = 0; i < count; i++) {
int src_traced, dst_traced, is_wait_for_receive;
- xbt_dynar_get_cpy (srcs, i, &src_traced);
- xbt_dynar_get_cpy (dsts, i, &dst_traced);
- xbt_dynar_get_cpy (recvs, i, &is_wait_for_receive);
- if (is_wait_for_receive){
- TRACE_smpi_recv (rank_traced, src_traced, dst_traced);
+ xbt_dynar_get_cpy(srcs, i, &src_traced);
+ xbt_dynar_get_cpy(dsts, i, &dst_traced);
+ xbt_dynar_get_cpy(recvs, i, &is_wait_for_receive);
+ if (is_wait_for_receive) {
+ TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
}
}
- TRACE_smpi_ptp_out (rank_traced, -1, -1, __FUNCTION__);
+ TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
//clean-up of dynars
- xbt_free (srcs);
- xbt_free (dsts);
- xbt_free (recvs);
+ xbt_free(srcs);
+ xbt_free(dsts);
+ xbt_free(recvs);
#endif
smpi_bench_begin(-1, NULL);
return MPI_SUCCESS;
}
-int MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[]) {
+int MPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
+ int *indices, MPI_Status status[])
+{
int retval;
- smpi_bench_end(-1, NULL); //FIXME
- if(outcount == NULL || indices == NULL) {
+ smpi_bench_end(-1, NULL); //FIXME
+ if (outcount == NULL || indices == NULL) {
retval = MPI_ERR_ARG;
} else {
*outcount = smpi_mpi_waitsome(incount, requests, indices, status);
return retval;
}
-int MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) {
+int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root,
+ MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Bcast");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else {
smpi_mpi_bcast(buf, count, datatype, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Bcast");
return retval;
}
-int MPI_Barrier(MPI_Comm comm) {
+int MPI_Barrier(MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Barrier");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
} else {
smpi_mpi_barrier(comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Barrier");
return retval;
}
-int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Gather");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
} else {
- smpi_mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
+ smpi_mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
+ recvtype, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Gather");
return retval;
}
-int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts, int *displs,
+ MPI_Datatype recvtype, int root, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Gatherv");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(recvcounts == NULL || displs == NULL) {
+ } else if (recvcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
- smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm);
+ smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
+ displs, recvtype, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Gatherv");
return retval;
}
-int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Allgather");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
} else {
- smpi_mpi_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
+ smpi_mpi_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
+ recvtype, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Allgather");
return retval;
}
-int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm) {
+int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int *recvcounts, int *displs,
+ MPI_Datatype recvtype, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Allgatherv");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(recvcounts == NULL || displs == NULL) {
+ } else if (recvcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
- smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
+ smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
+ displs, recvtype, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Allgatherv");
return retval;
}
-int MPI_Scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ int root, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Scatter");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
} else {
- smpi_mpi_scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
+ smpi_mpi_scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
+ recvtype, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Scatter");
return retval;
}
-int MPI_Scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
+int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
+ MPI_Datatype sendtype, void *recvbuf, int recvcount,
+ MPI_Datatype recvtype, int root, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Scatterv");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(sendcounts == NULL || displs == NULL) {
+ } else if (sendcounts == NULL || displs == NULL) {
retval = MPI_ERR_ARG;
} else {
- smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm);
+ smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
+ recvcount, recvtype, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Scatterv");
return retval;
}
-int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) {
+int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Reduce");
#ifdef HAVE_TRACING
int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
- TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
+ } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
retval = MPI_ERR_ARG;
} else {
smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Reduce");
return retval;
}
-int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
+int MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Allreduce");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(datatype == MPI_DATATYPE_NULL) {
+ } else if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(op == MPI_OP_NULL) {
+ } else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else {
smpi_mpi_allreduce(sendbuf, recvbuf, count, datatype, op, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Allreduce");
return retval;
}
-int MPI_Scan(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
+int MPI_Scan(void *sendbuf, void *recvbuf, int count,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Scan");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(datatype == MPI_DATATYPE_NULL) {
+ } else if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(op == MPI_OP_NULL) {
+ } else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
} else {
smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Scan");
return retval;
}
-int MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
+int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+{
int retval, i, size, count;
- int* displs;
+ int *displs;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Reduce_scatter");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(datatype == MPI_DATATYPE_NULL) {
+ } else if (datatype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(op == MPI_OP_NULL) {
+ } else if (op == MPI_OP_NULL) {
retval = MPI_ERR_OP;
- } else if(recvcounts == NULL) {
+ } else if (recvcounts == NULL) {
retval = MPI_ERR_ARG;
} else {
/* arbitrarily choose root as rank 0 */
size = smpi_comm_size(comm);
count = 0;
displs = xbt_new(int, size);
- for(i = 0; i < size; i++) {
+ for (i = 0; i < size; i++) {
count += recvcounts[i];
displs[i] = 0;
}
smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
- smpi_mpi_scatterv(recvbuf, recvcounts, displs, datatype, recvbuf, recvcounts[rank], datatype, 0, comm);
+ smpi_mpi_scatterv(recvbuf, recvcounts, displs, datatype, recvbuf,
+ recvcounts[rank], datatype, 0, comm);
xbt_free(displs);
retval = MPI_SUCCESS;
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Reduce_scatter");
return retval;
}
-int MPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
+int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype,
+ MPI_Comm comm)
+{
int retval, size, sendsize;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Alltoall");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
} else {
size = smpi_comm_size(comm);
sendsize = smpi_datatype_size(sendtype) * sendcount;
- if(sendsize < 200 && size > 12) {
- retval = smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
- } else if(sendsize < 3000) {
- retval = smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
+ if (sendsize < 200 && size > 12) {
+ retval =
+ smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
+ recvbuf, recvcount, recvtype,
+ comm);
+ } else if (sendsize < 3000) {
+ retval =
+ smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
+ sendtype, recvbuf,
+ recvcount, recvtype, comm);
} else {
- retval = smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
+ retval =
+ smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
+ recvbuf, recvcount, recvtype,
+ comm);
}
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Alltoall");
return retval;
}
-int MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm) {
+int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
+ MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
+ int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
+{
int retval;
int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
smpi_bench_end(rank, "Alltoallv");
#ifdef HAVE_TRACING
- TRACE_smpi_collective_in (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
#endif
- if(comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
retval = MPI_ERR_COMM;
- } else if(sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ } else if (sendtype == MPI_DATATYPE_NULL
+ || recvtype == MPI_DATATYPE_NULL) {
retval = MPI_ERR_TYPE;
- } else if(sendcounts == NULL || senddisps == NULL || recvcounts == NULL || recvdisps == NULL) {
+ } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
+ || recvdisps == NULL) {
retval = MPI_ERR_ARG;
} else {
- retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm);
+ retval =
+ smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype,
+ recvbuf, recvcounts, recvdisps, recvtype,
+ comm);
}
#ifdef HAVE_TRACING
- TRACE_smpi_collective_out (rank, -1, __FUNCTION__);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
#endif
smpi_bench_begin(rank, "Alltoallv");
return retval;
}
-int MPI_Get_processor_name(char* name, int* resultlen) {
+int MPI_Get_processor_name(char *name, int *resultlen)
+{
int retval = MPI_SUCCESS;
smpi_bench_end(-1, NULL);
- strncpy( name , SIMIX_host_get_name(SIMIX_host_self()), MPI_MAX_PROCESSOR_NAME-1);
- *resultlen= strlen(name) > MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
+ strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
+ MPI_MAX_PROCESSOR_NAME - 1);
+ *resultlen =
+ strlen(name) >
+ MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
smpi_bench_begin(-1, NULL);
return retval;
}
-int MPI_Get_count(MPI_Status* status, MPI_Datatype datatype, int* count) {
+int MPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
+{
int retval = MPI_SUCCESS;
size_t size;
} else {
size = smpi_datatype_size(datatype);
if (size == 0) {
- *count = 0;
+ *count = 0;
} else if (status->count % size != 0) {
- retval = MPI_UNDEFINED;
+ retval = MPI_UNDEFINED;
} else {
- *count = smpi_mpi_get_count(status, datatype);
+ *count = smpi_mpi_get_count(status, datatype);
}
}
smpi_bench_begin(-1, NULL);
//The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
-typedef struct { float value; int index;} float_int;
-typedef struct { long value; int index;} long_int ;
-typedef struct { double value; int index;} double_int;
-typedef struct { short value; int index;} short_int;
-typedef struct { int value; int index;} int_int;
-typedef struct { long double value; int index;} long_double_int;
+typedef struct {
+ float value;
+ int index;
+} float_int;
+typedef struct {
+ long value;
+ int index;
+} long_int;
+typedef struct {
+ double value;
+ int index;
+} double_int;
+typedef struct {
+ short value;
+ int index;
+} short_int;
+typedef struct {
+ int value;
+ int index;
+} int_int;
+typedef struct {
+ long double value;
+ int index;
+} long_double_int;
// Predefined data types
-CREATE_MPI_DATATYPE(MPI_CHAR, char);
-CREATE_MPI_DATATYPE(MPI_SHORT, short);
-CREATE_MPI_DATATYPE(MPI_INT, int);
-CREATE_MPI_DATATYPE(MPI_LONG, long);
-CREATE_MPI_DATATYPE(MPI_LONG_LONG, long long);
-CREATE_MPI_DATATYPE(MPI_SIGNED_CHAR, signed char);
-CREATE_MPI_DATATYPE(MPI_UNSIGNED_CHAR, unsigned char);
-CREATE_MPI_DATATYPE(MPI_UNSIGNED_SHORT, unsigned short);
-CREATE_MPI_DATATYPE(MPI_UNSIGNED, unsigned int);
-CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG, unsigned long);
-CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG, unsigned long long);
-CREATE_MPI_DATATYPE(MPI_FLOAT, float);
-CREATE_MPI_DATATYPE(MPI_DOUBLE, double);
-CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE, long double);
-CREATE_MPI_DATATYPE(MPI_WCHAR, wchar_t);
-CREATE_MPI_DATATYPE(MPI_C_BOOL, _Bool);
-CREATE_MPI_DATATYPE(MPI_INT8_T, int8_t);
-CREATE_MPI_DATATYPE(MPI_INT16_T, int16_t);
-CREATE_MPI_DATATYPE(MPI_INT32_T, int32_t);
-CREATE_MPI_DATATYPE(MPI_INT64_T, int64_t);
-CREATE_MPI_DATATYPE(MPI_UINT8_T, uint8_t);
-CREATE_MPI_DATATYPE(MPI_UINT16_T, uint16_t);
-CREATE_MPI_DATATYPE(MPI_UINT32_T, uint32_t);
-CREATE_MPI_DATATYPE(MPI_UINT64_T, uint64_t);
-CREATE_MPI_DATATYPE(MPI_C_FLOAT_COMPLEX, float _Complex);
-CREATE_MPI_DATATYPE(MPI_C_DOUBLE_COMPLEX, double _Complex);
+CREATE_MPI_DATATYPE(MPI_CHAR, char);
+CREATE_MPI_DATATYPE(MPI_SHORT, short);
+CREATE_MPI_DATATYPE(MPI_INT, int);
+CREATE_MPI_DATATYPE(MPI_LONG, long);
+CREATE_MPI_DATATYPE(MPI_LONG_LONG, long long);
+CREATE_MPI_DATATYPE(MPI_SIGNED_CHAR, signed char);
+CREATE_MPI_DATATYPE(MPI_UNSIGNED_CHAR, unsigned char);
+CREATE_MPI_DATATYPE(MPI_UNSIGNED_SHORT, unsigned short);
+CREATE_MPI_DATATYPE(MPI_UNSIGNED, unsigned int);
+CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG, unsigned long);
+CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG, unsigned long long);
+CREATE_MPI_DATATYPE(MPI_FLOAT, float);
+CREATE_MPI_DATATYPE(MPI_DOUBLE, double);
+CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE, long double);
+CREATE_MPI_DATATYPE(MPI_WCHAR, wchar_t);
+CREATE_MPI_DATATYPE(MPI_C_BOOL, _Bool);
+CREATE_MPI_DATATYPE(MPI_INT8_T, int8_t);
+CREATE_MPI_DATATYPE(MPI_INT16_T, int16_t);
+CREATE_MPI_DATATYPE(MPI_INT32_T, int32_t);
+CREATE_MPI_DATATYPE(MPI_INT64_T, int64_t);
+CREATE_MPI_DATATYPE(MPI_UINT8_T, uint8_t);
+CREATE_MPI_DATATYPE(MPI_UINT16_T, uint16_t);
+CREATE_MPI_DATATYPE(MPI_UINT32_T, uint32_t);
+CREATE_MPI_DATATYPE(MPI_UINT64_T, uint64_t);
+CREATE_MPI_DATATYPE(MPI_C_FLOAT_COMPLEX, float _Complex);
+CREATE_MPI_DATATYPE(MPI_C_DOUBLE_COMPLEX, double _Complex);
CREATE_MPI_DATATYPE(MPI_C_LONG_DOUBLE_COMPLEX, long double _Complex);
-CREATE_MPI_DATATYPE(MPI_AINT, MPI_Aint);
-CREATE_MPI_DATATYPE(MPI_OFFSET, MPI_Offset);
+CREATE_MPI_DATATYPE(MPI_AINT, MPI_Aint);
+CREATE_MPI_DATATYPE(MPI_OFFSET, MPI_Offset);
-CREATE_MPI_DATATYPE(MPI_FLOAT_INT, float_int);
-CREATE_MPI_DATATYPE(MPI_LONG_INT, long_int);
-CREATE_MPI_DATATYPE(MPI_DOUBLE_INT, double_int);
-CREATE_MPI_DATATYPE(MPI_SHORT_INT, short_int);
-CREATE_MPI_DATATYPE(MPI_2INT, int_int);
-CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int);
+CREATE_MPI_DATATYPE(MPI_FLOAT_INT, float_int);
+CREATE_MPI_DATATYPE(MPI_LONG_INT, long_int);
+CREATE_MPI_DATATYPE(MPI_DOUBLE_INT, double_int);
+CREATE_MPI_DATATYPE(MPI_SHORT_INT, short_int);
+CREATE_MPI_DATATYPE(MPI_2INT, int_int);
+CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int);
-size_t smpi_datatype_size(MPI_Datatype datatype) {
+size_t smpi_datatype_size(MPI_Datatype datatype)
+{
return datatype->size;
}
-MPI_Aint smpi_datatype_lb(MPI_Datatype datatype) {
+MPI_Aint smpi_datatype_lb(MPI_Datatype datatype)
+{
return datatype->lb;
}
-MPI_Aint smpi_datatype_ub(MPI_Datatype datatype) {
+MPI_Aint smpi_datatype_ub(MPI_Datatype datatype)
+{
return datatype->ub;
}
-int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint * extent) {
+int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
+ MPI_Aint * extent)
+{
int retval;
- if((datatype->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
+ if ((datatype->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
retval = MPI_ERR_TYPE;
} else {
- *lb = datatype->lb;
- *extent = datatype->ub - datatype->lb;
+ *lb = datatype->lb;
+ *extent = datatype->ub - datatype->lb;
retval = MPI_SUCCESS;
}
return MPI_SUCCESS;
}
-int smpi_datatype_copy(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype) {
+int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
+ void *recvbuf, int recvcount, MPI_Datatype recvtype)
+{
int retval, count;
/* First check if we really have something to do */
- if(recvcount == 0) {
+ if (recvcount == 0) {
retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE;
} else {
- /* FIXME: treat packed cases */
- sendcount *= smpi_datatype_size(sendtype);
- recvcount *= smpi_datatype_size(recvtype);
- count = sendcount < recvcount ? sendcount : recvcount;
- memcpy(recvbuf, sendbuf, count);
- retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
+ /* FIXME: treat packed cases */
+ sendcount *= smpi_datatype_size(sendtype);
+ recvcount *= smpi_datatype_size(recvtype);
+ count = sendcount < recvcount ? sendcount : recvcount;
+ memcpy(recvbuf, sendbuf, count);
+ retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
}
return retval;
}
typedef struct s_smpi_mpi_op {
- MPI_User_function* func;
+ MPI_User_function *func;
} s_smpi_mpi_op_t;
#define MAX_OP(a, b) (b) = (a) < (b) ? (b) : (a)
} \
}
-static void max_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void max_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, MAX_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, MAX_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, MAX_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, MAX_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, MAX_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, MAX_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, MAX_OP);
- } else if(*datatype == MPI_FLOAT) {
+ } else if (*datatype == MPI_FLOAT) {
APPLY_FUNC(a, b, length, float, MAX_OP);
- } else if(*datatype == MPI_DOUBLE) {
+ } else if (*datatype == MPI_DOUBLE) {
APPLY_FUNC(a, b, length, double, MAX_OP);
- } else if(*datatype == MPI_LONG_DOUBLE) {
+ } else if (*datatype == MPI_LONG_DOUBLE) {
APPLY_FUNC(a, b, length, long double, MAX_OP);
}
}
-static void min_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void min_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, MIN_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, MIN_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, MIN_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, MIN_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, MIN_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, MIN_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, MIN_OP);
- } else if(*datatype == MPI_FLOAT) {
+ } else if (*datatype == MPI_FLOAT) {
APPLY_FUNC(a, b, length, float, MIN_OP);
- } else if(*datatype == MPI_DOUBLE) {
+ } else if (*datatype == MPI_DOUBLE) {
APPLY_FUNC(a, b, length, double, MIN_OP);
- } else if(*datatype == MPI_LONG_DOUBLE) {
+ } else if (*datatype == MPI_LONG_DOUBLE) {
APPLY_FUNC(a, b, length, long double, MIN_OP);
}
}
-static void sum_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void sum_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, SUM_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, SUM_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, SUM_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, SUM_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, SUM_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, SUM_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, SUM_OP);
- } else if(*datatype == MPI_FLOAT) {
+ } else if (*datatype == MPI_FLOAT) {
APPLY_FUNC(a, b, length, float, SUM_OP);
- } else if(*datatype == MPI_DOUBLE) {
+ } else if (*datatype == MPI_DOUBLE) {
APPLY_FUNC(a, b, length, double, SUM_OP);
- } else if(*datatype == MPI_LONG_DOUBLE) {
+ } else if (*datatype == MPI_LONG_DOUBLE) {
APPLY_FUNC(a, b, length, long double, SUM_OP);
- } else if(*datatype == MPI_C_FLOAT_COMPLEX) {
+ } else if (*datatype == MPI_C_FLOAT_COMPLEX) {
APPLY_FUNC(a, b, length, float _Complex, SUM_OP);
- } else if(*datatype == MPI_C_DOUBLE_COMPLEX) {
+ } else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
APPLY_FUNC(a, b, length, double _Complex, SUM_OP);
- } else if(*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
+ } else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
APPLY_FUNC(a, b, length, long double _Complex, SUM_OP);
}
}
-static void prod_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void prod_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, PROD_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, PROD_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, PROD_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, PROD_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, PROD_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, PROD_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, PROD_OP);
- } else if(*datatype == MPI_FLOAT) {
+ } else if (*datatype == MPI_FLOAT) {
APPLY_FUNC(a, b, length, float, PROD_OP);
- } else if(*datatype == MPI_DOUBLE) {
+ } else if (*datatype == MPI_DOUBLE) {
APPLY_FUNC(a, b, length, double, PROD_OP);
- } else if(*datatype == MPI_LONG_DOUBLE) {
+ } else if (*datatype == MPI_LONG_DOUBLE) {
APPLY_FUNC(a, b, length, long double, PROD_OP);
- } else if(*datatype == MPI_C_FLOAT_COMPLEX) {
+ } else if (*datatype == MPI_C_FLOAT_COMPLEX) {
APPLY_FUNC(a, b, length, float _Complex, PROD_OP);
- } else if(*datatype == MPI_C_DOUBLE_COMPLEX) {
- APPLY_FUNC(a, b, length, double _Complex, PROD_OP);
- } else if(*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
+ } else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
+ APPLY_FUNC(a, b, length, double _Complex, PROD_OP);
+ } else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
APPLY_FUNC(a, b, length, long double _Complex, PROD_OP);
}
}
-static void land_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void land_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, LAND_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, LAND_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, LAND_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, LAND_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, LAND_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, LAND_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, LAND_OP);
- } else if(*datatype == MPI_C_BOOL) {
+ } else if (*datatype == MPI_C_BOOL) {
APPLY_FUNC(a, b, length, _Bool, LAND_OP);
}
}
-static void lor_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void lor_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, LOR_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, LOR_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, LOR_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, LOR_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, LOR_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, LOR_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, LOR_OP);
- } else if(*datatype == MPI_C_BOOL) {
+ } else if (*datatype == MPI_C_BOOL) {
APPLY_FUNC(a, b, length, _Bool, LOR_OP);
}
}
-static void lxor_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void lxor_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, LXOR_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, LXOR_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, LXOR_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, LXOR_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, LXOR_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, LXOR_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, LXOR_OP);
- } else if(*datatype == MPI_C_BOOL) {
+ } else if (*datatype == MPI_C_BOOL) {
APPLY_FUNC(a, b, length, _Bool, LXOR_OP);
}
}
-static void band_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void band_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, BAND_OP);
- } if(*datatype == MPI_SHORT) {
+ }
+ if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, BAND_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, BAND_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, BAND_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, BAND_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, BAND_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, BAND_OP);
- } else if(*datatype == MPI_BYTE) {
+ } else if (*datatype == MPI_BYTE) {
APPLY_FUNC(a, b, length, uint8_t, BAND_OP);
}
}
-static void bor_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void bor_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, BOR_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, BOR_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, BOR_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, BOR_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, BOR_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, BOR_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, BOR_OP);
- } else if(*datatype == MPI_BYTE) {
+ } else if (*datatype == MPI_BYTE) {
APPLY_FUNC(a, b, length, uint8_t, BOR_OP);
}
}
-static void bxor_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_CHAR) {
+static void bxor_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
APPLY_FUNC(a, b, length, char, BXOR_OP);
- } else if(*datatype == MPI_SHORT) {
+ } else if (*datatype == MPI_SHORT) {
APPLY_FUNC(a, b, length, short, BXOR_OP);
- } else if(*datatype == MPI_INT) {
+ } else if (*datatype == MPI_INT) {
APPLY_FUNC(a, b, length, int, BXOR_OP);
- } else if(*datatype == MPI_LONG) {
+ } else if (*datatype == MPI_LONG) {
APPLY_FUNC(a, b, length, long, BXOR_OP);
- } else if(*datatype == MPI_UNSIGNED_SHORT) {
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
APPLY_FUNC(a, b, length, unsigned short, BXOR_OP);
- } else if(*datatype == MPI_UNSIGNED) {
+ } else if (*datatype == MPI_UNSIGNED) {
APPLY_FUNC(a, b, length, unsigned int, BXOR_OP);
- } else if(*datatype == MPI_UNSIGNED_LONG) {
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
APPLY_FUNC(a, b, length, unsigned long, BXOR_OP);
- } else if(*datatype == MPI_BYTE) {
+ } else if (*datatype == MPI_BYTE) {
APPLY_FUNC(a, b, length, uint8_t, BXOR_OP);
}
}
-static void minloc_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_FLOAT_INT) {
+static void minloc_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_FLOAT_INT) {
APPLY_FUNC(a, b, length, float_int, MINLOC_OP);
- } else if(*datatype == MPI_LONG_INT) {
+ } else if (*datatype == MPI_LONG_INT) {
APPLY_FUNC(a, b, length, long_int, MINLOC_OP);
- } else if(*datatype == MPI_DOUBLE_INT) {
+ } else if (*datatype == MPI_DOUBLE_INT) {
APPLY_FUNC(a, b, length, double_int, MINLOC_OP);
- } else if(*datatype == MPI_SHORT_INT) {
+ } else if (*datatype == MPI_SHORT_INT) {
APPLY_FUNC(a, b, length, short_int, MINLOC_OP);
- } else if(*datatype == MPI_2INT) {
+ } else if (*datatype == MPI_2INT) {
APPLY_FUNC(a, b, length, int_int, MINLOC_OP);
- } else if(*datatype == MPI_LONG_DOUBLE_INT) {
+ } else if (*datatype == MPI_LONG_DOUBLE_INT) {
APPLY_FUNC(a, b, length, long_double_int, MINLOC_OP);
}
}
-static void maxloc_func(void* a, void* b, int* length, MPI_Datatype* datatype) {
- if(*datatype == MPI_FLOAT_INT) {
+static void maxloc_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_FLOAT_INT) {
APPLY_FUNC(a, b, length, float_int, MAXLOC_OP);
- } else if(*datatype == MPI_LONG_INT) {
+ } else if (*datatype == MPI_LONG_INT) {
APPLY_FUNC(a, b, length, long_int, MAXLOC_OP);
- } else if(*datatype == MPI_DOUBLE_INT) {
+ } else if (*datatype == MPI_DOUBLE_INT) {
APPLY_FUNC(a, b, length, double_int, MAXLOC_OP);
- } else if(*datatype == MPI_SHORT_INT) {
+ } else if (*datatype == MPI_SHORT_INT) {
APPLY_FUNC(a, b, length, short_int, MAXLOC_OP);
- } else if(*datatype == MPI_2INT) {
+ } else if (*datatype == MPI_2INT) {
APPLY_FUNC(a, b, length, int_int, MAXLOC_OP);
- } else if(*datatype == MPI_LONG_DOUBLE_INT) {
+ } else if (*datatype == MPI_LONG_DOUBLE_INT) {
APPLY_FUNC(a, b, length, long_double_int, MAXLOC_OP);
}
}
static s_smpi_mpi_op_t mpi_##name = { &(func) /* func */ }; \
MPI_Op name = &mpi_##name;
-CREATE_MPI_OP(MPI_MAX, max_func);
-CREATE_MPI_OP(MPI_MIN, min_func);
-CREATE_MPI_OP(MPI_SUM, sum_func);
-CREATE_MPI_OP(MPI_PROD, prod_func);
-CREATE_MPI_OP(MPI_LAND, land_func);
-CREATE_MPI_OP(MPI_LOR, lor_func);
-CREATE_MPI_OP(MPI_LXOR, lxor_func);
-CREATE_MPI_OP(MPI_BAND, band_func);
-CREATE_MPI_OP(MPI_BOR, bor_func);
-CREATE_MPI_OP(MPI_BXOR, bxor_func);
-CREATE_MPI_OP(MPI_MAXLOC, maxloc_func);
-CREATE_MPI_OP(MPI_MINLOC, minloc_func);
-
-MPI_Op smpi_op_new(MPI_User_function* function, int commute) {
+CREATE_MPI_OP(MPI_MAX, max_func);
+CREATE_MPI_OP(MPI_MIN, min_func);
+CREATE_MPI_OP(MPI_SUM, sum_func);
+CREATE_MPI_OP(MPI_PROD, prod_func);
+CREATE_MPI_OP(MPI_LAND, land_func);
+CREATE_MPI_OP(MPI_LOR, lor_func);
+CREATE_MPI_OP(MPI_LXOR, lxor_func);
+CREATE_MPI_OP(MPI_BAND, band_func);
+CREATE_MPI_OP(MPI_BOR, bor_func);
+CREATE_MPI_OP(MPI_BXOR, bxor_func);
+CREATE_MPI_OP(MPI_MAXLOC, maxloc_func);
+CREATE_MPI_OP(MPI_MINLOC, minloc_func);
+
+MPI_Op smpi_op_new(MPI_User_function * function, int commute)
+{
MPI_Op op;
//FIXME: add commute param
return op;
}
-void smpi_op_destroy(MPI_Op op) {
+void smpi_op_destroy(MPI_Op op)
+{
xbt_free(op);
}
-void smpi_op_apply(MPI_Op op, void* invec, void* inoutvec, int* len, MPI_Datatype* datatype) {
+void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
+ MPI_Datatype * datatype)
+{
op->func(invec, inoutvec, len, datatype);
}
#include "surf_private.h"
typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t,
- *surf_action_cpu_Cas01_t;
+ *surf_action_cpu_Cas01_t;
typedef struct cpu_Cas01 {
s_surf_resource_t generic_resource;
lmm_system_t cpu_maxmin_system = NULL;
-static xbt_swag_t cpu_running_action_set_that_does_not_need_being_checked = NULL;
+static xbt_swag_t cpu_running_action_set_that_does_not_need_being_checked =
+ NULL;
static cpu_Cas01_t cpu_new(char *name, double power_peak,
double power_scale,
{
cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
- "Host '%s' declared several times in the platform file", name);
+ "Host '%s' declared several times in the platform file",
+ name);
cpu->generic_resource.model = surf_cpu_model;
cpu->generic_resource.name = name;
cpu->generic_resource.properties = cpu_properties;
cpu->power_scale = power_scale;
if (power_trace)
cpu->power_event =
- tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
cpu->state_current = state_initial;
if (state_trace)
cpu->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
cpu->constraint =
- lmm_constraint_new(cpu_maxmin_system, cpu,
- cpu->power_scale * cpu->power_peak);
+ lmm_constraint_new(cpu_maxmin_system, cpu,
+ cpu->power_scale * cpu->power_peak);
xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
surf_resource_free);
#ifdef HAVE_TRACING
- TRACE_surf_host_declaration (name, cpu->power_scale * cpu->power_peak);
+ TRACE_surf_host_declaration(name, cpu->power_scale * cpu->power_peak);
#endif
return cpu;
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->state_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->power_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
}
lmm_variable_free(cpu_maxmin_system,
((surf_action_cpu_Cas01_t) action)->variable);
#ifdef HAVE_TRACING
- if (action->category) xbt_free (action->category);
+ if (action->category)
+ xbt_free(action->category);
#endif
free(action);
return 1;
xbt_swag_foreach_safe(action, next_action, running_actions) {
#ifdef HAVE_TRACING
- cpu_Cas01_t x = lmm_constraint_id(lmm_get_cnst_from_var (cpu_maxmin_system, action->variable, 0));
-
- TRACE_surf_host_set_utilization (x->generic_resource.name,
- action->generic_action.data, (surf_action_t)action, lmm_variable_getvalue(action->variable), now-delta, delta);
+ cpu_Cas01_t x =
+ lmm_constraint_id(lmm_get_cnst_from_var
+ (cpu_maxmin_system, action->variable, 0));
+
+ TRACE_surf_host_set_utilization(x->generic_resource.name,
+ action->generic_action.data,
+ (surf_action_t) action,
+ lmm_variable_getvalue
+ (action->variable), now - delta,
+ delta);
#endif
double_update(&(action->generic_action.remains),
lmm_variable_getvalue(action->variable) * delta);
}
static void cpu_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
cpu_Cas01_t cpu = id;
lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint,
cpu->power_scale * cpu->power_peak);
#ifdef HAVE_TRACING
- TRACE_surf_host_set_power (date, cpu->generic_resource.name, cpu->power_scale * cpu->power_peak);
+ TRACE_surf_host_set_power(date, cpu->generic_resource.name,
+ cpu->power_scale * cpu->power_peak);
#endif
if (tmgr_trace_event_free(event_type))
cpu->power_event = NULL;
if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
surf_action_state_get(action) == SURF_ACTION_READY ||
- surf_action_state_get(action) == SURF_ACTION_NOT_IN_THE_SYSTEM) {
+ surf_action_state_get(action) ==
+ SURF_ACTION_NOT_IN_THE_SYSTEM) {
action->finish = date;
cpu_action_state_set(action, SURF_ACTION_FAILED);
}
XBT_IN2("(%s,%g)", surf_resource_name(CPU), size);
action =
- surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size, surf_cpu_model,
- CPU->state_current != SURF_RESOURCE_ON);
+ surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size,
+ surf_cpu_model,
+ CPU->state_current != SURF_RESOURCE_ON);
action->suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
is used to speed up update_resource_state */
xbt_swag_remove(action, ((surf_action_t) action)->state_set);
((surf_action_t) action)->state_set =
- cpu_running_action_set_that_does_not_need_being_checked;
+ cpu_running_action_set_that_does_not_need_being_checked;
xbt_swag_insert(action, ((surf_action_t) action)->state_set);
}
XBT_IN1("(%p)", action);
if (((surf_action_cpu_Cas01_t) action)->suspended != 2) {
lmm_update_variable_weight(cpu_maxmin_system,
- ((surf_action_cpu_Cas01_t) action)->variable,
- 0.0);
+ ((surf_action_cpu_Cas01_t)
+ action)->variable, 0.0);
((surf_action_cpu_Cas01_t) action)->suspended = 1;
}
XBT_OUT;
XBT_IN1("(%p)", action);
if (((surf_action_cpu_Cas01_t) action)->suspended != 2) {
lmm_update_variable_weight(cpu_maxmin_system,
- ((surf_action_cpu_Cas01_t) action)->variable,
- action->priority);
+ ((surf_action_cpu_Cas01_t)
+ action)->variable, action->priority);
((surf_action_cpu_Cas01_t) action)->suspended = 0;
}
XBT_OUT;
return (((surf_action_cpu_Cas01_t) action)->suspended == 1);
}
-static void cpu_action_set_max_duration(surf_action_t action, double duration)
+static void cpu_action_set_max_duration(surf_action_t action,
+ double duration)
{
XBT_IN2("(%p,%g)", action, duration);
action->max_duration = duration;
}
static void cpu_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- cpu_new(name,power_peak,power_scale,power_trace,
- state_initial,state_trace,cpu_properties);
+ cpu_new(name, power_peak, power_scale, power_trace,
+ state_initial, state_trace, cpu_properties);
}
static void cpu_finalize(void)
surf_cpu_model = surf_model_init();
cpu_running_action_set_that_does_not_need_being_checked =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
surf_cpu_model->name = "CPU";
surf_cpu_model->model_private->resource_used = cpu_resource_used;
surf_cpu_model->model_private->share_resources = cpu_share_resources;
- surf_cpu_model->model_private->update_actions_state = cpu_update_actions_state;
+ surf_cpu_model->model_private->update_actions_state =
+ cpu_update_actions_state;
surf_cpu_model->model_private->update_resource_state =
- cpu_update_resource_state;
+ cpu_update_resource_state;
surf_cpu_model->model_private->finalize = cpu_finalize;
surf_cpu_model->suspend = cpu_action_suspend;
surf_cpu_model->extension.cpu.get_state = cpu_get_state;
surf_cpu_model->extension.cpu.get_speed = cpu_get_speed;
- surf_cpu_model->extension.cpu.get_available_speed = cpu_get_available_speed;
+ surf_cpu_model->extension.cpu.get_available_speed =
+ cpu_get_available_speed;
surf_cpu_model->extension.cpu.create_resource = cpu_create_resource;
surf_cpu_model->extension.cpu.add_traces = add_traces_cpu;
extern int sg_maxmin_selective_update;
-static xbt_swag_t cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
+static xbt_swag_t
+ cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
cpu_Cas01_im_t cpu = NULL;
s_surf_action_cpu_Cas01_im_t action;
cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
- #ifdef HAVE_TRACING
- TRACE_surf_host_declaration (name, power_scale * power_peak);
- #endif
+#ifdef HAVE_TRACING
+ TRACE_surf_host_declaration(name, power_scale * power_peak);
+#endif
xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
- "Host '%s' declared several times in the platform file", name);
+ "Host '%s' declared several times in the platform file",
+ name);
cpu->generic_resource.model = surf_cpu_model;
cpu->generic_resource.name = name;
cpu->generic_resource.properties = cpu_properties;
cpu->power_scale = power_scale;
if (power_trace)
cpu->power_event =
- tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
cpu->state_current = state_initial;
if (state_trace)
cpu->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
cpu->constraint =
- lmm_constraint_new(cpu_im_maxmin_system, cpu,
- cpu->power_scale * cpu->power_peak);
+ lmm_constraint_new(cpu_im_maxmin_system, cpu,
+ cpu->power_scale * cpu->power_peak);
xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
surf_resource_free);
current_property_set = xbt_dict_new();
cpu_im_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->state_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->power_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
}
surf_parse_reset_parser();
surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_im_init);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &cpu_im_add_traces_cpu);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list,
+ &cpu_im_add_traces_cpu);
}
static int cpu_im_resource_used(void *resource_id)
((cpu_Cas01_im_t) ACTION_GET_CPU(action))->action_set);
xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
#ifdef HAVE_TRACING
- if (action->category) xbt_free (action->category);
+ if (action->category)
+ xbt_free(action->category);
#endif
free(action);
return 1;
}
static void cpu_im_cpu_action_state_set(surf_action_t action,
- e_surf_action_state_t state)
+ e_surf_action_state_t state)
{
/* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
/* if(((surf_action_lmm_t)action)->variable) { */
(action).variable) * (now -
cpu->last_update));
#ifdef HAVE_TRACING
- TRACE_surf_host_set_utilization (cpu->generic_resource.name,
- action->generic_lmm_action.generic_action.data, (surf_action_t)action, lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), cpu->last_update, now-cpu->last_update);
+ TRACE_surf_host_set_utilization(cpu->generic_resource.name,
+ action->
+ generic_lmm_action.generic_action.
+ data, (surf_action_t) action,
+ lmm_variable_getvalue
+ (GENERIC_LMM_ACTION
+ (action).variable),
+ cpu->last_update,
+ now - cpu->last_update);
#endif
DEBUG2("Update action(%p) remains %lf", action,
GENERIC_ACTION(action).remains);
cpu_Cas01_im_t cpu, cpu_next;
xbt_swag_foreach(cpu, cpu_im_modified_cpu)
- cpu_im_update_remains(cpu, now);
+ cpu_im_update_remains(cpu, now);
lmm_solve(cpu_im_maxmin_system);
|| GENERIC_ACTION(action).start +
GENERIC_ACTION(action).max_duration < min))
min =
- GENERIC_ACTION(action).start + GENERIC_ACTION(action).max_duration;
+ GENERIC_ACTION(action).start +
+ GENERIC_ACTION(action).max_duration;
DEBUG4("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
GENERIC_ACTION(action).start, now + value,
if (action->index_heap >= 0) {
surf_action_cpu_Cas01_im_t heap_act =
- xbt_heap_remove(cpu_im_action_heap, action->index_heap);
+ xbt_heap_remove(cpu_im_action_heap, action->index_heap);
if (heap_act != action)
DIE_IMPOSSIBLE;
}
xbt_swag_remove(cpu, cpu_im_modified_cpu);
}
return xbt_heap_size(cpu_im_action_heap) >
- 0 ? xbt_heap_maxkey(cpu_im_action_heap) - now : -1;
+ 0 ? xbt_heap_maxkey(cpu_im_action_heap) - now : -1;
}
static void cpu_im_update_actions_state(double now, double delta)
GENERIC_ACTION(action).finish = surf_get_clock();
/* set the remains to 0 due to precision problems when updating the remaining amount */
#ifdef HAVE_TRACING
- TRACE_surf_host_set_utilization (((cpu_Cas01_im_t)(action->cpu))->generic_resource.name,
- action->generic_lmm_action.generic_action.data, (surf_action_t)action, lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), ((cpu_Cas01_im_t)(action->cpu))->last_update, now-((cpu_Cas01_im_t)(action->cpu))->last_update);
+ TRACE_surf_host_set_utilization(((cpu_Cas01_im_t)
+ (action->cpu))->generic_resource.name,
+ action->
+ generic_lmm_action.generic_action.data,
+ (surf_action_t) action,
+ lmm_variable_getvalue
+ (GENERIC_LMM_ACTION(action).variable),
+ ((cpu_Cas01_im_t)
+ (action->cpu))->last_update,
+ now -
+ ((cpu_Cas01_im_t)
+ (action->cpu))->last_update);
#endif
GENERIC_ACTION(action).remains = 0;
cpu_im_cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
}
static void cpu_im_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
cpu_Cas01_im_t cpu = id;
if (event_type == cpu->power_event) {
lmm_update_constraint_bound(cpu_im_maxmin_system, cpu->constraint,
cpu->power_scale * cpu->power_peak);
#ifdef HAVE_TRACING
- TRACE_surf_host_set_power (date, cpu->generic_resource.name, cpu->power_scale * cpu->power_peak);
+ TRACE_surf_host_set_power(date, cpu->generic_resource.name,
+ cpu->power_scale * cpu->power_peak);
#endif
xbt_swag_insert(cpu, cpu_im_modified_cpu);
if (tmgr_trace_event_free(event_type))
cpu->state_current = SURF_RESOURCE_OFF;
- while ((var = lmm_get_var_from_cnst(cpu_im_maxmin_system, cnst, &elem))) {
+ while ((var =
+ lmm_get_var_from_cnst(cpu_im_maxmin_system, cnst, &elem))) {
surf_action_t action = lmm_variable_id(var);
if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
surf_action_state_get(action) == SURF_ACTION_READY ||
- surf_action_state_get(action) == SURF_ACTION_NOT_IN_THE_SYSTEM) {
+ surf_action_state_get(action) ==
+ SURF_ACTION_NOT_IN_THE_SYSTEM) {
action->finish = date;
cpu_im_cpu_action_state_set(action, SURF_ACTION_FAILED);
}
XBT_IN2("(%s,%g)", surf_resource_name(CPU), size);
action =
- surf_action_new(sizeof(s_surf_action_cpu_Cas01_im_t), size,
- surf_cpu_model, CPU->state_current != SURF_RESOURCE_ON);
+ surf_action_new(sizeof(s_surf_action_cpu_Cas01_im_t), size,
+ surf_cpu_model,
+ CPU->state_current != SURF_RESOURCE_ON);
GENERIC_LMM_ACTION(action).suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
GENERIC_LMM_ACTION(action).variable =
- lmm_variable_new(cpu_im_maxmin_system, action,
- GENERIC_ACTION(action).priority, -1.0, 1);
+ lmm_variable_new(cpu_im_maxmin_system, action,
+ GENERIC_ACTION(action).priority, -1.0, 1);
action->index_heap = -1;
action->cpu = CPU;
xbt_swag_insert(CPU, cpu_im_modified_cpu);
is used to speed up update_resource_state */
xbt_swag_remove(action, ((surf_action_t) action)->state_set);
((surf_action_t) action)->state_set =
- cpu_im_running_action_set_that_does_not_need_being_checked;
+ cpu_im_running_action_set_that_does_not_need_being_checked;
xbt_swag_insert(action, ((surf_action_t) action)->state_set);
}
XBT_IN1("(%p)", action);
if (((surf_action_lmm_t) action)->suspended != 2) {
lmm_update_variable_weight(cpu_im_maxmin_system,
- ((surf_action_lmm_t) action)->variable, 0.0);
+ ((surf_action_lmm_t) action)->variable,
+ 0.0);
((surf_action_lmm_t) action)->suspended = 1;
xbt_heap_remove(cpu_im_action_heap,
((surf_action_cpu_Cas01_im_t) action)->index_heap);
return (((surf_action_lmm_t) action)->suspended == 1);
}
-static void cpu_im_action_set_max_duration(surf_action_t action, double duration)
+static void cpu_im_action_set_max_duration(surf_action_t action,
+ double duration)
{
XBT_IN2("(%p,%g)", action, duration);
XBT_OUT;
}
-static void cpu_im_action_set_priority(surf_action_t action, double priority)
+static void cpu_im_action_set_priority(surf_action_t action,
+ double priority)
{
XBT_IN2("(%p,%g)", action, priority);
action->priority = priority;
{
((surf_action_cpu_Cas01_im_t) action)->index_heap = i;
}
+
static void cpu_im_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- cpu_im_new(name,power_peak,power_scale,power_trace,
- state_initial,state_trace,cpu_properties);
+ cpu_im_new(name, power_peak, power_scale, power_trace,
+ state_initial, state_trace, cpu_properties);
}
static void cpu_im_finalize(void)
void *cpu;
xbt_dict_cursor_t cursor;
char *key;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key, cpu) {
+ xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
+ cpu) {
cpu_Cas01_im_t CPU = cpu;
xbt_swag_free(CPU->action_set);
}
surf_model_exit(surf_cpu_model);
surf_cpu_model = NULL;
- xbt_swag_free(cpu_im_running_action_set_that_does_not_need_being_checked);
+ xbt_swag_free
+ (cpu_im_running_action_set_that_does_not_need_being_checked);
cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
xbt_heap_free(cpu_im_action_heap);
xbt_swag_free(cpu_im_modified_cpu);
surf_cpu_model = surf_model_init();
cpu_im_running_action_set_that_does_not_need_being_checked =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
surf_cpu_model->name = "CPU_IM";
surf_cpu_model->model_private->resource_used = cpu_im_resource_used;
surf_cpu_model->model_private->share_resources = cpu_im_share_resources;
- surf_cpu_model->model_private->update_actions_state = cpu_im_update_actions_state;
+ surf_cpu_model->model_private->update_actions_state =
+ cpu_im_update_actions_state;
surf_cpu_model->model_private->update_resource_state =
- cpu_im_update_resource_state;
+ cpu_im_update_resource_state;
surf_cpu_model->model_private->finalize = cpu_im_finalize;
surf_cpu_model->suspend = cpu_im_action_suspend;
surf_cpu_model->extension.cpu.get_state = cpu_im_get_state;
surf_cpu_model->extension.cpu.get_speed = cpu_im_get_speed;
- surf_cpu_model->extension.cpu.get_available_speed = cpu_im_get_available_speed;
+ surf_cpu_model->extension.cpu.get_available_speed =
+ cpu_im_get_available_speed;
surf_cpu_model->extension.cpu.create_resource = cpu_im_create_resource;
surf_cpu_model->extension.cpu.add_traces = cpu_im_add_traces_cpu;
cpu_im_maxmin_system = lmm_system_new();
}
cpu_im_action_heap = xbt_heap_new(8, NULL);
- xbt_heap_set_update_callback(cpu_im_action_heap, cpu_im_action_update_index_heap);
- cpu_im_modified_cpu = xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
+ xbt_heap_set_update_callback(cpu_im_action_heap,
+ cpu_im_action_update_index_heap);
+ cpu_im_modified_cpu =
+ xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
}
/*********************************************************************/
"Logging specific to the SURF CPU TRACE INTEGRATION module");
-static xbt_swag_t cpu_ti_running_action_set_that_does_not_need_being_checked = NULL;
+static xbt_swag_t
+ cpu_ti_running_action_set_that_does_not_need_being_checked = NULL;
static xbt_swag_t cpu_ti_modified_cpu = NULL;
static xbt_heap_t cpu_ti_action_heap;
/* prototypes of new trace functions */
-static double surf_cpu_ti_integrate_trace(surf_cpu_ti_tgmr_t trace, double a,
- double b);
+static double surf_cpu_ti_integrate_trace(surf_cpu_ti_tgmr_t trace,
+ double a, double b);
static double surf_cpu_ti_solve_trace(surf_cpu_ti_tgmr_t trace, double a,
- double amount);
-static double surf_cpu_ti_solve_trace_somewhat_simple(surf_cpu_ti_tgmr_t trace,
- double a, double amount);
+ double amount);
+static double surf_cpu_ti_solve_trace_somewhat_simple(surf_cpu_ti_tgmr_t
+ trace, double a,
+ double amount);
static void surf_cpu_ti_free_tmgr(surf_cpu_ti_tgmr_t trace);
static double surf_cpu_ti_integrate_trace_simple(surf_cpu_ti_trace_t trace,
- double a, double b);
-static double surf_cpu_ti_integrate_trace_simple_point(surf_cpu_ti_trace_t trace,
- double a);
-static double surf_cpu_ti_solve_trace_simple(surf_cpu_ti_trace_t trace, double a,
- double amount);
-static int surf_cpu_ti_binary_search(double *array, double a, int low, int high);
+ double a, double b);
+static double surf_cpu_ti_integrate_trace_simple_point(surf_cpu_ti_trace_t
+ trace, double a);
+static double surf_cpu_ti_solve_trace_simple(surf_cpu_ti_trace_t trace,
+ double a, double amount);
+static int surf_cpu_ti_binary_search(double *array, double a, int low,
+ int high);
/* end prototypes */
static void surf_cpu_ti_free_trace(surf_cpu_ti_trace_t trace)
int i = 0;
trace = xbt_new0(s_surf_cpu_ti_trace_t, 1);
trace->time_points =
- xbt_malloc0(sizeof(double) *
- (xbt_dynar_length(power_trace->event_list) + 1));
+ xbt_malloc0(sizeof(double) *
+ (xbt_dynar_length(power_trace->event_list) + 1));
trace->integral =
- xbt_malloc0(sizeof(double) *
- (xbt_dynar_length(power_trace->event_list) + 1));
+ xbt_malloc0(sizeof(double) *
+ (xbt_dynar_length(power_trace->event_list) + 1));
trace->nb_points = xbt_dynar_length(power_trace->event_list);
xbt_dynar_foreach(power_trace->event_list, cpt, val) {
trace->time_points[i] = time;
}
trace->trace = surf_cpu_ti_trace_new(power_trace);
trace->last_time = total_time;
- trace->total = surf_cpu_ti_integrate_trace_simple(trace->trace, 0, total_time);
+ trace->total =
+ surf_cpu_ti_integrate_trace_simple(trace->trace, 0, total_time);
DEBUG2("Total integral %lf, last_time %lf ",
trace->total, trace->last_time);
static cpu_ti_t cpu_ti_new(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace, xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
tmgr_trace_t empty_trace;
s_tmgr_event_t val;
cpu_ti_t cpu = xbt_new0(s_cpu_ti_t, 1);
s_surf_action_cpu_ti_t ti_action;
xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
- "Host '%s' declared several times in the platform file", name);
- cpu->action_set = xbt_swag_new(xbt_swag_offset(ti_action, cpu_list_hookup));
+ "Host '%s' declared several times in the platform file",
+ name);
+ cpu->action_set =
+ xbt_swag_new(xbt_swag_offset(ti_action, cpu_list_hookup));
cpu->generic_resource.model = surf_cpu_model;
cpu->generic_resource.name = name;
cpu->generic_resource.properties = cpu_properties;
cpu->state_current = state_initial;
if (state_trace)
cpu->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
if (power_trace && xbt_dynar_length(power_trace->event_list) > 1) {
/* add a fake trace event if periodicity == 0 */
xbt_dynar_get_cpy(power_trace->event_list,
if (val.delta == 0) {
empty_trace = tmgr_empty_trace_new();
cpu->power_event =
- tmgr_history_add_trace(history, empty_trace,
- cpu->avail_trace->last_time, 0, cpu);
+ tmgr_history_add_trace(history, empty_trace,
+ cpu->avail_trace->last_time, 0, cpu);
}
}
xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
current_property_set = xbt_dict_new();
cpu_ti_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
- power_trace, state_initial, state_trace, current_property_set);
+ power_trace, state_initial, state_trace,
+ current_property_set);
}
xbt_assert1(trace, "Trace %s undefined", trace_name);
if (cpu->state_event) {
- DEBUG1("Trace already configured for this CPU(%s), ignoring it", elm);
+ DEBUG1("Trace already configured for this CPU(%s), ignoring it",
+ elm);
continue;
}
DEBUG2("Add state trace: %s to CPU(%s)", trace_name, elm);
tmgr_trace_t empty_trace;
empty_trace = tmgr_empty_trace_new();
cpu->power_event =
- tmgr_history_add_trace(history, empty_trace,
- cpu->avail_trace->last_time, 0, cpu);
+ tmgr_history_add_trace(history, empty_trace,
+ cpu->avail_trace->last_time, 0, cpu);
}
}
}
/* remove from action_set */
xbt_swag_remove(action, ACTION_GET_CPU(action)->action_set);
/* remove from heap */
- xbt_heap_remove(cpu_ti_action_heap, ((surf_action_cpu_ti_t) action)->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap,
+ ((surf_action_cpu_ti_t) action)->index_heap);
xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
free(action);
return 1;
static void cpu_ti_action_cancel(surf_action_t action)
{
surf_action_state_set(action, SURF_ACTION_FAILED);
- xbt_heap_remove(cpu_ti_action_heap, ((surf_action_cpu_ti_t) action)->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap,
+ ((surf_action_cpu_ti_t) action)->index_heap);
xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
return;
}
static void cpu_ti_action_state_set(surf_action_t action,
- e_surf_action_state_t state)
+ e_surf_action_state_t state)
{
surf_action_state_set(action, state);
xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
/* calcule the surface */
area_total =
- surf_cpu_ti_integrate_trace(cpu->avail_trace, cpu->last_update,
- now) * cpu->power_peak;
- DEBUG2("Flops total: %lf, Last update %lf", area_total, cpu->last_update);
+ surf_cpu_ti_integrate_trace(cpu->avail_trace, cpu->last_update,
+ now) * cpu->power_peak;
+ DEBUG2("Flops total: %lf, Last update %lf", area_total,
+ cpu->last_update);
xbt_swag_foreach(action, cpu->action_set) {
/* action not running, skip it */
if (action->suspended == 0 && GENERIC_ACTION(action).priority > 0) {
/* total area needed to finish the action. Used in trace integration */
total_area =
- (GENERIC_ACTION(action).remains) * sum_priority *
- GENERIC_ACTION(action).priority;
+ (GENERIC_ACTION(action).remains) * sum_priority *
+ GENERIC_ACTION(action).priority;
total_area /= cpu->power_peak;
GENERIC_ACTION(action).finish =
- surf_cpu_ti_solve_trace(cpu->avail_trace, now, total_area);
+ surf_cpu_ti_solve_trace(cpu->avail_trace, now, total_area);
/* verify which event will happen before (max_duration or finish time) */
if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
(GENERIC_ACTION(action).start +
GENERIC_ACTION(action).max_duration <
GENERIC_ACTION(action).finish))
min_finish = GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration;
+ GENERIC_ACTION(action).max_duration;
else
min_finish = GENERIC_ACTION(action).finish;
} else {
/* put the max duration time on heap */
if (GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
min_finish =
- (GENERIC_ACTION(action).start +
- GENERIC_ACTION(action).max_duration);
+ (GENERIC_ACTION(action).start +
+ GENERIC_ACTION(action).max_duration);
}
/* add in action heap */
DEBUG2("action(%p) index %d", action, action->index_heap);
if (action->index_heap >= 0) {
surf_action_cpu_ti_t heap_act =
- xbt_heap_remove(cpu_ti_action_heap, action->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap, action->index_heap);
if (heap_act != action)
DIE_IMPOSSIBLE;
}
xbt_heap_push(cpu_ti_action_heap, action, min_finish);
DEBUG5
- ("Update finish time: Cpu(%s) Action: %p, Start Time: %lf Finish Time: %lf Max duration %lf",
- cpu->generic_resource.name, action, GENERIC_ACTION(action).start,
- GENERIC_ACTION(action).finish, GENERIC_ACTION(action).max_duration);
+ ("Update finish time: Cpu(%s) Action: %p, Start Time: %lf Finish Time: %lf Max duration %lf",
+ cpu->generic_resource.name, action, GENERIC_ACTION(action).start,
+ GENERIC_ACTION(action).finish,
+ GENERIC_ACTION(action).max_duration);
}
/* remove from modified cpu */
xbt_swag_remove(cpu, cpu_ti_modified_cpu);
}
static void cpu_ti_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
cpu_ti_t cpu = id;
surf_action_cpu_ti_t action;
|| surf_action_state_get((surf_action_t) action) ==
SURF_ACTION_NOT_IN_THE_SYSTEM) {
action->generic_action.finish = date;
- cpu_ti_action_state_set((surf_action_t) action, SURF_ACTION_FAILED);
+ cpu_ti_action_state_set((surf_action_t) action,
+ SURF_ACTION_FAILED);
if (action->index_heap >= 0) {
surf_action_cpu_ti_t heap_act =
- xbt_heap_remove(cpu_ti_action_heap, action->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap, action->index_heap);
if (heap_act != action)
DIE_IMPOSSIBLE;
}
XBT_IN2("(%s,%g)", surf_resource_name(CPU), size);
action =
- surf_action_new(sizeof(s_surf_action_cpu_ti_t), size, surf_cpu_model,
- CPU->state_current != SURF_RESOURCE_ON);
+ surf_action_new(sizeof(s_surf_action_cpu_ti_t), size, surf_cpu_model,
+ CPU->state_current != SURF_RESOURCE_ON);
action->cpu = cpu;
action->index_heap = -1;
is used to speed up update_resource_state */
xbt_swag_remove(action, ((surf_action_t) action)->state_set);
((surf_action_t) action)->state_set =
- cpu_ti_running_action_set_that_does_not_need_being_checked;
+ cpu_ti_running_action_set_that_does_not_need_being_checked;
xbt_swag_insert(action, ((surf_action_t) action)->state_set);
}
XBT_OUT;
XBT_IN1("(%p)", action);
if (((surf_action_cpu_ti_t) action)->suspended != 2) {
((surf_action_cpu_ti_t) action)->suspended = 1;
- xbt_heap_remove(cpu_ti_action_heap, ((surf_action_cpu_ti_t) action)->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap,
+ ((surf_action_cpu_ti_t) action)->index_heap);
xbt_swag_insert(ACTION_GET_CPU(action), cpu_ti_modified_cpu);
}
XBT_OUT;
return (((surf_action_cpu_ti_t) action)->suspended == 1);
}
-static void cpu_ti_action_set_max_duration(surf_action_t action, double duration)
+static void cpu_ti_action_set_max_duration(surf_action_t action,
+ double duration)
{
surf_action_cpu_ti_t ACT = (surf_action_cpu_ti_t) action;
double min_finish;
if (duration >= 0)
min_finish =
- (action->start + action->max_duration) <
- action->finish ? (action->start +
- action->max_duration) : action->finish;
+ (action->start + action->max_duration) <
+ action->finish ? (action->start +
+ action->max_duration) : action->finish;
else
min_finish = action->finish;
/* add in action heap */
if (ACT->index_heap >= 0) {
surf_action_cpu_ti_t heap_act =
- xbt_heap_remove(cpu_ti_action_heap, ACT->index_heap);
+ xbt_heap_remove(cpu_ti_action_heap, ACT->index_heap);
if (heap_act != ACT)
DIE_IMPOSSIBLE;
}
XBT_OUT;
}
-static void cpu_ti_action_set_priority(surf_action_t action, double priority)
+static void cpu_ti_action_set_priority(surf_action_t action,
+ double priority)
{
XBT_IN2("(%p,%g)", action, priority);
action->priority = priority;
static double cpu_ti_action_get_remains(surf_action_t action)
{
XBT_IN1("(%p)", action);
- cpu_ti_update_remaining_amount((cpu_ti_t) ((surf_action_cpu_ti_t) action)->cpu,
- surf_get_clock());
+ cpu_ti_update_remaining_amount((cpu_ti_t)
+ ((surf_action_cpu_ti_t) action)->cpu,
+ surf_get_clock());
return action->remains;
XBT_OUT;
}
* \param a Time
* \return CPU power scale
*/
-static double surf_cpu_ti_get_power_scale(surf_cpu_ti_tgmr_t trace, double a)
+static double surf_cpu_ti_get_power_scale(surf_cpu_ti_tgmr_t trace,
+ double a)
{
double reduced_a;
int point;
reduced_a = a - floor(a / trace->last_time) * trace->last_time;
point =
- surf_cpu_ti_binary_search(trace->trace->time_points, reduced_a, 0,
- trace->trace->nb_points - 1);
+ surf_cpu_ti_binary_search(trace->trace->time_points, reduced_a, 0,
+ trace->trace->nb_points - 1);
xbt_dynar_get_cpy(trace->power_trace->event_list, 0, &val);
return val.value;
}
{
cpu_ti_t CPU = cpu;
CPU->power_scale =
- surf_cpu_ti_get_power_scale(CPU->avail_trace, surf_get_clock());
+ surf_cpu_ti_get_power_scale(CPU->avail_trace, surf_get_clock());
/* number between 0 and 1 */
return CPU->power_scale;
}
static void cpu_ti_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- cpu_ti_new(name,power_peak,power_scale,power_trace,
- state_initial,state_trace,cpu_properties);
+ cpu_ti_new(name, power_peak, power_scale, power_trace,
+ state_initial, state_trace, cpu_properties);
}
static void cpu_ti_finalize(void)
void *cpu;
xbt_dict_cursor_t cursor;
char *key;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key, cpu) {
+ xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key,
+ cpu) {
cpu_ti_t CPU = cpu;
xbt_swag_free(CPU->action_set);
surf_cpu_ti_free_tmgr(CPU->avail_trace);
surf_model_exit(surf_cpu_model);
surf_cpu_model = NULL;
- xbt_swag_free(cpu_ti_running_action_set_that_does_not_need_being_checked);
+ xbt_swag_free
+ (cpu_ti_running_action_set_that_does_not_need_being_checked);
xbt_swag_free(cpu_ti_modified_cpu);
cpu_ti_running_action_set_that_does_not_need_being_checked = NULL;
xbt_heap_free(cpu_ti_action_heap);
surf_cpu_model = surf_model_init();
cpu_ti_running_action_set_that_does_not_need_being_checked =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
- cpu_ti_modified_cpu = xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
+ cpu_ti_modified_cpu =
+ xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
surf_cpu_model->name = "CPU_TI";
surf_cpu_model->model_private->resource_used = cpu_ti_resource_used;
surf_cpu_model->model_private->share_resources = cpu_ti_share_resources;
- surf_cpu_model->model_private->update_actions_state = cpu_ti_update_actions_state;
+ surf_cpu_model->model_private->update_actions_state =
+ cpu_ti_update_actions_state;
surf_cpu_model->model_private->update_resource_state =
- cpu_ti_update_resource_state;
+ cpu_ti_update_resource_state;
surf_cpu_model->model_private->finalize = cpu_ti_finalize;
surf_cpu_model->suspend = cpu_ti_action_suspend;
surf_cpu_model->extension.cpu.get_state = cpu_ti_get_state;
surf_cpu_model->extension.cpu.get_speed = cpu_ti_get_speed;
- surf_cpu_model->extension.cpu.get_available_speed = cpu_ti_get_available_speed;
+ surf_cpu_model->extension.cpu.get_available_speed =
+ cpu_ti_get_available_speed;
surf_cpu_model->extension.cpu.create_resource = cpu_ti_create_resource;
surf_cpu_model->extension.cpu.add_traces = add_traces_cpu_ti;
cpu_ti_action_heap = xbt_heap_new(8, NULL);
- xbt_heap_set_update_callback(cpu_ti_action_heap, cpu_ti_action_update_index_heap);
+ xbt_heap_set_update_callback(cpu_ti_action_heap,
+ cpu_ti_action_update_index_heap);
}
* \param b End of interval
* \return the integrate value. -1 if an error occurs.
*/
-static double surf_cpu_ti_integrate_trace(surf_cpu_ti_tgmr_t trace, double a,
- double b)
+static double surf_cpu_ti_integrate_trace(surf_cpu_ti_tgmr_t trace,
+ double a, double b)
{
double first_chunk;
double middle_chunk;
if ((a < 0.0) || (a > b)) {
CRITICAL2
- ("Error, invalid integration interval [%.2f,%.2f]. You probably have a task executing with negative computation amount. Check your code.",
- a, b);
+ ("Error, invalid integration interval [%.2f,%.2f]. You probably have a task executing with negative computation amount. Check your code.",
+ a, b);
xbt_abort();
}
if (a == b)
if (a_index > b_index) { /* Same chunk */
return surf_cpu_ti_integrate_trace_simple(trace->trace,
- a - (a_index -
- 1) * trace->last_time,
- b - (b_index) * trace->last_time);
+ a - (a_index -
+ 1) * trace->last_time,
+ b -
+ (b_index) *
+ trace->last_time);
}
first_chunk = surf_cpu_ti_integrate_trace_simple(trace->trace,
- a - (a_index -
- 1) * trace->last_time,
- trace->last_time);
+ a - (a_index -
+ 1) *
+ trace->last_time,
+ trace->last_time);
middle_chunk = (b_index - a_index) * trace->total;
last_chunk = surf_cpu_ti_integrate_trace_simple(trace->trace,
- 0.0,
- b -
- (b_index) * trace->last_time);
+ 0.0,
+ b -
+ (b_index) *
+ trace->last_time);
DEBUG3("first_chunk=%.2f middle_chunk=%.2f last_chunk=%.2f\n",
first_chunk, middle_chunk, last_chunk);
* \return Integral
*/
static double surf_cpu_ti_integrate_trace_simple(surf_cpu_ti_trace_t trace,
- double a, double b)
+ double a, double b)
{
return surf_cpu_ti_integrate_trace_simple_point(trace,
- b) -
- surf_cpu_ti_integrate_trace_simple_point(trace, a);
+ b) -
+ surf_cpu_ti_integrate_trace_simple_point(trace, a);
}
/**
* \param a point
* \return Integral
*/
-static double surf_cpu_ti_integrate_trace_simple_point(surf_cpu_ti_trace_t trace,
- double a)
+static double surf_cpu_ti_integrate_trace_simple_point(surf_cpu_ti_trace_t
+ trace, double a)
{
double integral = 0;
int ind;
double a_aux = a;
ind =
- surf_cpu_ti_binary_search(trace->time_points, a, 0, trace->nb_points - 1);
+ surf_cpu_ti_binary_search(trace->time_points, a, 0,
+ trace->nb_points - 1);
integral += trace->integral[ind];
- DEBUG7("a %lf ind %d integral %lf ind + 1 %lf ind %lf time +1 %lf time %lf",
- a, ind, integral, trace->integral[ind + 1], trace->integral[ind],
- trace->time_points[ind + 1], trace->time_points[ind]);
+ DEBUG7
+ ("a %lf ind %d integral %lf ind + 1 %lf ind %lf time +1 %lf time %lf",
+ a, ind, integral, trace->integral[ind + 1], trace->integral[ind],
+ trace->time_points[ind + 1], trace->time_points[ind]);
double_update(&a_aux, trace->time_points[ind]);
if (a_aux > 0)
integral +=
- ((trace->integral[ind + 1] -
- trace->integral[ind]) / (trace->time_points[ind + 1] -
- trace->time_points[ind])) * (a -
- trace->
- time_points
- [ind]);
+ ((trace->integral[ind + 1] -
+ trace->integral[ind]) / (trace->time_points[ind + 1] -
+ trace->time_points[ind])) * (a -
+ trace->
+ time_points
+ [ind]);
DEBUG2("Integral a %lf = %lf", a, integral);
return integral;
* \return End time
*/
static double surf_cpu_ti_solve_trace(surf_cpu_ti_tgmr_t trace, double a,
- double amount)
+ double amount)
{
int quotient;
double reduced_b;
/* Sanity checks */
if ((a < 0.0) || (amount < 0.0)) {
CRITICAL2
- ("Error, invalid parameters [a = %.2f, amount = %.2f]. You probably have a task executing with negative computation amount. Check your code.",
- a, amount);
+ ("Error, invalid parameters [a = %.2f, amount = %.2f]. You probably have a task executing with negative computation amount. Check your code.",
+ a, amount);
xbt_abort();
}
fprintf(stderr,"reduced_amount = %.2f\n",reduced_amount);
*/
reduced_b =
- surf_cpu_ti_solve_trace_somewhat_simple(trace, reduced_a, reduced_amount);
+ surf_cpu_ti_solve_trace_somewhat_simple(trace, reduced_a,
+ reduced_amount);
/* Re-map to the original b and amount */
b = (trace->last_time) * (int) (floor(a / trace->last_time)) +
- (quotient * trace->last_time) + reduced_b;
+ (quotient * trace->last_time) + reduced_b;
return b;
}
* and a <=trace->last_time
*
*/
-static double surf_cpu_ti_solve_trace_somewhat_simple(surf_cpu_ti_tgmr_t trace,
- double a, double amount)
+static double surf_cpu_ti_solve_trace_somewhat_simple(surf_cpu_ti_tgmr_t
+ trace, double a,
+ double amount)
{
double amount_till_end;
double b;
DEBUG2("Solve integral: [%.2f, amount=%.2f]", a, amount);
- amount_till_end = surf_cpu_ti_integrate_trace(trace, a, trace->last_time);
+ amount_till_end =
+ surf_cpu_ti_integrate_trace(trace, a, trace->last_time);
/*
fprintf(stderr,"amount_till_end=%.2f\n",amount_till_end);
*/
b = surf_cpu_ti_solve_trace_simple(trace->trace, a, amount);
} else {
b = trace->last_time +
- surf_cpu_ti_solve_trace_simple(trace->trace, 0.0,
- amount - amount_till_end);
+ surf_cpu_ti_solve_trace_simple(trace->trace, 0.0,
+ amount - amount_till_end);
}
return b;
}
* \param amount Amount of flops
* \return The date when amount is available.
*/
-static double surf_cpu_ti_solve_trace_simple(surf_cpu_ti_trace_t trace, double a,
- double amount)
+static double surf_cpu_ti_solve_trace_simple(surf_cpu_ti_trace_t trace,
+ double a, double amount)
{
double integral_a;
int ind;
double time;
integral_a = surf_cpu_ti_integrate_trace_simple_point(trace, a);
ind =
- surf_cpu_ti_binary_search(trace->integral, integral_a + amount, 0,
- trace->nb_points - 1);
+ surf_cpu_ti_binary_search(trace->integral, integral_a + amount, 0,
+ trace->nb_points - 1);
time = trace->time_points[ind];
time +=
- (integral_a + amount -
- trace->integral[ind]) / ((trace->integral[ind + 1] -
- trace->integral[ind]) /
- (trace->time_points[ind + 1] -
- trace->time_points[ind]));
+ (integral_a + amount -
+ trace->integral[ind]) / ((trace->integral[ind + 1] -
+ trace->integral[ind]) /
+ (trace->time_points[ind + 1] -
+ trace->time_points[ind]));
return time;
}
* \param high Upper bound to search in array
* \return Index of point
*/
-static int surf_cpu_ti_binary_search(double *array, double a, int low, int high)
+static int surf_cpu_ti_binary_search(double *array, double a, int low,
+ int high)
{
int mid = low + (high - low) / 2;
DEBUG5("a %lf low %d high %d mid %d value %lf", a, low, high, mid,
#define ACTION_GET_CPU(action) ((cpu_ti_t)((surf_action_cpu_ti_t)action)->cpu)
-#endif /* _SURF_CPU_TI_PRIVATE_H */
+#endif /* _SURF_CPU_TI_PRIVATE_H */
xbt_swag_foreach(elem, elem_list) {
if (elem->variable->weight <= 0)
break;
- if ((elem->value > 0) && xbt_swag_belongs(elem->variable, var_list))
+ if ((elem->value > 0)
+ && xbt_swag_belongs(elem->variable, var_list))
nb++;
}
DEBUG1("\tThere are %d variables", nb);
}
xbt_swag_foreach_safe(var, var_next, var_list) {
- double min_inc = var->cnsts[0].constraint->usage / var->cnsts[0].value;
+ double min_inc =
+ var->cnsts[0].constraint->usage / var->cnsts[0].value;
for (i = 1; i < var->cnsts_number; i++) {
lmm_element_t elm = &var->cnsts[i];
min_inc = MIN(min_inc, elm->constraint->usage / elm->value);
break;
if (cnst->shared) {
DEBUG4("\tUpdate constraint %p (%g) with variable %p by %g",
- cnst, cnst->remaining, elem->variable, elem->variable->mu);
- double_update(&(cnst->remaining), elem->value * elem->variable->mu);
+ cnst, cnst->remaining, elem->variable,
+ elem->variable->mu);
+ double_update(&(cnst->remaining),
+ elem->value * elem->variable->mu);
} else {
DEBUG4
- ("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g",
- cnst, cnst->usage, elem->variable, elem->variable->mu);
+ ("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g",
+ cnst, cnst->usage, elem->variable, elem->variable->mu);
cnst->usage = MIN(cnst->usage, elem->value * elem->variable->mu);
}
}
int gtnets_create_flow(int src, int dst, long datasize, void *metadata);
double gtnets_get_time_to_next_flow_completion();
double gtnets_run_until_next_flow_completion(void ***metadata,
- int *number_of_flows);
+ int *number_of_flows);
double gtnets_get_flow_rx(void *metadata);
void gtnets_print_topology(void);
int add_router(int id);
int create_flow(int src, int dst, long datasize, void *metadata);
double get_time_to_next_flow_completion();
- int run_until_next_flow_completion(void ***metadata, int *number_of_flows);
+ int run_until_next_flow_completion(void ***metadata,
+ int *number_of_flows);
int run(double deltat);
// returns the total received by the TCPServer peer of the given action
double gtnets_get_flow_rx(void *metadata);
int nflow_;
double jitter_;
int jitter_seed_;
- map< int, Uniform * > uniform_jitter_generator_;
+ map < int, Uniform * >uniform_jitter_generator_;
- map < int, TCPServer * >gtnets_servers_;
- map < int, TCPSend * >gtnets_clients_;
- map < int, Linkp2p * >gtnets_links_;
- map < int, Node * >gtnets_nodes_;
- map < void *, int >gtnets_action_to_flow_;
+ map < int, TCPServer * >gtnets_servers_;
+ map < int, TCPSend * >gtnets_clients_;
+ map < int, Linkp2p * >gtnets_links_;
+ map < int, Node * >gtnets_nodes_;
+ map < void *, int >gtnets_action_to_flow_;
- map < int, void *>gtnets_metadata_;
+ map < int, void *>gtnets_metadata_;
};
-#endif /* __cplusplus */
+#endif /* __cplusplus */
#endif
public:
GTNETS_Node(int);
- GTNETS_Node(const GTNETS_Node & node);
- ~GTNETS_Node();
+ GTNETS_Node(const GTNETS_Node & node);
+ ~GTNETS_Node();
int add_host(int);
int add_router(int);
public:
GTNETS_Link();
GTNETS_Link(int id);
- GTNETS_Link(const GTNETS_Link &);
- ~GTNETS_Link();
+ GTNETS_Link(const GTNETS_Link &);
+ ~GTNETS_Link();
GTNETS_Node *src_node();
GTNETS_Node *dst_node();
private:
int nodeID_;
- map < int, GTNETS_Link * >links_;
- vector < GTNETS_Node * >nodes_;
+ map < int, GTNETS_Link * >links_;
+ vector < GTNETS_Node * >nodes_;
- map < int, int >hosts_; //hostid->nodeid
+ map < int, int >hosts_; //hostid->nodeid
- set < int >routers_;
+ set < int >routers_;
};
#endif
if (double_positive(tmp - cnst->bound)) {
if (warn)
WARN3
- ("The link (%p) is over-used. Expected less than %f and got %f",
- cnst, cnst->bound, tmp);
+ ("The link (%p) is over-used. Expected less than %f and got %f",
+ cnst, cnst->bound, tmp);
return 0;
}
DEBUG3
- ("Checking feasability for constraint (%p): sat = %f, lambda = %f ",
- cnst, tmp - cnst->bound, cnst->lambda);
+ ("Checking feasability for constraint (%p): sat = %f, lambda = %f ",
+ cnst, tmp - cnst->bound, cnst->lambda);
}
xbt_swag_foreach(var, var_list) {
if (double_positive(var->value - var->bound)) {
if (warn)
WARN3
- ("The variable (%p) is too large. Expected less than %f and got %f",
- var, var->bound, var->value);
+ ("The variable (%p) is too large. Expected less than %f and got %f",
+ var, var->bound, var->value);
return 0;
}
}
DEBUG2("var %p : sigma_i = %1.20f", var, sigma_i);
obj += var->func_f(var, var->func_fpi(var, sigma_i)) -
- sigma_i * var->func_fpi(var, sigma_i);
+ sigma_i * var->func_fpi(var, sigma_i);
if (var->bound > 0)
obj += var->mu * var->bound;
}
xbt_swag_foreach(cnst, cnst_list)
- obj += cnst->lambda * cnst->bound;
+ obj += cnst->lambda * cnst->bound;
return obj;
}
DEBUG0("Iterative method configuration snapshot =====>");
DEBUG1("#### Maximum number of iterations : %d", max_iterations);
- DEBUG1("#### Minimum error tolerated : %e", epsilon_min_error);
+ DEBUG1("#### Minimum error tolerated : %e",
+ epsilon_min_error);
DEBUG1("#### Minimum error tolerated (dichotomy) : %e",
dichotomy_min_error);
xbt_swag_foreach(cnst, cnst_list) {
DEBUG1("Working on cnst (%p)", cnst);
cnst->new_lambda =
- dichotomy(cnst->lambda, partial_diff_lambda, cnst,
- dichotomy_min_error);
+ dichotomy(cnst->lambda, partial_diff_lambda, cnst,
+ dichotomy_min_error);
/* dual_updated += (fabs(cnst->new_lambda-cnst->lambda)>dichotomy_min_error); */
/* DEBUG2("dual_updated (%d) : %1.20f",dual_updated,fabs(cnst->new_lambda-cnst->lambda)); */
DEBUG3("Updating lambda : cnst->lambda (%p) : %1.20f -> %1.20f",
tmp = new_value(var);
overall_modification =
- MAX(overall_modification, fabs(var->value - tmp));
+ MAX(overall_modification, fabs(var->value - tmp));
var->value = tmp;
DEBUG3("New value of var (%p) = %e, overall_modification = %e",
}
if (iteration >= max_iterations) {
DEBUG1
- ("Method reach %d iterations, which is the maximum number of iterations allowed.",
- iteration);
+ ("Method reach %d iterations, which is the maximum number of iterations allowed.",
+ iteration);
}
/* INFO1("Method converged after %d iterations", iteration); */
}
} else if (min_diff < 0 && max_diff > 0) {
middle = (max + min) / 2.0;
- CDEBUG1(surf_lagrange_dichotomy, "Trying (max+min)/2 : %1.20f", middle);
+ CDEBUG1(surf_lagrange_dichotomy, "Trying (max+min)/2 : %1.20f",
+ middle);
if ((min == middle) || (max == middle)) {
CWARN4(surf_lagrange_dichotomy,
if (var->weight <= 0)
continue;
- CDEBUG1(surf_lagrange_dichotomy, "Computing sigma_i for var (%p)", var);
+ CDEBUG1(surf_lagrange_dichotomy, "Computing sigma_i for var (%p)",
+ var);
// Initialize the summation variable
sigma_i = 0.0;
-
- (lmm_variable_t var, double x),
- double (*func_fp) (lmm_variable_t var,
- double x),
- double (*func_fpi) (lmm_variable_t var,
- double x))
+
+ (lmm_variable_t var, double x),
+ double (*func_fp) (lmm_variable_t
+ var, double x),
+ double (*func_fpi) (lmm_variable_t
+ var, double x))
{
func_f_def = func_f;
func_fp_def = func_fp;
{
xbt_assert0(var->weight > 0.0, "Don't call me with stupid values!");
- return RENO_SCALING * sqrt(3.0 / 2.0) / var->weight * atan(sqrt(3.0 / 2.0) *
- var->weight * x);
+ return RENO_SCALING * sqrt(3.0 / 2.0) / var->weight *
+ atan(sqrt(3.0 / 2.0) * var->weight * x);
}
double func_reno_fp(lmm_variable_t var, double x)
{
- return RENO_SCALING * 3.0 / (3.0 * var->weight * var->weight * x * x + 2.0);
+ return RENO_SCALING * 3.0 / (3.0 * var->weight * var->weight * x * x +
+ 2.0);
}
double func_reno_fpi(lmm_variable_t var, double x)
xbt_assert0(x > 0.0, "Don't call me with stupid values!");
res_fpi =
- 1.0 / (var->weight * var->weight * (x / RENO_SCALING)) -
- 2.0 / (3.0 * var->weight * var->weight);
+ 1.0 / (var->weight * var->weight * (x / RENO_SCALING)) -
+ 2.0 / (3.0 * var->weight * var->weight);
if (res_fpi <= 0.0)
return 0.0;
/* xbt_assert0(res_fpi>0.0,"Don't call me with stupid values!"); */
static void *lmm_variable_mallocator_new_f(void);
static void lmm_variable_mallocator_free_f(void *var);
static void lmm_variable_mallocator_reset_f(void *var);
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst);
+static void lmm_update_modified_set(lmm_system_t sys,
+ lmm_constraint_t cnst);
static void lmm_remove_all_modified_set(lmm_system_t sys);
int sg_maxmin_selective_update = 1;
static int Global_debug_id = 1;
lmm_constraint_t cnst = NULL;
while ((var = extract_variable(sys))) {
- WARN2("Variable %p (%d) still in LMM system when freing it: this may be a bug",
- var,var->id_int);
+ WARN2
+ ("Variable %p (%d) still in LMM system when freing it: this may be a bug",
+ var, var->id_int);
lmm_var_free(sys, var);
}
xbt_mallocator_release(sys->variable_mallocator, var);
}
-static XBT_INLINE void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)
+static XBT_INLINE void lmm_cnst_free(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
/* xbt_assert0(xbt_swag_size(&(cnst->element_set)), */
/* "This list should be empty!"); */
return (cnst->shared);
}
-XBT_INLINE void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst)
+XBT_INLINE void lmm_constraint_free(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
remove_constraint(sys, cnst);
lmm_cnst_free(sys, cnst);
}
XBT_INLINE lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
- lmm_variable_t var, int num)
+ lmm_variable_t var,
+ int num)
{
if (num < var->cnsts_number)
return (var->cnsts[num].constraint);
return NULL;
}
-XBT_INLINE int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var)
+XBT_INLINE int lmm_get_number_of_cnst_from_var(lmm_system_t sys,
+ lmm_variable_t var)
{
return (var->cnsts_number);
}
}
static XBT_INLINE void saturated_constraint_set_update(lmm_system_t sys,
- lmm_constraint_t cnst,
- double *min_usage)
+ lmm_constraint_t
+ cnst,
+ double *min_usage)
{
lmm_constraint_t useless_cnst = NULL;
var_list = &(sys->variable_set);
sprintf(print_buf, "MAX-MIN ( ");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
xbt_swag_foreach(var, var_list) {
sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight);
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
}
sprintf(print_buf, ")");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
fprintf(stderr, "%s", trace_buf);
//DEBUG1("%20s", trace_buf); FIXME
elem_list = &(cnst->element_set);
sprintf(print_buf, "\t");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
xbt_swag_foreach(elem, elem_list) {
sprintf(print_buf, "%f.'%d'(%f) + ", elem->value,
elem->variable->id_int, elem->variable->value);
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf,
+ strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
sum += elem->value * elem->variable->value;
}
sprintf(print_buf, "0 <= %f ('%d')", cnst->bound, cnst->id_int);
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
if (!cnst->shared) {
sprintf(print_buf, " [MAX-Constraint]");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf,
+ strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
}
// DEBUG1("%s", trace_buf);
/*
* Compute Usage and store the variables that reach the maximum.
*/
- cnst_list = sys->selective_update_active ? &(sys->modified_constraint_set) :
- &(sys->active_constraint_set);
+ cnst_list =
+ sys->
+ selective_update_active ? &(sys->modified_constraint_set) :
+ &(sys->active_constraint_set);
DEBUG1("Active constraints : %d", xbt_swag_size(cnst_list));
/* Init: Only modified code portions */
/* First check if some of these variables have reach their upper
bound and update min_usage accordingly. */
DEBUG5
- ("var=%d, var->bound=%f, var->weight=%f, min_usage=%f, var->bound*var->weight=%f",
- var->id_int, var->bound, var->weight, min_usage,
- var->bound * var->weight);
+ ("var=%d, var->bound=%f, var->weight=%f, min_usage=%f, var->bound*var->weight=%f",
+ var->id_int, var->bound, var->weight, min_usage,
+ var->bound * var->weight);
if ((var->bound > 0) && (var->bound * var->weight < min_usage)) {
if (min_bound < 0)
min_bound = var->bound;
if (elem->variable->value > 0)
break;
if ((elem->value > 0)) {
- cnst->usage=MAX(cnst->usage,elem->value / elem->variable->weight);
- DEBUG2("Constraint Usage %d : %f", cnst->id_int, cnst->usage);
+ cnst->usage =
+ MAX(cnst->usage, elem->value / elem->variable->weight);
+ DEBUG2("Constraint Usage %d : %f", cnst->id_int,
+ cnst->usage);
make_elem_active(elem);
}
}
/* Find out which variables reach the maximum */
cnst_list =
- sys->selective_update_active ? &(sys->modified_constraint_set) :
- &(sys->active_constraint_set);
+ sys->selective_update_active ? &(sys->modified_constraint_set) :
+ &(sys->active_constraint_set);
min_usage = -1;
min_bound = -1;
xbt_swag_foreach(cnst, cnst_list) {
return var->weight;
}
-XBT_INLINE void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
- double bound)
+XBT_INLINE void lmm_update_constraint_bound(lmm_system_t sys,
+ lmm_constraint_t cnst,
+ double bound)
{
sys->modified = 1;
lmm_update_modified_set(sys, cnst);
return xbt_swag_belongs(cnst, &(sys->active_constraint_set));
}
-XBT_INLINE lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys)
+XBT_INLINE lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t
+ sys)
{
return xbt_swag_getFirst(&(sys->active_constraint_set));
}
-XBT_INLINE lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
- lmm_constraint_t cnst)
+XBT_INLINE lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t
+ sys,
+ lmm_constraint_t
+ cnst)
{
return xbt_swag_getNext(cnst, (sys->active_constraint_set).offset);
}
* constraints that have changed. Each constraint change is propagated
* to the list of constraints for each variable.
*/
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
+static void lmm_update_modified_set(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
lmm_element_t elem = NULL;
lmm_variable_t var = NULL;
#define make_constraint_inactive(sys,cnst) remove_active_constraint(sys,cnst)
static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
-static XBT_INLINE void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
+static XBT_INLINE void lmm_cnst_free(lmm_system_t sys,
+ lmm_constraint_t cnst);
void lmm_print(lmm_system_t sys);
extern double (*func_fp_def) (lmm_variable_t, double);
extern double (*func_fpi_def) (lmm_variable_t, double);
-#endif /* _SURF_MAXMIN_PRIVATE_H */
+#endif /* _SURF_MAXMIN_PRIVATE_H */
static lmm_system_t network_maxmin_system = NULL;
static void (*network_solve) (lmm_system_t) = NULL;
-double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
-double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */
-double sg_weight_S_parameter = 0.0;/* default value; can be set by model or from command line */
+double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
+double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */
+double sg_weight_S_parameter = 0.0; /* default value; can be set by model or from command line */
double sg_tcp_gamma = 0.0;
int sg_network_fullduplex = 0;
/******************************************************************************/
/* Factors callbacks */
-/******************************************************************************/
+/******************************************************************************/
static double constant_latency_factor(double size)
{
return sg_latency_factor;
return sg_bandwidth_factor;
}
-static double constant_bandwidth_constraint(double rate, double bound, double size)
+static double constant_bandwidth_constraint(double rate, double bound,
+ double size)
{
return rate;
}
return 0.9359;
}
-static double smpi_bandwidth_constraint(double rate, double bound, double size)
+static double smpi_bandwidth_constraint(double rate, double bound,
+ double size)
{
return rate < 0 ? bound : min(bound, rate * smpi_bandwidth_factor(size));
}
-static double (*latency_factor_callback)(double) = &constant_latency_factor;
-static double (*bandwidth_factor_callback)(double) = &constant_bandwidth_factor;
-static double (*bandwidth_constraint_callback)(double, double, double) = &constant_bandwidth_constraint;
+static double (*latency_factor_callback) (double) =
+ &constant_latency_factor;
+static double (*bandwidth_factor_callback) (double) =
+ &constant_bandwidth_factor;
+static double (*bandwidth_constraint_callback) (double, double, double) =
+ &constant_bandwidth_constraint;
static link_CM02_t net_link_new(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties)
{
link_CM02_t nw_link = (link_CM02_t)
- surf_resource_lmm_new(sizeof(s_link_CM02_t),
- surf_network_model, name, properties,
- network_maxmin_system,
- sg_bandwidth_factor * bw_initial,
- history,
- state_initial, state_trace,
- bw_initial, bw_trace);
-
- xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
- "Link '%s' declared several times in the platform file.", name);
+ surf_resource_lmm_new(sizeof(s_link_CM02_t),
+ surf_network_model, name, properties,
+ network_maxmin_system,
+ sg_bandwidth_factor * bw_initial,
+ history,
+ state_initial, state_trace,
+ bw_initial, bw_trace);
+
+ xbt_assert1(!xbt_dict_get_or_null
+ (surf_network_model->resource_set, name),
+ "Link '%s' declared several times in the platform file.",
+ name);
nw_link->lat_current = lat_initial;
if (lat_trace)
nw_link->lat_event =
- tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
+ tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->lmm_resource.constraint);
xbt_dict_set(surf_network_model->resource_set, name, nw_link,
surf_resource_free);
#ifdef HAVE_TRACING
- TRACE_surf_link_declaration (nw_link, name, bw_initial, lat_initial);
+ TRACE_surf_link_declaration(nw_link, name, bw_initial, lat_initial);
#endif
return nw_link;
else if (A_surfxml_link_state == A_surfxml_link_state_OFF)
state_initial_link = SURF_RESOURCE_OFF;
- if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
+ if (A_surfxml_link_sharing_policy ==
+ A_surfxml_link_sharing_policy_SHARED)
policy_initial_link = SURF_LINK_SHARED;
else if (A_surfxml_link_sharing_policy ==
A_surfxml_link_sharing_policy_FATPIPE)
state_trace = tmgr_trace_new(A_surfxml_link_state_file);
net_link_new(name_link, bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial_link, state_trace,
- policy_initial_link, xbt_dict_new());
+ lat_initial, lat_trace, state_initial_link, state_trace,
+ policy_initial_link, xbt_dict_new());
}
static void net_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties)
-{
- net_link_new(name, bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial, state_trace,
- policy, xbt_dict_new());
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties)
+{
+ net_link_new(name, bw_initial, bw_trace,
+ lat_initial, lat_trace, state_initial, state_trace,
+ policy, xbt_dict_new());
}
+
static void net_add_traces(void)
{
xbt_dict_cursor_t cursor = NULL;
xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_CM02_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
trace_name, elm);
- xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
+ xbt_assert2(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
link->lmm_resource.state_event =
- tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ tmgr_history_add_trace(history, trace, 0.0, 0, link);
}
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_CM02_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
trace_name, elm);
- xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
+ xbt_assert2(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
link->lmm_resource.power.event =
- tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ tmgr_history_add_trace(history, trace, 0.0, 0, link);
}
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_CM02_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
trace_name, elm);
- xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
+ xbt_assert2(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
static int net_resource_used(void *resource_id)
{
return lmm_constraint_used(network_maxmin_system,
- ((surf_resource_lmm_t) resource_id)->constraint);
+ ((surf_resource_lmm_t)
+ resource_id)->constraint);
}
static int net_action_unref(surf_action_t action)
lmm_variable_free(network_maxmin_system,
((surf_action_network_CM02_t) action)->variable);
#ifdef HAVE_TRACING
- xbt_free (((surf_action_network_CM02_t)action)->src_name);
- xbt_free (((surf_action_network_CM02_t)action)->dst_name);
- if (action->category) xbt_free (action->category);
+ xbt_free(((surf_action_network_CM02_t) action)->src_name);
+ xbt_free(((surf_action_network_CM02_t) action)->dst_name);
+ if (action->category)
+ xbt_free(action->category);
#endif
free(action);
return 1;
{
s_surf_action_network_CM02_t s_action;
surf_action_network_CM02_t action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
double min;
min = generic_maxmin_share_resources(running_actions,
xbt_swag_offset(s_action,
variable),
- network_maxmin_system, network_solve);
+ network_maxmin_system,
+ network_solve);
#define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + xbt_swag_offset(s_action, variable) )))
xbt_swag_foreach(action, running_actions) {
#ifdef HAVE_LATENCY_BOUND_TRACKING
- if( lmm_is_variable_limited_by_latency(action->variable) ){
+ if (lmm_is_variable_limited_by_latency(action->variable)) {
(action->generic_action).latency_limited = 1;
- }else{
+ } else {
(action->generic_action).latency_limited = 0;
}
#endif
double deltap = 0.0;
surf_action_network_CM02_t action = NULL;
surf_action_network_CM02_t next_action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
/*
xbt_swag_t failed_actions =
surf_network_model->states.failed_action_set;
action->weight);
}
#ifdef HAVE_TRACING
- xbt_dynar_t route = global_routing->get_route(action->src_name, action->dst_name);
+ xbt_dynar_t route =
+ global_routing->get_route(action->src_name, action->dst_name);
link_CM02_t link;
unsigned int i;
xbt_dynar_foreach(route, i, link) {
- TRACE_surf_link_set_utilization (link,
- action->generic_action.data, (surf_action_t)action, lmm_variable_getvalue(action->variable), now-delta, delta);
+ TRACE_surf_link_set_utilization(link,
+ action->generic_action.data,
+ (surf_action_t) action,
+ lmm_variable_getvalue
+ (action->variable), now - delta,
+ delta);
}
#endif
double_update(&(action->generic_action.remains),
}
static void net_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
link_CM02_t nw_link = id;
/* printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
if (event_type == nw_link->lmm_resource.power.event) {
double delta =
- sg_weight_S_parameter / value - sg_weight_S_parameter /
- (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale);
+ sg_weight_S_parameter / value - sg_weight_S_parameter /
+ (nw_link->lmm_resource.power.peak *
+ nw_link->lmm_resource.power.scale);
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
surf_action_network_CM02_t action = NULL;
(nw_link->lmm_resource.power.peak *
nw_link->lmm_resource.power.scale));
#ifdef HAVE_TRACING
- TRACE_surf_link_set_bandwidth (date, nw_link, sg_bandwidth_factor * (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale));
+ TRACE_surf_link_set_bandwidth(date, nw_link,
+ sg_bandwidth_factor *
+ (nw_link->lmm_resource.power.peak *
+ nw_link->lmm_resource.power.scale));
#endif
if (sg_weight_S_parameter > 0) {
while ((var = lmm_get_var_from_cnst
action = lmm_variable_id(var);
action->weight += delta;
if (!(action->suspended))
- lmm_update_variable_weight(network_maxmin_system, action->variable,
- action->weight);
+ lmm_update_variable_weight(network_maxmin_system,
+ action->variable, action->weight);
}
}
if (tmgr_trace_event_free(event_type))
action->weight += delta;
if (action->rate < 0)
lmm_update_variable_bound(network_maxmin_system, action->variable,
- sg_tcp_gamma / (2.0 * action->lat_current));
- else{
+ sg_tcp_gamma / (2.0 *
+ action->lat_current));
+ else {
lmm_update_variable_bound(network_maxmin_system, action->variable,
min(action->rate,
sg_tcp_gamma / (2.0 *
action->lat_current)));
- if(action->rate < sg_tcp_gamma / (2.0 * action->lat_current) ){
- INFO0("Flow is limited BYBANDWIDTH");
- }else{
- INFO1("Flow is limited BYLATENCY, latency of flow is %f",action->lat_current);
+ if (action->rate < sg_tcp_gamma / (2.0 * action->lat_current)) {
+ INFO0("Flow is limited BYBANDWIDTH");
+ } else {
+ INFO1("Flow is limited BYLATENCY, latency of flow is %f",
+ action->lat_current);
}
}
if (!(action->suspended))
}
-static surf_action_t net_communicate(const char *src_name, const char *dst_name,
- double size, double rate)
+static surf_action_t net_communicate(const char *src_name,
+ const char *dst_name, double size,
+ double rate)
{
unsigned int i;
link_CM02_t link;
xbt_dynar_t back_route = NULL;
int constraints_per_variable = 0;
- if( sg_network_fullduplex == 1){
- back_route = global_routing->get_route(src_name, dst_name);
+ if (sg_network_fullduplex == 1) {
+ back_route = global_routing->get_route(src_name, dst_name);
}
-
+
/* LARGE PLATFORMS HACK:
total_route_size = route_size + src->link_nb + dst->nb */
}
}
action =
- surf_action_new(sizeof(s_surf_action_network_CM02_t), size,
- surf_network_model, failed);
+ surf_action_new(sizeof(s_surf_action_network_CM02_t), size,
+ surf_network_model, failed);
#ifdef HAVE_LATENCY_BOUND_TRACKING
(action->generic_action).latency_limited = 0;
#endif
xbt_dynar_foreach(route, i, link) {
action->latency += link->lat_current;
action->weight +=
- link->lat_current +
- sg_weight_S_parameter /
- (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
- if(bandwidth_bound < 0.0)
- bandwidth_bound = (*bandwidth_factor_callback)(size) * (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
+ link->lat_current +
+ sg_weight_S_parameter /
+ (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
+ if (bandwidth_bound < 0.0)
+ bandwidth_bound =
+ (*bandwidth_factor_callback) (size) *
+ (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
else
- bandwidth_bound = min(bandwidth_bound, (*bandwidth_factor_callback)(size) * (link->lmm_resource.power.peak * link->lmm_resource.power.scale));
+ bandwidth_bound =
+ min(bandwidth_bound,
+ (*bandwidth_factor_callback) (size) *
+ (link->lmm_resource.power.peak *
+ link->lmm_resource.power.scale));
}
/* LARGE PLATFORMS HACK:
Add src->link and dst->link latencies */
action->lat_current = action->latency;
- action->latency *= (*latency_factor_callback)(size);
- action->rate = (*bandwidth_constraint_callback)(action->rate, bandwidth_bound, size);
+ action->latency *= (*latency_factor_callback) (size);
+ action->rate =
+ (*bandwidth_constraint_callback) (action->rate, bandwidth_bound,
+ size);
/* LARGE PLATFORMS HACK:
lmm_variable_new(..., total_route_size) */
- if(back_route != NULL){
- constraints_per_variable = xbt_dynar_length(route)+xbt_dynar_length(back_route);
- }else{
- constraints_per_variable = xbt_dynar_length(route);
+ if (back_route != NULL) {
+ constraints_per_variable =
+ xbt_dynar_length(route) + xbt_dynar_length(back_route);
+ } else {
+ constraints_per_variable = xbt_dynar_length(route);
}
if (action->latency > 0)
action->variable =
- lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,constraints_per_variable);
+ lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
+ constraints_per_variable);
else
action->variable =
- lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,constraints_per_variable);
+ lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
+ constraints_per_variable);
if (action->rate < 0) {
if (action->lat_current > 0)
lmm_update_variable_bound(network_maxmin_system, action->variable,
- sg_tcp_gamma / (2.0 * action->lat_current));
+ sg_tcp_gamma / (2.0 *
+ action->lat_current));
else
lmm_update_variable_bound(network_maxmin_system, action->variable,
-1.0);
action->variable, 1.0);
}
- if( sg_network_fullduplex == 1){
- DEBUG1("Fullduplex active adding backward flow using 5%c", '%');
- xbt_dynar_foreach(back_route, i, link) {
- lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
- action->variable, .05);
- }
- } /* LARGE PLATFORMS HACK:
+ if (sg_network_fullduplex == 1) {
+ DEBUG1("Fullduplex active adding backward flow using 5%c", '%');
+ xbt_dynar_foreach(back_route, i, link) {
+ lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
+ action->variable, .05);
+ }
+ }
+ /* LARGE PLATFORMS HACK:
expand also with src->link and dst->link */
-
#ifdef HAVE_TRACING
- action->src_name = xbt_new (char, strlen(src_name)+1);
- strncpy (action->src_name, src_name, strlen(src_name)+1);
+ action->src_name = xbt_new(char, strlen(src_name) + 1);
+ strncpy(action->src_name, src_name, strlen(src_name) + 1);
- action->dst_name = xbt_new (char, strlen(dst_name)+1);
- strncpy (action->dst_name, dst_name, strlen(dst_name)+1);
+ action->dst_name = xbt_new(char, strlen(dst_name) + 1);
+ strncpy(action->dst_name, dst_name, strlen(dst_name) + 1);
#endif
XBT_OUT;
static xbt_dynar_t net_get_route(const char *src, const char *dst)
{
- return global_routing->get_route( src, dst);
+ return global_routing->get_route(src, dst);
}
static double net_get_link_bandwidth(const void *link)
static double net_get_link_latency(const void *link)
{
- return ((link_CM02_t) link)->lat_current;
+ return ((link_CM02_t) link)->lat_current;
}
static int net_link_shared(const void *link)
{
- return lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
+ return
+ lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
}
static void net_action_suspend(surf_action_t action)
{
((surf_action_network_CM02_t) action)->suspended = 1;
lmm_update_variable_weight(network_maxmin_system,
- ((surf_action_network_CM02_t) action)->variable,
- 0.0);
+ ((surf_action_network_CM02_t)
+ action)->variable, 0.0);
}
static void net_action_resume(surf_action_t action)
lmm_update_variable_weight(network_maxmin_system,
((surf_action_network_CM02_t)
action)->variable,
- ((surf_action_network_CM02_t) action)->weight);
+ ((surf_action_network_CM02_t)
+ action)->weight);
((surf_action_network_CM02_t) action)->suspended = 0;
}
}
{
surf_model_exit(surf_network_model);
surf_network_model = NULL;
-
+
global_routing->finalize();
-
+
lmm_system_free(network_maxmin_system);
network_maxmin_system = NULL;
}
surf_network_model->model_private->resource_used = net_resource_used;
surf_network_model->model_private->share_resources = net_share_resources;
surf_network_model->model_private->update_actions_state =
- net_update_actions_state;
+ net_update_actions_state;
surf_network_model->model_private->update_resource_state =
- net_update_resource_state;
+ net_update_resource_state;
surf_network_model->model_private->finalize = net_finalize;
surf_network_model->suspend = net_action_suspend;
surf_network_model->extension.network.communicate = net_communicate;
surf_network_model->extension.network.get_route = net_get_route;
surf_network_model->extension.network.get_link_bandwidth =
- net_get_link_bandwidth;
+ net_get_link_bandwidth;
surf_network_model->extension.network.get_link_latency =
- net_get_link_latency;
+ net_get_link_latency;
surf_network_model->extension.network.link_shared = net_link_shared;
surf_network_model->extension.network.add_traces = net_add_traces;
- surf_network_model->extension.network.create_resource = net_create_resource;
+ surf_network_model->extension.network.create_resource =
+ net_create_resource;
if (!network_maxmin_system)
network_maxmin_system = lmm_system_new();
routing_model_create(sizeof(link_CM02_t),
net_link_new(xbt_strdup("__loopback__"),
- 498000000, NULL, 0.000015, NULL,
- SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE,
- NULL));
+ 498000000, NULL, 0.000015, NULL,
+ SURF_RESOURCE_ON, NULL,
+ SURF_LINK_FATPIPE, NULL));
}
xbt_dynar_push(model_list, &surf_network_model);
network_solve = lmm_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S", 8775);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
update_model_description(surf_network_model_description,
"SMPI", surf_network_model);
xbt_dynar_push(model_list, &surf_network_model);
network_solve = lmm_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor",10.4);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/bandwidth_factor", 0.92);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S", 8775);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
+ 0.92);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
update_model_description(surf_network_model_description,
"LV08", surf_network_model);
net_define_callbacks(filename);
xbt_dynar_push(model_list, &surf_network_model);
- lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
+ lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
+ func_reno_fpi);
network_solve = lagrange_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/bandwidth_factor", 0.92);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S", 8775);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
+ 0.92);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
update_model_description(surf_network_model_description,
"Reno", surf_network_model);
func_reno2_fpi);
network_solve = lagrange_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/bandwidth_factor", 0.92);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S_parameter", 8775);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
+ 0.92);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S_parameter",
+ 8775);
update_model_description(surf_network_model_description,
"Reno2", surf_network_model);
func_vegas_fpi);
network_solve = lagrange_solve;
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/bandwidth_factor", 0.92);
- xbt_cfg_setdefault_double(_surf_cfg_set,"network/weight_S", 8775);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
+ 0.92);
+ xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
update_model_description(surf_network_model_description,
"Vegas", surf_network_model);
}
-
-
static double netcste_share_resources(double now)
{
surf_action_network_Constant_t action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
double min = -1.0;
xbt_swag_foreach(action, running_actions) {
{
surf_action_network_Constant_t action = NULL;
surf_action_network_Constant_t next_action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
xbt_swag_foreach_safe(action, next_action, running_actions) {
if (action->latency > 0) {
}
static void netcste_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double time)
+ tmgr_trace_event_t event_type,
+ double value, double time)
{
DIE_IMPOSSIBLE;
}
-static surf_action_t netcste_communicate(const char *src_name, const char *dst_name,
- double size, double rate)
+static surf_action_t netcste_communicate(const char *src_name,
+ const char *dst_name, double size,
+ double rate)
{
surf_action_network_Constant_t action = NULL;
XBT_IN4("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
action =
- surf_action_new(sizeof(s_surf_action_network_Constant_t), size,
- surf_network_model, 0);
+ surf_action_new(sizeof(s_surf_action_network_Constant_t), size,
+ surf_network_model, 0);
action->suspended = 0;
if (action->latency <= 0.0) {
action->generic_action.state_set =
- surf_network_model->states.done_action_set;
+ surf_network_model->states.done_action_set;
xbt_swag_insert(action, action->generic_action.state_set);
}
#endif
surf_network_model->model_private->resource_used = netcste_resource_used;
- surf_network_model->model_private->share_resources = netcste_share_resources;
+ surf_network_model->model_private->share_resources =
+ netcste_share_resources;
surf_network_model->model_private->update_actions_state =
- netcste_update_actions_state;
+ netcste_update_actions_state;
surf_network_model->model_private->update_resource_state =
- netcste_update_resource_state;
+ netcste_update_resource_state;
surf_network_model->model_private->finalize = netcste_finalize;
surf_network_model->suspend = netcste_action_suspend;
surf_network_model->extension.network.communicate = netcste_communicate;
surf_network_model->extension.network.get_link_bandwidth =
- netcste_get_link_bandwidth;
- surf_network_model->extension.network.get_link_latency = netcste_get_link_latency;
+ netcste_get_link_bandwidth;
+ surf_network_model->extension.network.get_link_latency =
+ netcste_get_link_latency;
surf_network_model->extension.network.link_shared = link_shared;
if (!random_latency)
extern routing_global_t global_routing;
-double sg_gtnets_jitter=0.0;
-int sg_gtnets_jitter_seed=10;
+double sg_gtnets_jitter = 0.0;
+int sg_gtnets_jitter_seed = 10;
static void link_new(char *name, double bw, double lat, xbt_dict_t props)
{
static int link_count = -1;
network_link_GTNETS_t gtnets_link;
network_link_GTNETS_t gtnets_link_friend;
- int tmp_idsrc=-1;
- int tmp_iddst=-1;
+ int tmp_idsrc = -1;
+ int tmp_iddst = -1;
char *name_friend;
if (xbt_dict_get_or_null(surf_network_model->resource_set, name)) {
return;
}
-
#ifdef HAVE_TRACING
- TRACE_surf_link_declaration (name, bw, lat);
+ TRACE_surf_link_declaration(name, bw, lat);
#endif
DEBUG1("Scanning link name %s", name);
sscanf(name, "%d_%d", &tmp_idsrc, &tmp_iddst);
DEBUG2("Link name split into %d and %d", tmp_idsrc, tmp_iddst);
- xbt_assert0( (tmp_idsrc!=-1)&&(tmp_idsrc!=-1), "You need to respect fullduplex convention x_y for xml link id.");
+ xbt_assert0((tmp_idsrc != -1)
+ && (tmp_idsrc != -1),
+ "You need to respect fullduplex convention x_y for xml link id.");
- name_friend = (char *)calloc(strlen(name), sizeof(char));
+ name_friend = (char *) calloc(strlen(name), sizeof(char));
sprintf(name_friend, "%d_%d", tmp_iddst, tmp_idsrc);
gtnets_link = xbt_new0(s_network_link_GTNETS_t, 1);
gtnets_link->bw_current = bw;
gtnets_link->lat_current = lat;
- if((gtnets_link_friend=xbt_dict_get_or_null(surf_network_model->resource_set, name_friend))) {
+ if ((gtnets_link_friend =
+ xbt_dict_get_or_null(surf_network_model->resource_set,
+ name_friend))) {
gtnets_link->id = gtnets_link_friend->id;
} else {
link_count++;
- DEBUG4("Adding new link, linkid %d, name %s, latency %g, bandwidth %g", link_count, name, lat, bw);
+ DEBUG4("Adding new link, linkid %d, name %s, latency %g, bandwidth %g",
+ link_count, name, lat, bw);
if (gtnets_add_link(link_count, bw, lat)) {
xbt_assert0(0, "Cannot create GTNetS link");
}
gtnets_link->id = link_count;
}
xbt_dict_set(surf_network_model->resource_set, name, gtnets_link,
- surf_resource_free);
+ surf_resource_free);
}
-static void route_new(int src_id, int dst_id, xbt_dynar_t links,int nb_link)
+static void route_new(int src_id, int dst_id, xbt_dynar_t links,
+ int nb_link)
{
network_link_GTNETS_t link;
unsigned int cursor;
- int i=0;
+ int i = 0;
int *gtnets_links;
XBT_IN4("(src_id=%d, dst_id=%d, links=%p, nb_link=%d)",
state_trace = tmgr_trace_new(A_surfxml_link_state_file);
if (bw_trace)
- INFO0("The GTNetS network model doesn't support bandwidth state traces");
+ INFO0
+ ("The GTNetS network model doesn't support bandwidth state traces");
if (lat_trace)
INFO0("The GTNetS network model doesn't support latency state traces");
if (state_trace)
// Ensuite, on peut utiliser les id pour refaire les appels GTNets qui suivent.
// xbt_dict_foreach(onelink_routes, cursor, key, data){
-// s_onelink_t link = (s_onelink_t) data;
+// s_onelink_t link = (s_onelink_t) data;
//
-// DEBUG3("Link (#%d), src (#%s), dst (#%s)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src, link->dst);
+// DEBUG3("Link (#%d), src (#%s), dst (#%s)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src, link->dst);
// DEBUG0("Calling one link route");
// if(global_routing->is_router(link->src)){
-// gtnets_add_router(link->src_id);
+// gtnets_add_router(link->src_id);
// }
// if(global_routing->is_router(link->dst)){
-// gtnets_add_router(link->dst_id);
+// gtnets_add_router(link->dst_id);
// }
// route_onehop_new(link->src_id, link->dst_id, (network_link_GTNETS_t)(link->link_ptr));
// }
//
// xbt_dict_free(&route_table);
// if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) {
-// gtnets_print_topology();
+// gtnets_print_topology();
// }
}
{
/* Figuring out the network links */
surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &create_gtnets_topology);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list,
+ &create_gtnets_topology);
}
static int resource_used(void *resource_id)
{
- xbt_assert0(0, "The resource_used feature is not implemented in GTNets model");
+ xbt_assert0(0,
+ "The resource_used feature is not implemented in GTNets model");
}
static int action_unref(surf_action_t action)
if (!action->refcount) {
xbt_swag_remove(action, action->state_set);
#ifdef HAVE_TRACING
- if (action->category) xbt_free (action->category);
+ if (action->category)
+ xbt_free(action->category);
#endif
free(action);
return 1;
static void action_cancel(surf_action_t action)
{
- xbt_assert0(0,"Cannot cancel GTNetS flow");
+ xbt_assert0(0, "Cannot cancel GTNetS flow");
return;
}
static void action_recycle(surf_action_t action)
{
- xbt_assert0(0,"Cannot recycle GTNetS flow");
+ xbt_assert0(0, "Cannot recycle GTNetS flow");
return;
}
static double share_resources(double now)
{
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
//get the first relevant value from the running_actions list
if (!xbt_swag_size(running_actions))
DEBUG0("Calling gtnets_get_time_to_next_flow_completion");
time_to_next_flow_completion = gtnets_get_time_to_next_flow_completion();
- DEBUG1("gtnets_get_time_to_next_flow_completion received %lg", time_to_next_flow_completion);
+ DEBUG1("gtnets_get_time_to_next_flow_completion received %lg",
+ time_to_next_flow_completion);
return time_to_next_flow_completion;
}
static void update_actions_state(double now, double delta)
{
surf_action_network_GTNETS_t action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
/* If there are no renning flows, just return */
if (time_to_next_flow_completion < 0.0) {
#ifdef HAVE_TRACING
double trace_sent = sent;
- if (trace_sent == 0){
+ if (trace_sent == 0) {
//if sent is equals to 0, means that gtnets sent all the bytes
trace_sent = action->generic_action.cost;
}
// network_link_GTNETS_t link;
// unsigned int i;
// xbt_dynar_foreach(route, i, link) {
-// TRACE_surf_link_set_utilization (link->generic_resource.name,
+// TRACE_surf_link_set_utilization (link->generic_resource.name,
// action->generic_action.data, trace_sent/delta, now-delta, delta);
// }
// }
if (sent == 0) {
action->generic_action.remains = 0;
} else {
- action->generic_action.remains = action->generic_action.cost - sent;
+ action->generic_action.remains =
+ action->generic_action.cost - sent;
}
DEBUG2("Action (%p) remains new value: %f", action,
action->generic_action.remains);
action->generic_action.finish = now + time_to_next_flow_completion;
#ifdef HAVE_TRACING
- TRACE_surf_gtnets_destroy (action);
+ TRACE_surf_gtnets_destroy(action);
#endif
action_state_set((surf_action_t) action, SURF_ACTION_DONE);
DEBUG1("----> Action (%p) just terminated", action);
}
/* Max durations are not supported */
-static surf_action_t communicate(const char *src_name, const char *dst_name,
- double size, double rate)
+static surf_action_t communicate(const char *src_name,
+ const char *dst_name, double size,
+ double rate)
{
- int src,dst;
+ int src, dst;
// Utiliser le dictionnaire définit dans create_gtnets_topology pour initialiser correctement src et dst
- src=dst=-1;
+ src = dst = -1;
surf_action_network_GTNETS_t action = NULL;
- xbt_assert0((src >= 0 && dst >= 0), "Either src or dst have invalid id (id<0)");
+ xbt_assert0((src >= 0
+ && dst >= 0), "Either src or dst have invalid id (id<0)");
- DEBUG4("Setting flow src %d \"%s\", dst %d \"%s\"", src, src_name, dst, dst_name);
+ DEBUG4("Setting flow src %d \"%s\", dst %d \"%s\"", src, src_name, dst,
+ dst_name);
xbt_dynar_t links = global_routing->get_route(src_name, dst_name);
route_new(src, dst, links, xbt_dynar_length(links));
- action = surf_action_new(sizeof(s_surf_action_network_GTNETS_t), size, surf_network_model, 0);
+ action =
+ surf_action_new(sizeof(s_surf_action_network_GTNETS_t), size,
+ surf_network_model, 0);
/* Add a flow to the GTNets Simulation, associated to this action */
if (gtnets_create_flow(src, dst, size, (void *) action) < 0) {
dst_name);
}
#ifdef HAVE_TRACING
- TRACE_surf_gtnets_communicate (action, src, dst);
+ TRACE_surf_gtnets_communicate(action, src, dst);
#endif
return (surf_action_t) action;
surf_network_model->model_private->resource_used = resource_used;
surf_network_model->model_private->share_resources = share_resources;
surf_network_model->model_private->update_actions_state =
- update_actions_state;
+ update_actions_state;
surf_network_model->model_private->update_resource_state =
- update_resource_state;
+ update_resource_state;
surf_network_model->model_private->finalize = finalize;
surf_network_model->suspend = action_suspend;
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
-static int get_latency_limited(surf_action_t action){
- return 0;
+static int get_latency_limited(surf_action_t action)
+{
+ return 0;
}
#endif
surf_network_model->get_latency_limited = get_latency_limited;
#endif
- if(sg_gtnets_jitter > 0.0){
- gtnets_set_jitter(sg_gtnets_jitter);
- gtnets_set_jitter_seed(sg_gtnets_jitter_seed);
+ if (sg_gtnets_jitter > 0.0) {
+ gtnets_set_jitter(sg_gtnets_jitter);
+ gtnets_set_jitter_seed(sg_gtnets_jitter_seed);
}
update_model_description(surf_network_model_description,
#include "xbt/dict.h"
typedef struct network_link_GTNETS {
- s_surf_resource_t generic_resource; /* Must remain first to allow casting */
+ s_surf_resource_t generic_resource; /* Must remain first to allow casting */
/* Using this object with the public part of
model does not make sense */
double bw_current;
-#endif /* _SURF_NETWORK_PRIVATE_H */
+#endif /* _SURF_NETWORK_PRIVATE_H */
#include "xbt/dict.h"
typedef struct network_link_CM02 {
- s_surf_resource_lmm_t lmm_resource; /* must remain first to be added to a trace */
+ s_surf_resource_lmm_t lmm_resource; /* must remain first to be added to a trace */
/* Using this object with the public part of
model does not make sense */
int suspended;
#ifdef HAVE_TRACING
- char* src_name;
- char* dst_name;
+ char *src_name;
+ char *dst_name;
#endif
-
+
} s_surf_action_network_CM02_t, *surf_action_network_CM02_t;
-#endif /* _SURF_NETWORK_PRIVATE_H */
+#endif /* _SURF_NETWORK_PRIVATE_H */
} s_surf_action_network_Vivaldi_t, *surf_action_network_Vivaldi_t;
typedef struct s_netviva_coords {
- double x,y,h;
+ double x, y, h;
} s_netviva_coords_t, *netviva_coords_t;
-xbt_dict_t coords; /* Host name -> coordinates */
+xbt_dict_t coords; /* Host name -> coordinates */
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
static random_data_t random_latency_viva = NULL;
surfxml_add_callback(STag_surfxml_host_cb_list, &netviva_count_hosts);
}
-static int netviva_resource_used(void *resource_id) {
+static int netviva_resource_used(void *resource_id)
+{
/* nothing to do here */
return 0;
}
if (!action->refcount) {
xbt_swag_remove(action, action->state_set);
#ifdef HAVE_TRACING
- if (action->category) xbt_free (action->category);
+ if (action->category)
+ xbt_free(action->category);
#endif
free(action);
return 1;
static double netviva_share_resources(double now)
{
surf_action_network_Vivaldi_t action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
double min = -1.0;
xbt_swag_foreach(action, running_actions) {
return min;
}
-static void netviva_update_actions_state(double now, double delta) {
+static void netviva_update_actions_state(double now, double delta)
+{
/* Advance the actions by delta seconds */
surf_action_network_Vivaldi_t action = NULL;
surf_action_network_Vivaldi_t next_action = NULL;
- xbt_swag_t running_actions = surf_network_model->states.running_action_set;
+ xbt_swag_t running_actions =
+ surf_network_model->states.running_action_set;
xbt_swag_foreach_safe(action, next_action, running_actions) {
if (action->latency > 0) {
if (action->generic_action.max_duration != NO_MAX_DURATION)
double_update(&(action->generic_action.max_duration), delta);
- if (action->generic_action.remains <= 0) { /* This action is done, inform SURF about it */
+ if (action->generic_action.remains <= 0) { /* This action is done, inform SURF about it */
action->generic_action.finish = surf_get_clock();
surf_network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
}
static void netviva_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double time)
-{ /* Called as soon as there is a trace modification */
+ tmgr_trace_event_t event_type,
+ double value, double time)
+{ /* Called as soon as there is a trace modification */
DIE_IMPOSSIBLE;
}
-static surf_action_t netviva_communicate(const char *src_name, const char *dst_name,
- double size, double rate)
+static surf_action_t netviva_communicate(const char *src_name,
+ const char *dst_name, double size,
+ double rate)
{
surf_action_network_Vivaldi_t action = NULL;
- netviva_coords_t c1,c2;
- c1 = xbt_dict_get(coords,src_name);
- c2 = xbt_dict_get(coords,dst_name);
+ netviva_coords_t c1, c2;
+ c1 = xbt_dict_get(coords, src_name);
+ c2 = xbt_dict_get(coords, dst_name);
- action = surf_action_new(sizeof(s_surf_action_network_Vivaldi_t), size,surf_network_model, 0);
+ action =
+ surf_action_new(sizeof(s_surf_action_network_Vivaldi_t), size,
+ surf_network_model, 0);
action->suspended = 0;
- action->latency = sqrt((c1->x-c2->x)*(c1->x-c2->x) + (c1->y-c2->y)*(c1->y-c2->y)) + fabs(c1->h)+ fabs(c2->h) ; //random_generate(random_latency_viva);
+ action->latency = sqrt((c1->x - c2->x) * (c1->x - c2->x) + (c1->y - c2->y) * (c1->y - c2->y)) + fabs(c1->h) + fabs(c2->h); //random_generate(random_latency_viva);
action->lat_init = action->latency;
if (action->latency <= 0.0) {
action->generic_action.state_set =
- surf_network_model->states.done_action_set;
+ surf_network_model->states.done_action_set;
xbt_swag_insert(action, action->generic_action.state_set);
}
return ((surf_action_network_Vivaldi_t) action)->suspended;
}
-static void netviva_action_set_max_duration(surf_action_t action, double duration)
+static void netviva_action_set_max_duration(surf_action_t action,
+ double duration)
{
action->max_duration = duration;
}
surf_network_model = NULL;
}
-static void netviva_parse_host(void) {
- netviva_coords_t coord = xbt_new(s_netviva_coords_t,1);
+static void netviva_parse_host(void)
+{
+ netviva_coords_t coord = xbt_new(s_netviva_coords_t, 1);
- xbt_dynar_t ctn =xbt_str_split_str(A_surfxml_host_vivaldi," ");
+ xbt_dynar_t ctn = xbt_str_split_str(A_surfxml_host_vivaldi, " ");
- coord->x = atof(xbt_dynar_get_as(ctn, 0, char*));
- coord->y = atof(xbt_dynar_get_as(ctn, 1, char*));
- coord->h = atof(xbt_dynar_get_as(ctn, 2, char*));
+ coord->x = atof(xbt_dynar_get_as(ctn, 0, char *));
+ coord->y = atof(xbt_dynar_get_as(ctn, 1, char *));
+ coord->h = atof(xbt_dynar_get_as(ctn, 2, char *));
#ifdef HAVE_TRACING
- TRACE_surf_host_vivaldi_parse (A_surfxml_host_id, coord->x, coord->y, coord->h);
+ TRACE_surf_host_vivaldi_parse(A_surfxml_host_id, coord->x, coord->y,
+ coord->h);
#endif
xbt_dynar_free(&ctn);
- xbt_dict_set(coords, A_surfxml_host_id,coord,NULL);
+ xbt_dict_set(coords, A_surfxml_host_id, coord, NULL);
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
-static int netviva_get_latency_limited(surf_action_t action){
+static int netviva_get_latency_limited(surf_action_t action)
+{
return 0;
}
#endif
#endif
surf_network_model->model_private->resource_used = netviva_resource_used;
- surf_network_model->model_private->share_resources = netviva_share_resources;
+ surf_network_model->model_private->share_resources =
+ netviva_share_resources;
surf_network_model->model_private->update_actions_state =
- netviva_update_actions_state;
+ netviva_update_actions_state;
surf_network_model->model_private->update_resource_state =
- netviva_update_resource_state;
+ netviva_update_resource_state;
surf_network_model->model_private->finalize = netviva_finalize;
surf_network_model->suspend = netviva_action_suspend;
surf_network_model->extension.network.communicate = netviva_communicate;
surf_network_model->extension.network.get_link_bandwidth =
- netviva_get_link_bandwidth;
- surf_network_model->extension.network.get_link_latency = netviva_get_link_latency;
+ netviva_get_link_bandwidth;
+ surf_network_model->extension.network.get_link_latency =
+ netviva_get_link_latency;
surf_network_model->extension.network.link_shared = netviva_link_shared;
if (!random_latency_viva)
"Vivaldi", surf_network_model);
#ifdef HAVE_TRACING
- TRACE_user_host_variable(0,"vivaldi_x",0,"declare");
- TRACE_user_host_variable(0,"vivaldi_y",0,"declare");
- TRACE_user_host_variable(0,"vivaldi_h",0,"declare");
+ TRACE_user_host_variable(0, "vivaldi_x", 0, "declare");
+ TRACE_user_host_variable(0, "vivaldi_y", 0, "declare");
+ TRACE_user_host_variable(0, "vivaldi_h", 0, "declare");
#endif
xbt_cfg_set_string(_surf_cfg_set, "routing", "none");
routing_model_create(sizeof(double), NULL);
}
-
return 0;
}
-int _drand48_iterate(unsigned short int xsubi[3], struct drand48_data *buffer)
+int _drand48_iterate(unsigned short int xsubi[3],
+ struct drand48_data *buffer)
{
uint64_t X;
uint64_t result;
{
double result;
- (void) _erand48_r(__libc_drand48_data.__x, &__libc_drand48_data, &result);
+ (void) _erand48_r(__libc_drand48_data.__x, &__libc_drand48_data,
+ &result);
return result;
}
if (random->std == 0)
return random->mean * (random->max - random->min) + random->min;
- a =
- random->mean * (random->mean * (1 - random->mean) /
- (random->std * random->std) - 1);
- b =
- (1 -
- random->mean) * (random->mean * (1 -
- random->mean) / (random->std *
- random->std) - 1);
+ a = random->mean * (random->mean * (1 - random->mean) /
+ (random->std * random->std) - 1);
+ b = (1 -
+ random->mean) * (random->mean * (1 -
+ random->mean) / (random->std *
+ random->std) - 1);
alpha = a + b;
if (a <= 1. || b <= 1.)
if (max < min)
THROW2(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
if (mean < min)
- THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean, min);
+ THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
+ min);
if (mean > max)
- THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean, max);
+ THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
+ max);
/* normalize the mean and standard deviation before storing */
random->mean = (mean - min) / (max - min);
#define YY_RESTORE_YY_MORE_OFFSET
char *surf_parse_text;
/* Validating XML processor for src/surf/simgrid.dtd.
- * Generated 2010/10/06 17:47:05.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
/* Validating XML processor for src/surf/simgrid.dtd.
- * Generated 2010/10/01 22:34:13.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
#define A_surfxml_random_generator AX_surfxml_random_generator
AT_surfxml_ASroute_gw_dst AX_surfxml_ASroute_gw_dst;
#define A_surfxml_ASroute_gw_dst (surfxml_bufferstack + AX_surfxml_ASroute_gw_dst)
+AT_surfxml_link_id AX_surfxml_link_id;
+#define A_surfxml_link_id (surfxml_bufferstack + AX_surfxml_link_id)
AT_surfxml_trace_connect_element AX_surfxml_trace_connect_element;
#define A_surfxml_trace_connect_element (surfxml_bufferstack + AX_surfxml_trace_connect_element)
AT_surfxml_prop_id AX_surfxml_prop_id;
#define A_surfxml_prop_id (surfxml_bufferstack + AX_surfxml_prop_id)
-AT_surfxml_host_interference_recv AX_surfxml_host_interference_recv;
-#define A_surfxml_host_interference_recv (surfxml_bufferstack + AX_surfxml_host_interference_recv)
AT_surfxml_host_id AX_surfxml_host_id;
#define A_surfxml_host_id (surfxml_bufferstack + AX_surfxml_host_id)
AT_surfxml_link_latency_file AX_surfxml_link_latency_file;
#define A_surfxml_link_latency_file (surfxml_bufferstack + AX_surfxml_link_latency_file)
+AT_surfxml_process_host AX_surfxml_process_host;
+#define A_surfxml_process_host (surfxml_bufferstack + AX_surfxml_process_host)
+AT_surfxml_cluster_lat AX_surfxml_cluster_lat;
+#define A_surfxml_cluster_lat (surfxml_bufferstack + AX_surfxml_cluster_lat)
AT_surfxml_host_state AX_surfxml_host_state;
#define A_surfxml_host_state AX_surfxml_host_state
-AT_surfxml_host_interference_send_recv AX_surfxml_host_interference_send_recv;
-#define A_surfxml_host_interference_send_recv (surfxml_bufferstack + AX_surfxml_host_interference_send_recv)
-AT_surfxml_host_interference_send AX_surfxml_host_interference_send;
-#define A_surfxml_host_interference_send (surfxml_bufferstack + AX_surfxml_host_interference_send)
+AT_surfxml_host_availability_file AX_surfxml_host_availability_file;
+#define A_surfxml_host_availability_file (surfxml_bufferstack + AX_surfxml_host_availability_file)
+AT_surfxml_trace_periodicity AX_surfxml_trace_periodicity;
+#define A_surfxml_trace_periodicity (surfxml_bufferstack + AX_surfxml_trace_periodicity)
+AT_surfxml_prop_value AX_surfxml_prop_value;
+#define A_surfxml_prop_value (surfxml_bufferstack + AX_surfxml_prop_value)
AT_surfxml_AS_id AX_surfxml_AS_id;
#define A_surfxml_AS_id (surfxml_bufferstack + AX_surfxml_AS_id)
+AT_surfxml_ASroute_dst AX_surfxml_ASroute_dst;
+#define A_surfxml_ASroute_dst (surfxml_bufferstack + AX_surfxml_ASroute_dst)
AT_surfxml_host_power AX_surfxml_host_power;
#define A_surfxml_host_power (surfxml_bufferstack + AX_surfxml_host_power)
+AT_surfxml_link_state_file AX_surfxml_link_state_file;
+#define A_surfxml_link_state_file (surfxml_bufferstack + AX_surfxml_link_state_file)
AT_surfxml_router_id AX_surfxml_router_id;
#define A_surfxml_router_id (surfxml_bufferstack + AX_surfxml_router_id)
+AT_surfxml_trace_connect_trace AX_surfxml_trace_connect_trace;
+#define A_surfxml_trace_connect_trace (surfxml_bufferstack + AX_surfxml_trace_connect_trace)
AT_surfxml_process_start_time AX_surfxml_process_start_time;
#define A_surfxml_process_start_time (surfxml_bufferstack + AX_surfxml_process_start_time)
AT_surfxml_cluster_suffix AX_surfxml_cluster_suffix;
#define A_surfxml_cluster_suffix (surfxml_bufferstack + AX_surfxml_cluster_suffix)
-AT_surfxml_platform_xmlns_c_route AX_surfxml_platform_xmlns_c_route;
-#define A_surfxml_platform_xmlns_c_route (surfxml_bufferstack + AX_surfxml_platform_xmlns_c_route)
+AT_surfxml_cluster_power AX_surfxml_cluster_power;
+#define A_surfxml_cluster_power (surfxml_bufferstack + AX_surfxml_cluster_power)
+AT_surfxml_process_function AX_surfxml_process_function;
+#define A_surfxml_process_function (surfxml_bufferstack + AX_surfxml_process_function)
AT_surfxml_ASroute_src AX_surfxml_ASroute_src;
#define A_surfxml_ASroute_src (surfxml_bufferstack + AX_surfxml_ASroute_src)
AT_surfxml_cluster_prefix AX_surfxml_cluster_prefix;
#define A_surfxml_link_sharing_policy AX_surfxml_link_sharing_policy
AT_surfxml_random_min AX_surfxml_random_min;
#define A_surfxml_random_min (surfxml_bufferstack + AX_surfxml_random_min)
+AT_surfxml_bypassRoute_dst AX_surfxml_bypassRoute_dst;
+#define A_surfxml_bypassRoute_dst (surfxml_bufferstack + AX_surfxml_bypassRoute_dst)
AT_surfxml_link_ctn_id AX_surfxml_link_ctn_id;
#define A_surfxml_link_ctn_id (surfxml_bufferstack + AX_surfxml_link_ctn_id)
AT_surfxml_process_kill_time AX_surfxml_process_kill_time;
#define A_surfxml_process_kill_time (surfxml_bufferstack + AX_surfxml_process_kill_time)
+AT_surfxml_host_availability AX_surfxml_host_availability;
+#define A_surfxml_host_availability (surfxml_bufferstack + AX_surfxml_host_availability)
AT_surfxml_cluster_bb_bw AX_surfxml_cluster_bb_bw;
#define A_surfxml_cluster_bb_bw (surfxml_bufferstack + AX_surfxml_cluster_bb_bw)
AT_surfxml_argument_value AX_surfxml_argument_value;
#define A_surfxml_argument_value (surfxml_bufferstack + AX_surfxml_argument_value)
+AT_surfxml_bypassRoute_src AX_surfxml_bypassRoute_src;
+#define A_surfxml_bypassRoute_src (surfxml_bufferstack + AX_surfxml_bypassRoute_src)
AT_surfxml_link_state AX_surfxml_link_state;
#define A_surfxml_link_state AX_surfxml_link_state
AT_surfxml_ASroute_gw_src AX_surfxml_ASroute_gw_src;
#define A_surfxml_ASroute_gw_src (surfxml_bufferstack + AX_surfxml_ASroute_gw_src)
+AT_surfxml_route_src AX_surfxml_route_src;
+#define A_surfxml_route_src (surfxml_bufferstack + AX_surfxml_route_src)
AT_surfxml_AS_routing AX_surfxml_AS_routing;
#define A_surfxml_AS_routing (surfxml_bufferstack + AX_surfxml_AS_routing)
AT_surfxml_link_bandwidth AX_surfxml_link_bandwidth;
#define A_surfxml_link_bandwidth (surfxml_bufferstack + AX_surfxml_link_bandwidth)
+AT_surfxml_bypassRoute_gw_dst AX_surfxml_bypassRoute_gw_dst;
+#define A_surfxml_bypassRoute_gw_dst (surfxml_bufferstack + AX_surfxml_bypassRoute_gw_dst)
AT_surfxml_cluster_id AX_surfxml_cluster_id;
#define A_surfxml_cluster_id (surfxml_bufferstack + AX_surfxml_cluster_id)
AT_surfxml_random_mean AX_surfxml_random_mean;
#define A_surfxml_random_mean (surfxml_bufferstack + AX_surfxml_random_mean)
+AT_surfxml_trace_id AX_surfxml_trace_id;
+#define A_surfxml_trace_id (surfxml_bufferstack + AX_surfxml_trace_id)
AT_surfxml_cluster_bb_lat AX_surfxml_cluster_bb_lat;
#define A_surfxml_cluster_bb_lat (surfxml_bufferstack + AX_surfxml_cluster_bb_lat)
AT_surfxml_link_latency AX_surfxml_link_latency;
#define A_surfxml_link_latency (surfxml_bufferstack + AX_surfxml_link_latency)
+AT_surfxml_cluster_radical AX_surfxml_cluster_radical;
+#define A_surfxml_cluster_radical (surfxml_bufferstack + AX_surfxml_cluster_radical)
+AT_surfxml_config_id AX_surfxml_config_id;
+#define A_surfxml_config_id (surfxml_bufferstack + AX_surfxml_config_id)
AT_surfxml_trace_connect_kind AX_surfxml_trace_connect_kind;
#define A_surfxml_trace_connect_kind AX_surfxml_trace_connect_kind
-AT_surfxml_platform_xmlns_c_link AX_surfxml_platform_xmlns_c_link;
-#define A_surfxml_platform_xmlns_c_link (surfxml_bufferstack + AX_surfxml_platform_xmlns_c_link)
+AT_surfxml_bypassRoute_gw_src AX_surfxml_bypassRoute_gw_src;
+#define A_surfxml_bypassRoute_gw_src (surfxml_bufferstack + AX_surfxml_bypassRoute_gw_src)
+AT_surfxml_random_std_deviation AX_surfxml_random_std_deviation;
+#define A_surfxml_random_std_deviation (surfxml_bufferstack + AX_surfxml_random_std_deviation)
AT_surfxml_link_bandwidth_file AX_surfxml_link_bandwidth_file;
#define A_surfxml_link_bandwidth_file (surfxml_bufferstack + AX_surfxml_link_bandwidth_file)
AT_surfxml_host_vivaldi AX_surfxml_host_vivaldi;
#define A_surfxml_host_vivaldi (surfxml_bufferstack + AX_surfxml_host_vivaldi)
-AT_surfxml_random_id AX_surfxml_random_id;
-#define A_surfxml_random_id (surfxml_bufferstack + AX_surfxml_random_id)
-AT_surfxml_random_max AX_surfxml_random_max;
-#define A_surfxml_random_max (surfxml_bufferstack + AX_surfxml_random_max)
-AT_surfxml_link_id AX_surfxml_link_id;
-#define A_surfxml_link_id (surfxml_bufferstack + AX_surfxml_link_id)
-AT_surfxml_process_host AX_surfxml_process_host;
-#define A_surfxml_process_host (surfxml_bufferstack + AX_surfxml_process_host)
-AT_surfxml_host_availability_file AX_surfxml_host_availability_file;
-#define A_surfxml_host_availability_file (surfxml_bufferstack + AX_surfxml_host_availability_file)
-AT_surfxml_cluster_lat AX_surfxml_cluster_lat;
-#define A_surfxml_cluster_lat (surfxml_bufferstack + AX_surfxml_cluster_lat)
-AT_surfxml_trace_periodicity AX_surfxml_trace_periodicity;
-#define A_surfxml_trace_periodicity (surfxml_bufferstack + AX_surfxml_trace_periodicity)
-AT_surfxml_prop_value AX_surfxml_prop_value;
-#define A_surfxml_prop_value (surfxml_bufferstack + AX_surfxml_prop_value)
-AT_surfxml_ASroute_dst AX_surfxml_ASroute_dst;
-#define A_surfxml_ASroute_dst (surfxml_bufferstack + AX_surfxml_ASroute_dst)
-AT_surfxml_link_state_file AX_surfxml_link_state_file;
-#define A_surfxml_link_state_file (surfxml_bufferstack + AX_surfxml_link_state_file)
-AT_surfxml_trace_connect_trace AX_surfxml_trace_connect_trace;
-#define A_surfxml_trace_connect_trace (surfxml_bufferstack + AX_surfxml_trace_connect_trace)
-AT_surfxml_cluster_power AX_surfxml_cluster_power;
-#define A_surfxml_cluster_power (surfxml_bufferstack + AX_surfxml_cluster_power)
-AT_surfxml_process_function AX_surfxml_process_function;
-#define A_surfxml_process_function (surfxml_bufferstack + AX_surfxml_process_function)
-AT_surfxml_host_max_outgoing_rate AX_surfxml_host_max_outgoing_rate;
-#define A_surfxml_host_max_outgoing_rate (surfxml_bufferstack + AX_surfxml_host_max_outgoing_rate)
-AT_surfxml_bypassRoute_dst AX_surfxml_bypassRoute_dst;
-#define A_surfxml_bypassRoute_dst (surfxml_bufferstack + AX_surfxml_bypassRoute_dst)
-AT_surfxml_host_availability AX_surfxml_host_availability;
-#define A_surfxml_host_availability (surfxml_bufferstack + AX_surfxml_host_availability)
-AT_surfxml_bypassRoute_src AX_surfxml_bypassRoute_src;
-#define A_surfxml_bypassRoute_src (surfxml_bufferstack + AX_surfxml_bypassRoute_src)
-AT_surfxml_route_src AX_surfxml_route_src;
-#define A_surfxml_route_src (surfxml_bufferstack + AX_surfxml_route_src)
-AT_surfxml_bypassRoute_gw_dst AX_surfxml_bypassRoute_gw_dst;
-#define A_surfxml_bypassRoute_gw_dst (surfxml_bufferstack + AX_surfxml_bypassRoute_gw_dst)
-AT_surfxml_trace_id AX_surfxml_trace_id;
-#define A_surfxml_trace_id (surfxml_bufferstack + AX_surfxml_trace_id)
-AT_surfxml_cluster_radical AX_surfxml_cluster_radical;
-#define A_surfxml_cluster_radical (surfxml_bufferstack + AX_surfxml_cluster_radical)
-AT_surfxml_random_std_deviation AX_surfxml_random_std_deviation;
-#define A_surfxml_random_std_deviation (surfxml_bufferstack + AX_surfxml_random_std_deviation)
-AT_surfxml_bypassRoute_gw_src AX_surfxml_bypassRoute_gw_src;
-#define A_surfxml_bypassRoute_gw_src (surfxml_bufferstack + AX_surfxml_bypassRoute_gw_src)
AT_surfxml_host_state_file AX_surfxml_host_state_file;
#define A_surfxml_host_state_file (surfxml_bufferstack + AX_surfxml_host_state_file)
+AT_surfxml_random_id AX_surfxml_random_id;
+#define A_surfxml_random_id (surfxml_bufferstack + AX_surfxml_random_id)
AT_surfxml_route_dst AX_surfxml_route_dst;
#define A_surfxml_route_dst (surfxml_bufferstack + AX_surfxml_route_dst)
AT_surfxml_cluster_bw AX_surfxml_cluster_bw;
#define A_surfxml_cluster_bw (surfxml_bufferstack + AX_surfxml_cluster_bw)
+AT_surfxml_random_max AX_surfxml_random_max;
+#define A_surfxml_random_max (surfxml_bufferstack + AX_surfxml_random_max)
AT_surfxml_platform_version AX_surfxml_platform_version;
#define A_surfxml_platform_version (surfxml_bufferstack + AX_surfxml_platform_version)
* IMPOSSIBLE dummy to permit disabling rules; must be last
*/
%x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
-%x ROOT_surfxml_platform AL_surfxml_platform S_surfxml_platform S_surfxml_platform_1 S_surfxml_platform_2 S_surfxml_platform_3 S_surfxml_platform_4 S_surfxml_platform_5 S_surfxml_platform_6 S_surfxml_platform_7 S_surfxml_platform_8 E_surfxml_platform
+%x ROOT_surfxml_platform AL_surfxml_platform S_surfxml_platform S_surfxml_platform_1 S_surfxml_platform_2 S_surfxml_platform_3 S_surfxml_platform_4 S_surfxml_platform_5 S_surfxml_platform_6 E_surfxml_platform
%x AL_surfxml_trace IN_trace
%x AL_surfxml_random S_surfxml_random S_surfxml_random_1 S_surfxml_random_2 E_surfxml_random
%x AL_surfxml_trace_connect E_surfxml_trace_connect
%x AL_surfxml_bypassRoute S_surfxml_bypassRoute S_surfxml_bypassRoute_1 S_surfxml_bypassRoute_2 E_surfxml_bypassRoute
%x AL_surfxml_process S_surfxml_process S_surfxml_process_1 S_surfxml_process_2 E_surfxml_process
%x AL_surfxml_argument E_surfxml_argument
+%x AL_surfxml_config S_surfxml_config S_surfxml_config_1 S_surfxml_config_2 E_surfxml_config
%x AL_surfxml_prop E_surfxml_prop
%x IMPOSSIBLE
/* FleXML_init */
bnext = inext = 1;
surfxml_bufferliteral('\0', &bnext, "0.0");
- surfxml_bufferliteral('\0', &bnext, "http://simgrid.gforge.inria.fr/");
- surfxml_bufferliteral('\0', &bnext, "http://simgrid.gforge.inria.fr/");
- surfxml_bufferliteral('\0', &bnext, "1.0");
- surfxml_bufferliteral('\0', &bnext, "1.0");
- surfxml_bufferliteral('\0', &bnext, "1.0");
surfxml_bufferliteral('\0', &bnext, "1.0");
- surfxml_bufferliteral('\0', &bnext, "-1.0");
surfxml_bufferliteral('\0', &bnext, "0 0 0");
surfxml_bufferliteral('\0', &bnext, "0.0");
surfxml_bufferliteral('\0', &bnext, "-1.0");
surfxml_statenames[S_surfxml_platform_4] = "platform";
surfxml_statenames[S_surfxml_platform_5] = "platform";
surfxml_statenames[S_surfxml_platform_6] = "platform";
- surfxml_statenames[S_surfxml_platform_7] = "platform";
- surfxml_statenames[S_surfxml_platform_8] = "platform";
surfxml_statenames[E_surfxml_platform] = "platform";
surfxml_statenames[AL_surfxml_trace] = NULL;
surfxml_statenames[IN_trace] = "trace";
surfxml_statenames[E_surfxml_process] = "process";
surfxml_statenames[AL_surfxml_argument] = NULL;
surfxml_statenames[E_surfxml_argument] = "argument";
+ surfxml_statenames[AL_surfxml_config] = NULL;
+ surfxml_statenames[S_surfxml_config] = "config";
+ surfxml_statenames[S_surfxml_config_1] = "config";
+ surfxml_statenames[S_surfxml_config_2] = "config";
+ surfxml_statenames[E_surfxml_config] = "config";
surfxml_statenames[AL_surfxml_prop] = NULL;
surfxml_statenames[E_surfxml_prop] = "prop";
}
/* COMMENTS and PIs: handled uniformly for efficiency. */
-<ROOT_surfxml_platform,AL_surfxml_platform,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_platform_2,S_surfxml_platform_3,S_surfxml_platform_4,S_surfxml_platform_5,S_surfxml_platform_6,S_surfxml_platform_7,S_surfxml_platform_8,E_surfxml_platform,AL_surfxml_trace,IN_trace,AL_surfxml_random,S_surfxml_random,S_surfxml_random_1,S_surfxml_random_2,E_surfxml_random,AL_surfxml_trace_connect,E_surfxml_trace_connect,AL_surfxml_AS,S_surfxml_AS,S_surfxml_AS_1,S_surfxml_AS_2,S_surfxml_AS_3,S_surfxml_AS_4,S_surfxml_AS_5,S_surfxml_AS_6,S_surfxml_AS_7,S_surfxml_AS_8,S_surfxml_AS_9,S_surfxml_AS_10,S_surfxml_AS_11,S_surfxml_AS_12,S_surfxml_AS_13,E_surfxml_AS,AL_surfxml_host,S_surfxml_host,S_surfxml_host_1,S_surfxml_host_2,E_surfxml_host,AL_surfxml_cluster,E_surfxml_cluster,AL_surfxml_router,E_surfxml_router,AL_surfxml_link,S_surfxml_link,S_surfxml_link_1,S_surfxml_link_2,E_surfxml_link,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,AL_surfxml_ASroute,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2,E_surfxml_ASroute,AL_surfxml_link_ctn,E_surfxml_link_ctn,AL_surfxml_bypassRoute,S_surfxml_bypassRoute,S_surfxml_bypassRoute_1,S_surfxml_bypassRoute_2,E_surfxml_bypassRoute,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,AL_surfxml_argument,E_surfxml_argument,AL_surfxml_prop,E_surfxml_prop,PROLOG,DOCTYPE,EPILOG>{
+<ROOT_surfxml_platform,AL_surfxml_platform,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_platform_2,S_surfxml_platform_3,S_surfxml_platform_4,S_surfxml_platform_5,S_surfxml_platform_6,E_surfxml_platform,AL_surfxml_trace,IN_trace,AL_surfxml_random,S_surfxml_random,S_surfxml_random_1,S_surfxml_random_2,E_surfxml_random,AL_surfxml_trace_connect,E_surfxml_trace_connect,AL_surfxml_AS,S_surfxml_AS,S_surfxml_AS_1,S_surfxml_AS_2,S_surfxml_AS_3,S_surfxml_AS_4,S_surfxml_AS_5,S_surfxml_AS_6,S_surfxml_AS_7,S_surfxml_AS_8,S_surfxml_AS_9,S_surfxml_AS_10,S_surfxml_AS_11,S_surfxml_AS_12,S_surfxml_AS_13,E_surfxml_AS,AL_surfxml_host,S_surfxml_host,S_surfxml_host_1,S_surfxml_host_2,E_surfxml_host,AL_surfxml_cluster,E_surfxml_cluster,AL_surfxml_router,E_surfxml_router,AL_surfxml_link,S_surfxml_link,S_surfxml_link_1,S_surfxml_link_2,E_surfxml_link,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,AL_surfxml_ASroute,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2,E_surfxml_ASroute,AL_surfxml_link_ctn,E_surfxml_link_ctn,AL_surfxml_bypassRoute,S_surfxml_bypassRoute,S_surfxml_bypassRoute_1,S_surfxml_bypassRoute_2,E_surfxml_bypassRoute,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,AL_surfxml_argument,E_surfxml_argument,AL_surfxml_config,S_surfxml_config,S_surfxml_config_1,S_surfxml_config_2,E_surfxml_config,AL_surfxml_prop,E_surfxml_prop,PROLOG,DOCTYPE,EPILOG>{
"<!--" ENTER(INCOMMENT);
"<?" ENTER(INPI);
}
/* SPACES: skipped uniformly */
-<ROOT_surfxml_platform,AL_surfxml_platform,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_platform_2,S_surfxml_platform_3,S_surfxml_platform_4,S_surfxml_platform_5,S_surfxml_platform_6,S_surfxml_platform_7,S_surfxml_platform_8,E_surfxml_platform,AL_surfxml_trace,AL_surfxml_random,S_surfxml_random,S_surfxml_random_1,S_surfxml_random_2,E_surfxml_random,AL_surfxml_trace_connect,E_surfxml_trace_connect,AL_surfxml_AS,S_surfxml_AS,S_surfxml_AS_1,S_surfxml_AS_2,S_surfxml_AS_3,S_surfxml_AS_4,S_surfxml_AS_5,S_surfxml_AS_6,S_surfxml_AS_7,S_surfxml_AS_8,S_surfxml_AS_9,S_surfxml_AS_10,S_surfxml_AS_11,S_surfxml_AS_12,S_surfxml_AS_13,E_surfxml_AS,AL_surfxml_host,S_surfxml_host,S_surfxml_host_1,S_surfxml_host_2,E_surfxml_host,AL_surfxml_cluster,E_surfxml_cluster,AL_surfxml_router,E_surfxml_router,AL_surfxml_link,S_surfxml_link,S_surfxml_link_1,S_surfxml_link_2,E_surfxml_link,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,AL_surfxml_ASroute,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2,E_surfxml_ASroute,AL_surfxml_link_ctn,E_surfxml_link_ctn,AL_surfxml_bypassRoute,S_surfxml_bypassRoute,S_surfxml_bypassRoute_1,S_surfxml_bypassRoute_2,E_surfxml_bypassRoute,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,AL_surfxml_argument,E_surfxml_argument,AL_surfxml_prop,E_surfxml_prop,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
+<ROOT_surfxml_platform,AL_surfxml_platform,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_platform_2,S_surfxml_platform_3,S_surfxml_platform_4,S_surfxml_platform_5,S_surfxml_platform_6,E_surfxml_platform,AL_surfxml_trace,AL_surfxml_random,S_surfxml_random,S_surfxml_random_1,S_surfxml_random_2,E_surfxml_random,AL_surfxml_trace_connect,E_surfxml_trace_connect,AL_surfxml_AS,S_surfxml_AS,S_surfxml_AS_1,S_surfxml_AS_2,S_surfxml_AS_3,S_surfxml_AS_4,S_surfxml_AS_5,S_surfxml_AS_6,S_surfxml_AS_7,S_surfxml_AS_8,S_surfxml_AS_9,S_surfxml_AS_10,S_surfxml_AS_11,S_surfxml_AS_12,S_surfxml_AS_13,E_surfxml_AS,AL_surfxml_host,S_surfxml_host,S_surfxml_host_1,S_surfxml_host_2,E_surfxml_host,AL_surfxml_cluster,E_surfxml_cluster,AL_surfxml_router,E_surfxml_router,AL_surfxml_link,S_surfxml_link,S_surfxml_link_1,S_surfxml_link_2,E_surfxml_link,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,AL_surfxml_ASroute,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2,E_surfxml_ASroute,AL_surfxml_link_ctn,E_surfxml_link_ctn,AL_surfxml_bypassRoute,S_surfxml_bypassRoute,S_surfxml_bypassRoute_1,S_surfxml_bypassRoute_2,E_surfxml_bypassRoute,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,AL_surfxml_argument,E_surfxml_argument,AL_surfxml_config,S_surfxml_config,S_surfxml_config_1,S_surfxml_config_2,E_surfxml_config,AL_surfxml_prop,E_surfxml_prop,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
/* PROLOG: determine root element and process it. */
/* <!-- Small DTD for SURF based tools. --> */
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_AS_6,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<platform"{s} FAIL("Starting tag <platform> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_AS_6,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<platform"{s} FAIL("Starting tag <platform> is not allowed here.");
<ROOT_surfxml_platform>"<platform"{s} {
AX_surfxml_platform_version = 1;
- AX_surfxml_platform_xmlns_c_link = 5;
- AX_surfxml_platform_xmlns_c_route = 37;
ENTER(AL_surfxml_platform); pushbuffer(0);
}
"version"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_platform_version);
"version"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_platform_version);
- "xmlns:link"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_platform_xmlns_c_link);
- "xmlns:link"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_platform_xmlns_c_link);
-
- "xmlns:route"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_platform_xmlns_c_route);
- "xmlns:route"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_platform_xmlns_c_route);
-
">" {
LEAVE; STag_surfxml_platform();surfxml_pcdata_ix = 0; ENTER(S_surfxml_platform);
}
<<EOF>> FAIL("EOF in attribute list of `platform' element.");
}
-<S_surfxml_platform_8,S_surfxml_platform_1,S_surfxml_platform_3,S_surfxml_platform,S_surfxml_platform_4,S_surfxml_platform_6,E_surfxml_platform>{
+<S_surfxml_platform_2,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_4,S_surfxml_platform_6,E_surfxml_platform>{
"</platform"{s}">" {
LEAVE;
ETag_surfxml_platform();
<<EOF>> FAIL("Premature EOF: `</platform>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,ROOT_surfxml_trace,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<trace"{s} FAIL("Starting tag <trace> is not allowed here.");
+<ROOT_surfxml_trace,S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_config_1,S_surfxml_route,E_surfxml_bypassRoute>"<trace"{s} FAIL("Starting tag <trace> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_platform_1,S_surfxml_platform_3,S_surfxml_platform,S_surfxml_platform_6>"<trace"{s} {
+<S_surfxml_AS_12,S_surfxml_AS_1,S_surfxml_AS_9,S_surfxml_AS_11,S_surfxml_AS_2,S_surfxml_AS_5,S_surfxml_AS_10,S_surfxml_AS_13,S_surfxml_AS,S_surfxml_AS_8,S_surfxml_platform_4,S_surfxml_AS_4,S_surfxml_AS_7,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_AS_6,S_surfxml_AS_3,S_surfxml_platform_3>"<trace"{s} {
AX_surfxml_trace_id = 0;
AX_surfxml_trace_file = 0;
AX_surfxml_trace_periodicity = 0;
if (!AX_surfxml_trace_periodicity) FAIL("Required attribute `periodicity' not set for `trace' element.");
LEAVE; STag_surfxml_trace(); surfxml_pcdata_ix = 0; ETag_surfxml_trace(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform_3: case S_surfxml_platform: case S_surfxml_platform_6: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
+ case S_surfxml_AS_2: SET(S_surfxml_AS_3); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
+ case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_13: SET(S_surfxml_AS_13); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of trace element.", yytext[0]);
surfxml_pcdata_ix = popbuffer();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform_3: case S_surfxml_platform: case S_surfxml_platform_6: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
+ case S_surfxml_AS_2: SET(S_surfxml_AS_3); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
+ case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_13: SET(S_surfxml_AS_13); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</trace>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</trace>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,ROOT_surfxml_random,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<random"{s} FAIL("Starting tag <random> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,ROOT_surfxml_random,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<random"{s} FAIL("Starting tag <random> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_platform_1,S_surfxml_platform_3,S_surfxml_platform,S_surfxml_platform_6>"<random"{s} {
+<S_surfxml_config>"<random"{s} {
AX_surfxml_random_id = 0;
AX_surfxml_random_min = 0;
AX_surfxml_random_max = 0;
if (!AX_surfxml_random_std_deviation) FAIL("Required attribute `std_deviation' not set for `random' element.");
LEAVE; STag_surfxml_random(); surfxml_pcdata_ix = 0; ETag_surfxml_random(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform_3: case S_surfxml_platform: case S_surfxml_platform_6: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_config: SET(E_surfxml_config); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of random element.", yytext[0]);
ETag_surfxml_random();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform_3: case S_surfxml_platform: case S_surfxml_platform_6: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_config: SET(E_surfxml_config); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</random>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</random>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,ROOT_surfxml_trace_connect,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<trace_connect"{s} FAIL("Starting tag <trace_connect> is not allowed here.");
+<S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_bypassRoute_1,E_surfxml_config,ROOT_surfxml_trace_connect,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_config_1,S_surfxml_route,E_surfxml_bypassRoute>"<trace_connect"{s} FAIL("Starting tag <trace_connect> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_platform_8,S_surfxml_platform_7,S_surfxml_platform_3,S_surfxml_platform_4>"<trace_connect"{s} {
+<S_surfxml_AS_12,S_surfxml_AS_1,S_surfxml_AS_9,S_surfxml_AS_11,S_surfxml_AS_2,S_surfxml_AS_5,S_surfxml_AS_10,S_surfxml_AS_13,S_surfxml_AS,S_surfxml_AS_8,S_surfxml_platform_4,S_surfxml_AS_4,S_surfxml_AS_7,S_surfxml_platform_1,S_surfxml_AS_6,S_surfxml_platform,S_surfxml_AS_3,S_surfxml_platform_3>"<trace_connect"{s} {
AX_surfxml_trace_connect_kind = A_surfxml_trace_connect_kind_HOST_AVAIL;
AX_surfxml_trace_connect_trace = 0;
AX_surfxml_trace_connect_element = 0;
if (!AX_surfxml_trace_connect_element) FAIL("Required attribute `element' not set for `trace_connect' element.");
LEAVE; STag_surfxml_trace_connect(); surfxml_pcdata_ix = 0; ETag_surfxml_trace_connect(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
+ case S_surfxml_AS_2: SET(S_surfxml_AS_3); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
+ case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_13: SET(S_surfxml_AS_13); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of trace_connect element.", yytext[0]);
ETag_surfxml_trace_connect();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_5: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
+ case S_surfxml_AS_2: SET(S_surfxml_AS_3); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
+ case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_13: SET(S_surfxml_AS_13); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</trace_connect>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</trace_connect>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,ROOT_surfxml_AS,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<AS"{s} FAIL("Starting tag <AS> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,ROOT_surfxml_AS,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<AS"{s} FAIL("Starting tag <AS> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_AS_2,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_AS_3,S_surfxml_AS,S_surfxml_platform_3>"<AS"{s} {
+<S_surfxml_AS_2,S_surfxml_AS,S_surfxml_platform_4,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_AS_3,S_surfxml_platform_3>"<AS"{s} {
AX_surfxml_AS_id = 0;
AX_surfxml_AS_routing = 0;
ENTER(AL_surfxml_AS); pushbuffer(0);
if (!AX_surfxml_AS_routing) FAIL("Required attribute `routing' not set for `AS' element.");
LEAVE; STag_surfxml_AS(); surfxml_pcdata_ix = 0; ETag_surfxml_AS(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_2: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_2: case S_surfxml_AS: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of AS element.", yytext[0]);
ETag_surfxml_AS();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_2: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_2: case S_surfxml_AS: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</AS>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</AS>' expected.");
}
-<S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,ROOT_surfxml_host,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<host"{s} FAIL("Starting tag <host> is not allowed here.");
+<S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,ROOT_surfxml_host,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<host"{s} FAIL("Starting tag <host> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_AS_11,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_AS_10,S_surfxml_AS,S_surfxml_platform_3>"<host"{s} {
+<S_surfxml_AS_11,S_surfxml_AS_10,S_surfxml_AS>"<host"{s} {
AX_surfxml_host_id = 0;
AX_surfxml_host_power = 0;
- AX_surfxml_host_availability = 69;
+ AX_surfxml_host_availability = 5;
AX_surfxml_host_availability_file = 0;
AX_surfxml_host_state = A_surfxml_host_state_ON;
AX_surfxml_host_state_file = 0;
- AX_surfxml_host_interference_send = 73;
- AX_surfxml_host_interference_recv = 77;
- AX_surfxml_host_interference_send_recv = 81;
- AX_surfxml_host_max_outgoing_rate = 85;
- AX_surfxml_host_vivaldi = 90;
+ AX_surfxml_host_vivaldi = 9;
ENTER(AL_surfxml_host); pushbuffer(0);
}
"state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_state_file);
"state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_state_file);
- "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_interference_send);
- "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_interference_send);
-
- "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_interference_recv);
- "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_interference_recv);
-
- "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_interference_send_recv);
- "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_interference_send_recv);
-
- "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_max_outgoing_rate);
- "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_max_outgoing_rate);
-
"vivaldi"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_host_vivaldi);
"vivaldi"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_host_vivaldi);
LEAVE; STag_surfxml_host(); surfxml_pcdata_ix = 0; ETag_surfxml_host(); popbuffer(); /* attribute */
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of host element.", yytext[0]);
popbuffer(); /* attribute */
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</host>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</host>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,ROOT_surfxml_cluster,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<cluster"{s} FAIL("Starting tag <cluster> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,ROOT_surfxml_cluster,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<cluster"{s} FAIL("Starting tag <cluster> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_AS_2,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_AS_3,S_surfxml_AS,S_surfxml_platform_3>"<cluster"{s} {
+<S_surfxml_AS_2,S_surfxml_AS,S_surfxml_platform_4,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_AS_3,S_surfxml_platform_3>"<cluster"{s} {
AX_surfxml_cluster_id = 0;
AX_surfxml_cluster_prefix = 0;
AX_surfxml_cluster_suffix = 0;
if (!AX_surfxml_cluster_bb_lat) FAIL("Required attribute `bb_lat' not set for `cluster' element.");
LEAVE; STag_surfxml_cluster(); surfxml_pcdata_ix = 0; ETag_surfxml_cluster(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_2: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_2: case S_surfxml_AS: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of cluster element.", yytext[0]);
ETag_surfxml_cluster();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_2: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
- case S_surfxml_platform_2: SET(S_surfxml_platform_3); break;
+ case S_surfxml_AS_2: case S_surfxml_AS: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
+ case S_surfxml_platform_4: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_3: SET(S_surfxml_platform_4); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cluster>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</cluster>' expected.");
}
-<S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,ROOT_surfxml_router,S_surfxml_platform_7,E_surfxml_bypassRoute>"<router"{s} FAIL("Starting tag <router> is not allowed here.");
+<S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,ROOT_surfxml_router,E_surfxml_bypassRoute>"<router"{s} FAIL("Starting tag <router> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_AS_11,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_AS_10,S_surfxml_AS,S_surfxml_platform_3>"<router"{s} {
+<S_surfxml_AS_11,S_surfxml_AS_10,S_surfxml_AS>"<router"{s} {
AX_surfxml_router_id = 0;
ENTER(AL_surfxml_router); pushbuffer(0);
}
LEAVE; STag_surfxml_router(); surfxml_pcdata_ix = 0; ETag_surfxml_router(); popbuffer(); /* attribute */
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of router element.", yytext[0]);
popbuffer(); /* attribute */
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</router>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</router>' expected.");
}
-<S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,ROOT_surfxml_link,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<link"{s} FAIL("Starting tag <link> is not allowed here.");
+<S_surfxml_random,S_surfxml_ASroute_1,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,ROOT_surfxml_link,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<link"{s} FAIL("Starting tag <link> is not allowed here.");
-<S_surfxml_platform_5,S_surfxml_AS_11,S_surfxml_AS_2,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_AS,S_surfxml_platform_3>"<link"{s} {
+<S_surfxml_AS_11,S_surfxml_AS_2,S_surfxml_AS_10,S_surfxml_AS,S_surfxml_AS_3>"<link"{s} {
AX_surfxml_link_id = 0;
AX_surfxml_link_bandwidth = 0;
AX_surfxml_link_bandwidth_file = 0;
- AX_surfxml_link_latency = 96;
+ AX_surfxml_link_latency = 15;
AX_surfxml_link_latency_file = 0;
AX_surfxml_link_state = A_surfxml_link_state_ON;
AX_surfxml_link_state_file = 0;
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
case S_surfxml_AS_2: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of link element.", yytext[0]);
switch (YY_START) {
case S_surfxml_AS_11: case S_surfxml_AS_10: case S_surfxml_AS: SET(S_surfxml_AS_11); break;
case S_surfxml_AS_2: case S_surfxml_AS_3: SET(S_surfxml_AS_3); break;
- case S_surfxml_platform_5: case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_3: SET(S_surfxml_platform_6); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</link>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</link>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_route_1,S_surfxml_link_1,ROOT_surfxml_route,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<route"{s} FAIL("Starting tag <route> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_link_1,ROOT_surfxml_route,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<route"{s} FAIL("Starting tag <route> is not allowed here.");
-<S_surfxml_AS_12,S_surfxml_AS_9,S_surfxml_AS_11,S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_platform_8,S_surfxml_AS_13,S_surfxml_platform_7,S_surfxml_AS,S_surfxml_platform_3,S_surfxml_platform_4>"<route"{s} {
+<S_surfxml_AS_12,S_surfxml_AS_9,S_surfxml_AS_11,S_surfxml_AS_13,S_surfxml_AS>"<route"{s} {
AX_surfxml_route_src = 0;
AX_surfxml_route_dst = 0;
ENTER(AL_surfxml_route); pushbuffer(0);
if (!AX_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
LEAVE; STag_surfxml_route(); surfxml_pcdata_ix = 0; ETag_surfxml_route(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_11: case S_surfxml_AS_13: case S_surfxml_AS: SET(S_surfxml_AS_13); break;
}
}
ETag_surfxml_route();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
case S_surfxml_AS_12: case S_surfxml_AS_9: case S_surfxml_AS_11: case S_surfxml_AS_13: case S_surfxml_AS: SET(S_surfxml_AS_13); break;
}
}
<<EOF>> FAIL("Premature EOF: `</route>' expected.");
}
-<S_surfxml_AS_10,ROOT_surfxml_ASroute,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<ASroute"{s} FAIL("Starting tag <ASroute> is not allowed here.");
+<S_surfxml_AS_10,ROOT_surfxml_ASroute,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<ASroute"{s} FAIL("Starting tag <ASroute> is not allowed here.");
-<S_surfxml_AS_1,S_surfxml_AS_6,S_surfxml_AS_5,S_surfxml_AS_3,S_surfxml_AS>"<ASroute"{s} {
+<S_surfxml_AS_1,S_surfxml_AS_5,S_surfxml_AS,S_surfxml_AS_6,S_surfxml_AS_3>"<ASroute"{s} {
AX_surfxml_ASroute_src = 0;
AX_surfxml_ASroute_dst = 0;
AX_surfxml_ASroute_gw_src = 0;
if (!AX_surfxml_ASroute_gw_dst) FAIL("Required attribute `gw_dst' not set for `ASroute' element.");
LEAVE; STag_surfxml_ASroute(); surfxml_pcdata_ix = 0; ETag_surfxml_ASroute(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_1: case S_surfxml_AS_6: case S_surfxml_AS_5: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_6); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: case S_surfxml_AS: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_6); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of ASroute element.", yytext[0]);
ETag_surfxml_ASroute();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_1: case S_surfxml_AS_6: case S_surfxml_AS_5: case S_surfxml_AS_3: case S_surfxml_AS: SET(S_surfxml_AS_6); break;
+ case S_surfxml_AS_1: case S_surfxml_AS_5: case S_surfxml_AS: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_6); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</ASroute>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</ASroute>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_link,E_surfxml_host,ROOT_surfxml_link_ctn,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_host_1,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_platform_7,E_surfxml_bypassRoute>"<link_ctn"{s} FAIL("Starting tag <link_ctn> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_link,E_surfxml_host,S_surfxml_config,ROOT_surfxml_link_ctn,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,E_surfxml_config,S_surfxml_host_1,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,E_surfxml_bypassRoute>"<link_ctn"{s} FAIL("Starting tag <link_ctn> is not allowed here.");
-<S_surfxml_route_1,S_surfxml_bypassRoute,S_surfxml_bypassRoute_2,S_surfxml_route,S_surfxml_bypassRoute_1,S_surfxml_route_2,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2>"<link_ctn"{s} {
+<S_surfxml_route_1,S_surfxml_bypassRoute,S_surfxml_route,S_surfxml_bypassRoute_2,S_surfxml_bypassRoute_1,S_surfxml_route_2,S_surfxml_ASroute,S_surfxml_ASroute_1,S_surfxml_ASroute_2>"<link_ctn"{s} {
AX_surfxml_link_ctn_id = 0;
ENTER(AL_surfxml_link_ctn); pushbuffer(0);
}
<<EOF>> FAIL("Premature EOF: `</link_ctn>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,ROOT_surfxml_bypassRoute,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<bypassRoute"{s} FAIL("Starting tag <bypassRoute> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,ROOT_surfxml_bypassRoute,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_route,E_surfxml_bypassRoute>"<bypassRoute"{s} FAIL("Starting tag <bypassRoute> is not allowed here.");
-<S_surfxml_AS_1,S_surfxml_AS_7,S_surfxml_AS_6,S_surfxml_AS_3,S_surfxml_AS,S_surfxml_AS_8,S_surfxml_AS_4>"<bypassRoute"{s} {
+<S_surfxml_AS_1,S_surfxml_AS,S_surfxml_AS_8,S_surfxml_AS_4,S_surfxml_AS_7,S_surfxml_AS_6,S_surfxml_AS_3>"<bypassRoute"{s} {
AX_surfxml_bypassRoute_src = 0;
AX_surfxml_bypassRoute_dst = 0;
AX_surfxml_bypassRoute_gw_src = 0;
if (!AX_surfxml_bypassRoute_gw_dst) FAIL("Required attribute `gw_dst' not set for `bypassRoute' element.");
LEAVE; STag_surfxml_bypassRoute(); surfxml_pcdata_ix = 0; ETag_surfxml_bypassRoute(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_1: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: case S_surfxml_AS: case S_surfxml_AS_8: case S_surfxml_AS_4: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_1: case S_surfxml_AS: case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of bypassRoute element.", yytext[0]);
ETag_surfxml_bypassRoute();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_AS_1: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: case S_surfxml_AS: case S_surfxml_AS_8: case S_surfxml_AS_4: SET(S_surfxml_AS_8); break;
+ case S_surfxml_AS_1: case S_surfxml_AS: case S_surfxml_AS_8: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_6: case S_surfxml_AS_3: SET(S_surfxml_AS_8); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</bypassRoute>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</bypassRoute>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,ROOT_surfxml_process,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<process"{s} FAIL("Starting tag <process> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_process_2,E_surfxml_ASroute,ROOT_surfxml_process,S_surfxml_AS_6,E_surfxml_link,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_AS_1,S_surfxml_host,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<process"{s} FAIL("Starting tag <process> is not allowed here.");
-<S_surfxml_platform_1,S_surfxml_platform,S_surfxml_platform_6,S_surfxml_platform_8,S_surfxml_platform_7,S_surfxml_platform_3,S_surfxml_platform_4>"<process"{s} {
+<S_surfxml_platform_6,S_surfxml_platform_4,S_surfxml_platform_5,S_surfxml_platform_2,S_surfxml_platform_1,S_surfxml_platform>"<process"{s} {
AX_surfxml_process_host = 0;
AX_surfxml_process_function = 0;
- AX_surfxml_process_start_time = 100;
- AX_surfxml_process_kill_time = 105;
+ AX_surfxml_process_start_time = 19;
+ AX_surfxml_process_kill_time = 24;
ENTER(AL_surfxml_process); pushbuffer(0);
}
if (!AX_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
LEAVE; STag_surfxml_process(); surfxml_pcdata_ix = 0; ETag_surfxml_process(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
+ case S_surfxml_platform_6: case S_surfxml_platform_4: case S_surfxml_platform_5: case S_surfxml_platform_2: case S_surfxml_platform_1: case S_surfxml_platform: SET(S_surfxml_platform_6); break;
}
}
. FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
ETag_surfxml_process();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_platform_1: case S_surfxml_platform: case S_surfxml_platform_6: case S_surfxml_platform_8: case S_surfxml_platform_7: case S_surfxml_platform_3: case S_surfxml_platform_4: SET(S_surfxml_platform_8); break;
+ case S_surfxml_platform_6: case S_surfxml_platform_4: case S_surfxml_platform_5: case S_surfxml_platform_2: case S_surfxml_platform_1: case S_surfxml_platform: SET(S_surfxml_platform_6); break;
}
}
"</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
<<EOF>> FAIL("Premature EOF: `</process>' expected.");
}
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,ROOT_surfxml_argument,E_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_random_1,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<argument"{s} FAIL("Starting tag <argument> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,ROOT_surfxml_argument,E_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<argument"{s} FAIL("Starting tag <argument> is not allowed here.");
<S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<argument"{s} {
AX_surfxml_argument_value = 0;
<<EOF>> FAIL("Premature EOF: `</argument>' expected.");
}
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_random,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,S_surfxml_process,S_surfxml_link_2,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_link_1,S_surfxml_AS,S_surfxml_bypassRoute,S_surfxml_link,E_surfxml_host,S_surfxml_config,S_surfxml_ASroute_2,S_surfxml_random_2,S_surfxml_platform_6,S_surfxml_process_2,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_host_1,ROOT_surfxml_config,S_surfxml_route_2,E_surfxml_platform,S_surfxml_config_2,S_surfxml_random_1,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_host,S_surfxml_platform_2,S_surfxml_process_1,S_surfxml_host_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_config_1,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<config"{s} FAIL("Starting tag <config> is not allowed here.");
+
+<S_surfxml_platform>"<config"{s} {
+ AX_surfxml_config_id = 0;
+ ENTER(AL_surfxml_config); pushbuffer(0);
+ }
+
+<AL_surfxml_config>{
+ "id"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_config_id);
+ "id"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_config_id);
+
+ ">" {
+ LEAVE; STag_surfxml_config();surfxml_pcdata_ix = 0; ENTER(S_surfxml_config);
+ }
+ "/>" {
+ LEAVE; STag_surfxml_config(); surfxml_pcdata_ix = 0; ETag_surfxml_config(); popbuffer(); /* attribute */
+ switch (YY_START) {
+ case S_surfxml_platform: SET(S_surfxml_platform_1); break;
+ }
+ }
+ . FAIL("Unexpected character `%c' in attribute list of config element.", yytext[0]);
+ {Name} FAIL("Bad attribute `%s' in `config' element start tag.",yytext);
+ <<EOF>> FAIL("EOF in attribute list of `config' element.");
+}
+
+<S_surfxml_config,S_surfxml_config_2,E_surfxml_config>{
+ "</config"{s}">" {
+ LEAVE;
+ ETag_surfxml_config();
+ popbuffer(); /* attribute */
+ switch (YY_START) {
+ case S_surfxml_platform: SET(S_surfxml_platform_1); break;
+ }
+ }
+ "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</config>' expected.",yytext);
+ . FAIL("Unexpected character `%c': `</config>' expected.",yytext[0]);
+ <<EOF>> FAIL("Premature EOF: `</config>' expected.");
+}
+
/* <!-- <!ATTLIST prop key CDATA #REQUIRED> -->
* <!-- <!ATTLIST prop key CDATA #REQUIRED> --> */
-<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,ROOT_surfxml_prop,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_AS,S_surfxml_bypassRoute,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_platform_6,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,S_surfxml_route_2,E_surfxml_platform,S_surfxml_platform_8,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_platform_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,S_surfxml_platform_7,E_surfxml_bypassRoute>"<prop"{s} FAIL("Starting tag <prop> is not allowed here.");
+<S_surfxml_AS_10,S_surfxml_AS_3,S_surfxml_ASroute_1,S_surfxml_AS_2,E_surfxml_AS,S_surfxml_AS_12,E_surfxml_process,E_surfxml_random,S_surfxml_AS_8,S_surfxml_bypassRoute_2,E_surfxml_route,ROOT_surfxml_prop,S_surfxml_AS_9,S_surfxml_platform_3,S_surfxml_route_1,S_surfxml_AS_11,S_surfxml_AS,S_surfxml_bypassRoute,E_surfxml_host,S_surfxml_ASroute_2,S_surfxml_platform_6,E_surfxml_ASroute,S_surfxml_AS_6,E_surfxml_link,S_surfxml_platform,S_surfxml_platform_1,S_surfxml_bypassRoute_1,E_surfxml_config,S_surfxml_route_2,E_surfxml_platform,S_surfxml_platform_4,S_surfxml_AS_1,S_surfxml_platform_2,S_surfxml_AS_7,S_surfxml_AS_13,S_surfxml_ASroute,S_surfxml_platform_5,S_surfxml_AS_5,S_surfxml_AS_4,S_surfxml_route,E_surfxml_bypassRoute>"<prop"{s} FAIL("Starting tag <prop> is not allowed here.");
-<S_surfxml_host,S_surfxml_link_1,S_surfxml_link_2,S_surfxml_random_2,S_surfxml_random,S_surfxml_link,S_surfxml_host_1,S_surfxml_random_1,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2,S_surfxml_host_2>"<prop"{s} {
+<S_surfxml_config_1,S_surfxml_config,S_surfxml_random,S_surfxml_host_1,S_surfxml_host_2,S_surfxml_host,S_surfxml_link_1,S_surfxml_link_2,S_surfxml_config_2,S_surfxml_random_2,S_surfxml_link,S_surfxml_random_1,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<prop"{s} {
AX_surfxml_prop_id = 0;
AX_surfxml_prop_value = 0;
ENTER(AL_surfxml_prop); pushbuffer(0);
if (!AX_surfxml_prop_value) FAIL("Required attribute `value' not set for `prop' element.");
LEAVE; STag_surfxml_prop(); surfxml_pcdata_ix = 0; ETag_surfxml_prop(); popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_random_2: case S_surfxml_random: case S_surfxml_random_1: SET(S_surfxml_random_2); break;
+ case S_surfxml_random: case S_surfxml_random_2: case S_surfxml_random_1: SET(S_surfxml_random_2); break;
+ case S_surfxml_config_1: case S_surfxml_config: case S_surfxml_config_2: SET(S_surfxml_config_2); break;
case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
- case S_surfxml_host: case S_surfxml_host_1: case S_surfxml_host_2: SET(S_surfxml_host_2); break;
+ case S_surfxml_host_1: case S_surfxml_host_2: case S_surfxml_host: SET(S_surfxml_host_2); break;
case S_surfxml_link_1: case S_surfxml_link_2: case S_surfxml_link: SET(S_surfxml_link_2); break;
}
}
ETag_surfxml_prop();
popbuffer(); /* attribute */
switch (YY_START) {
- case S_surfxml_random_2: case S_surfxml_random: case S_surfxml_random_1: SET(S_surfxml_random_2); break;
+ case S_surfxml_random: case S_surfxml_random_2: case S_surfxml_random_1: SET(S_surfxml_random_2); break;
+ case S_surfxml_config_1: case S_surfxml_config: case S_surfxml_config_2: SET(S_surfxml_config_2); break;
case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
- case S_surfxml_host: case S_surfxml_host_1: case S_surfxml_host_2: SET(S_surfxml_host_2); break;
+ case S_surfxml_host_1: case S_surfxml_host_2: case S_surfxml_host: SET(S_surfxml_host_2); break;
case S_surfxml_link_1: case S_surfxml_link_2: case S_surfxml_link: SET(S_surfxml_link_2); break;
}
}
"Y:\\",
"Z:\\"
};
-#endif /* #ifdef _XBT_WIN32 */
+#endif /* #ifdef _XBT_WIN32 */
/*
* Returns the initial path. On Windows the initial path is
/* Don't forget to update the option description in smx_config when you change this */
s_surf_model_description_t surf_network_model_description[] = {
- {"Constant", "Simplistic network model where all communication take a constant time (one second)", NULL, surf_network_model_init_Constant},
- {"Vivaldi", "Scalable network model using the Vivaldi coordinate ideas", NULL, surf_network_model_init_Vivaldi},
- {"CM02", "Realistic network model with lmm_solve and no correction factors", NULL, surf_network_model_init_CM02},
- {"LV08", "Realistic network model with lmm_solve and these correction factors: latency*=10.4, bandwidth*=.92, S=8775" , NULL, surf_network_model_init_LegrandVelho},
- {"SMPI", "Realistic network model with lmm_solve and correction factors on three intervals (< 1KiB, < 64 KiB, >= 64 KiB)", NULL, surf_network_model_init_SMPI},
+ {"Constant",
+ "Simplistic network model where all communication take a constant time (one second)",
+ NULL, surf_network_model_init_Constant},
+ {"Vivaldi", "Scalable network model using the Vivaldi coordinate ideas",
+ NULL, surf_network_model_init_Vivaldi},
+ {"CM02",
+ "Realistic network model with lmm_solve and no correction factors",
+ NULL, surf_network_model_init_CM02},
+ {"LV08",
+ "Realistic network model with lmm_solve and these correction factors: latency*=10.4, bandwidth*=.92, S=8775",
+ NULL, surf_network_model_init_LegrandVelho},
+ {"SMPI",
+ "Realistic network model with lmm_solve and correction factors on three intervals (< 1KiB, < 64 KiB, >= 64 KiB)",
+ NULL, surf_network_model_init_SMPI},
#ifdef HAVE_GTNETS
- {"GTNets", "Network Pseudo-model using the GTNets simulator instead of an analytic model", NULL, surf_network_model_init_GTNETS},
+ {"GTNets",
+ "Network Pseudo-model using the GTNets simulator instead of an analytic model",
+ NULL, surf_network_model_init_GTNETS},
#endif
- {"Reno", "Model using lagrange_solve instead of lmm_solve (experts only)", NULL, surf_network_model_init_Reno},
- {"Reno2", "Model using lagrange_solve instead of lmm_solve (experts only)", NULL, surf_network_model_init_Reno2},
- {"Vegas", "Model using lagrange_solve instead of lmm_solve (experts only)", NULL, surf_network_model_init_Vegas},
- {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
+ {"Reno",
+ "Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
+ surf_network_model_init_Reno},
+ {"Reno2",
+ "Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
+ surf_network_model_init_Reno2},
+ {"Vegas",
+ "Model using lagrange_solve instead of lmm_solve (experts only)", NULL,
+ surf_network_model_init_Vegas},
+ {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
};
s_surf_model_description_t surf_cpu_model_description[] = {
- {"Cas01_fullupdate", "CPU classical model time=size/power", NULL, surf_cpu_model_init_Cas01},
- {"Cas01", "Variation of Cas01_fullupdate with partial invalidation optimization of lmm system. Should produce the same values, only faster", NULL, surf_cpu_model_init_Cas01_im},
- {"CpuTI", "Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces", NULL, surf_cpu_model_init_ti},
- {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
+ {"Cas01_fullupdate", "CPU classical model time=size/power", NULL,
+ surf_cpu_model_init_Cas01},
+ {"Cas01",
+ "Variation of Cas01_fullupdate with partial invalidation optimization of lmm system. Should produce the same values, only faster",
+ NULL, surf_cpu_model_init_Cas01_im},
+ {"CpuTI",
+ "Variation of Cas01 with also trace integration. Should produce the same values, only faster if you use availability traces",
+ NULL, surf_cpu_model_init_ti},
+ {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
};
s_surf_model_description_t surf_workstation_model_description[] = {
- {"CLM03", "Default workstation model, using LV08 and CM02 as network and CPU", NULL, surf_workstation_model_init_CLM03, create_workstations},
- {"compound", "Workstation model allowing you to use other network and CPU models", NULL, surf_workstation_model_init_compound, create_workstations},
- {"ptask_L07", "Workstation model with better parallel task modeling", NULL, surf_workstation_model_init_ptask_L07, NULL},
- {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
+ {"CLM03",
+ "Default workstation model, using LV08 and CM02 as network and CPU",
+ NULL, surf_workstation_model_init_CLM03, create_workstations},
+ {"compound",
+ "Workstation model allowing you to use other network and CPU models",
+ NULL, surf_workstation_model_init_compound, create_workstations},
+ {"ptask_L07", "Workstation model with better parallel task modeling",
+ NULL, surf_workstation_model_init_ptask_L07, NULL},
+ {NULL, NULL, NULL, NULL} /* this array must be NULL terminated */
};
void update_model_description(s_surf_model_description_t * table,
}
/** Displays the long description of all registered models, and quit */
-void model_help(const char* category, s_surf_model_description_t * table) {
+void model_help(const char *category, s_surf_model_description_t * table)
+{
int i;
- printf("Long description of the %s models accepted by this simulator:\n",category);
+ printf("Long description of the %s models accepted by this simulator:\n",
+ category);
for (i = 0; table[i].name; i++)
printf(" %s: %s\n", table[i].name, table[i].description);
}
name_list = strdup(table[0].name);
for (i = 1; table[i].name; i++) {
name_list =
- xbt_realloc(name_list, strlen(name_list) + strlen(table[i].name) + 2);
+ xbt_realloc(name_list,
+ strlen(name_list) + strlen(table[i].name) + 2);
strcat(name_list, ", ");
strcat(name_list, table[i].name);
}
for (action = xbt_swag_getNext(action, running_actions->offset);
- action; action = xbt_swag_getNext(action, running_actions->offset)) {
+ action;
+ action = xbt_swag_getNext(action, running_actions->offset)) {
value = lmm_variable_getvalue(VARIABLE(action));
if (value > 0) {
if (action->remains > 0)
#endif
void surf_init(int *argc, char **argv)
-{
+{
/* Connect our log channels: that must be done manually under windows */
XBT_LOG_CONNECT(surf_cpu, surf);
XBT_LOG_CONNECT(surf_kernel, surf);
surf_config_finalize();
xbt_dynar_foreach(model_list, iter, model)
- model->model_private->finalize();
+ model->model_private->finalize();
xbt_dynar_free(&model_list);
if (maxmin_system) {
unsigned int iter;
DEBUG0
- ("First Run! Let's \"purge\" events and put models in the right state");
+ ("First Run! Let's \"purge\" events and put models in the right state");
while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
if (next_event_date > NOW)
break;
while ((event =
tmgr_history_get_next_event_leq(history, next_event_date,
- &value, (void **) &resource))) {
+ &value,
+ (void **) &resource))) {
resource->model->model_private->update_resource_state(resource,
event, value,
NOW);
}
}
xbt_dynar_foreach(model_list, iter, model)
- model->model_private->update_actions_state(NOW, 0.0);
+ model->model_private->update_actions_state(NOW, 0.0);
}
double surf_solve(void)
DEBUG0("Updating models");
while ((event =
tmgr_history_get_next_event_leq(history, next_event_date,
- &value, (void **) &resource))) {
+ &value,
+ (void **) &resource))) {
if (resource->model->model_private->resource_used(resource)) {
min = next_event_date - NOW;
DEBUG1
- ("This event will modify model state. Next event set to %f", min);
+ ("This event will modify model state. Next event set to %f",
+ min);
}
/* update state of model_obj according to new value. Does not touch lmm.
It will be modified if needed when updating actions */
DEBUG2("Calling update_resource_state for resource %s with min %lf",
resource->model->name, min);
- resource->model->model_private->update_resource_state(resource, event,
- value, NOW + min);
+ resource->model->model_private->update_resource_state(resource,
+ event, value,
+ NOW + min);
}
}
NOW = NOW + min;
xbt_dynar_foreach(model_list, iter, model)
- model->model_private->update_actions_state(NOW, min);
+ model->model_private->update_actions_state(NOW, min);
return min;
}
*action = NULL;
}
-void surf_action_state_set(surf_action_t action, e_surf_action_state_t state)
+void surf_action_state_set(surf_action_t action,
+ e_surf_action_state_t state)
{
surf_action_state_t action_state = &(action->model_type->states);
XBT_IN2("(%p,%s)", action, surf_action_state_names[state]);
remove_it = 1;
} else if (!strncmp(argv[i], "--cfg-help", strlen("--cfg-help") + 1) ||
!strncmp(argv[i], "--help", strlen("--help") + 1)) {
- printf("Description of the configuration accepted by this simulator:\n");
+ printf
+ ("Description of the configuration accepted by this simulator:\n");
xbt_cfg_help(_surf_cfg_set);
- printf("\nYou can also use --help-models to see the details of all models known by this simulator.\n");
+ printf
+ ("\nYou can also use --help-models to see the details of all models known by this simulator.\n");
exit(0);
- } else if (!strncmp(argv[i], "--help-models", strlen("--help-models")+1)) {
- model_help("workstation",surf_workstation_model_description);
- model_help("CPU",surf_cpu_model_description);
- model_help("network",surf_network_model_description);
+ } else
+ if (!strncmp
+ (argv[i], "--help-models", strlen("--help-models") + 1)) {
+ model_help("workstation", surf_workstation_model_description);
+ model_help("CPU", surf_cpu_model_description);
+ model_help("network", surf_network_model_description);
exit(0);
}
if (remove_it) { /*remove this from argv */
val = xbt_cfg_get_string(_surf_cfg_set, name);
- if (!strcmp(val,"help")) {
- model_help("workstation",surf_workstation_model_description);
+ if (!strcmp(val, "help")) {
+ model_help("workstation", surf_workstation_model_description);
exit(0);
}
val = xbt_cfg_get_string(_surf_cfg_set, name);
- if (!strcmp(val,"help")) {
- model_help("CPU",surf_cpu_model_description);
+ if (!strcmp(val, "help")) {
+ model_help("CPU", surf_cpu_model_description);
exit(0);
}
val = xbt_cfg_get_string(_surf_cfg_set, name);
- if (!strcmp(val,"help")) {
- model_help("network",surf_network_model_description);
+ if (!strcmp(val, "help")) {
+ model_help("network", surf_network_model_description);
exit(0);
}
/* callbacks of the network models values */
-static void _surf_cfg_cb__tcp_gamma(const char *name, int pos) {
+static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
+{
sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
}
-static void _surf_cfg_cb__latency_factor(const char *name, int pos) {
+
+static void _surf_cfg_cb__latency_factor(const char *name, int pos)
+{
sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
}
-static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos) {
+
+static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
+{
sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
}
-static void _surf_cfg_cb__weight_S(const char *name, int pos) {
+
+static void _surf_cfg_cb__weight_S(const char *name, int pos)
+{
sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
}
-static void _surf_cfg_cb__surf_maxmin_selective_update(const char *name, int pos) {
- sg_maxmin_selective_update = xbt_cfg_get_int(_surf_cfg_set, name);
+
+static void _surf_cfg_cb__surf_maxmin_selective_update(const char *name,
+ int pos)
+{
+ sg_maxmin_selective_update = xbt_cfg_get_int(_surf_cfg_set, name);
}
/* callback of the inclusion path */
-static void _surf_cfg_cb__surf_path(const char *name, int pos) {
+static void _surf_cfg_cb__surf_path(const char *name, int pos)
+{
char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
xbt_dynar_push(surf_path, &path);
}
/* callback to decide if we want to use the model-checking */
#include "xbt_modinter.h"
-int _surf_do_model_check = 0; /* this variable is used accros the lib */
+int _surf_do_model_check = 0; /* this variable is used accros the lib */
-static void _surf_cfg_cb_model_check(const char *name, int pos) {
+static void _surf_cfg_cb_model_check(const char *name, int pos)
+{
_surf_do_model_check = 1;
/* Tell modules using mallocators that they shouldn't. MC don't like them */
xbt_fifo_preinit();
xbt_dict_preinit();
}
-static void _surf_cfg_cb__surf_network_fullduplex(const char *name, int pos)
+static void _surf_cfg_cb__surf_network_fullduplex(const char *name,
+ int pos)
{
- sg_network_fullduplex = xbt_cfg_get_int(_surf_cfg_set, name);
+ sg_network_fullduplex = xbt_cfg_get_int(_surf_cfg_set, name);
}
#ifdef HAVE_GTNETS
-static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos){
- sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
+static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
+{
+ sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
}
-static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos){
- sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
+
+static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
+{
+ sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
}
#endif
/* create the config set, register what should be and parse the command line*/
void surf_config_init(int *argc, char **argv)
{
- char *description = xbt_malloc(1024), *p = description;
- char *default_value;
- double double_default_value;
- int default_value_int;
- int i;
+ char *description = xbt_malloc(1024), *p = description;
+ char *default_value;
+ double double_default_value;
+ int default_value_int;
+ int i;
/* Create the configuration support */
if (_surf_init_status == 0) { /* Only create stuff if not already inited */
_surf_init_status = 1;
- sprintf(description, "The model to use for the CPU. Possible values: ");
+ sprintf(description,
+ "The model to use for the CPU. Possible values: ");
p = description;
while (*(++p) != '\0');
for (i = 0; surf_cpu_model_description[i].name; i++)
- p +=
- sprintf(p, "%s%s", (i == 0 ? "" : ", "),
- surf_cpu_model_description[i].name);
- sprintf(p,".\n (use 'help' as a value to see the long description of each model)");
+ p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
+ surf_cpu_model_description[i].name);
+ sprintf(p,
+ ".\n (use 'help' as a value to see the long description of each model)");
default_value = xbt_strdup("Cas01");
xbt_cfg_register(&_surf_cfg_set,
"cpu/model", description, xbt_cfgelm_string,
p = description;
while (*(++p) != '\0');
for (i = 0; surf_network_model_description[i].name; i++)
- p +=
- sprintf(p, "%s%s", (i == 0 ? "" : ", "),
- surf_network_model_description[i].name);
- sprintf(p,".\n (use 'help' as a value to see the long description of each model)");
+ p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
+ surf_network_model_description[i].name);
+ sprintf(p,
+ ".\n (use 'help' as a value to see the long description of each model)");
default_value = xbt_strdup("LV08");
xbt_cfg_register(&_surf_cfg_set,
"network/model", description, xbt_cfgelm_string,
p = description;
while (*(++p) != '\0');
for (i = 0; surf_workstation_model_description[i].name; i++)
- p +=
- sprintf(p, "%s%s", (i == 0 ? "" : ", "),
- surf_workstation_model_description[i].name);
- sprintf(p,".\n (use 'help' as a value to see the long description of each model)");
+ p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
+ surf_workstation_model_description[i].name);
+ sprintf(p,
+ ".\n (use 'help' as a value to see the long description of each model)");
default_value = xbt_strdup("CLM03");
xbt_cfg_register(&_surf_cfg_set,
"workstation/model", description, xbt_cfgelm_string,
- &default_value, 1, 1, &_surf_cfg_cb__workstation_model,
- NULL);
+ &default_value, 1, 1,
+ &_surf_cfg_cb__workstation_model, NULL);
xbt_free(description);
xbt_cfg_register(&_surf_cfg_set, "TCP_gamma",
"Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; Use the last given value, which is the max window size)",
- xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL);
+ xbt_cfgelm_double, NULL, 1, 1,
+ _surf_cfg_cb__tcp_gamma, NULL);
xbt_cfg_set_double(_surf_cfg_set, "TCP_gamma", 20000.0);
/* The parameters of network models */
double_default_value = 1.0;
xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
"Correction factor to apply to the provided latency (default value set by network model)",
- xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__latency_factor, NULL);
+ xbt_cfgelm_double, &double_default_value, 1, 1,
+ _surf_cfg_cb__latency_factor, NULL);
double_default_value = 1.0;
xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
"Correction factor to apply to the provided bandwidth (default value set by network model)",
- xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__bandwidth_factor, NULL);
+ xbt_cfgelm_double, &double_default_value, 1, 1,
+ _surf_cfg_cb__bandwidth_factor, NULL);
double_default_value = 0.0;
xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
"Correction factor to apply to the weight of competing streams(default value set by network model)",
- xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__weight_S, NULL);
+ xbt_cfgelm_double, &double_default_value, 1, 1,
+ _surf_cfg_cb__weight_S, NULL);
/* Inclusion path */
xbt_cfg_register(&_surf_cfg_set, "path",
"Lookup path for inclusions in platform and deployment XML files",
- xbt_cfgelm_string, NULL, 0, 0, _surf_cfg_cb__surf_path,
- NULL);
+ xbt_cfgelm_string, NULL, 0, 0,
+ _surf_cfg_cb__surf_path, NULL);
- default_value_int = 0;
+ default_value_int = 0;
xbt_cfg_register(&_surf_cfg_set, "maxmin_selective_update",
"Update the constraint set propagating recursively to others constraints",
- xbt_cfgelm_int, &default_value_int, 0, 1, _surf_cfg_cb__surf_maxmin_selective_update, NULL);
+ xbt_cfgelm_int, &default_value_int, 0, 1,
+ _surf_cfg_cb__surf_maxmin_selective_update, NULL);
/* do model-check */
default_value_int = 0;
xbt_cfg_register(&_surf_cfg_set, "model-check",
"Activate the model-checking of the \"simulated\" system (EXPERIMENTAL -- msg only for now)",
- xbt_cfgelm_int, &default_value_int, 0, 1, _surf_cfg_cb_model_check, NULL);
+ xbt_cfgelm_int, &default_value_int, 0, 1,
+ _surf_cfg_cb_model_check, NULL);
/*
- FIXME: this function is not setting model-check to it's default value because
- internally it calls to variable->cb_set that in this case is the function
- _surf_cfg_cb_model_check which sets it's value to 1 (instead of the defalut value 0)
- xbt_cfg_set_int(_surf_cfg_set, "model-check", default_value_int); */
+ FIXME: this function is not setting model-check to it's default value because
+ internally it calls to variable->cb_set that in this case is the function
+ _surf_cfg_cb_model_check which sets it's value to 1 (instead of the defalut value 0)
+ xbt_cfg_set_int(_surf_cfg_set, "model-check", default_value_int); */
default_value_int = 0;
xbt_cfg_register(&_surf_cfg_set, "fullduplex",
- "Update the constraint set propagating recursively to others constraints",
- xbt_cfgelm_int, &default_value_int, 0, 1, _surf_cfg_cb__surf_network_fullduplex, NULL);
+ "Update the constraint set propagating recursively to others constraints",
+ xbt_cfgelm_int, &default_value_int, 0, 1,
+ _surf_cfg_cb__surf_network_fullduplex, NULL);
xbt_cfg_set_int(_surf_cfg_set, "fullduplex", default_value_int);
#ifdef HAVE_GTNETS
xbt_cfg_register(&_surf_cfg_set, "gtnets_jitter",
- "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)", xbt_cfgelm_double,
- NULL, 1, 1, _surf_cfg_cb__gtnets_jitter, NULL);
+ "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
+ xbt_cfgelm_double, NULL, 1, 1,
+ _surf_cfg_cb__gtnets_jitter, NULL);
xbt_cfg_set_double(_surf_cfg_set, "gtnets_jitter", 0.0);
default_value_int = 10;
xbt_cfg_register(&_surf_cfg_set, "gtnets_jitter_seed",
"Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
- xbt_cfgelm_int, &default_value_int, 0, 1, _surf_cfg_cb__gtnets_jitter_seed, NULL);
+ xbt_cfgelm_int, &default_value_int, 0, 1,
+ _surf_cfg_cb__gtnets_jitter_seed, NULL);
#endif
if (!surf_path) {
surf_timer_model_init(platform_file);
workstation_model_name =
- xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
+ xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
* we should switch to the "compound" workstation model to correctly dispatch stuff to
* the right net/cpu models.
*/
- if ((strcmp(network_model_name,"LV08") || strcmp(cpu_model_name,"Cas01"))
- && !strcmp(workstation_model_name, "CLM03")){
+ if ((strcmp(network_model_name, "LV08")
+ || strcmp(cpu_model_name, "Cas01"))
+ && !strcmp(workstation_model_name, "CLM03")) {
const char *val = "compound";
- INFO0("Switching workstation model to compound since you changed the network and/or cpu model(s)");
- xbt_cfg_set_string(_surf_cfg_set,"workstation/model",val);
- workstation_model_name = (char*)"compound";
+ INFO0
+ ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
+ xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
+ workstation_model_name = (char *) "compound";
}
DEBUG1("Workstation model: %s", workstation_model_name);
workstation_id =
- find_model_description(surf_workstation_model_description,
- workstation_model_name);
+ find_model_description(surf_workstation_model_description,
+ workstation_model_name);
if (!strcmp(workstation_model_name, "compound")) {
int network_id = -1;
int cpu_id = -1;
xbt_assert0(cpu_model_name,
- "Set a cpu model to use with the 'compound' workstation model");
+ "Set a cpu model to use with the 'compound' workstation model");
xbt_assert0(network_model_name,
- "Set a network model to use with the 'compound' workstation model");
+ "Set a network model to use with the 'compound' workstation model");
network_id =
- find_model_description(surf_network_model_description,
- network_model_name);
+ find_model_description(surf_network_model_description,
+ network_model_name);
cpu_id =
- find_model_description(surf_cpu_model_description, cpu_model_name);
+ find_model_description(surf_cpu_model_description, cpu_model_name);
surf_cpu_model_description[cpu_id].model_init_preparse(platform_file);
- surf_network_model_description[network_id].
- model_init_preparse(platform_file);
+ surf_network_model_description[network_id].model_init_preparse
+ (platform_file);
}
DEBUG0("Call workstation_model_init");
surf_workstation_model_description[workstation_id].model_init_preparse
- (platform_file);
+ (platform_file);
}
void surf_config_models_create_elms(void)
{
char *workstation_model_name =
- xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
+ xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
int workstation_id =
- find_model_description(surf_workstation_model_description,
- workstation_model_name);
- if (surf_workstation_model_description[workstation_id].
- model_init_postparse != NULL)
- surf_workstation_model_description[workstation_id].model_init_postparse();
+ find_model_description(surf_workstation_model_description,
+ workstation_model_name);
+ if (surf_workstation_model_description
+ [workstation_id].model_init_postparse != NULL)
+ surf_workstation_model_description[workstation_id].model_init_postparse
+ ();
}
model->model_private = xbt_new0(s_surf_model_private_t, 1);
model->states.ready_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.running_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.failed_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->states.done_action_set =
- xbt_swag_new(xbt_swag_offset(action, state_hookup));
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
model->resource_set = xbt_dict_new();
model->action_unref = int_die_impossible_paction;
return model;
}
+
/** @brief finalize common datastructures to all models */
void surf_model_exit(surf_model_t model)
{
{
return xbt_dict_get_or_null(model->resource_set, name);
}
-
-
command->args = args;
xbt_swag_insert(command, command_pending);
command->action =
- surf_action_new(sizeof(s_surf_action_timer_t), 0, surf_timer_model, 0);
+ surf_action_new(sizeof(s_surf_action_timer_t), 0, surf_timer_model,
+ 0);
return command;
}
surf_timer_model->model_private->resource_used = resource_used;
surf_timer_model->model_private->share_resources = share_resources;
surf_timer_model->model_private->update_actions_state =
- update_actions_state;
+ update_actions_state;
surf_timer_model->model_private->update_resource_state =
- update_resource_state;
+ update_resource_state;
surf_timer_model->model_private->finalize = finalize;
surf_timer_model->suspend = action_suspend;
{
s_command_t var;
- command_pending = xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
- command_to_run = xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
+ command_pending =
+ xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
+ command_to_run =
+ xbt_swag_new(xbt_swag_offset(var, command_set_hookup));
}
empty_trace = tmgr_empty_trace_new();
extern int sg_maxmin_selective_update;
extern int sg_network_fullduplex;
#ifdef HAVE_GTNETS
- extern double sg_gtnets_jitter;
- extern int sg_gtnets_jitter_seed;
+extern double sg_gtnets_jitter;
+extern int sg_gtnets_jitter_seed;
#endif
void (*solve) (lmm_system_t));
/* Generic functions common to all models */
-e_surf_action_state_t surf_action_state_get(surf_action_t action); /* cannot declare inline since we use a pointer to it */
-double surf_action_get_start_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
-double surf_action_get_finish_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
+e_surf_action_state_t surf_action_state_get(surf_action_t action); /* cannot declare inline since we use a pointer to it */
+double surf_action_get_start_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
+double surf_action_get_finish_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
void surf_action_free(surf_action_t * action);
-void surf_action_state_set(surf_action_t action, e_surf_action_state_t state);
-void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
+void surf_action_state_set(surf_action_t action,
+ e_surf_action_state_t state);
+void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
FILE *surf_fopen(const char *name, const char *mode);
extern tmgr_history_t history;
* One link routing list
*/
typedef struct s_onelink {
- char *src;
- char *dst;
- void *link_ptr;
+ char *src;
+ char *dst;
+ void *link_ptr;
} s_onelink_t, *onelink_t;
/**
*/
typedef struct s_model_type {
- const char *name;
- const char *desc;
- void* (*create)();
- void (*load)();
- void (*unload)();
- void (*end)();
+ const char *name;
+ const char *desc;
+ void *(*create) ();
+ void (*load) ();
+ void (*unload) ();
+ void (*end) ();
} s_model_type_t, *model_type_t;
-typedef struct s_route {
+typedef struct s_route {
xbt_dynar_t link_list;
} s_route_t, *route_t;
typedef struct s_route_limits {
- char* src_gateway;
- char* dst_gateway;
+ char *src_gateway;
+ char *dst_gateway;
} s_route_limits_t, *route_limits_t;
typedef struct s_route_extended {
- s_route_t generic_route;
- char* src_gateway;
- char* dst_gateway;
+ s_route_t generic_route;
+ char *src_gateway;
+ char *dst_gateway;
} s_route_extended_t, *route_extended_t;
/* This enum used in the routing structure helps knowing in which situation we are. */
typedef enum {
- SURF_ROUTING_NULL = 0, /**< Indefined type */
+ SURF_ROUTING_NULL = 0, /**< Indefined type */
SURF_ROUTING_BASE, /**< Base case: use simple link lists for routing */
SURF_ROUTING_RECURSIVE /**< Recursive case: also return gateway informations */
} e_surf_routing_hierarchy_t;
typedef enum {
- SURF_NETWORK_ELEMENT_NULL = 0, /* NULL */
- SURF_NETWORK_ELEMENT_HOST, /* host type */
- SURF_NETWORK_ELEMENT_ROUTER, /* router type */
- SURF_NETWORK_ELEMENT_AS, /* AS type */
+ SURF_NETWORK_ELEMENT_NULL = 0, /* NULL */
+ SURF_NETWORK_ELEMENT_HOST, /* host type */
+ SURF_NETWORK_ELEMENT_ROUTER, /* router type */
+ SURF_NETWORK_ELEMENT_AS, /* AS type */
} e_surf_network_element_type_t;
typedef struct s_routing_component *routing_component_t;
typedef struct s_routing_component {
- model_type_t routing;
- e_surf_routing_hierarchy_t hierarchy;
- char *name;
- struct s_routing_component* routing_father;
- xbt_dict_t routing_sons;
- route_extended_t (*get_route)(routing_component_t rc, const char* src, const char* dst);
- xbt_dynar_t (*get_onelink_routes)(routing_component_t rc);
- e_surf_network_element_type_t (*get_network_element_type) (const char *name);
- route_extended_t (*get_bypass_route)(routing_component_t rc, const char* src, const char* dst);
- void (*finalize)(routing_component_t rc);
- void (*set_processing_unit)(routing_component_t rc, const char* name);
- void (*set_autonomous_system)(routing_component_t rc, const char* name);
- void (*set_route)(routing_component_t rc, const char* src, const char* dst, route_t route);
- void (*set_ASroute)(routing_component_t rc, const char* src, const char* dst, route_extended_t route);
- void (*set_bypassroute)(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route);
+ model_type_t routing;
+ e_surf_routing_hierarchy_t hierarchy;
+ char *name;
+ struct s_routing_component *routing_father;
+ xbt_dict_t routing_sons;
+ route_extended_t(*get_route) (routing_component_t rc, const char *src,
+ const char *dst);
+ xbt_dynar_t(*get_onelink_routes) (routing_component_t rc);
+ e_surf_network_element_type_t(*get_network_element_type) (const char
+ *name);
+ route_extended_t(*get_bypass_route) (routing_component_t rc,
+ const char *src, const char *dst);
+ void (*finalize) (routing_component_t rc);
+ void (*set_processing_unit) (routing_component_t rc, const char *name);
+ void (*set_autonomous_system) (routing_component_t rc, const char *name);
+ void (*set_route) (routing_component_t rc, const char *src,
+ const char *dst, route_t route);
+ void (*set_ASroute) (routing_component_t rc, const char *src,
+ const char *dst, route_extended_t route);
+ void (*set_bypassroute) (routing_component_t rc, const char *src,
+ const char *dst, route_extended_t e_route);
} s_routing_component_t;
typedef struct s_network_element_info {
- routing_component_t rc_component;
- e_surf_network_element_type_t rc_type;
+ routing_component_t rc_component;
+ e_surf_network_element_type_t rc_type;
} s_network_element_info_t, *network_element_info_t;
typedef int *network_element_t;
struct s_routing_global {
routing_component_t root;
- xbt_dict_t where_network_elements; /* char* -> network_element_info_t */
+ xbt_dict_t where_network_elements; /* char* -> network_element_info_t */
void *loopback;
size_t size_of_link;
- xbt_dynar_t (*get_route)(const char* src, const char* dst);
- xbt_dynar_t (*get_onelink_routes)(void);
- e_surf_network_element_type_t (*get_network_element_type)(const char *name);
- void (*finalize)(void);
+ xbt_dynar_t(*get_route) (const char *src, const char *dst);
+ xbt_dynar_t(*get_onelink_routes) (void);
+ e_surf_network_element_type_t(*get_network_element_type) (const char
+ *name);
+ void (*finalize) (void);
xbt_dynar_t last_route;
};
-XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback);
+XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback);
/**
* Resource protected methods
XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
-#endif /* _SURF_SURF_PRIVATE_H */
+#endif /* _SURF_SURF_PRIVATE_H */
#include "gras_config.h"
#ifdef HAVE_PCRE_LIB
- #include <pcre.h> /* regular expresion library */
+#include <pcre.h> /* regular expresion library */
#endif
#include "surf_private.h"
#include "xbt/dynar.h"
#include "xbt/graph.h"
#include "xbt/set.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route,surf,"Routing part of surf");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
/* Global vars */
routing_global_t global_routing = NULL;
model_type_t current_routing_model = NULL;
/* Prototypes of each model */
-static void* model_full_create(void); /* create structures for full routing model */
-static void model_full_load(void); /* load parse functions for full routing model */
-static void model_full_unload(void); /* unload parse functions for full routing model */
-static void model_full_end(void); /* finalize the creation of full routing model */
+static void *model_full_create(void); /* create structures for full routing model */
+static void model_full_load(void); /* load parse functions for full routing model */
+static void model_full_unload(void); /* unload parse functions for full routing model */
+static void model_full_end(void); /* finalize the creation of full routing model */
-static void* model_floyd_create(void); /* create structures for floyd routing model */
-static void model_floyd_load(void); /* load parse functions for floyd routing model */
-static void model_floyd_unload(void); /* unload parse functions for floyd routing model */
-static void model_floyd_end(void); /* finalize the creation of floyd routing model */
+static void *model_floyd_create(void); /* create structures for floyd routing model */
+static void model_floyd_load(void); /* load parse functions for floyd routing model */
+static void model_floyd_unload(void); /* unload parse functions for floyd routing model */
+static void model_floyd_end(void); /* finalize the creation of floyd routing model */
-static void* model_dijkstra_both_create(int cached); /* create by calling dijkstra or dijkstracache */
-static void* model_dijkstra_create(void); /* create structures for dijkstra routing model */
-static void* model_dijkstracache_create(void); /* create structures for dijkstracache routing model */
-static void model_dijkstra_both_load(void); /* load parse functions for dijkstra routing model */
-static void model_dijkstra_both_unload(void); /* unload parse functions for dijkstra routing model */
-static void model_dijkstra_both_end(void); /* finalize the creation of dijkstra routing model */
+static void *model_dijkstra_both_create(int cached); /* create by calling dijkstra or dijkstracache */
+static void *model_dijkstra_create(void); /* create structures for dijkstra routing model */
+static void *model_dijkstracache_create(void); /* create structures for dijkstracache routing model */
+static void model_dijkstra_both_load(void); /* load parse functions for dijkstra routing model */
+static void model_dijkstra_both_unload(void); /* unload parse functions for dijkstra routing model */
+static void model_dijkstra_both_end(void); /* finalize the creation of dijkstra routing model */
-static void* model_rulebased_create(void); /* create structures for rulebased routing model */
-static void model_rulebased_load(void); /* load parse functions for rulebased routing model */
-static void model_rulebased_unload(void); /* unload parse functions for rulebased routing model */
-static void model_rulebased_end(void); /* finalize the creation of rulebased routing model */
+static void *model_rulebased_create(void); /* create structures for rulebased routing model */
+static void model_rulebased_load(void); /* load parse functions for rulebased routing model */
+static void model_rulebased_unload(void); /* unload parse functions for rulebased routing model */
+static void model_rulebased_end(void); /* finalize the creation of rulebased routing model */
-static void* model_none_create(void); /* none routing model */
-static void model_none_load(void); /* none routing model */
-static void model_none_unload(void); /* none routing model */
-static void model_none_end(void); /* none routing model */
+static void *model_none_create(void); /* none routing model */
+static void model_none_load(void); /* none routing model */
+static void model_none_unload(void); /* none routing model */
+static void model_none_end(void); /* none routing model */
-static void routing_full_parse_Scluster(void);/*cluster bypass*/
+static void routing_full_parse_Scluster(void); /*cluster bypass */
-static void parse_Sconfig(void);/*config Tag*/
+static void parse_Sconfig(void); /*config Tag */
/* this lines are only for replace use like index in the model table */
typedef enum {
- SURF_MODEL_FULL=0,
- SURF_MODEL_FLOYD,
- SURF_MODEL_DIJKSTRA,
- SURF_MODEL_DIJKSTRACACHE,
- SURF_MODEL_NONE,
+ SURF_MODEL_FULL = 0,
+ SURF_MODEL_FLOYD,
+ SURF_MODEL_DIJKSTRA,
+ SURF_MODEL_DIJKSTRACACHE,
+ SURF_MODEL_NONE,
#ifdef HAVE_PCRE_LIB
- SURF_MODEL_RULEBASED
+ SURF_MODEL_RULEBASED
#endif
} e_routing_types;
/* must be finish with null and carefull if change de order */
-struct s_model_type routing_models[] =
-{ {"Full", "Full routing data (fast, large memory requirements, fully expressive)",
- model_full_create, model_full_load, model_full_unload, model_full_end },
- {"Floyd", "Floyd routing data (slow initialization, fast lookup, lesser memory requirements, shortest path routing only)",
- model_floyd_create, model_floyd_load, model_floyd_unload, model_floyd_end },
- {"Dijkstra", "Dijkstra routing data (fast initialization, slow lookup, small memory requirements, shortest path routing only)",
- model_dijkstra_create ,model_dijkstra_both_load, model_dijkstra_both_unload, model_dijkstra_both_end },
- {"DijkstraCache", "Dijkstra routing data (fast initialization, fast lookup, small memory requirements, shortest path routing only)",
- model_dijkstracache_create, model_dijkstra_both_load, model_dijkstra_both_unload, model_dijkstra_both_end },
- {"none", "No routing (usable with Constant network only)",
- model_none_create, model_none_load, model_none_unload, model_none_end },
+struct s_model_type routing_models[] = { {"Full",
+ "Full routing data (fast, large memory requirements, fully expressive)",
+ model_full_create,
+ model_full_load,
+ model_full_unload,
+ model_full_end},
+{"Floyd",
+ "Floyd routing data (slow initialization, fast lookup, lesser memory requirements, shortest path routing only)",
+ model_floyd_create, model_floyd_load, model_floyd_unload,
+ model_floyd_end},
+{"Dijkstra",
+ "Dijkstra routing data (fast initialization, slow lookup, small memory requirements, shortest path routing only)",
+ model_dijkstra_create, model_dijkstra_both_load,
+ model_dijkstra_both_unload, model_dijkstra_both_end},
+{"DijkstraCache",
+ "Dijkstra routing data (fast initialization, fast lookup, small memory requirements, shortest path routing only)",
+ model_dijkstracache_create, model_dijkstra_both_load,
+ model_dijkstra_both_unload, model_dijkstra_both_end},
+{"none", "No routing (usable with Constant network only)",
+ model_none_create, model_none_load, model_none_unload, model_none_end},
#ifdef HAVE_PCRE_LIB
- {"RuleBased", "Rule-Based routing data (...)", model_rulebased_create, model_rulebased_load, model_rulebased_unload, model_rulebased_end },
+{"RuleBased", "Rule-Based routing data (...)", model_rulebased_create,
+ model_rulebased_load, model_rulebased_unload, model_rulebased_end},
#endif
- {NULL,NULL,NULL,NULL,NULL,NULL}};
+{NULL, NULL, NULL, NULL, NULL, NULL}
+};
/* ************************************************************************** */
/* ***************** GENERIC PARSE FUNCTIONS (declarations) ***************** */
-static void generic_set_processing_unit(routing_component_t rc, const char* name);
-static void generic_set_autonomous_system(routing_component_t rc, const char* name);
-static void generic_set_route(routing_component_t rc, const char* src, const char* dst, route_t route);
-static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route);
-static void generic_set_bypassroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route);
+static void generic_set_processing_unit(routing_component_t rc,
+ const char *name);
+static void generic_set_autonomous_system(routing_component_t rc,
+ const char *name);
+static void generic_set_route(routing_component_t rc, const char *src,
+ const char *dst, route_t route);
+static void generic_set_ASroute(routing_component_t rc, const char *src,
+ const char *dst, route_extended_t e_route);
+static void generic_set_bypassroute(routing_component_t rc,
+ const char *src, const char *dst,
+ route_extended_t e_route);
/* ************************************************************************** */
/* *************** GENERIC BUSINESS METHODS (declarations) ****************** */
-static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc);
-static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst);
+static xbt_dynar_t generic_get_onelink_routes(routing_component_t rc);
+static route_extended_t generic_get_bypassroute(routing_component_t rc,
+ const char *src,
+ const char *dst);
/* ************************************************************************** */
/* ****************** GENERIC AUX FUNCTIONS (declarations) ****************** */
-static route_extended_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, void* data, int order);
+static route_extended_t
+generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
+ void *data, int order);
static void generic_free_route(route_t route);
static void generic_free_extended_route(route_extended_t e_route);
-static routing_component_t generic_autonomous_system_exist(routing_component_t rc, char* element);
-static routing_component_t generic_processing_units_exist(routing_component_t rc, char* element);
-static void generic_src_dst_check(routing_component_t rc, const char* src, const char* dst);
+static routing_component_t
+generic_autonomous_system_exist(routing_component_t rc, char *element);
+static routing_component_t
+generic_processing_units_exist(routing_component_t rc, char *element);
+static void generic_src_dst_check(routing_component_t rc, const char *src,
+ const char *dst);
/* ************************************************************************** */
/* **************************** GLOBAL FUNCTIONS **************************** */
-
+
/* global parse functions */
-static char* src = NULL; /* temporary store the source name of a route */
-static char* dst = NULL; /* temporary store the destination name of a route */
-static char* gw_src = NULL; /* temporary store the gateway source name of a route */
-static char* gw_dst = NULL; /* temporary store the gateway destination name of a route */
-static xbt_dynar_t link_list = NULL; /* temporary store of current list link of a route */
+static char *src = NULL; /* temporary store the source name of a route */
+static char *dst = NULL; /* temporary store the destination name of a route */
+static char *gw_src = NULL; /* temporary store the gateway source name of a route */
+static char *gw_dst = NULL; /* temporary store the gateway destination name of a route */
+static xbt_dynar_t link_list = NULL; /* temporary store of current list link of a route */
/**
* \brief Add a "host" to the network element list
*/
-static void parse_S_host(char* host_id) {
- network_element_info_t info = NULL;
- if( current_routing->hierarchy == SURF_ROUTING_NULL ) current_routing->hierarchy = SURF_ROUTING_BASE;
- xbt_assert1(!xbt_dict_get_or_null(global_routing->where_network_elements,host_id),
- "Reading a host, processing unit \"%s\" already exist",host_id);
+static void parse_S_host(char *host_id)
+{
+ network_element_info_t info = NULL;
+ if (current_routing->hierarchy == SURF_ROUTING_NULL)
+ current_routing->hierarchy = SURF_ROUTING_BASE;
+ xbt_assert1(!xbt_dict_get_or_null
+ (global_routing->where_network_elements, host_id),
+ "Reading a host, processing unit \"%s\" already exist",
+ host_id);
xbt_assert1(current_routing->set_processing_unit,
- "no defined method \"set_processing_unit\" in \"%s\"",current_routing->name);
- (*(current_routing->set_processing_unit))(current_routing,host_id);
- info = xbt_new0(s_network_element_info_t,1);
- info->rc_component=current_routing;
- info->rc_type=SURF_NETWORK_ELEMENT_HOST;
- xbt_dict_set(global_routing->where_network_elements,host_id,(void*)info,NULL);
+ "no defined method \"set_processing_unit\" in \"%s\"",
+ current_routing->name);
+ (*(current_routing->set_processing_unit)) (current_routing, host_id);
+ info = xbt_new0(s_network_element_info_t, 1);
+ info->rc_component = current_routing;
+ info->rc_type = SURF_NETWORK_ELEMENT_HOST;
+ xbt_dict_set(global_routing->where_network_elements, host_id,
+ (void *) info, NULL);
}
/*
*/
static void parse_S_host_XML(void)
{
- parse_S_host(A_surfxml_host_id);
+ parse_S_host(A_surfxml_host_id);
}
/*
*/
static void parse_S_host_lua(char *host_id)
{
- parse_S_host(host_id);
+ parse_S_host(host_id);
}
+
/*
*
*/
/**
* \brief Add a "router" to the network element list
*/
-static void parse_S_router(void) {
+static void parse_S_router(void)
+{
network_element_info_t info = NULL;
- if( current_routing->hierarchy == SURF_ROUTING_NULL ) current_routing->hierarchy = SURF_ROUTING_BASE;
- xbt_assert1(!xbt_dict_get_or_null(global_routing->where_network_elements,A_surfxml_router_id),
- "Reading a router, processing unit \"%s\" already exist",A_surfxml_router_id);
+ if (current_routing->hierarchy == SURF_ROUTING_NULL)
+ current_routing->hierarchy = SURF_ROUTING_BASE;
+ xbt_assert1(!xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ A_surfxml_router_id),
+ "Reading a router, processing unit \"%s\" already exist",
+ A_surfxml_router_id);
xbt_assert1(current_routing->set_processing_unit,
- "no defined method \"set_processing_unit\" in \"%s\"",current_routing->name);
- (*(current_routing->set_processing_unit))(current_routing,A_surfxml_router_id);
- info = xbt_new0(s_network_element_info_t,1);
- info->rc_component=current_routing;
- info->rc_type=SURF_NETWORK_ELEMENT_ROUTER;
- xbt_dict_set(global_routing->where_network_elements,A_surfxml_router_id,(void*)info,NULL);
- #ifdef HAVE_TRACING
- TRACE_surf_host_declaration (A_surfxml_router_id, 0);
- #endif
+ "no defined method \"set_processing_unit\" in \"%s\"",
+ current_routing->name);
+ (*(current_routing->set_processing_unit)) (current_routing,
+ A_surfxml_router_id);
+ info = xbt_new0(s_network_element_info_t, 1);
+ info->rc_component = current_routing;
+ info->rc_type = SURF_NETWORK_ELEMENT_ROUTER;
+ xbt_dict_set(global_routing->where_network_elements, A_surfxml_router_id,
+ (void *) info, NULL);
+#ifdef HAVE_TRACING
+ TRACE_surf_host_declaration(A_surfxml_router_id, 0);
+#endif
}
/**
* \brief Set the endponints for a route
*/
-static void parse_S_route_new_and_endpoints(char *src_id,char *dst_id) {
- if( src != NULL && dst != NULL && link_list != NULL )
- THROW2(arg_error,0,"Route between %s to %s can not be defined",src_id,dst_id);
+static void parse_S_route_new_and_endpoints(char *src_id, char *dst_id)
+{
+ if (src != NULL && dst != NULL && link_list != NULL)
+ THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+ src_id, dst_id);
src = src_id;
dst = dst_id;
- xbt_assert2(strlen(src)>0||strlen(dst)>0,
- "Some limits are null in the route between \"%s\" and \"%s\"",src,dst);
- link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
+ xbt_assert2(strlen(src) > 0 || strlen(dst) > 0,
+ "Some limits are null in the route between \"%s\" and \"%s\"",
+ src, dst);
+ link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
/**
*/
static void parse_S_route_new_and_endpoints_XML(void)
{
- parse_S_route_new_and_endpoints(A_surfxml_route_src,A_surfxml_route_dst);
+ parse_S_route_new_and_endpoints(A_surfxml_route_src,
+ A_surfxml_route_dst);
}
/**
* \breif Set the endpoints for a route from lua
*/
-static void parse_S_route_new_and_endpoints_lua(char *id_src,char *id_dst)
+static void parse_S_route_new_and_endpoints_lua(char *id_src, char *id_dst)
{
- parse_S_route_new_and_endpoints(id_src,id_dst);
+ parse_S_route_new_and_endpoints(id_src, id_dst);
}
/**
* \brief Set the endponints and gateways for a ASroute
*/
-static void parse_S_ASroute_new_and_endpoints(void) {
- if( src != NULL && dst != NULL && link_list != NULL )
- THROW2(arg_error,0,"Route between %s to %s can not be defined",A_surfxml_ASroute_src,A_surfxml_ASroute_dst);
+static void parse_S_ASroute_new_and_endpoints(void)
+{
+ if (src != NULL && dst != NULL && link_list != NULL)
+ THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+ A_surfxml_ASroute_src, A_surfxml_ASroute_dst);
src = A_surfxml_ASroute_src;
dst = A_surfxml_ASroute_dst;
gw_src = A_surfxml_ASroute_gw_src;
gw_dst = A_surfxml_ASroute_gw_dst;
- xbt_assert2(strlen(src)>0||strlen(dst)>0||strlen(gw_src)>0||strlen(gw_dst)>0,
- "Some limits are null in the route between \"%s\" and \"%s\"",src,dst);
- link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
+ xbt_assert2(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0
+ || strlen(gw_dst) > 0,
+ "Some limits are null in the route between \"%s\" and \"%s\"",
+ src, dst);
+ link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
/**
* \brief Set the endponints for a bypassRoute
*/
-static void parse_S_bypassRoute_new_and_endpoints(void) {
- if( src != NULL && dst != NULL && link_list != NULL )
- THROW2(arg_error,0,"Bypass Route between %s to %s can not be defined",A_surfxml_bypassRoute_src,A_surfxml_bypassRoute_dst);
+static void parse_S_bypassRoute_new_and_endpoints(void)
+{
+ if (src != NULL && dst != NULL && link_list != NULL)
+ THROW2(arg_error, 0,
+ "Bypass Route between %s to %s can not be defined",
+ A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
src = A_surfxml_bypassRoute_src;
dst = A_surfxml_bypassRoute_dst;
gw_src = A_surfxml_bypassRoute_gw_src;
gw_dst = A_surfxml_bypassRoute_gw_dst;
- xbt_assert2(strlen(src)>0||strlen(dst)>0||strlen(gw_src)>0||strlen(gw_dst)>0,
- "Some limits are null in the route between \"%s\" and \"%s\"",src,dst);
- link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
+ xbt_assert2(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0
+ || strlen(gw_dst) > 0,
+ "Some limits are null in the route between \"%s\" and \"%s\"",
+ src, dst);
+ link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
/**
* \brief Set a new link on the actual list of link for a route or ASroute
*/
-static void parse_E_link_ctn_new_elem(char *link_id) {
+static void parse_E_link_ctn_new_elem(char *link_id)
+{
char *val;
val = xbt_strdup(link_id);
xbt_dynar_push(link_list, &val);
static void parse_E_link_ctn_new_elem_XML(void)
{
- parse_E_link_ctn_new_elem(A_surfxml_link_ctn_id);
+ parse_E_link_ctn_new_elem(A_surfxml_link_ctn_id);
}
/**
* \brief Set a new link on the actual list of link for a route or ASroute from lua
*/
-static void parse_E_link_c_ctn_new_elem_lua(char *link_id) {
+static void parse_E_link_c_ctn_new_elem_lua(char *link_id)
+{
- parse_E_link_ctn_new_elem(link_id);
+ parse_E_link_ctn_new_elem(link_id);
}
/**
* \brief Store the route by calling the set_route function of the current routing component
*/
-static void parse_E_route_store_route(void) {
- route_t route = xbt_new0(s_route_t,1);
+static void parse_E_route_store_route(void)
+{
+ route_t route = xbt_new0(s_route_t, 1);
route->link_list = link_list;
// xbt_assert1(generic_processing_units_exist(current_routing,src),"the \"%s\" processing units gateway does not exist",src);
// xbt_assert1(generic_processing_units_exist(current_routing,dst),"the \"%s\" processing units gateway does not exist",dst);
- xbt_assert1(current_routing->set_route,"no defined method \"set_route\" in \"%s\"",current_routing->name);
- (*(current_routing->set_route))(current_routing,src,dst,route);
+ xbt_assert1(current_routing->set_route,
+ "no defined method \"set_route\" in \"%s\"",
+ current_routing->name);
+ (*(current_routing->set_route)) (current_routing, src, dst, route);
link_list = NULL;
src = NULL;
dst = NULL;
/**
* \brief Store the ASroute by calling the set_ASroute function of the current routing component
*/
-static void parse_E_ASroute_store_route(void) {
- route_extended_t e_route = xbt_new0(s_route_extended_t,1);
+static void parse_E_ASroute_store_route(void)
+{
+ route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
e_route->generic_route.link_list = link_list;
e_route->src_gateway = xbt_strdup(gw_src);
- e_route->dst_gateway = xbt_strdup(gw_dst);
+ e_route->dst_gateway = xbt_strdup(gw_dst);
// xbt_assert1(generic_autonomous_system_exist(current_routing,src),"the \"%s\" autonomous system does not exist",src);
// xbt_assert1(generic_autonomous_system_exist(current_routing,dst),"the \"%s\" autonomous system does not exist",dst);
// xbt_assert1(generic_processing_units_exist(current_routing,gw_src),"the \"%s\" processing units gateway does not exist",gw_src);
// xbt_assert1(generic_processing_units_exist(current_routing,gw_dst),"the \"%s\" processing units gateway does not exist",gw_dst);
- xbt_assert1(current_routing->set_ASroute,"no defined method \"set_ASroute\" in \"%s\"",current_routing->name);
- (*(current_routing->set_ASroute))(current_routing,src,dst,e_route);
+ xbt_assert1(current_routing->set_ASroute,
+ "no defined method \"set_ASroute\" in \"%s\"",
+ current_routing->name);
+ (*(current_routing->set_ASroute)) (current_routing, src, dst, e_route);
link_list = NULL;
src = NULL;
dst = NULL;
/**
* \brief Store the bypass route by calling the set_bypassroute function of the current routing component
*/
-static void parse_E_bypassRoute_store_route(void) {
- route_extended_t e_route = xbt_new0(s_route_extended_t,1);
+static void parse_E_bypassRoute_store_route(void)
+{
+ route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
e_route->generic_route.link_list = link_list;
e_route->src_gateway = xbt_strdup(gw_src);
e_route->dst_gateway = xbt_strdup(gw_dst);
// xbt_assert1(generic_autonomous_system_exist(current_routing,dst),"the \"%s\" autonomous system does not exist",dst);
// xbt_assert1(generic_processing_units_exist(current_routing,gw_src),"the \"%s\" processing units gateway does not exist",gw_src);
// xbt_assert1(generic_processing_units_exist(current_routing,gw_dst),"the \"%s\" processing units gateway does not exist",gw_dst);
- xbt_assert1(current_routing->set_bypassroute,"no defined method \"set_bypassroute\" in \"%s\"",current_routing->name);
- (*(current_routing->set_bypassroute))(current_routing,src,dst,e_route);
+ xbt_assert1(current_routing->set_bypassroute,
+ "no defined method \"set_bypassroute\" in \"%s\"",
+ current_routing->name);
+ (*(current_routing->set_bypassroute)) (current_routing, src, dst,
+ e_route);
link_list = NULL;
src = NULL;
dst = NULL;
* make the new structure and
* set the parsing functions to allows parsing the part of the routing tree
*/
-static void parse_S_AS(char* AS_id,char* AS_routing) {
+static void parse_S_AS(char *AS_id, char *AS_routing)
+{
routing_component_t new_routing;
model_type_t model = NULL;
- char* wanted = AS_routing;
+ char *wanted = AS_routing;
int cpt;
/* seach the routing model */
- for (cpt=0;routing_models[cpt].name;cpt++)
- if (!strcmp(wanted,routing_models[cpt].name))
- model = &routing_models[cpt];
+ for (cpt = 0; routing_models[cpt].name; cpt++)
+ if (!strcmp(wanted, routing_models[cpt].name))
+ model = &routing_models[cpt];
/* if its not exist, error */
- if( model == NULL ) {
- fprintf(stderr,"Routing model %s not found. Existing models:\n",wanted);
- for (cpt=0;routing_models[cpt].name;cpt++)
- if (!strcmp(wanted,routing_models[cpt].name))
- fprintf(stderr," %s: %s\n",routing_models[cpt].name,routing_models[cpt].desc);
+ if (model == NULL) {
+ fprintf(stderr, "Routing model %s not found. Existing models:\n",
+ wanted);
+ for (cpt = 0; routing_models[cpt].name; cpt++)
+ if (!strcmp(wanted, routing_models[cpt].name))
+ fprintf(stderr, " %s: %s\n", routing_models[cpt].name,
+ routing_models[cpt].desc);
xbt_die(NULL);
}
/* make a new routing component */
- new_routing = (routing_component_t)(*(model->create))();
+ new_routing = (routing_component_t) (*(model->create)) ();
new_routing->routing = model;
new_routing->hierarchy = SURF_ROUTING_NULL;
new_routing->name = xbt_strdup(AS_id);
new_routing->routing_sons = xbt_dict_new();
//INFO2("Routing %s for AS %s",A_surfxml_AS_routing,A_surfxml_AS_id);
-
- if( current_routing == NULL && global_routing->root == NULL ){
-
+
+ if (current_routing == NULL && global_routing->root == NULL) {
+
/* it is the first one */
new_routing->routing_father = NULL;
global_routing->root = new_routing;
-
- } else if( current_routing != NULL && global_routing->root != NULL ) {
-
- xbt_assert1(!xbt_dict_get_or_null(current_routing->routing_sons,AS_id),
- "The AS \"%s\" already exist",AS_id);
- /* it is a part of the tree */
+
+ } else if (current_routing != NULL && global_routing->root != NULL) {
+
+ xbt_assert1(!xbt_dict_get_or_null
+ (current_routing->routing_sons, AS_id),
+ "The AS \"%s\" already exist", AS_id);
+ /* it is a part of the tree */
new_routing->routing_father = current_routing;
/* set the father behavior */
- if( current_routing->hierarchy == SURF_ROUTING_NULL ) current_routing->hierarchy = SURF_ROUTING_RECURSIVE;
+ if (current_routing->hierarchy == SURF_ROUTING_NULL)
+ current_routing->hierarchy = SURF_ROUTING_RECURSIVE;
/* add to the sons dictionary */
- xbt_dict_set(current_routing->routing_sons,AS_id,(void*)new_routing,NULL);
+ xbt_dict_set(current_routing->routing_sons, AS_id,
+ (void *) new_routing, NULL);
/* add to the father element list */
- (*(current_routing->set_autonomous_system))(current_routing,AS_id);
+ (*(current_routing->set_autonomous_system)) (current_routing, AS_id);
/* unload the prev parse rules */
- (*(current_routing->routing->unload))();
-
+ (*(current_routing->routing->unload)) ();
+
} else {
- THROW0(arg_error,0,"All defined components must be belong to a AS");
+ THROW0(arg_error, 0, "All defined components must be belong to a AS");
}
/* set the new parse rules */
- (*(new_routing->routing->load))();
+ (*(new_routing->routing->load)) ();
/* set the new current component of the tree */
current_routing = new_routing;
}
*/
static void parse_S_AS_XML(void)
{
- parse_S_AS(A_surfxml_AS_id,A_surfxml_AS_routing);
+ parse_S_AS(A_surfxml_AS_id, A_surfxml_AS_routing);
}
/*
* define the routing model type of routing component from lua script
*/
-static void parse_S_AS_lua(char* id,char* mode)
+static void parse_S_AS_lua(char *id, char *mode)
{
- parse_S_AS(id,mode);
+ parse_S_AS(id, mode);
}
* When you finish to read the routing component, other structures must be created.
* the "end" method allow to do that for any routing model type
*/
-static void parse_E_AS(char *AS_id) {
+static void parse_E_AS(char *AS_id)
+{
- if( current_routing == NULL ) {
- THROW1(arg_error,0,"Close AS(%s), that never open",AS_id);
+ if (current_routing == NULL) {
+ THROW1(arg_error, 0, "Close AS(%s), that never open", AS_id);
} else {
- network_element_info_t info = NULL;
- xbt_assert1(!xbt_dict_get_or_null(global_routing->where_network_elements,current_routing->name),
- "The AS \"%s\" already exist",current_routing->name);
- info = xbt_new0(s_network_element_info_t,1);
- info->rc_component=current_routing->routing_father;
- info->rc_type=SURF_NETWORK_ELEMENT_AS;
- xbt_dict_set(global_routing->where_network_elements,current_routing->name,info,NULL);
- (*(current_routing->routing->unload))();
- (*(current_routing->routing->end))();
- current_routing = current_routing->routing_father;
- if( current_routing != NULL )
- (*(current_routing->routing->load))();
+ network_element_info_t info = NULL;
+ xbt_assert1(!xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ current_routing->name), "The AS \"%s\" already exist",
+ current_routing->name);
+ info = xbt_new0(s_network_element_info_t, 1);
+ info->rc_component = current_routing->routing_father;
+ info->rc_type = SURF_NETWORK_ELEMENT_AS;
+ xbt_dict_set(global_routing->where_network_elements,
+ current_routing->name, info, NULL);
+ (*(current_routing->routing->unload)) ();
+ (*(current_routing->routing->end)) ();
+ current_routing = current_routing->routing_father;
+ if (current_routing != NULL)
+ (*(current_routing->routing->load)) ();
}
}
*/
static void parse_E_AS_XML(void)
{
- parse_E_AS(A_surfxml_AS_id);
+ parse_E_AS(A_surfxml_AS_id);
}
/*
*/
static void parse_E_AS_lua(char *id)
{
- parse_E_AS(id);
+ parse_E_AS(id);
}
/* Aux Business methods */
* Get the common father of the to processing units, and the first different
* father in the chain
*/
-static xbt_dynar_t elements_father(const char* src,const char* dst) {
-
- xbt_assert0(src&&dst,"bad parameters for \"elements_father\" method");
-
- xbt_dynar_t result = xbt_dynar_new(sizeof(char*), NULL);
-
+static xbt_dynar_t elements_father(const char *src, const char *dst)
+{
+
+ xbt_assert0(src && dst, "bad parameters for \"elements_father\" method");
+
+ xbt_dynar_t result = xbt_dynar_new(sizeof(char *), NULL);
+
routing_component_t src_as, dst_as;
int index_src, index_dst, index_father_src, index_father_dst;
xbt_dynar_t path_src = NULL;
xbt_dynar_t path_dst = NULL;
routing_component_t current = NULL;
- routing_component_t* current_src = NULL;
- routing_component_t* current_dst = NULL;
- routing_component_t* father = NULL;
-
+ routing_component_t *current_src = NULL;
+ routing_component_t *current_dst = NULL;
+ routing_component_t *father = NULL;
+
/* (1) find the as where the src and dst are located */
- src_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,src))->rc_component;
- dst_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,dst))->rc_component;
- xbt_assert2(src_as&&dst_as, "Ask for route \"from\"(%s) or \"to\"(%s) no found",src,dst);
-
+ src_as = ((network_element_info_t)
+ xbt_dict_get_or_null(global_routing->where_network_elements,
+ src))->rc_component;
+ dst_as = ((network_element_info_t)
+ xbt_dict_get_or_null(global_routing->where_network_elements,
+ dst))->rc_component;
+ xbt_assert2(src_as
+ && dst_as,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found", src,
+ dst);
+
/* (2) find the path to the root routing component */
path_src = xbt_dynar_new(sizeof(routing_component_t), NULL);
- current = src_as;
- while( current != NULL ) {
- xbt_dynar_push(path_src,¤t);
+ current = src_as;
+ while (current != NULL) {
+ xbt_dynar_push(path_src, ¤t);
current = current->routing_father;
}
path_dst = xbt_dynar_new(sizeof(routing_component_t), NULL);
- current = dst_as;
- while( current != NULL ) {
- xbt_dynar_push(path_dst,¤t);
+ current = dst_as;
+ while (current != NULL) {
+ xbt_dynar_push(path_dst, ¤t);
current = current->routing_father;
}
-
+
/* (3) find the common father */
- index_src = (path_src->used)-1;
- index_dst = (path_dst->used)-1;
- current_src = xbt_dynar_get_ptr(path_src,index_src);
- current_dst = xbt_dynar_get_ptr(path_dst,index_dst);
- while( index_src >= 0 && index_dst >= 0 && *current_src == *current_dst ) {
- current_src = xbt_dynar_get_ptr(path_src,index_src);
- current_dst = xbt_dynar_get_ptr(path_dst,index_dst);
+ index_src = (path_src->used) - 1;
+ index_dst = (path_dst->used) - 1;
+ current_src = xbt_dynar_get_ptr(path_src, index_src);
+ current_dst = xbt_dynar_get_ptr(path_dst, index_dst);
+ while (index_src >= 0 && index_dst >= 0 && *current_src == *current_dst) {
+ current_src = xbt_dynar_get_ptr(path_src, index_src);
+ current_dst = xbt_dynar_get_ptr(path_dst, index_dst);
index_src--;
index_dst--;
}
index_src++;
index_dst++;
- current_src = xbt_dynar_get_ptr(path_src,index_src);
- current_dst = xbt_dynar_get_ptr(path_dst,index_dst);
+ current_src = xbt_dynar_get_ptr(path_src, index_src);
+ current_dst = xbt_dynar_get_ptr(path_dst, index_dst);
/* (4) they are not in the same routing component, make the path */
- index_father_src = index_src+1;
- index_father_dst = index_dst+1;
-
- if(*current_src==*current_dst)
+ index_father_src = index_src + 1;
+ index_father_dst = index_dst + 1;
+
+ if (*current_src == *current_dst)
father = current_src;
else
- father = xbt_dynar_get_ptr(path_src,index_father_src);
-
+ father = xbt_dynar_get_ptr(path_src, index_father_src);
+
/* (5) result generation */
- xbt_dynar_push(result,father); /* first same the father of src and dst */
- xbt_dynar_push(result,current_src); /* second the first different father of src */
- xbt_dynar_push(result,current_dst); /* three the first different father of dst */
-
+ xbt_dynar_push(result, father); /* first same the father of src and dst */
+ xbt_dynar_push(result, current_src); /* second the first different father of src */
+ xbt_dynar_push(result, current_dst); /* three the first different father of dst */
+
xbt_dynar_free(&path_src);
xbt_dynar_free(&path_dst);
-
+
return result;
}
* This fuction is call by "get_route". It allow to walk through the
* routing components tree.
*/
-static route_extended_t _get_route(const char* src,const char* dst) {
-
- void* link;
- unsigned int cpt=0;
-
- DEBUG2("Solve route \"%s\" to \"%s\"",src,dst);
-
- xbt_assert0(src&&dst,"bad parameters for \"_get_route\" method");
-
- route_extended_t e_route, e_route_cnt, e_route_src=NULL, e_route_dst=NULL;
-
- xbt_dynar_t elem_father_list = elements_father(src,dst);
-
- routing_component_t common_father = xbt_dynar_get_as(elem_father_list, 0, routing_component_t);
- routing_component_t src_father = xbt_dynar_get_as(elem_father_list, 1, routing_component_t);
- routing_component_t dst_father = xbt_dynar_get_as(elem_father_list, 2, routing_component_t);
-
- e_route = xbt_new0(s_route_extended_t,1);
+static route_extended_t _get_route(const char *src, const char *dst)
+{
+
+ void *link;
+ unsigned int cpt = 0;
+
+ DEBUG2("Solve route \"%s\" to \"%s\"", src, dst);
+
+ xbt_assert0(src && dst, "bad parameters for \"_get_route\" method");
+
+ route_extended_t e_route, e_route_cnt, e_route_src = NULL, e_route_dst =
+ NULL;
+
+ xbt_dynar_t elem_father_list = elements_father(src, dst);
+
+ routing_component_t common_father =
+ xbt_dynar_get_as(elem_father_list, 0, routing_component_t);
+ routing_component_t src_father =
+ xbt_dynar_get_as(elem_father_list, 1, routing_component_t);
+ routing_component_t dst_father =
+ xbt_dynar_get_as(elem_father_list, 2, routing_component_t);
+
+ e_route = xbt_new0(s_route_extended_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
-
- if(src_father==dst_father) { /* SURF_ROUTING_BASE */
-
- if( strcmp(src,dst) ){
- e_route_cnt = (*(common_father->get_route))(common_father,src,dst);
- xbt_assert2(e_route_cnt,"no route between \"%s\" and \"%s\"",src,dst);
+ e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+
+ if (src_father == dst_father) { /* SURF_ROUTING_BASE */
+
+ if (strcmp(src, dst)) {
+ e_route_cnt =
+ (*(common_father->get_route)) (common_father, src, dst);
+ xbt_assert2(e_route_cnt, "no route between \"%s\" and \"%s\"", src,
+ dst);
xbt_dynar_foreach(e_route_cnt->generic_route.link_list, cpt, link) {
- xbt_dynar_push(e_route->generic_route.link_list,&link);
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
}
generic_free_extended_route(e_route_cnt);
}
-
- } else { /* SURF_ROUTING_RECURSIVE */
+
+ } else { /* SURF_ROUTING_RECURSIVE */
route_extended_t e_route_bypass = NULL;
-
- if(common_father->get_bypass_route)
- e_route_bypass = (*(common_father->get_bypass_route))(common_father,src,dst);
-
- if(e_route_bypass)
- e_route_cnt = e_route_bypass;
- else
- e_route_cnt = (*(common_father->get_route))(common_father,src_father->name,dst_father->name);
-
- xbt_assert2(e_route_cnt,"no route between \"%s\" and \"%s\"",src_father->name,dst_father->name);
- xbt_assert2( (e_route_cnt->src_gateway==NULL) == (e_route_cnt->dst_gateway==NULL) ,
- "bad gateway for route between \"%s\" and \"%s\"",src,dst);
+ if (common_father->get_bypass_route)
+ e_route_bypass =
+ (*(common_father->get_bypass_route)) (common_father, src, dst);
- if( src != e_route_cnt->src_gateway ) {
- e_route_src = _get_route(src,e_route_cnt->src_gateway);
- xbt_assert2(e_route_src,"no route between \"%s\" and \"%s\"",src,e_route_cnt->src_gateway);
+ if (e_route_bypass)
+ e_route_cnt = e_route_bypass;
+ else
+ e_route_cnt =
+ (*(common_father->get_route)) (common_father, src_father->name,
+ dst_father->name);
+
+ xbt_assert2(e_route_cnt, "no route between \"%s\" and \"%s\"",
+ src_father->name, dst_father->name);
+
+ xbt_assert2((e_route_cnt->src_gateway == NULL) ==
+ (e_route_cnt->dst_gateway == NULL),
+ "bad gateway for route between \"%s\" and \"%s\"", src,
+ dst);
+
+ if (src != e_route_cnt->src_gateway) {
+ e_route_src = _get_route(src, e_route_cnt->src_gateway);
+ xbt_assert2(e_route_src, "no route between \"%s\" and \"%s\"", src,
+ e_route_cnt->src_gateway);
xbt_dynar_foreach(e_route_src->generic_route.link_list, cpt, link) {
- xbt_dynar_push(e_route->generic_route.link_list,&link);
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
}
}
-
+
xbt_dynar_foreach(e_route_cnt->generic_route.link_list, cpt, link) {
- xbt_dynar_push(e_route->generic_route.link_list,&link);
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
}
-
- if( e_route_cnt->dst_gateway != dst ) {
- e_route_dst = _get_route(e_route_cnt->dst_gateway,dst);
- xbt_assert2(e_route_dst,"no route between \"%s\" and \"%s\"",e_route_cnt->dst_gateway,dst);
+
+ if (e_route_cnt->dst_gateway != dst) {
+ e_route_dst = _get_route(e_route_cnt->dst_gateway, dst);
+ xbt_assert2(e_route_dst, "no route between \"%s\" and \"%s\"",
+ e_route_cnt->dst_gateway, dst);
xbt_dynar_foreach(e_route_dst->generic_route.link_list, cpt, link) {
- xbt_dynar_push(e_route->generic_route.link_list,&link);
+ xbt_dynar_push(e_route->generic_route.link_list, &link);
}
}
-
+
e_route->src_gateway = xbt_strdup(e_route_cnt->src_gateway);
e_route->dst_gateway = xbt_strdup(e_route_cnt->dst_gateway);
generic_free_extended_route(e_route_cnt);
generic_free_extended_route(e_route_dst);
}
-
+
xbt_dynar_free(&elem_father_list);
-
- return e_route;
+
+ return e_route;
}
/**
* walk through the routing components tree and find a route between hosts
* by calling the differents "get_route" functions in each routing component
*/
-static xbt_dynar_t get_route(const char* src,const char* dst) {
-
+static xbt_dynar_t get_route(const char *src, const char *dst)
+{
+
route_extended_t e_route;
- xbt_dynar_t elem_father_list = elements_father(src,dst);
- routing_component_t common_father = xbt_dynar_get_as(elem_father_list, 0, routing_component_t);
-
- if(strcmp(src,dst))
- e_route = _get_route(src,dst);
+ xbt_dynar_t elem_father_list = elements_father(src, dst);
+ routing_component_t common_father =
+ xbt_dynar_get_as(elem_father_list, 0, routing_component_t);
+
+ if (strcmp(src, dst))
+ e_route = _get_route(src, dst);
else
- e_route = (*(common_father->get_route))(common_father,src,dst);
-
- xbt_assert2(e_route,"no route between \"%s\" and \"%s\"",src,dst);
-
- if(global_routing->last_route) xbt_dynar_free( &(global_routing->last_route) );
+ e_route = (*(common_father->get_route)) (common_father, src, dst);
+
+ xbt_assert2(e_route, "no route between \"%s\" and \"%s\"", src, dst);
+
+ if (global_routing->last_route)
+ xbt_dynar_free(&(global_routing->last_route));
global_routing->last_route = e_route->generic_route.link_list;
-
- if(e_route->src_gateway) xbt_free(e_route->src_gateway);
- if(e_route->dst_gateway) xbt_free(e_route->dst_gateway);
-
+
+ if (e_route->src_gateway)
+ xbt_free(e_route->src_gateway);
+ if (e_route->dst_gateway)
+ xbt_free(e_route->dst_gateway);
+
xbt_free(e_route);
xbt_dynar_free(&elem_father_list);
-
- if( xbt_dynar_length(global_routing->last_route)==0 )
+
+ if (xbt_dynar_length(global_routing->last_route) == 0)
return NULL;
else
return global_routing->last_route;
* This fuction is call by "finalize". It allow to finalize the
* AS or routing components. It delete all the structures.
*/
-static void _finalize(routing_component_t rc) {
- if(rc) {
+static void _finalize(routing_component_t rc)
+{
+ if (rc) {
xbt_dict_cursor_t cursor = NULL;
char *key;
routing_component_t elem;
_finalize(elem);
}
xbt_dict_t tmp_sons = rc->routing_sons;
- char* tmp_name = rc->name;
+ char *tmp_name = rc->name;
xbt_dict_free(&tmp_sons);
xbt_free(tmp_name);
- xbt_assert1(rc->finalize,"no defined method \"finalize\" in \"%s\"",current_routing->name);
- (*(rc->finalize))(rc);
+ xbt_assert1(rc->finalize, "no defined method \"finalize\" in \"%s\"",
+ current_routing->name);
+ (*(rc->finalize)) (rc);
}
}
* walk through the routing components tree and delete the structures
* by calling the differents "finalize" functions in each routing component
*/
-static void finalize(void) {
- /* delete recursibly all the tree */
+static void finalize(void)
+{
+ /* delete recursibly all the tree */
_finalize(global_routing->root);
/* delete "where" dict */
xbt_dict_free(&(global_routing->where_network_elements));
xbt_free(global_routing);
}
-static xbt_dynar_t recursive_get_onelink_routes (routing_component_t rc)
+static xbt_dynar_t recursive_get_onelink_routes(routing_component_t rc)
{
- xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
//adding my one link routes
unsigned int cpt;
void *link;
- xbt_dynar_t onelink_mine = rc->get_onelink_routes (rc);
- if (onelink_mine){
+ xbt_dynar_t onelink_mine = rc->get_onelink_routes(rc);
+ if (onelink_mine) {
xbt_dynar_foreach(onelink_mine, cpt, link) {
- xbt_dynar_push(ret,&link);
+ xbt_dynar_push(ret, &link);
}
}
-
//recursing
char *key;
- xbt_dict_cursor_t cursor=NULL;
+ xbt_dict_cursor_t cursor = NULL;
routing_component_t rc_child;
xbt_dict_foreach(rc->routing_sons, cursor, key, rc_child) {
- xbt_dynar_t onelink_child = recursive_get_onelink_routes (rc_child);
- if (onelink_child){
+ xbt_dynar_t onelink_child = recursive_get_onelink_routes(rc_child);
+ if (onelink_child) {
xbt_dynar_foreach(onelink_child, cpt, link) {
- xbt_dynar_push(ret,&link);
+ xbt_dynar_push(ret, &link);
}
}
}
static xbt_dynar_t get_onelink_routes(void)
{
- return recursive_get_onelink_routes (global_routing->root);
+ return recursive_get_onelink_routes(global_routing->root);
}
-static e_surf_network_element_type_t get_network_element_type(const char *name)
+static e_surf_network_element_type_t get_network_element_type(const char
+ *name)
{
- network_element_info_t rc=NULL;
- rc = xbt_dict_get(global_routing->where_network_elements,name);
- return rc->rc_type;
+ network_element_info_t rc = NULL;
+ rc = xbt_dict_get(global_routing->where_network_elements, name);
+ return rc->rc_type;
}
/**
*
* Make a global routing structure and set all the parsing functions.
*/
-void routing_model_create(size_t size_of_links, void* loopback) {
-
+void routing_model_create(size_t size_of_links, void *loopback)
+{
+
/* config the uniq global routing */
- global_routing = xbt_new0(s_routing_global_t,1);
+ global_routing = xbt_new0(s_routing_global_t, 1);
global_routing->where_network_elements = xbt_dict_new();
global_routing->root = NULL;
global_routing->get_route = get_route;
global_routing->loopback = loopback;
global_routing->size_of_link = size_of_links;
global_routing->last_route = xbt_dynar_new(size_of_links, NULL);
-
+
/* no current routing at moment */
current_routing = NULL;
surfxml_add_callback(STag_surfxml_host_cb_list, &parse_S_host_XML);
surfxml_add_callback(STag_surfxml_router_cb_list, &parse_S_router);
- surfxml_add_callback(STag_surfxml_route_cb_list, &parse_S_route_new_and_endpoints_XML);
- surfxml_add_callback(STag_surfxml_ASroute_cb_list, &parse_S_ASroute_new_and_endpoints);
- surfxml_add_callback(STag_surfxml_bypassRoute_cb_list, &parse_S_bypassRoute_new_and_endpoints);
-
- surfxml_add_callback(ETag_surfxml_link_ctn_cb_list, &parse_E_link_ctn_new_elem_XML);
-
- surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_E_route_store_route);
- surfxml_add_callback(ETag_surfxml_ASroute_cb_list, &parse_E_ASroute_store_route);
- surfxml_add_callback(ETag_surfxml_bypassRoute_cb_list, &parse_E_bypassRoute_store_route);
-
+ surfxml_add_callback(STag_surfxml_route_cb_list,
+ &parse_S_route_new_and_endpoints_XML);
+ surfxml_add_callback(STag_surfxml_ASroute_cb_list,
+ &parse_S_ASroute_new_and_endpoints);
+ surfxml_add_callback(STag_surfxml_bypassRoute_cb_list,
+ &parse_S_bypassRoute_new_and_endpoints);
+
+ surfxml_add_callback(ETag_surfxml_link_ctn_cb_list,
+ &parse_E_link_ctn_new_elem_XML);
+
+ surfxml_add_callback(ETag_surfxml_route_cb_list,
+ &parse_E_route_store_route);
+ surfxml_add_callback(ETag_surfxml_ASroute_cb_list,
+ &parse_E_ASroute_store_route);
+ surfxml_add_callback(ETag_surfxml_bypassRoute_cb_list,
+ &parse_E_bypassRoute_store_route);
+
surfxml_add_callback(STag_surfxml_AS_cb_list, &parse_S_AS_XML);
surfxml_add_callback(ETag_surfxml_AS_cb_list, &parse_E_AS_XML);
- surfxml_add_callback(STag_surfxml_cluster_cb_list, &routing_full_parse_Scluster);
+ surfxml_add_callback(STag_surfxml_cluster_cb_list,
+ &routing_full_parse_Scluster);
surfxml_add_callback(STag_surfxml_config_cb_list, &parse_Sconfig);
}
typedef struct {
s_routing_component_t generic_routing;
- xbt_dict_t parse_routes; /* store data during the parse process */
- xbt_dict_t to_index; /* char* -> network_element_t */
+ xbt_dict_t parse_routes; /* store data during the parse process */
+ xbt_dict_t to_index; /* char* -> network_element_t */
xbt_dict_t bypassRoutes;
route_extended_t *routing_table;
-} s_routing_component_full_t,*routing_component_full_t;
+} s_routing_component_full_t, *routing_component_full_t;
/* Business methods */
static xbt_dynar_t full_get_onelink_routes(routing_component_t rc)
{
- xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
- routing_component_full_t routing = (routing_component_full_t)rc;
+ routing_component_full_t routing = (routing_component_full_t) rc;
int table_size = xbt_dict_length(routing->to_index);
xbt_dict_cursor_t c1 = NULL, c2 = NULL;
char *k1, *d1, *k2, *d2;
xbt_dict_foreach(routing->to_index, c1, k1, d1) {
- xbt_dict_foreach (routing->to_index, c2, k2, d2) {
+ xbt_dict_foreach(routing->to_index, c2, k2, d2) {
int *src_id = xbt_dict_get_or_null(routing->to_index, k1);
int *dst_id = xbt_dict_get_or_null(routing->to_index, k2);
- xbt_assert2(src_id && dst_id, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
- route_extended_t route = TO_ROUTE_FULL(*src_id,*dst_id);
- if (route){
- if (xbt_dynar_length(route->generic_route.link_list) == 1){
- void *link = *(void**)xbt_dynar_get_ptr(route->generic_route.link_list,0);
- onelink_t onelink = xbt_new0 (s_onelink_t, 1);
+ xbt_assert2(src_id
+ && dst_id,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
+ src, dst);
+ route_extended_t route = TO_ROUTE_FULL(*src_id, *dst_id);
+ if (route) {
+ if (xbt_dynar_length(route->generic_route.link_list) == 1) {
+ void *link =
+ *(void **) xbt_dynar_get_ptr(route->generic_route.link_list,
+ 0);
+ onelink_t onelink = xbt_new0(s_onelink_t, 1);
onelink->link_ptr = link;
- if (routing->generic_routing.hierarchy == SURF_ROUTING_BASE){
- onelink->src = xbt_strdup (k1);
- onelink->dst = xbt_strdup (k2);
- }else if (routing->generic_routing.hierarchy == SURF_ROUTING_RECURSIVE){
- onelink->src = xbt_strdup (route->src_gateway);
- onelink->dst = xbt_strdup (route->dst_gateway);
+ if (routing->generic_routing.hierarchy == SURF_ROUTING_BASE) {
+ onelink->src = xbt_strdup(k1);
+ onelink->dst = xbt_strdup(k2);
+ } else if (routing->generic_routing.hierarchy ==
+ SURF_ROUTING_RECURSIVE) {
+ onelink->src = xbt_strdup(route->src_gateway);
+ onelink->dst = xbt_strdup(route->dst_gateway);
}
- xbt_dynar_push (ret, &onelink);
+ xbt_dynar_push(ret, &onelink);
}
}
}
return ret;
}
-static route_extended_t full_get_route(routing_component_t rc, const char* src,const char* dst) {
- xbt_assert1(rc&&src&&dst, "Invalid params for \"get_route\" function at AS \"%s\"",rc->name);
-
+static route_extended_t full_get_route(routing_component_t rc,
+ const char *src, const char *dst)
+{
+ xbt_assert1(rc && src
+ && dst,
+ "Invalid params for \"get_route\" function at AS \"%s\"",
+ rc->name);
+
/* set utils vars */
- routing_component_full_t routing = (routing_component_full_t)rc;
+ routing_component_full_t routing = (routing_component_full_t) rc;
int table_size = xbt_dict_length(routing->to_index);
-
- generic_src_dst_check(rc,src,dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index,src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index,dst);
- xbt_assert2(src_id && dst_id, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
+
+ generic_src_dst_check(rc, src, dst);
+ int *src_id = xbt_dict_get_or_null(routing->to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ xbt_assert2(src_id
+ && dst_id,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
+ src, dst);
route_extended_t e_route = NULL;
route_extended_t new_e_route = NULL;
- void* link;
- unsigned int cpt=0;
+ void *link;
+ unsigned int cpt = 0;
+
+ e_route = TO_ROUTE_FULL(*src_id, *dst_id);
- e_route = TO_ROUTE_FULL(*src_id,*dst_id);
-
- if(e_route) {
- new_e_route = xbt_new0(s_route_extended_t,1);
+ if (e_route) {
+ new_e_route = xbt_new0(s_route_extended_t, 1);
new_e_route->src_gateway = xbt_strdup(e_route->src_gateway);
new_e_route->dst_gateway = xbt_strdup(e_route->dst_gateway);
- new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+ new_e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
xbt_dynar_foreach(e_route->generic_route.link_list, cpt, link) {
- xbt_dynar_push(new_e_route->generic_route.link_list,&link);
+ xbt_dynar_push(new_e_route->generic_route.link_list, &link);
}
}
return new_e_route;
}
-static void full_finalize(routing_component_t rc) {
- routing_component_full_t routing = (routing_component_full_t)rc;
+static void full_finalize(routing_component_t rc)
+{
+ routing_component_full_t routing = (routing_component_full_t) rc;
int table_size = xbt_dict_length(routing->to_index);
- int i,j;
+ int i, j;
if (routing) {
/* Delete routing table */
- for (i=0;i<table_size;i++)
- for (j=0;j<table_size;j++)
- generic_free_extended_route(TO_ROUTE_FULL(i,j));
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++)
+ generic_free_extended_route(TO_ROUTE_FULL(i, j));
xbt_free(routing->routing_table);
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
/* Creation routing model functions */
-static void* model_full_create(void) {
- routing_component_full_t new_component = xbt_new0(s_routing_component_full_t,1);
- new_component->generic_routing.set_processing_unit = generic_set_processing_unit;
- new_component->generic_routing.set_autonomous_system = generic_set_autonomous_system;
+static void *model_full_create(void)
+{
+ routing_component_full_t new_component =
+ xbt_new0(s_routing_component_full_t, 1);
+ new_component->generic_routing.set_processing_unit =
+ generic_set_processing_unit;
+ new_component->generic_routing.set_autonomous_system =
+ generic_set_autonomous_system;
new_component->generic_routing.set_route = generic_set_route;
new_component->generic_routing.set_ASroute = generic_set_ASroute;
new_component->generic_routing.set_bypassroute = generic_set_bypassroute;
new_component->generic_routing.get_route = full_get_route;
- new_component->generic_routing.get_onelink_routes = full_get_onelink_routes;
- new_component->generic_routing.get_bypass_route = generic_get_bypassroute;
+ new_component->generic_routing.get_onelink_routes =
+ full_get_onelink_routes;
+ new_component->generic_routing.get_bypass_route =
+ generic_get_bypassroute;
new_component->generic_routing.finalize = full_finalize;
new_component->to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
return new_component;
}
-static void model_full_load(void) {
- /* use "surfxml_add_callback" to add a parse function call */
+static void model_full_load(void)
+{
+ /* use "surfxml_add_callback" to add a parse function call */
}
-static void model_full_unload(void) {
- /* use "surfxml_del_callback" to remove a parse function call */
+static void model_full_unload(void)
+{
+ /* use "surfxml_del_callback" to remove a parse function call */
}
-static void model_full_end(void) {
-
+static void model_full_end(void)
+{
+
char *key, *end;
- const char* sep = "#";
+ const char *sep = "#";
int src_id, dst_id;
unsigned int i, j;
route_t route;
route_extended_t e_route;
- void* data;
-
+ void *data;
+
xbt_dict_cursor_t cursor = NULL;
xbt_dynar_t keys = NULL;
-
+
/* set utils vars */
- routing_component_full_t routing = ((routing_component_full_t)current_routing);
+ routing_component_full_t routing =
+ ((routing_component_full_t) current_routing);
int table_size = xbt_dict_length(routing->to_index);
-
+
/* Create the routing table */
- routing->routing_table = xbt_new0(route_extended_t, table_size * table_size);
-
+ routing->routing_table =
+ xbt_new0(route_extended_t, table_size * table_size);
+
/* Put the routes in position */
xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
keys = xbt_str_split_str(key, sep);
src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
- TO_ROUTE_FULL(src_id,dst_id) = generic_new_extended_route(current_routing->hierarchy,data,1);
- xbt_dynar_free(&keys);
- }
+ TO_ROUTE_FULL(src_id, dst_id) =
+ generic_new_extended_route(current_routing->hierarchy, data, 1);
+ xbt_dynar_free(&keys);
+ }
- /* delete the parse table */
+ /* delete the parse table */
xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
- route = (route_t)data;
+ route = (route_t) data;
xbt_dynar_free(&(route->link_list));
xbt_free(data);
}
-
+
/* delete parse dict */
xbt_dict_free(&(routing->parse_routes));
/* Add the loopback if needed */
- if(current_routing->hierarchy == SURF_ROUTING_BASE) {
+ if (current_routing->hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
e_route = TO_ROUTE_FULL(i, i);
- if(!e_route) {
- e_route = xbt_new0(s_route_extended_t,1);
+ if (!e_route) {
+ e_route = xbt_new0(s_route_extended_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
- xbt_dynar_push(e_route->generic_route.link_list,&global_routing->loopback);
+ e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_push(e_route->generic_route.link_list,
+ &global_routing->loopback);
TO_ROUTE_FULL(i, i) = e_route;
}
}
}
/* Shrink the dynar routes (save unused slots) */
- for (i=0;i<table_size;i++)
- for (j=0;j<table_size;j++)
- if(TO_ROUTE_FULL(i,j))
- xbt_dynar_shrink(TO_ROUTE_FULL(i,j)->generic_route.link_list,0);
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++)
+ if (TO_ROUTE_FULL(i, j))
+ xbt_dynar_shrink(TO_ROUTE_FULL(i, j)->generic_route.link_list, 0);
}
/* ************************************************************************** */
route_extended_t *link_table; /* char* -> int* */
xbt_dict_t to_index;
xbt_dict_t bypassRoutes;
- /* store data during the parse process */
- xbt_dict_t parse_routes;
-} s_routing_component_floyd_t,*routing_component_floyd_t;
+ /* store data during the parse process */
+ xbt_dict_t parse_routes;
+} s_routing_component_floyd_t, *routing_component_floyd_t;
-static route_extended_t floyd_get_route(routing_component_t rc, const char* src,const char* dst);
+static route_extended_t floyd_get_route(routing_component_t rc,
+ const char *src, const char *dst);
/* Business methods */
static xbt_dynar_t floyd_get_onelink_routes(routing_component_t rc)
{
- xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
- routing_component_floyd_t routing = (routing_component_floyd_t)rc;
+ routing_component_floyd_t routing = (routing_component_floyd_t) rc;
//int table_size = xbt_dict_length(routing->to_index);
xbt_dict_cursor_t c1 = NULL, c2 = NULL;
char *k1, *d1, *k2, *d2;
xbt_dict_foreach(routing->to_index, c1, k1, d1) {
- xbt_dict_foreach (routing->to_index, c2, k2, d2) {
- route_extended_t route = floyd_get_route (rc, k1, k2);
- if (route){
- if (xbt_dynar_length(route->generic_route.link_list) == 1){
- void *link = *(void**)xbt_dynar_get_ptr(route->generic_route.link_list,0);
- onelink_t onelink = xbt_new0 (s_onelink_t, 1);
+ xbt_dict_foreach(routing->to_index, c2, k2, d2) {
+ route_extended_t route = floyd_get_route(rc, k1, k2);
+ if (route) {
+ if (xbt_dynar_length(route->generic_route.link_list) == 1) {
+ void *link =
+ *(void **) xbt_dynar_get_ptr(route->generic_route.link_list,
+ 0);
+ onelink_t onelink = xbt_new0(s_onelink_t, 1);
onelink->link_ptr = link;
- if (routing->generic_routing.hierarchy == SURF_ROUTING_BASE){
- onelink->src = xbt_strdup (k1);
- onelink->dst = xbt_strdup (k2);
- }else if (routing->generic_routing.hierarchy == SURF_ROUTING_RECURSIVE){
- onelink->src = xbt_strdup (route->src_gateway);
- onelink->dst = xbt_strdup (route->dst_gateway);
+ if (routing->generic_routing.hierarchy == SURF_ROUTING_BASE) {
+ onelink->src = xbt_strdup(k1);
+ onelink->dst = xbt_strdup(k2);
+ } else if (routing->generic_routing.hierarchy ==
+ SURF_ROUTING_RECURSIVE) {
+ onelink->src = xbt_strdup(route->src_gateway);
+ onelink->dst = xbt_strdup(route->dst_gateway);
}
- xbt_dynar_push (ret, &onelink);
+ xbt_dynar_push(ret, &onelink);
}
}
}
return ret;
}
-static route_extended_t floyd_get_route(routing_component_t rc, const char* src,const char* dst) {
- xbt_assert1(rc&&src&&dst, "Invalid params for \"get_route\" function at AS \"%s\"",rc->name);
-
+static route_extended_t floyd_get_route(routing_component_t rc,
+ const char *src, const char *dst)
+{
+ xbt_assert1(rc && src
+ && dst,
+ "Invalid params for \"get_route\" function at AS \"%s\"",
+ rc->name);
+
/* set utils vars */
routing_component_floyd_t routing = (routing_component_floyd_t) rc;
int table_size = xbt_dict_length(routing->to_index);
-
- generic_src_dst_check(rc,src,dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index,src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index,dst);
- xbt_assert2(src_id && dst_id, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
-
+
+ generic_src_dst_check(rc, src, dst);
+ int *src_id = xbt_dict_get_or_null(routing->to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ xbt_assert2(src_id
+ && dst_id,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
+ src, dst);
+
/* create a result route */
- route_extended_t new_e_route = xbt_new0(s_route_extended_t,1);
- new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+ route_extended_t new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
new_e_route->src_gateway = NULL;
new_e_route->dst_gateway = NULL;
-
+
int first = 1;
int pred = *dst_id;
int prev_pred = 0;
- char *gw_src=NULL,*gw_dst=NULL, *prev_gw_src,*prev_gw_dst, *first_gw=NULL;
+ char *gw_src = NULL, *gw_dst =
+ NULL, *prev_gw_src, *prev_gw_dst, *first_gw = NULL;
unsigned int cpt;
- void* link;
+ void *link;
xbt_dynar_t links;
-
+
do {
prev_pred = pred;
pred = TO_FLOYD_PRED(*src_id, pred);
- if(pred == -1) /* if no pred in route -> no route to host */
- break;
- xbt_assert2(TO_FLOYD_LINK(pred,prev_pred),"Invalid link for the route between \"%s\" or \"%s\"", src, dst);
-
+ if (pred == -1) /* if no pred in route -> no route to host */
+ break;
+ xbt_assert2(TO_FLOYD_LINK(pred, prev_pred),
+ "Invalid link for the route between \"%s\" or \"%s\"", src,
+ dst);
+
prev_gw_src = gw_src;
prev_gw_dst = gw_dst;
-
- route_extended_t e_route = TO_FLOYD_LINK(pred,prev_pred);
+
+ route_extended_t e_route = TO_FLOYD_LINK(pred, prev_pred);
gw_src = e_route->src_gateway;
gw_dst = e_route->dst_gateway;
-
- if(first) first_gw = gw_dst;
-
- if(rc->hierarchy == SURF_ROUTING_RECURSIVE && !first && strcmp(gw_dst,prev_gw_src)) {
- xbt_dynar_t e_route_as_to_as = (*(global_routing->get_route))(gw_dst,prev_gw_src);
- xbt_assert2(e_route_as_to_as,"no route between \"%s\" and \"%s\"",gw_dst,prev_gw_src);
+
+ if (first)
+ first_gw = gw_dst;
+
+ if (rc->hierarchy == SURF_ROUTING_RECURSIVE && !first
+ && strcmp(gw_dst, prev_gw_src)) {
+ xbt_dynar_t e_route_as_to_as =
+ (*(global_routing->get_route)) (gw_dst, prev_gw_src);
+ xbt_assert2(e_route_as_to_as, "no route between \"%s\" and \"%s\"",
+ gw_dst, prev_gw_src);
links = e_route_as_to_as;
int pos = 0;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_insert_at(new_e_route->generic_route.link_list,pos,&link);
+ xbt_dynar_insert_at(new_e_route->generic_route.link_list, pos,
+ &link);
pos++;
}
}
-
+
links = e_route->generic_route.link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list,&link);
+ xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
}
- first=0;
-
- } while(pred != *src_id);
- xbt_assert4(pred != -1, "no route from host %d to %d (\"%s\" to \"%s\")", *src_id, *dst_id,src,dst);
-
- if(rc->hierarchy == SURF_ROUTING_RECURSIVE) {
+ first = 0;
+
+ } while (pred != *src_id);
+ xbt_assert4(pred != -1, "no route from host %d to %d (\"%s\" to \"%s\")",
+ *src_id, *dst_id, src, dst);
+
+ if (rc->hierarchy == SURF_ROUTING_RECURSIVE) {
new_e_route->src_gateway = xbt_strdup(gw_src);
new_e_route->dst_gateway = xbt_strdup(first_gw);
}
-
+
return new_e_route;
}
-static void floyd_finalize(routing_component_t rc) {
- routing_component_floyd_t routing = (routing_component_floyd_t)rc;
- int i,j,table_size;
+static void floyd_finalize(routing_component_t rc)
+{
+ routing_component_floyd_t routing = (routing_component_floyd_t) rc;
+ int i, j, table_size;
if (routing) {
table_size = xbt_dict_length(routing->to_index);
/* Delete link_table */
- for (i=0;i<table_size;i++)
- for (j=0;j<table_size;j++)
- generic_free_extended_route(TO_FLOYD_LINK(i,j));
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++)
+ generic_free_extended_route(TO_FLOYD_LINK(i, j));
xbt_free(routing->link_table);
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
}
}
-static void* model_floyd_create(void) {
- routing_component_floyd_t new_component = xbt_new0(s_routing_component_floyd_t,1);
- new_component->generic_routing.set_processing_unit = generic_set_processing_unit;
- new_component->generic_routing.set_autonomous_system = generic_set_autonomous_system;
+static void *model_floyd_create(void)
+{
+ routing_component_floyd_t new_component =
+ xbt_new0(s_routing_component_floyd_t, 1);
+ new_component->generic_routing.set_processing_unit =
+ generic_set_processing_unit;
+ new_component->generic_routing.set_autonomous_system =
+ generic_set_autonomous_system;
new_component->generic_routing.set_route = generic_set_route;
new_component->generic_routing.set_ASroute = generic_set_ASroute;
new_component->generic_routing.set_bypassroute = generic_set_bypassroute;
new_component->generic_routing.get_route = floyd_get_route;
- new_component->generic_routing.get_onelink_routes = floyd_get_onelink_routes;
- new_component->generic_routing.get_bypass_route = generic_get_bypassroute;
+ new_component->generic_routing.get_onelink_routes =
+ floyd_get_onelink_routes;
+ new_component->generic_routing.get_bypass_route =
+ generic_get_bypassroute;
new_component->generic_routing.finalize = floyd_finalize;
new_component->to_index = xbt_dict_new();
new_component->bypassRoutes = xbt_dict_new();
return new_component;
}
-static void model_floyd_load(void) {
- /* use "surfxml_add_callback" to add a parse function call */
+static void model_floyd_load(void)
+{
+ /* use "surfxml_add_callback" to add a parse function call */
}
-static void model_floyd_unload(void) {
- /* use "surfxml_del_callback" to remove a parse function call */
+static void model_floyd_unload(void)
+{
+ /* use "surfxml_del_callback" to remove a parse function call */
}
-static void model_floyd_end(void) {
-
- routing_component_floyd_t routing = ((routing_component_floyd_t)current_routing);
+static void model_floyd_end(void)
+{
+
+ routing_component_floyd_t routing =
+ ((routing_component_floyd_t) current_routing);
xbt_dict_cursor_t cursor = NULL;
- double * cost_table;
- char *key,*data, *end;
+ double *cost_table;
+ char *key, *data, *end;
const char *sep = "#";
xbt_dynar_t keys;
int src_id, dst_id;
- unsigned int i,j,a,b,c;
+ unsigned int i, j, a, b, c;
/* set the size of inicial table */
int table_size = xbt_dict_length(routing->to_index);
-
+
/* Create Cost, Predecessor and Link tables */
- cost_table = xbt_new0(double, table_size*table_size); /* link cost from host to host */
- routing->predecessor_table = xbt_new0(int, table_size*table_size); /* predecessor host numbers */
- routing->link_table = xbt_new0(route_extended_t, table_size*table_size); /* actual link between src and dst */
-
- /* Initialize costs and predecessors*/
- for(i = 0; i<table_size;i++)
- for(j = 0; j<table_size;j++) {
- TO_FLOYD_COST(i,j) = DBL_MAX;
- TO_FLOYD_PRED(i,j) = -1;
- TO_FLOYD_LINK(i,j) = NULL; /* fixed, missing in the previous version */
+ cost_table = xbt_new0(double, table_size * table_size); /* link cost from host to host */
+ routing->predecessor_table = xbt_new0(int, table_size * table_size); /* predecessor host numbers */
+ routing->link_table = xbt_new0(route_extended_t, table_size * table_size); /* actual link between src and dst */
+
+ /* Initialize costs and predecessors */
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++) {
+ TO_FLOYD_COST(i, j) = DBL_MAX;
+ TO_FLOYD_PRED(i, j) = -1;
+ TO_FLOYD_LINK(i, j) = NULL; /* fixed, missing in the previous version */
}
- /* Put the routes in position */
+ /* Put the routes in position */
xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
keys = xbt_str_split_str(key, sep);
src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
- TO_FLOYD_LINK(src_id,dst_id) = generic_new_extended_route(current_routing->hierarchy,data,0);
- TO_FLOYD_PRED(src_id,dst_id) = src_id;
+ TO_FLOYD_LINK(src_id, dst_id) =
+ generic_new_extended_route(current_routing->hierarchy, data, 0);
+ TO_FLOYD_PRED(src_id, dst_id) = src_id;
/* set link cost */
- TO_FLOYD_COST(src_id,dst_id) = ((TO_FLOYD_LINK(src_id,dst_id))->generic_route.link_list)->used; /* count of links, old model assume 1 */
+ TO_FLOYD_COST(src_id, dst_id) = ((TO_FLOYD_LINK(src_id, dst_id))->generic_route.link_list)->used; /* count of links, old model assume 1 */
xbt_dynar_free(&keys);
}
/* Add the loopback if needed */
- if(current_routing->hierarchy == SURF_ROUTING_BASE) {
+ if (current_routing->hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
route_extended_t e_route = TO_FLOYD_LINK(i, i);
- if(!e_route) {
- e_route = xbt_new0(s_route_extended_t,1);
+ if (!e_route) {
+ e_route = xbt_new0(s_route_extended_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
- xbt_dynar_push(e_route->generic_route.link_list,&global_routing->loopback);
- TO_FLOYD_LINK(i,i) = e_route;
- TO_FLOYD_PRED(i,i) = i;
- TO_FLOYD_COST(i,i) = 1;
+ e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_push(e_route->generic_route.link_list,
+ &global_routing->loopback);
+ TO_FLOYD_LINK(i, i) = e_route;
+ TO_FLOYD_PRED(i, i) = i;
+ TO_FLOYD_COST(i, i) = 1;
}
}
}
/* Calculate path costs */
- for(c=0;c<table_size;c++) {
- for(a=0;a<table_size;a++) {
- for(b=0;b<table_size;b++) {
- if(TO_FLOYD_COST(a,c) < DBL_MAX && TO_FLOYD_COST(c,b) < DBL_MAX) {
- if(TO_FLOYD_COST(a,b) == DBL_MAX ||
- (TO_FLOYD_COST(a,c)+TO_FLOYD_COST(c,b) < TO_FLOYD_COST(a,b))) {
- TO_FLOYD_COST(a,b) = TO_FLOYD_COST(a,c)+TO_FLOYD_COST(c,b);
- TO_FLOYD_PRED(a,b) = TO_FLOYD_PRED(c,b);
+ for (c = 0; c < table_size; c++) {
+ for (a = 0; a < table_size; a++) {
+ for (b = 0; b < table_size; b++) {
+ if (TO_FLOYD_COST(a, c) < DBL_MAX && TO_FLOYD_COST(c, b) < DBL_MAX) {
+ if (TO_FLOYD_COST(a, b) == DBL_MAX ||
+ (TO_FLOYD_COST(a, c) + TO_FLOYD_COST(c, b) <
+ TO_FLOYD_COST(a, b))) {
+ TO_FLOYD_COST(a, b) =
+ TO_FLOYD_COST(a, c) + TO_FLOYD_COST(c, b);
+ TO_FLOYD_PRED(a, b) = TO_FLOYD_PRED(c, b);
}
}
}
}
}
- /* delete the parse table */
+ /* delete the parse table */
xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
- route_t route = (route_t)data;
+ route_t route = (route_t) data;
xbt_dynar_free(&(route->link_list));
xbt_free(data);
}
-
+
/* delete parse dict */
xbt_dict_free(&(routing->parse_routes));
s_routing_component_t generic_routing;
xbt_dict_t to_index;
xbt_dict_t bypassRoutes;
- xbt_graph_t route_graph; /* xbt_graph */
- xbt_dict_t graph_node_map; /* map */
- xbt_dict_t route_cache; /* use in cache mode */
+ xbt_graph_t route_graph; /* xbt_graph */
+ xbt_dict_t graph_node_map; /* map */
+ xbt_dict_t route_cache; /* use in cache mode */
int cached;
xbt_dict_t parse_routes;
-} s_routing_component_dijkstra_t,*routing_component_dijkstra_t;
+} s_routing_component_dijkstra_t, *routing_component_dijkstra_t;
typedef struct graph_node_data {
- int id;
- int graph_id; /* used for caching internal graph id's */
-} s_graph_node_data_t, * graph_node_data_t;
+ int id;
+ int graph_id; /* used for caching internal graph id's */
+} s_graph_node_data_t, *graph_node_data_t;
typedef struct graph_node_map_element {
xbt_node_t node;
-} s_graph_node_map_element_t, * graph_node_map_element_t;
+} s_graph_node_map_element_t, *graph_node_map_element_t;
typedef struct route_cache_element {
- int * pred_arr;
+ int *pred_arr;
int size;
-} s_route_cache_element_t, * route_cache_element_t;
+} s_route_cache_element_t, *route_cache_element_t;
/* Free functions */
-static void route_cache_elem_free(void *e) {
- route_cache_element_t elm=(route_cache_element_t)e;
+static void route_cache_elem_free(void *e)
+{
+ route_cache_element_t elm = (route_cache_element_t) e;
if (elm) {
xbt_free(elm->pred_arr);
xbt_free(elm);
}
}
-static void graph_node_map_elem_free(void *e) {
- graph_node_map_element_t elm = (graph_node_map_element_t)e;
- if(elm) {
+static void graph_node_map_elem_free(void *e)
+{
+ graph_node_map_element_t elm = (graph_node_map_element_t) e;
+ if (elm) {
xbt_free(elm);
}
}
-static void graph_edge_data_free(void *e) {
- route_extended_t e_route = (route_extended_t)e;
- if(e_route) {
+static void graph_edge_data_free(void *e)
+{
+ route_extended_t e_route = (route_extended_t) e;
+ if (e_route) {
xbt_dynar_free(&(e_route->generic_route.link_list));
- if(e_route->src_gateway) xbt_free(e_route->src_gateway);
- if(e_route->dst_gateway) xbt_free(e_route->dst_gateway);
+ if (e_route->src_gateway)
+ xbt_free(e_route->src_gateway);
+ if (e_route->dst_gateway)
+ xbt_free(e_route->dst_gateway);
xbt_free(e_route);
}
}
/* Utility functions */
-static xbt_node_t route_graph_new_node(routing_component_dijkstra_t rc, int id, int graph_id) {
+static xbt_node_t route_graph_new_node(routing_component_dijkstra_t rc,
+ int id, int graph_id)
+{
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
xbt_node_t node = NULL;
graph_node_data_t data = NULL;
elm = xbt_new0(struct graph_node_map_element, 1);
elm->node = node;
- xbt_dict_set_ext(routing->graph_node_map, (char*)(&id), sizeof(int), (xbt_set_elm_t)elm, &graph_node_map_elem_free);
+ xbt_dict_set_ext(routing->graph_node_map, (char *) (&id), sizeof(int),
+ (xbt_set_elm_t) elm, &graph_node_map_elem_free);
return node;
}
-
-static graph_node_map_element_t graph_node_map_search(routing_component_dijkstra_t rc, int id) {
+
+static graph_node_map_element_t
+graph_node_map_search(routing_component_dijkstra_t rc, int id)
+{
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
- graph_node_map_element_t elm = (graph_node_map_element_t)xbt_dict_get_or_null_ext(routing->graph_node_map, (char*)(&id), sizeof(int));
+ graph_node_map_element_t elm = (graph_node_map_element_t)
+ xbt_dict_get_or_null_ext(routing->graph_node_map,
+ (char *) (&id),
+ sizeof(int));
return elm;
}
/* Parsing */
-static void route_new_dijkstra(routing_component_dijkstra_t rc, int src_id, int dst_id, route_extended_t e_route ) {
+static void route_new_dijkstra(routing_component_dijkstra_t rc, int src_id,
+ int dst_id, route_extended_t e_route)
+{
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
xbt_node_t src = NULL;
xbt_node_t dst = NULL;
- graph_node_map_element_t src_elm = (graph_node_map_element_t)xbt_dict_get_or_null_ext(routing->graph_node_map, (char*)(&src_id), sizeof(int));
- graph_node_map_element_t dst_elm = (graph_node_map_element_t)xbt_dict_get_or_null_ext(routing->graph_node_map, (char*)(&dst_id), sizeof(int));
-
- if(src_elm)
+ graph_node_map_element_t src_elm = (graph_node_map_element_t)
+ xbt_dict_get_or_null_ext(routing->graph_node_map,
+ (char *) (&src_id),
+ sizeof(int));
+ graph_node_map_element_t dst_elm = (graph_node_map_element_t)
+ xbt_dict_get_or_null_ext(routing->graph_node_map,
+ (char *) (&dst_id),
+ sizeof(int));
+
+ if (src_elm)
src = src_elm->node;
- if(dst_elm)
+ if (dst_elm)
dst = dst_elm->node;
/* add nodes if they don't exist in the graph */
- if(src_id == dst_id && src == NULL && dst == NULL) {
- src = route_graph_new_node(rc,src_id, -1);
+ if (src_id == dst_id && src == NULL && dst == NULL) {
+ src = route_graph_new_node(rc, src_id, -1);
dst = src;
} else {
- if(src == NULL) {
- src = route_graph_new_node(rc,src_id, -1);
+ if (src == NULL) {
+ src = route_graph_new_node(rc, src_id, -1);
}
- if(dst == NULL) {
- dst = route_graph_new_node(rc,dst_id, -1);
+ if (dst == NULL) {
+ dst = route_graph_new_node(rc, dst_id, -1);
}
}
xbt_graph_new_edge(routing->route_graph, src, dst, e_route);
}
-static void add_loopback_dijkstra(routing_component_dijkstra_t rc) {
+static void add_loopback_dijkstra(routing_component_dijkstra_t rc)
+{
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
xbt_dynar_t nodes = xbt_graph_get_nodes(routing->route_graph);
xbt_node_t node = NULL;
unsigned int cursor2;
xbt_dynar_foreach(nodes, cursor2, node) {
- xbt_dynar_t out_edges = xbt_graph_node_get_outedges(node);
+ xbt_dynar_t out_edges = xbt_graph_node_get_outedges(node);
xbt_edge_t edge = NULL;
unsigned int cursor;
int found = 0;
xbt_dynar_foreach(out_edges, cursor, edge) {
xbt_node_t other_node = xbt_graph_edge_get_target(edge);
- if(other_node == node) {
+ if (other_node == node) {
found = 1;
break;
}
}
- if(!found) {
- route_extended_t e_route = xbt_new0(s_route_extended_t,1);
+ if (!found) {
+ route_extended_t e_route = xbt_new0(s_route_extended_t, 1);
e_route->src_gateway = NULL;
e_route->dst_gateway = NULL;
- e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
- xbt_dynar_push(e_route->generic_route.link_list,&global_routing->loopback);
+ e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+ xbt_dynar_push(e_route->generic_route.link_list,
+ &global_routing->loopback);
xbt_graph_new_edge(routing->route_graph, node, node, e_route);
}
}
xbt_die("\"dijkstra_get_onelink_routes\" function not implemented yet");
}
-static route_extended_t dijkstra_get_route(routing_component_t rc, const char* src,const char* dst) {
- xbt_assert1(rc&&src&&dst, "Invalid params for \"get_route\" function at AS \"%s\"",rc->name);
-
+static route_extended_t dijkstra_get_route(routing_component_t rc,
+ const char *src,
+ const char *dst)
+{
+ xbt_assert1(rc && src
+ && dst,
+ "Invalid params for \"get_route\" function at AS \"%s\"",
+ rc->name);
+
/* set utils vars */
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
-
- generic_src_dst_check(rc,src,dst);
- int *src_id = xbt_dict_get_or_null(routing->to_index,src);
- int *dst_id = xbt_dict_get_or_null(routing->to_index,dst);
- xbt_assert2(src_id && dst_id, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
-
+
+ generic_src_dst_check(rc, src, dst);
+ int *src_id = xbt_dict_get_or_null(routing->to_index, src);
+ int *dst_id = xbt_dict_get_or_null(routing->to_index, dst);
+ xbt_assert2(src_id
+ && dst_id,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
+ src, dst);
+
/* create a result route */
- route_extended_t new_e_route = xbt_new0(s_route_extended_t,1);
- new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+ route_extended_t new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
new_e_route->src_gateway = NULL;
new_e_route->dst_gateway = NULL;
-
+
int *pred_arr = NULL;
int src_node_id = 0;
int dst_node_id = 0;
- int * nodeid = NULL;
+ int *nodeid = NULL;
int v;
route_extended_t e_route;
int size = 0;
unsigned int cpt;
- void* link;
+ void *link;
xbt_dynar_t links = NULL;
route_cache_element_t elm = NULL;
xbt_dynar_t nodes = xbt_graph_get_nodes(routing->route_graph);
-
+
/* Use the graph_node id mapping set to quickly find the nodes */
- graph_node_map_element_t src_elm = graph_node_map_search(routing,*src_id);
- graph_node_map_element_t dst_elm = graph_node_map_search(routing,*dst_id);
- xbt_assert2(src_elm != NULL && dst_elm != NULL, "src %d or dst %d does not exist", *src_id, *dst_id);
- src_node_id = ((graph_node_data_t)xbt_graph_node_get_data(src_elm->node))->graph_id;
- dst_node_id = ((graph_node_data_t)xbt_graph_node_get_data(dst_elm->node))->graph_id;
-
- /* if the src and dst are the same */ /* fixed, missing in the previous version */
- if( src_node_id == dst_node_id ) {
-
+ graph_node_map_element_t src_elm =
+ graph_node_map_search(routing, *src_id);
+ graph_node_map_element_t dst_elm =
+ graph_node_map_search(routing, *dst_id);
+ xbt_assert2(src_elm != NULL
+ && dst_elm != NULL, "src %d or dst %d does not exist",
+ *src_id, *dst_id);
+ src_node_id = ((graph_node_data_t)
+ xbt_graph_node_get_data(src_elm->node))->graph_id;
+ dst_node_id = ((graph_node_data_t)
+ xbt_graph_node_get_data(dst_elm->node))->graph_id;
+
+ /* if the src and dst are the same *//* fixed, missing in the previous version */
+ if (src_node_id == dst_node_id) {
+
xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t);
xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(routing->route_graph, node_s_v, node_e_v);
+ xbt_edge_t edge =
+ xbt_graph_get_edge(routing->route_graph, node_s_v, node_e_v);
+
+ xbt_assert2(edge != NULL, "no route between host %d and %d", *src_id,
+ *dst_id);
- xbt_assert2(edge != NULL, "no route between host %d and %d", *src_id, *dst_id);
-
- e_route = (route_extended_t)xbt_graph_edge_get_data(edge);
+ e_route = (route_extended_t) xbt_graph_edge_get_data(edge);
links = e_route->generic_route.link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list,&link);
+ xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
}
-
+
return new_e_route;
}
-
- if(routing->cached) {
+
+ if (routing->cached) {
/*check if there is a cached predecessor list avail */
- elm = (route_cache_element_t)xbt_dict_get_or_null_ext(routing->route_cache, (char*)(&src_id), sizeof(int));
+ elm = (route_cache_element_t)
+ xbt_dict_get_or_null_ext(routing->route_cache, (char *) (&src_id),
+ sizeof(int));
}
- if(elm) { /* cached mode and cache hit */
+ if (elm) { /* cached mode and cache hit */
pred_arr = elm->pred_arr;
- } else { /* not cached mode or cache miss */
- double * cost_arr = NULL;
+ } else { /* not cached mode or cache miss */
+ double *cost_arr = NULL;
xbt_heap_t pqueue = NULL;
int i = 0;
int nr_nodes = xbt_dynar_length(nodes);
- cost_arr = xbt_new0(double, nr_nodes); /* link cost from src to other hosts */
- pred_arr = xbt_new0(int, nr_nodes); /* predecessors in path from src */
+ cost_arr = xbt_new0(double, nr_nodes); /* link cost from src to other hosts */
+ pred_arr = xbt_new0(int, nr_nodes); /* predecessors in path from src */
pqueue = xbt_heap_new(nr_nodes, xbt_free);
/* initialize */
cost_arr[src_node_id] = 0.0;
- for(i = 0; i < nr_nodes; i++) {
- if(i != src_node_id) {
+ for (i = 0; i < nr_nodes; i++) {
+ if (i != src_node_id) {
cost_arr[i] = DBL_MAX;
}
}
/* apply dijkstra using the indexes from the graph's node array */
- while(xbt_heap_size(pqueue) > 0) {
- int * v_id = xbt_heap_pop(pqueue);
+ while (xbt_heap_size(pqueue) > 0) {
+ int *v_id = xbt_heap_pop(pqueue);
xbt_node_t v_node = xbt_dynar_get_as(nodes, *v_id, xbt_node_t);
- xbt_dynar_t out_edges = xbt_graph_node_get_outedges(v_node);
+ xbt_dynar_t out_edges = xbt_graph_node_get_outedges(v_node);
xbt_edge_t edge = NULL;
unsigned int cursor;
xbt_node_t u_node = xbt_graph_edge_get_target(edge);
graph_node_data_t data = xbt_graph_node_get_data(u_node);
int u_id = data->graph_id;
- route_extended_t tmp_e_route = (route_extended_t)xbt_graph_edge_get_data(edge);
- int cost_v_u = (tmp_e_route->generic_route.link_list)->used; /* count of links, old model assume 1 */
+ route_extended_t tmp_e_route =
+ (route_extended_t) xbt_graph_edge_get_data(edge);
+ int cost_v_u = (tmp_e_route->generic_route.link_list)->used; /* count of links, old model assume 1 */
- if(cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
+ if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
pred_arr[u_id] = *v_id;
cost_arr[u_id] = cost_v_u + cost_arr[*v_id];
nodeid = xbt_new0(int, 1);
xbt_free(cost_arr);
xbt_heap_free(pqueue);
}
-
+
/* compose route path with links */
- char *gw_src=NULL,*gw_dst=NULL, *prev_gw_src,*prev_gw_dst, *first_gw=NULL;
-
- for(v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
- xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
+ char *gw_src = NULL, *gw_dst =
+ NULL, *prev_gw_src, *prev_gw_dst, *first_gw = NULL;
+
+ for (v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
+ xbt_node_t node_pred_v =
+ xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
- xbt_edge_t edge = xbt_graph_get_edge(routing->route_graph, node_pred_v, node_v);
+ xbt_edge_t edge =
+ xbt_graph_get_edge(routing->route_graph, node_pred_v, node_v);
+
+ xbt_assert2(edge != NULL, "no route between host %d and %d", *src_id,
+ *dst_id);
- xbt_assert2(edge != NULL, "no route between host %d and %d", *src_id, *dst_id);
-
prev_gw_src = gw_src;
prev_gw_dst = gw_dst;
-
- e_route = (route_extended_t)xbt_graph_edge_get_data(edge);
+
+ e_route = (route_extended_t) xbt_graph_edge_get_data(edge);
gw_src = e_route->src_gateway;
gw_dst = e_route->dst_gateway;
-
- if(v==dst_node_id) first_gw = gw_dst;
-
- if(rc->hierarchy == SURF_ROUTING_RECURSIVE && v!=dst_node_id && strcmp(gw_dst,prev_gw_src)) {
- xbt_dynar_t e_route_as_to_as = (*(global_routing->get_route))(gw_dst,prev_gw_src);
- xbt_assert2(e_route_as_to_as,"no route between \"%s\" and \"%s\"",gw_dst,prev_gw_src);
+
+ if (v == dst_node_id)
+ first_gw = gw_dst;
+
+ if (rc->hierarchy == SURF_ROUTING_RECURSIVE && v != dst_node_id
+ && strcmp(gw_dst, prev_gw_src)) {
+ xbt_dynar_t e_route_as_to_as =
+ (*(global_routing->get_route)) (gw_dst, prev_gw_src);
+ xbt_assert2(e_route_as_to_as, "no route between \"%s\" and \"%s\"",
+ gw_dst, prev_gw_src);
links = e_route_as_to_as;
int pos = 0;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_insert_at(new_e_route->generic_route.link_list,pos,&link);
+ xbt_dynar_insert_at(new_e_route->generic_route.link_list, pos,
+ &link);
pos++;
}
}
-
+
links = e_route->generic_route.link_list;
xbt_dynar_foreach(links, cpt, link) {
- xbt_dynar_unshift(new_e_route->generic_route.link_list,&link);
+ xbt_dynar_unshift(new_e_route->generic_route.link_list, &link);
}
size++;
}
- if(rc->hierarchy == SURF_ROUTING_RECURSIVE) {
+ if (rc->hierarchy == SURF_ROUTING_RECURSIVE) {
new_e_route->src_gateway = xbt_strdup(gw_src);
new_e_route->dst_gateway = xbt_strdup(first_gw);
}
- if(routing->cached && elm == NULL) {
+ if (routing->cached && elm == NULL) {
/* add to predecessor list of the current src-host to cache */
elm = xbt_new0(struct route_cache_element, 1);
elm->pred_arr = pred_arr;
elm->size = size;
- xbt_dict_set_ext(routing->route_cache, (char*)(&src_id), sizeof(int), (xbt_set_elm_t)elm, &route_cache_elem_free);
+ xbt_dict_set_ext(routing->route_cache, (char *) (&src_id), sizeof(int),
+ (xbt_set_elm_t) elm, &route_cache_elem_free);
}
- if(!routing->cached)
+ if (!routing->cached)
xbt_free(pred_arr);
-
+
return new_e_route;
}
-static void dijkstra_finalize(routing_component_t rc) {
+static void dijkstra_finalize(routing_component_t rc)
+{
routing_component_dijkstra_t routing = (routing_component_dijkstra_t) rc;
if (routing) {
- xbt_graph_free_graph(routing->route_graph, &xbt_free, &graph_edge_data_free, &xbt_free);
+ xbt_graph_free_graph(routing->route_graph, &xbt_free,
+ &graph_edge_data_free, &xbt_free);
xbt_dict_free(&routing->graph_node_map);
- if(routing->cached)
+ if (routing->cached)
xbt_dict_free(&routing->route_cache);
/* Delete bypass dict */
xbt_dict_free(&routing->bypassRoutes);
/* Creation routing model functions */
-static void* model_dijkstra_both_create(int cached) {
- routing_component_dijkstra_t new_component = xbt_new0(s_routing_component_dijkstra_t,1);
- new_component->generic_routing.set_processing_unit = generic_set_processing_unit;
- new_component->generic_routing.set_autonomous_system = generic_set_autonomous_system;
+static void *model_dijkstra_both_create(int cached)
+{
+ routing_component_dijkstra_t new_component =
+ xbt_new0(s_routing_component_dijkstra_t, 1);
+ new_component->generic_routing.set_processing_unit =
+ generic_set_processing_unit;
+ new_component->generic_routing.set_autonomous_system =
+ generic_set_autonomous_system;
new_component->generic_routing.set_route = generic_set_route;
new_component->generic_routing.set_ASroute = generic_set_ASroute;
new_component->generic_routing.set_bypassroute = generic_set_bypassroute;
new_component->generic_routing.get_route = dijkstra_get_route;
- new_component->generic_routing.get_onelink_routes = dijkstra_get_onelink_routes;
- new_component->generic_routing.get_bypass_route = generic_get_bypassroute;
+ new_component->generic_routing.get_onelink_routes =
+ dijkstra_get_onelink_routes;
+ new_component->generic_routing.get_bypass_route =
+ generic_get_bypassroute;
new_component->generic_routing.finalize = dijkstra_finalize;
new_component->cached = cached;
new_component->to_index = xbt_dict_new();
return new_component;
}
-static void* model_dijkstra_create(void) {
+static void *model_dijkstra_create(void)
+{
return model_dijkstra_both_create(0);
}
-static void* model_dijkstracache_create(void) {
+static void *model_dijkstracache_create(void)
+{
return model_dijkstra_both_create(1);
}
-static void model_dijkstra_both_load(void) {
- /* use "surfxml_add_callback" to add a parse function call */
+static void model_dijkstra_both_load(void)
+{
+ /* use "surfxml_add_callback" to add a parse function call */
}
-static void model_dijkstra_both_unload(void) {
- /* use "surfxml_del_callback" to remove a parse function call */
+static void model_dijkstra_both_unload(void)
+{
+ /* use "surfxml_del_callback" to remove a parse function call */
}
-static void model_dijkstra_both_end(void) {
- routing_component_dijkstra_t routing = (routing_component_dijkstra_t) current_routing;
- xbt_dict_cursor_t cursor = NULL;
- char *key, *data, *end;
- const char *sep = "#";
- xbt_dynar_t keys;
+static void model_dijkstra_both_end(void)
+{
+ routing_component_dijkstra_t routing =
+ (routing_component_dijkstra_t) current_routing;
+ xbt_dict_cursor_t cursor = NULL;
+ char *key, *data, *end;
+ const char *sep = "#";
+ xbt_dynar_t keys;
xbt_node_t node = NULL;
unsigned int cursor2;
xbt_dynar_t nodes = NULL;
int src_id, dst_id;
route_t route;
-
+
/* Create the topology graph */
routing->route_graph = xbt_graph_new_graph(1, NULL);
routing->graph_node_map = xbt_dict_new();
-
- if(routing->cached)
+
+ if (routing->cached)
routing->route_cache = xbt_dict_new();
/* Put the routes in position */
keys = xbt_str_split_str(key, sep);
src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
- route_extended_t e_route = generic_new_extended_route(current_routing->hierarchy,data,0);
- route_new_dijkstra(routing,src_id,dst_id,e_route);
+ route_extended_t e_route =
+ generic_new_extended_route(current_routing->hierarchy, data, 0);
+ route_new_dijkstra(routing, src_id, dst_id, e_route);
xbt_dynar_free(&keys);
}
/* delete the parse table */
xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
- route = (route_t)data;
+ route = (route_t) data;
xbt_dynar_free(&(route->link_list));
xbt_free(data);
}
-
+
/* delete parse dict */
xbt_dict_free(&(routing->parse_routes));
-
+
/* Add the loopback if needed */
- if(current_routing->hierarchy == SURF_ROUTING_BASE)
+ if (current_routing->hierarchy == SURF_ROUTING_BASE)
add_loopback_dijkstra(routing);
/* initialize graph indexes in nodes after graph has been built */
graph_node_data_t data = xbt_graph_node_get_data(node);
data->graph_id = cursor2;
}
-
+
}
#ifdef HAVE_PCRE_LIB
typedef struct {
s_routing_component_t generic_routing;
- xbt_dict_t dict_processing_units;
- xbt_dict_t dict_autonomous_systems;
+ xbt_dict_t dict_processing_units;
+ xbt_dict_t dict_autonomous_systems;
xbt_dynar_t list_route;
xbt_dynar_t list_ASroute;
-} s_routing_component_rulebased_t,*routing_component_rulebased_t;
+} s_routing_component_rulebased_t, *routing_component_rulebased_t;
typedef struct s_rule_route s_rule_route_t, *rule_route_t;
-typedef struct s_rule_route_extended s_rule_route_extended_t, *rule_route_extended_t;
+typedef struct s_rule_route_extended s_rule_route_extended_t,
+ *rule_route_extended_t;
struct s_rule_route {
- xbt_dynar_t re_str_link; // dynar of char*
- pcre* re_src;
- pcre* re_dst;
+ xbt_dynar_t re_str_link; // dynar of char*
+ pcre *re_src;
+ pcre *re_dst;
};
struct s_rule_route_extended {
s_rule_route_t generic_rule_route;
- char* re_src_gateway;
- char* re_dst_gateway;
+ char *re_src_gateway;
+ char *re_dst_gateway;
};
-static void rule_route_free(void *e) {
- rule_route_t* elem = (rule_route_t*)(e);
+static void rule_route_free(void *e)
+{
+ rule_route_t *elem = (rule_route_t *) (e);
if (*elem) {
xbt_dynar_free(&(*elem)->re_str_link);
pcre_free((*elem)->re_src);
(*elem) = NULL;
}
-static void rule_route_extended_free(void *e) {
- rule_route_extended_t* elem = (rule_route_extended_t*)e;
+static void rule_route_extended_free(void *e)
+{
+ rule_route_extended_t *elem = (rule_route_extended_t *) e;
if (*elem) {
xbt_dynar_free(&(*elem)->generic_rule_route.re_str_link);
pcre_free((*elem)->generic_rule_route.re_src);
/* Parse routing model functions */
-static void model_rulebased_set_processing_unit(routing_component_t rc, const char* name) {
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
- xbt_dict_set(routing->dict_processing_units, name, (void*)(-1), NULL);
+static void model_rulebased_set_processing_unit(routing_component_t rc,
+ const char *name)
+{
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
+ xbt_dict_set(routing->dict_processing_units, name, (void *) (-1), NULL);
}
-static void model_rulebased_set_autonomous_system(routing_component_t rc, const char* name) {
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
- xbt_dict_set(routing->dict_autonomous_systems, name, (void*)(-1), NULL);
+static void model_rulebased_set_autonomous_system(routing_component_t rc,
+ const char *name)
+{
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
+ xbt_dict_set(routing->dict_autonomous_systems, name, (void *) (-1),
+ NULL);
}
-static void model_rulebased_set_route(routing_component_t rc, const char* src, const char* dst, route_t route) {
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
- rule_route_t ruleroute = xbt_new0(s_rule_route_t,1);
+static void model_rulebased_set_route(routing_component_t rc,
+ const char *src, const char *dst,
+ route_t route)
+{
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
+ rule_route_t ruleroute = xbt_new0(s_rule_route_t, 1);
const char *error;
int erroffset;
- ruleroute->re_src = pcre_compile(src,0,&error,&erroffset,NULL);
- xbt_assert3(ruleroute->re_src,"PCRE compilation failed at offset %d (\"%s\"): %s\n", erroffset, src, error);
- ruleroute->re_dst = pcre_compile(dst,0,&error,&erroffset,NULL);
- xbt_assert3(ruleroute->re_src,"PCRE compilation failed at offset %d (\"%s\"): %s\n", erroffset, dst, error);
+ ruleroute->re_src = pcre_compile(src, 0, &error, &erroffset, NULL);
+ xbt_assert3(ruleroute->re_src,
+ "PCRE compilation failed at offset %d (\"%s\"): %s\n",
+ erroffset, src, error);
+ ruleroute->re_dst = pcre_compile(dst, 0, &error, &erroffset, NULL);
+ xbt_assert3(ruleroute->re_src,
+ "PCRE compilation failed at offset %d (\"%s\"): %s\n",
+ erroffset, dst, error);
ruleroute->re_str_link = route->link_list;
- xbt_dynar_push(routing->list_route,&ruleroute);
+ xbt_dynar_push(routing->list_route, &ruleroute);
xbt_free(route);
}
-static void model_rulebased_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t route) {
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
- rule_route_extended_t ruleroute_e = xbt_new0(s_rule_route_extended_t,1);
+static void model_rulebased_set_ASroute(routing_component_t rc,
+ const char *src, const char *dst,
+ route_extended_t route)
+{
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
+ rule_route_extended_t ruleroute_e = xbt_new0(s_rule_route_extended_t, 1);
const char *error;
int erroffset;
- ruleroute_e->generic_rule_route.re_src = pcre_compile(src,0,&error,&erroffset,NULL);
- xbt_assert3(ruleroute_e->generic_rule_route.re_src,"PCRE compilation failed at offset %d (\"%s\"): %s\n", erroffset, src, error);
- ruleroute_e->generic_rule_route.re_dst = pcre_compile(dst,0,&error,&erroffset,NULL);
- xbt_assert3(ruleroute_e->generic_rule_route.re_src,"PCRE compilation failed at offset %d (\"%s\"): %s\n", erroffset, dst, error);
- ruleroute_e->generic_rule_route.re_str_link = route->generic_route.link_list;
+ ruleroute_e->generic_rule_route.re_src =
+ pcre_compile(src, 0, &error, &erroffset, NULL);
+ xbt_assert3(ruleroute_e->generic_rule_route.re_src,
+ "PCRE compilation failed at offset %d (\"%s\"): %s\n",
+ erroffset, src, error);
+ ruleroute_e->generic_rule_route.re_dst =
+ pcre_compile(dst, 0, &error, &erroffset, NULL);
+ xbt_assert3(ruleroute_e->generic_rule_route.re_src,
+ "PCRE compilation failed at offset %d (\"%s\"): %s\n",
+ erroffset, dst, error);
+ ruleroute_e->generic_rule_route.re_str_link =
+ route->generic_route.link_list;
ruleroute_e->re_src_gateway = route->src_gateway;
ruleroute_e->re_dst_gateway = route->dst_gateway;
- xbt_dynar_push(routing->list_ASroute,&ruleroute_e);
+ xbt_dynar_push(routing->list_ASroute, &ruleroute_e);
xbt_free(route->src_gateway);
xbt_free(route->dst_gateway);
xbt_free(route);
}
-static void model_rulebased_set_bypassroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
+static void model_rulebased_set_bypassroute(routing_component_t rc,
+ const char *src,
+ const char *dst,
+ route_extended_t e_route)
+{
xbt_die("bypass routing not supported for Route-Based model");
}
-#define BUFFER_SIZE 4096 /* result buffer size */
-#define OVECCOUNT 30 /* should be a multiple of 3 */
+#define BUFFER_SIZE 4096 /* result buffer size */
+#define OVECCOUNT 30 /* should be a multiple of 3 */
-static char* remplace(char* value, const char** src_list, int src_size, const char** dst_list, int dst_size ) {
+static char *remplace(char *value, const char **src_list, int src_size,
+ const char **dst_list, int dst_size)
+{
char result_result[BUFFER_SIZE];
int i_result_buffer;
- int value_length = (int)strlen(value);
- int number=0;
-
- int i=0;
+ int value_length = (int) strlen(value);
+ int number = 0;
+
+ int i = 0;
i_result_buffer = 0;
do {
- if( value[i] == '$' ) {
- i++; // skip $
-
+ if (value[i] == '$') {
+ i++; // skip $
+
// find the number
int number_length = 0;
- while( '0' <= value[i+number_length] && value[i+number_length] <= '9' ) {
+ while ('0' <= value[i + number_length]
+ && value[i + number_length] <= '9') {
number_length++;
}
- xbt_assert2( number_length!=0, "bad string parameter, no number indication, at offset: %d (\"%s\")",i,value);
-
+ xbt_assert2(number_length != 0,
+ "bad string parameter, no number indication, at offset: %d (\"%s\")",
+ i, value);
+
// solve number
- number = atoi(value+i);
- i=i+number_length;
- xbt_assert2(i+2<value_length,"bad string parameter, too few chars, at offset: %d (\"%s\")",i,value);
-
+ number = atoi(value + i);
+ i = i + number_length;
+ xbt_assert2(i + 2 < value_length,
+ "bad string parameter, too few chars, at offset: %d (\"%s\")",
+ i, value);
+
// solve the indication
- const char** param_list;
+ const char **param_list;
int param_size;
- if( value[i] == 's' && value[i+1] == 'r' && value[i+2] == 'c' ) {
+ if (value[i] == 's' && value[i + 1] == 'r' && value[i + 2] == 'c') {
param_list = src_list;
param_size = src_size;
- } else if( value[i] == 'd' && value[i+1] == 's' && value[i+2] == 't' ) {
+ } else if (value[i] == 'd' && value[i + 1] == 's'
+ && value[i + 2] == 't') {
param_list = dst_list;
param_size = dst_size;
} else {
- xbt_assert2(0,"bad string parameter, support only \"src\" and \"dst\", at offset: %d (\"%s\")",i,value);
+ xbt_assert2(0,
+ "bad string parameter, support only \"src\" and \"dst\", at offset: %d (\"%s\")",
+ i, value);
}
- i=i+3;
-
- xbt_assert4( param_size >= number, "bad string parameter, not enough length param_size, at offset: %d (\"%s\") %d %d",i,value,param_size,number);
-
- const char* param = param_list[number];
+ i = i + 3;
+
+ xbt_assert4(param_size >= number,
+ "bad string parameter, not enough length param_size, at offset: %d (\"%s\") %d %d",
+ i, value, param_size, number);
+
+ const char *param = param_list[number];
int size = strlen(param);
int cp;
- for(cp = 0; cp < size; cp++ ) {
+ for (cp = 0; cp < size; cp++) {
result_result[i_result_buffer] = param[cp];
i_result_buffer++;
- if( i_result_buffer >= BUFFER_SIZE ) break;
+ if (i_result_buffer >= BUFFER_SIZE)
+ break;
}
} else {
result_result[i_result_buffer] = value[i];
i_result_buffer++;
- i++; // next char
+ i++; // next char
}
-
- } while(i<value_length && i_result_buffer < BUFFER_SIZE);
-
- xbt_assert2( i_result_buffer < BUFFER_SIZE, "solving string \"%s\", small buffer size (%d)",value,BUFFER_SIZE);
+
+ } while (i < value_length && i_result_buffer < BUFFER_SIZE);
+
+ xbt_assert2(i_result_buffer < BUFFER_SIZE,
+ "solving string \"%s\", small buffer size (%d)", value,
+ BUFFER_SIZE);
result_result[i_result_buffer] = 0;
return xbt_strdup(result_result);
}
}
/* Business methods */
-static route_extended_t rulebased_get_route(routing_component_t rc, const char* src,const char* dst) {
- xbt_assert1(rc&&src&&dst, "Invalid params for \"get_route\" function at AS \"%s\"",rc->name);
+static route_extended_t rulebased_get_route(routing_component_t rc,
+ const char *src,
+ const char *dst)
+{
+ xbt_assert1(rc && src
+ && dst,
+ "Invalid params for \"get_route\" function at AS \"%s\"",
+ rc->name);
/* set utils vars */
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
int are_processing_units;
xbt_dynar_t rule_list;
- if( xbt_dict_get_or_null(routing->dict_processing_units,src) && xbt_dict_get_or_null(routing->dict_processing_units,dst) ) {
+ if (xbt_dict_get_or_null(routing->dict_processing_units, src)
+ && xbt_dict_get_or_null(routing->dict_processing_units, dst)) {
are_processing_units = 1;
rule_list = routing->list_route;
- } else if( xbt_dict_get_or_null(routing->dict_autonomous_systems,src) && xbt_dict_get_or_null(routing->dict_autonomous_systems,dst) ) {
+ } else if (xbt_dict_get_or_null(routing->dict_autonomous_systems, src)
+ && xbt_dict_get_or_null(routing->dict_autonomous_systems,
+ dst)) {
are_processing_units = 0;
- rule_list = routing->list_ASroute;
+ rule_list = routing->list_ASroute;
} else
- xbt_assert2(NULL, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst);
+ xbt_assert2(NULL,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",
+ src, dst);
int rc_src = -1;
int rc_dst = -1;
- int src_length = (int)strlen(src);
- int dst_length = (int)strlen(dst);
-
- xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link,NULL);
-
+ int src_length = (int) strlen(src);
+ int dst_length = (int) strlen(dst);
+
+ xbt_dynar_t links_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
+
rule_route_t ruleroute;
unsigned int cpt;
int ovector_src[OVECCOUNT];
int ovector_dst[OVECCOUNT];
- const char** list_src = NULL;
- const char** list_dst = NULL;
+ const char **list_src = NULL;
+ const char **list_dst = NULL;
xbt_dynar_foreach(rule_list, cpt, ruleroute) {
- rc_src = pcre_exec(ruleroute->re_src,NULL,src,src_length,0,0,ovector_src,OVECCOUNT);
- if( rc_src >= 0 ) {
- rc_dst = pcre_exec(ruleroute->re_dst,NULL,dst,dst_length,0,0,ovector_dst,OVECCOUNT);
- if( rc_dst >= 0 ) {
- xbt_assert1(!pcre_get_substring_list(src,ovector_src,rc_src,&list_src),"error solving substring list for src \"%s\"",src);
- xbt_assert1(!pcre_get_substring_list(dst,ovector_dst,rc_dst,&list_dst),"error solving substring list for src \"%s\"",dst);
- char* link_name;
+ rc_src =
+ pcre_exec(ruleroute->re_src, NULL, src, src_length, 0, 0,
+ ovector_src, OVECCOUNT);
+ if (rc_src >= 0) {
+ rc_dst =
+ pcre_exec(ruleroute->re_dst, NULL, dst, dst_length, 0, 0,
+ ovector_dst, OVECCOUNT);
+ if (rc_dst >= 0) {
+ xbt_assert1(!pcre_get_substring_list
+ (src, ovector_src, rc_src, &list_src),
+ "error solving substring list for src \"%s\"", src);
+ xbt_assert1(!pcre_get_substring_list
+ (dst, ovector_dst, rc_dst, &list_dst),
+ "error solving substring list for src \"%s\"", dst);
+ char *link_name;
xbt_dynar_foreach(ruleroute->re_str_link, cpt, link_name) {
- char* new_link_name = remplace(link_name,list_src,rc_src,list_dst,rc_dst);
- void* link = xbt_dict_get_or_null(surf_network_model->resource_set, new_link_name);
+ char *new_link_name =
+ remplace(link_name, list_src, rc_src, list_dst, rc_dst);
+ void *link =
+ xbt_dict_get_or_null(surf_network_model->resource_set,
+ new_link_name);
if (link)
- xbt_dynar_push(links_list,&link);
+ xbt_dynar_push(links_list, &link);
else
- THROW1(mismatch_error,0,"Link %s not found", new_link_name);
+ THROW1(mismatch_error, 0, "Link %s not found", new_link_name);
xbt_free(new_link_name);
}
}
}
- if( rc_src >= 0 && rc_dst >= 0 ) break;
+ if (rc_src >= 0 && rc_dst >= 0)
+ break;
}
-
+
route_extended_t new_e_route = NULL;
- if(rc_src >= 0 && rc_dst >= 0) {
- new_e_route = xbt_new0(s_route_extended_t,1);
+ if (rc_src >= 0 && rc_dst >= 0) {
+ new_e_route = xbt_new0(s_route_extended_t, 1);
new_e_route->generic_route.link_list = links_list;
- } else if( !strcmp(src,dst) && are_processing_units ) {
- new_e_route = xbt_new0(s_route_extended_t,1);
- xbt_dynar_push(links_list,&(global_routing->loopback));
+ } else if (!strcmp(src, dst) && are_processing_units) {
+ new_e_route = xbt_new0(s_route_extended_t, 1);
+ xbt_dynar_push(links_list, &(global_routing->loopback));
new_e_route->generic_route.link_list = links_list;
- } else {
+ } else {
xbt_dynar_free(&link_list);
}
- if(!are_processing_units && new_e_route)
- {
- rule_route_extended_t ruleroute_extended = (rule_route_extended_t)ruleroute;
- new_e_route->src_gateway = remplace(ruleroute_extended->re_src_gateway,list_src,rc_src,list_dst,rc_dst);
- new_e_route->dst_gateway = remplace(ruleroute_extended->re_dst_gateway,list_src,rc_src,list_dst,rc_dst);
+ if (!are_processing_units && new_e_route) {
+ rule_route_extended_t ruleroute_extended =
+ (rule_route_extended_t) ruleroute;
+ new_e_route->src_gateway =
+ remplace(ruleroute_extended->re_src_gateway, list_src, rc_src,
+ list_dst, rc_dst);
+ new_e_route->dst_gateway =
+ remplace(ruleroute_extended->re_dst_gateway, list_src, rc_src,
+ list_dst, rc_dst);
}
-
- if(list_src) pcre_free_substring_list(list_src);
- if(list_dst) pcre_free_substring_list(list_dst);
-
+
+ if (list_src)
+ pcre_free_substring_list(list_src);
+ if (list_dst)
+ pcre_free_substring_list(list_dst);
+
return new_e_route;
}
-static route_extended_t rulebased_get_bypass_route(routing_component_t rc, const char* src,const char* dst) {
+static route_extended_t rulebased_get_bypass_route(routing_component_t rc,
+ const char *src,
+ const char *dst)
+{
return NULL;
}
-static void rulebased_finalize(routing_component_t rc) {
- routing_component_rulebased_t routing = (routing_component_rulebased_t) rc;
+static void rulebased_finalize(routing_component_t rc)
+{
+ routing_component_rulebased_t routing =
+ (routing_component_rulebased_t) rc;
if (routing) {
xbt_dict_free(&routing->dict_processing_units);
xbt_dict_free(&routing->dict_autonomous_systems);
}
/* Creation routing model functions */
-static void* model_rulebased_create(void) {
- routing_component_rulebased_t new_component = xbt_new0(s_routing_component_rulebased_t,1);
- new_component->generic_routing.set_processing_unit = model_rulebased_set_processing_unit;
- new_component->generic_routing.set_autonomous_system = model_rulebased_set_autonomous_system;
+static void *model_rulebased_create(void)
+{
+ routing_component_rulebased_t new_component =
+ xbt_new0(s_routing_component_rulebased_t, 1);
+ new_component->generic_routing.set_processing_unit =
+ model_rulebased_set_processing_unit;
+ new_component->generic_routing.set_autonomous_system =
+ model_rulebased_set_autonomous_system;
new_component->generic_routing.set_route = model_rulebased_set_route;
new_component->generic_routing.set_ASroute = model_rulebased_set_ASroute;
- new_component->generic_routing.set_bypassroute = model_rulebased_set_bypassroute;
- new_component->generic_routing.get_onelink_routes = rulebased_get_onelink_routes;
+ new_component->generic_routing.set_bypassroute =
+ model_rulebased_set_bypassroute;
+ new_component->generic_routing.get_onelink_routes =
+ rulebased_get_onelink_routes;
new_component->generic_routing.get_route = rulebased_get_route;
- new_component->generic_routing.get_bypass_route = NULL; //rulebased_get_bypass_route;
+ new_component->generic_routing.get_bypass_route = NULL; //rulebased_get_bypass_route;
new_component->generic_routing.finalize = rulebased_finalize;
/* initialization of internal structures */
new_component->dict_processing_units = xbt_dict_new();
new_component->dict_autonomous_systems = xbt_dict_new();
- new_component->list_route = xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);
- new_component->list_ASroute = xbt_dynar_new(sizeof(rule_route_extended_t), &rule_route_extended_free);
+ new_component->list_route =
+ xbt_dynar_new(sizeof(rule_route_t), &rule_route_free);
+ new_component->list_ASroute =
+ xbt_dynar_new(sizeof(rule_route_extended_t),
+ &rule_route_extended_free);
return new_component;
}
-static void model_rulebased_load(void) {
- /* use "surfxml_add_callback" to add a parse function call */
+static void model_rulebased_load(void)
+{
+ /* use "surfxml_add_callback" to add a parse function call */
}
-static void model_rulebased_unload(void) {
- /* use "surfxml_del_callback" to remove a parse function call */
+static void model_rulebased_unload(void)
+{
+ /* use "surfxml_del_callback" to remove a parse function call */
}
-static void model_rulebased_end(void) {
+static void model_rulebased_end(void)
+{
}
-#endif /* HAVE_PCRE_LIB */
+#endif /* HAVE_PCRE_LIB */
/* ************************************************************************** */
/* ******************************* NO ROUTING ******************************* */
/* Routing model structure */
typedef struct {
s_routing_component_t generic_routing;
-} s_routing_component_none_t,*routing_component_none_t;
+} s_routing_component_none_t, *routing_component_none_t;
/* Business methods */
-static xbt_dynar_t none_get_onelink_routes(routing_component_t rc){
+static xbt_dynar_t none_get_onelink_routes(routing_component_t rc)
+{
return NULL;
}
-static route_extended_t none_get_route(routing_component_t rc, const char* src,const char* dst){
+
+static route_extended_t none_get_route(routing_component_t rc,
+ const char *src, const char *dst)
+{
return NULL;
}
-static route_extended_t none_get_bypass_route(routing_component_t rc, const char* src,const char* dst){
+
+static route_extended_t none_get_bypass_route(routing_component_t rc,
+ const char *src,
+ const char *dst)
+{
return NULL;
}
-static void none_finalize(routing_component_t rc) {
+
+static void none_finalize(routing_component_t rc)
+{
xbt_free(rc);
}
-static void none_set_processing_unit(routing_component_t rc, const char* name) {}
-static void none_set_autonomous_system(routing_component_t rc, const char* name) {}
+static void none_set_processing_unit(routing_component_t rc,
+ const char *name)
+{
+}
+
+static void none_set_autonomous_system(routing_component_t rc,
+ const char *name)
+{
+}
/* Creation routing model functions */
-static void* model_none_create(void) {
- routing_component_none_t new_component = xbt_new0(s_routing_component_none_t,1);
- new_component->generic_routing.set_processing_unit = none_set_processing_unit;
- new_component->generic_routing.set_autonomous_system = none_set_autonomous_system;
+static void *model_none_create(void)
+{
+ routing_component_none_t new_component =
+ xbt_new0(s_routing_component_none_t, 1);
+ new_component->generic_routing.set_processing_unit =
+ none_set_processing_unit;
+ new_component->generic_routing.set_autonomous_system =
+ none_set_autonomous_system;
new_component->generic_routing.set_route = NULL;
new_component->generic_routing.set_ASroute = NULL;
new_component->generic_routing.set_bypassroute = NULL;
new_component->generic_routing.get_route = none_get_route;
- new_component->generic_routing.get_onelink_routes = none_get_onelink_routes;
+ new_component->generic_routing.get_onelink_routes =
+ none_get_onelink_routes;
new_component->generic_routing.get_bypass_route = none_get_bypass_route;
new_component->generic_routing.finalize = none_finalize;
return new_component;
}
-static void model_none_load(void) {}
-static void model_none_unload(void) {}
-static void model_none_end(void) {}
+static void model_none_load(void)
+{
+}
+
+static void model_none_unload(void)
+{
+}
+
+static void model_none_end(void)
+{
+}
/* ************************************************** */
/* ********** PATERN FOR NEW ROUTING **************** */
// static void model_NEW_end(void) {} /* mandatory */
/* ************************************************************************** */
-/* ************************* GENERIC PARSE FUNCTIONS ************************ */
+/* ************************* GENERIC PARSE FUNCTIONS ************************ */
-static void generic_set_processing_unit(routing_component_t rc, const char* name) {
- DEBUG1("Load process unit \"%s\"",name);
+static void generic_set_processing_unit(routing_component_t rc,
+ const char *name)
+{
+ DEBUG1("Load process unit \"%s\"", name);
model_type_t modeltype = rc->routing;
- int *id = xbt_new0(int,1);
+ int *id = xbt_new0(int, 1);
xbt_dict_t _to_index;
- if(modeltype==&routing_models[SURF_MODEL_FULL])
- _to_index = ((routing_component_full_t)rc)->to_index;
-
- else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
- _to_index = ((routing_component_floyd_t)rc)->to_index;
-
- else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE])
- _to_index = ((routing_component_dijkstra_t)rc)->to_index;
-
- else xbt_die("\"generic_set_processing_unit\" not supported");
+ if (modeltype == &routing_models[SURF_MODEL_FULL])
+ _to_index = ((routing_component_full_t) rc)->to_index;
+
+ else if (modeltype == &routing_models[SURF_MODEL_FLOYD])
+ _to_index = ((routing_component_floyd_t) rc)->to_index;
+
+ else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE])
+ _to_index = ((routing_component_dijkstra_t) rc)->to_index;
+
+ else
+ xbt_die("\"generic_set_processing_unit\" not supported");
*id = xbt_dict_length(_to_index);
- xbt_dict_set(_to_index,name,id,xbt_free);
+ xbt_dict_set(_to_index, name, id, xbt_free);
}
-static void generic_set_autonomous_system(routing_component_t rc, const char* name) {
- DEBUG1("Load Autonomous system \"%s\"",name);
+static void generic_set_autonomous_system(routing_component_t rc,
+ const char *name)
+{
+ DEBUG1("Load Autonomous system \"%s\"", name);
model_type_t modeltype = rc->routing;
- int *id = xbt_new0(int,1);
+ int *id = xbt_new0(int, 1);
xbt_dict_t _to_index;
- if(modeltype==&routing_models[SURF_MODEL_FULL])
- _to_index = ((routing_component_full_t)rc)->to_index;
-
- else if(modeltype==&routing_models[SURF_MODEL_FLOYD])
- _to_index = ((routing_component_floyd_t)rc)->to_index;
-
- else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE])
- _to_index = ((routing_component_dijkstra_t)rc)->to_index;
-
- else xbt_die("\"generic_set_autonomous_system\" not supported");
+ if (modeltype == &routing_models[SURF_MODEL_FULL])
+ _to_index = ((routing_component_full_t) rc)->to_index;
+
+ else if (modeltype == &routing_models[SURF_MODEL_FLOYD])
+ _to_index = ((routing_component_floyd_t) rc)->to_index;
+
+ else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE])
+ _to_index = ((routing_component_dijkstra_t) rc)->to_index;
+
+ else
+ xbt_die("\"generic_set_autonomous_system\" not supported");
*id = xbt_dict_length(_to_index);
- xbt_dict_set(_to_index,name,id,xbt_free);
+ xbt_dict_set(_to_index, name, id, xbt_free);
}
-static void generic_set_route(routing_component_t rc, const char* src, const char* dst, route_t route) {
- DEBUG2("Load Route from \"%s\" to \"%s\"",src,dst);
+static void generic_set_route(routing_component_t rc, const char *src,
+ const char *dst, route_t route)
+{
+ DEBUG2("Load Route from \"%s\" to \"%s\"", src, dst);
model_type_t modeltype = rc->routing;
xbt_dict_t _parse_routes;
xbt_dict_t _to_index;
char *route_name;
int *src_id, *dst_id;
-
- if(modeltype==&routing_models[SURF_MODEL_FULL]) {
- _parse_routes = ((routing_component_full_t)rc)->parse_routes;
- _to_index = ((routing_component_full_t)rc)->to_index;
-
- } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
- _parse_routes = ((routing_component_floyd_t)rc)->parse_routes;
- _to_index = ((routing_component_floyd_t)rc)->to_index;
-
- } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
- _parse_routes = ((routing_component_dijkstra_t)rc)->parse_routes;
- _to_index = ((routing_component_dijkstra_t)rc)->to_index;
-
- } else xbt_die("\"generic_set_route\" not supported");
+
+ if (modeltype == &routing_models[SURF_MODEL_FULL]) {
+ _parse_routes = ((routing_component_full_t) rc)->parse_routes;
+ _to_index = ((routing_component_full_t) rc)->to_index;
+
+ } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
+ _parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
+ _to_index = ((routing_component_floyd_t) rc)->to_index;
+
+ } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ _parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
+ _to_index = ((routing_component_dijkstra_t) rc)->to_index;
+
+ } else
+ xbt_die("\"generic_set_route\" not supported");
src_id = xbt_dict_get_or_null(_to_index, src);
dst_id = xbt_dict_get_or_null(_to_index, dst);
-
- xbt_assert2(src_id&&dst_id,"Network elements %s or %s not found", src, dst);
- route_name = bprintf("%d#%d",*src_id,*dst_id);
-
- xbt_assert2(xbt_dynar_length(route->link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
- xbt_assert2(!xbt_dict_get_or_null(_parse_routes,route_name),
- "The route between \"%s\" and \"%s\" already exist",src,dst);
+
+ xbt_assert2(src_id
+ && dst_id, "Network elements %s or %s not found", src, dst);
+ route_name = bprintf("%d#%d", *src_id, *dst_id);
+
+ xbt_assert2(xbt_dynar_length(route->link_list) > 0,
+ "Invalid count of links, must be greater than zero (%s,%s)",
+ src, dst);
+ xbt_assert2(!xbt_dict_get_or_null(_parse_routes, route_name),
+ "The route between \"%s\" and \"%s\" already exist", src,
+ dst);
xbt_dict_set(_parse_routes, route_name, route, NULL);
xbt_free(route_name);
}
-static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
- DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",src,e_route->src_gateway,dst,e_route->dst_gateway);
+static void generic_set_ASroute(routing_component_t rc, const char *src,
+ const char *dst, route_extended_t e_route)
+{
+ DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
+ e_route->src_gateway, dst, e_route->dst_gateway);
model_type_t modeltype = rc->routing;
xbt_dict_t _parse_routes;
xbt_dict_t _to_index;
char *route_name;
int *src_id, *dst_id;
-
- if(modeltype==&routing_models[SURF_MODEL_FULL]) {
- _parse_routes = ((routing_component_full_t)rc)->parse_routes;
- _to_index = ((routing_component_full_t)rc)->to_index;
-
- } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
- _parse_routes = ((routing_component_floyd_t)rc)->parse_routes;
- _to_index = ((routing_component_floyd_t)rc)->to_index;
-
- } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
- _parse_routes = ((routing_component_dijkstra_t)rc)->parse_routes;
- _to_index = ((routing_component_dijkstra_t)rc)->to_index;
-
- } else xbt_die("\"generic_set_route\" not supported");
-
+
+ if (modeltype == &routing_models[SURF_MODEL_FULL]) {
+ _parse_routes = ((routing_component_full_t) rc)->parse_routes;
+ _to_index = ((routing_component_full_t) rc)->to_index;
+
+ } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
+ _parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
+ _to_index = ((routing_component_floyd_t) rc)->to_index;
+
+ } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ _parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
+ _to_index = ((routing_component_dijkstra_t) rc)->to_index;
+
+ } else
+ xbt_die("\"generic_set_route\" not supported");
+
src_id = xbt_dict_get_or_null(_to_index, src);
dst_id = xbt_dict_get_or_null(_to_index, dst);
-
- xbt_assert2(src_id&&dst_id,"Network elements %s or %s not found", src, dst);
- route_name = bprintf("%d#%d",*src_id,*dst_id);
-
- xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
- xbt_assert4(!xbt_dict_get_or_null(_parse_routes,route_name),
- "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",src,e_route->src_gateway,dst,e_route->dst_gateway);
-
+
+ xbt_assert2(src_id
+ && dst_id, "Network elements %s or %s not found", src, dst);
+ route_name = bprintf("%d#%d", *src_id, *dst_id);
+
+ xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list) > 0,
+ "Invalid count of links, must be greater than zero (%s,%s)",
+ src, dst);
+ xbt_assert4(!xbt_dict_get_or_null(_parse_routes, route_name),
+ "The route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",
+ src, e_route->src_gateway, dst, e_route->dst_gateway);
+
xbt_dict_set(_parse_routes, route_name, e_route, NULL);
xbt_free(route_name);
}
-static void generic_set_bypassroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) {
- DEBUG2("Load bypassRoute from \"%s\" to \"%s\"",src,dst);
+static void generic_set_bypassroute(routing_component_t rc,
+ const char *src, const char *dst,
+ route_extended_t e_route)
+{
+ DEBUG2("Load bypassRoute from \"%s\" to \"%s\"", src, dst);
model_type_t modeltype = rc->routing;
xbt_dict_t dict_bypassRoutes;
char *route_name;
- if(modeltype==&routing_models[SURF_MODEL_FULL]) {
- dict_bypassRoutes = ((routing_component_full_t)rc)->bypassRoutes;
- } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
- dict_bypassRoutes = ((routing_component_floyd_t)rc)->bypassRoutes;
- } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
- dict_bypassRoutes = ((routing_component_dijkstra_t)rc)->bypassRoutes;
- } else xbt_die("\"generic_set_bypassroute\" not supported");
- route_name = bprintf("%s#%s",src,dst);
- xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list)>0, "Invalid count of links, must be greater than zero (%s,%s)",src,dst);
- xbt_assert4(!xbt_dict_get_or_null(dict_bypassRoutes,route_name),
- "The bypass route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",src,e_route->src_gateway,dst,e_route->dst_gateway);
-
- route_extended_t new_e_route = generic_new_extended_route(SURF_ROUTING_RECURSIVE,e_route,0);
- xbt_dynar_free( &(e_route->generic_route.link_list) );
+ if (modeltype == &routing_models[SURF_MODEL_FULL]) {
+ dict_bypassRoutes = ((routing_component_full_t) rc)->bypassRoutes;
+ } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
+ dict_bypassRoutes = ((routing_component_floyd_t) rc)->bypassRoutes;
+ } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ dict_bypassRoutes = ((routing_component_dijkstra_t) rc)->bypassRoutes;
+ } else
+ xbt_die("\"generic_set_bypassroute\" not supported");
+ route_name = bprintf("%s#%s", src, dst);
+ xbt_assert2(xbt_dynar_length(e_route->generic_route.link_list) > 0,
+ "Invalid count of links, must be greater than zero (%s,%s)",
+ src, dst);
+ xbt_assert4(!xbt_dict_get_or_null(dict_bypassRoutes, route_name),
+ "The bypass route between \"%s\"(\"%s\") and \"%s\"(\"%s\") already exist",
+ src, e_route->src_gateway, dst, e_route->dst_gateway);
+
+ route_extended_t new_e_route =
+ generic_new_extended_route(SURF_ROUTING_RECURSIVE, e_route, 0);
+ xbt_dynar_free(&(e_route->generic_route.link_list));
xbt_free(e_route);
-
- xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, (void(*)(void*))generic_free_extended_route );
+
+ xbt_dict_set(dict_bypassRoutes, route_name, new_e_route,
+ (void (*)(void *)) generic_free_extended_route);
xbt_free(route_name);
}
/* ************************************************************************** */
/* *********************** GENERIC BUSINESS METHODS ************************* */
-static xbt_dynar_t generic_get_onelink_routes (routing_component_t rc)
+static xbt_dynar_t generic_get_onelink_routes(routing_component_t rc)
{
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
}
-static route_extended_t generic_get_bypassroute(routing_component_t rc, const char* src, const char* dst) {
+static route_extended_t generic_get_bypassroute(routing_component_t rc,
+ const char *src,
+ const char *dst)
+{
model_type_t modeltype = rc->routing;
xbt_dict_t dict_bypassRoutes;
-
- if(modeltype==&routing_models[SURF_MODEL_FULL]) {
- dict_bypassRoutes = ((routing_component_full_t)rc)->bypassRoutes;
- } else if(modeltype==&routing_models[SURF_MODEL_FLOYD]) {
- dict_bypassRoutes = ((routing_component_floyd_t)rc)->bypassRoutes;
- } else if(modeltype==&routing_models[SURF_MODEL_DIJKSTRA]||
- modeltype==&routing_models[SURF_MODEL_DIJKSTRACACHE]) {
- dict_bypassRoutes = ((routing_component_dijkstra_t)rc)->bypassRoutes;
- } else xbt_die("\"generic_get_bypassroute\" not supported");
-
+
+ if (modeltype == &routing_models[SURF_MODEL_FULL]) {
+ dict_bypassRoutes = ((routing_component_full_t) rc)->bypassRoutes;
+ } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
+ dict_bypassRoutes = ((routing_component_floyd_t) rc)->bypassRoutes;
+ } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
+ modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
+ dict_bypassRoutes = ((routing_component_dijkstra_t) rc)->bypassRoutes;
+ } else
+ xbt_die("\"generic_get_bypassroute\" not supported");
+
routing_component_t src_as, dst_as;
int index_src, index_dst;
xbt_dynar_t path_src = NULL;
xbt_dynar_t path_dst = NULL;
routing_component_t current = NULL;
- routing_component_t* current_src = NULL;
- routing_component_t* current_dst = NULL;
+ routing_component_t *current_src = NULL;
+ routing_component_t *current_dst = NULL;
/* (1) find the as where the src and dst are located */
- src_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,src))->rc_component;
- dst_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,dst))->rc_component;
- xbt_assert2(src_as&&dst_as, "Ask for route \"from\"(%s) or \"to\"(%s) no found",src,dst);
-
+ src_as = ((network_element_info_t)
+ xbt_dict_get_or_null(global_routing->where_network_elements,
+ src))->rc_component;
+ dst_as = ((network_element_info_t)
+ xbt_dict_get_or_null(global_routing->where_network_elements,
+ dst))->rc_component;
+ xbt_assert2(src_as
+ && dst_as,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found", src,
+ dst);
+
/* (2) find the path to the root routing component */
path_src = xbt_dynar_new(sizeof(routing_component_t), NULL);
- current = src_as;
- while( current != NULL ) {
- xbt_dynar_push(path_src,¤t);
+ current = src_as;
+ while (current != NULL) {
+ xbt_dynar_push(path_src, ¤t);
current = current->routing_father;
}
path_dst = xbt_dynar_new(sizeof(routing_component_t), NULL);
- current = dst_as;
- while( current != NULL ) {
- xbt_dynar_push(path_dst,¤t);
+ current = dst_as;
+ while (current != NULL) {
+ xbt_dynar_push(path_dst, ¤t);
current = current->routing_father;
}
/* (3) find the common father */
- index_src = (path_src->used)-1;
- index_dst = (path_dst->used)-1;
- current_src = xbt_dynar_get_ptr(path_src,index_src);
- current_dst = xbt_dynar_get_ptr(path_dst,index_dst);
- while( index_src >= 0 && index_dst >= 0 && *current_src == *current_dst ) {
- routing_component_t *tmp_src,*tmp_dst;
+ index_src = (path_src->used) - 1;
+ index_dst = (path_dst->used) - 1;
+ current_src = xbt_dynar_get_ptr(path_src, index_src);
+ current_dst = xbt_dynar_get_ptr(path_dst, index_dst);
+ while (index_src >= 0 && index_dst >= 0 && *current_src == *current_dst) {
+ routing_component_t *tmp_src, *tmp_dst;
tmp_src = xbt_dynar_pop_ptr(path_src);
tmp_dst = xbt_dynar_pop_ptr(path_dst);
index_src--;
index_dst--;
- current_src = xbt_dynar_get_ptr(path_src,index_src);
- current_dst = xbt_dynar_get_ptr(path_dst,index_dst);
+ current_src = xbt_dynar_get_ptr(path_src, index_src);
+ current_dst = xbt_dynar_get_ptr(path_dst, index_dst);
}
-
- int max_index_src = (path_src->used)-1;
- int max_index_dst = (path_dst->used)-1;
-
- int max_index = max(max_index_src,max_index_dst);
+
+ int max_index_src = (path_src->used) - 1;
+ int max_index_dst = (path_dst->used) - 1;
+
+ int max_index = max(max_index_src, max_index_dst);
int i, max;
-
- route_extended_t e_route_bypass = NULL;
-
- for( max=0;max<=max_index;max++)
- {
- for(i=0;i<max;i++)
- {
- if( i <= max_index_src && max <= max_index_dst ) {
- char* route_name = bprintf("%s#%s",
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_src,i)))->name,
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_dst,max)))->name);
- e_route_bypass = xbt_dict_get_or_null(dict_bypassRoutes,route_name);
+
+ route_extended_t e_route_bypass = NULL;
+
+ for (max = 0; max <= max_index; max++) {
+ for (i = 0; i < max; i++) {
+ if (i <= max_index_src && max <= max_index_dst) {
+ char *route_name = bprintf("%s#%s",
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_src, i)))->name,
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_dst, max)))->name);
+ e_route_bypass =
+ xbt_dict_get_or_null(dict_bypassRoutes, route_name);
xbt_free(route_name);
}
- if( e_route_bypass ) break;
- if( max <= max_index_src && i <= max_index_dst ) {
- char* route_name = bprintf("%s#%s",
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_src,max)))->name,
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_dst,i)))->name);
- e_route_bypass = xbt_dict_get_or_null(dict_bypassRoutes,route_name);
+ if (e_route_bypass)
+ break;
+ if (max <= max_index_src && i <= max_index_dst) {
+ char *route_name = bprintf("%s#%s",
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_src, max)))->name,
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_dst, i)))->name);
+ e_route_bypass =
+ xbt_dict_get_or_null(dict_bypassRoutes, route_name);
xbt_free(route_name);
}
- if( e_route_bypass ) break;
+ if (e_route_bypass)
+ break;
}
-
- if( e_route_bypass ) break;
-
- if( max <= max_index_src && max <= max_index_dst ) {
- char* route_name = bprintf("%s#%s",
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_src,max)))->name,
- (*(routing_component_t*)(xbt_dynar_get_ptr(path_dst,max)))->name);
- e_route_bypass = xbt_dict_get_or_null(dict_bypassRoutes,route_name);
+
+ if (e_route_bypass)
+ break;
+
+ if (max <= max_index_src && max <= max_index_dst) {
+ char *route_name = bprintf("%s#%s",
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_src, max)))->name,
+ (*(routing_component_t *)
+ (xbt_dynar_get_ptr
+ (path_dst, max)))->name);
+ e_route_bypass = xbt_dict_get_or_null(dict_bypassRoutes, route_name);
xbt_free(route_name);
}
- if( e_route_bypass ) break;
+ if (e_route_bypass)
+ break;
}
xbt_dynar_free(&path_src);
xbt_dynar_free(&path_dst);
-
+
route_extended_t new_e_route = NULL;
-
- if(e_route_bypass) {
- void* link;
- unsigned int cpt=0;
- new_e_route = xbt_new0(s_route_extended_t,1);
+
+ if (e_route_bypass) {
+ void *link;
+ unsigned int cpt = 0;
+ new_e_route = xbt_new0(s_route_extended_t, 1);
new_e_route->src_gateway = xbt_strdup(e_route_bypass->src_gateway);
new_e_route->dst_gateway = xbt_strdup(e_route_bypass->dst_gateway);
- new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+ new_e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
xbt_dynar_foreach(e_route_bypass->generic_route.link_list, cpt, link) {
- xbt_dynar_push(new_e_route->generic_route.link_list,&link);
+ xbt_dynar_push(new_e_route->generic_route.link_list, &link);
}
}
/* ************************************************************************** */
/* ************************* GENERIC AUX FUNCTIONS ************************** */
-static route_extended_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, void* data, int order) {
-
+static route_extended_t
+generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
+ void *data, int order)
+{
+
char *link_name;
route_extended_t e_route, new_e_route;
route_t route;
unsigned int cpt;
xbt_dynar_t links, links_id;
-
- new_e_route = xbt_new0(s_route_extended_t,1);
- new_e_route->generic_route.link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+
+ new_e_route = xbt_new0(s_route_extended_t, 1);
+ new_e_route->generic_route.link_list =
+ xbt_dynar_new(global_routing->size_of_link, NULL);
new_e_route->src_gateway = NULL;
new_e_route->dst_gateway = NULL;
- xbt_assert0(hierarchy == SURF_ROUTING_BASE || hierarchy == SURF_ROUTING_RECURSIVE,
- "the hierarchy type is not defined");
-
- if(hierarchy == SURF_ROUTING_BASE ) {
-
- route = (route_t)data;
+ xbt_assert0(hierarchy == SURF_ROUTING_BASE
+ || hierarchy == SURF_ROUTING_RECURSIVE,
+ "the hierarchy type is not defined");
+
+ if (hierarchy == SURF_ROUTING_BASE) {
+
+ route = (route_t) data;
links = route->link_list;
-
- } else if(hierarchy == SURF_ROUTING_RECURSIVE ) {
- e_route = (route_extended_t)data;
- xbt_assert0(e_route->src_gateway&&e_route->dst_gateway,"bad gateway, is null");
+ } else if (hierarchy == SURF_ROUTING_RECURSIVE) {
+
+ e_route = (route_extended_t) data;
+ xbt_assert0(e_route->src_gateway
+ && e_route->dst_gateway, "bad gateway, is null");
links = e_route->generic_route.link_list;
-
+
/* remeber not erase the gateway names */
new_e_route->src_gateway = e_route->src_gateway;
new_e_route->dst_gateway = e_route->dst_gateway;
}
-
+
links_id = new_e_route->generic_route.link_list;
-
+
xbt_dynar_foreach(links, cpt, link_name) {
-
- void* link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
- if (link)
- {
- if( order )
- xbt_dynar_push(links_id,&link);
+
+ void *link =
+ xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
+ if (link) {
+ if (order)
+ xbt_dynar_push(links_id, &link);
else
- xbt_dynar_unshift(links_id,&link);
- }
- else
- THROW1(mismatch_error,0,"Link %s not found", link_name);
+ xbt_dynar_unshift(links_id, &link);
+ } else
+ THROW1(mismatch_error, 0, "Link %s not found", link_name);
}
-
+
return new_e_route;
}
-static void generic_free_route(route_t route) {
- if(route) {
+static void generic_free_route(route_t route)
+{
+ if (route) {
xbt_dynar_free(&(route->link_list));
xbt_free(route);
}
}
-static void generic_free_extended_route(route_extended_t e_route) {
- if(e_route) {
+static void generic_free_extended_route(route_extended_t e_route)
+{
+ if (e_route) {
xbt_dynar_free(&(e_route->generic_route.link_list));
- if(e_route->src_gateway) xbt_free(e_route->src_gateway);
- if(e_route->dst_gateway) xbt_free(e_route->dst_gateway);
+ if (e_route->src_gateway)
+ xbt_free(e_route->src_gateway);
+ if (e_route->dst_gateway)
+ xbt_free(e_route->dst_gateway);
xbt_free(e_route);
}
}
-static routing_component_t generic_as_exist(routing_component_t find_from, routing_component_t to_find) {
+static routing_component_t generic_as_exist(routing_component_t find_from,
+ routing_component_t to_find)
+{
//return to_find; // FIXME: BYPASSERROR OF FOREACH WITH BREAK
xbt_dict_cursor_t cursor = NULL;
char *key;
- int found=0;
+ int found = 0;
routing_component_t elem;
xbt_dict_foreach(find_from->routing_sons, cursor, key, elem) {
- if( to_find == elem || generic_as_exist(elem,to_find) ){
- found=1;
+ if (to_find == elem || generic_as_exist(elem, to_find)) {
+ found = 1;
break;
}
}
- if(found) return to_find;
+ if (found)
+ return to_find;
return NULL;
}
-static routing_component_t generic_autonomous_system_exist(routing_component_t rc, char* element) {
+static routing_component_t
+generic_autonomous_system_exist(routing_component_t rc, char *element)
+{
//return rc; // FIXME: BYPASSERROR OF FOREACH WITH BREAK
routing_component_t element_as, result, elem;
xbt_dict_cursor_t cursor = NULL;
char *key;
- element_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,element))->rc_component;
- result = ((routing_component_t)-1);
- if(element_as!=rc)
- result = generic_as_exist(rc,element_as);
-
- int found=0;
- if(result)
- {
+ element_as = ((network_element_info_t)
+ xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ element))->rc_component;
+ result = ((routing_component_t) - 1);
+ if (element_as != rc)
+ result = generic_as_exist(rc, element_as);
+
+ int found = 0;
+ if (result) {
xbt_dict_foreach(element_as->routing_sons, cursor, key, elem) {
- found = !strcmp(elem->name,element);
- if( found ) break;
+ found = !strcmp(elem->name, element);
+ if (found)
+ break;
}
- if( found ) return element_as;
+ if (found)
+ return element_as;
}
return NULL;
}
-static routing_component_t generic_processing_units_exist(routing_component_t rc, char* element) {
+static routing_component_t
+generic_processing_units_exist(routing_component_t rc, char *element)
+{
routing_component_t element_as;
- element_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,element))->rc_component;
- if(element_as==rc) return element_as;
- return generic_as_exist(rc,element_as);
-}
-
-static void generic_src_dst_check(routing_component_t rc, const char* src, const char* dst) {
-
- routing_component_t src_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,src))->rc_component;
- routing_component_t dst_as = ((network_element_info_t)xbt_dict_get_or_null(global_routing->where_network_elements,dst))->rc_component;
-
- xbt_assert3(src_as != NULL && dst_as != NULL,
- "Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",src,dst,rc->name);
+ element_as = ((network_element_info_t)
+ xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ element))->rc_component;
+ if (element_as == rc)
+ return element_as;
+ return generic_as_exist(rc, element_as);
+}
+
+static void generic_src_dst_check(routing_component_t rc, const char *src,
+ const char *dst)
+{
+
+ routing_component_t src_as = ((network_element_info_t)
+ xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ src))->rc_component;
+ routing_component_t dst_as = ((network_element_info_t)
+ xbt_dict_get_or_null
+ (global_routing->where_network_elements,
+ dst))->rc_component;
+
+ xbt_assert3(src_as != NULL && dst_as != NULL,
+ "Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
+ src, dst, rc->name);
xbt_assert4(src_as == dst_as,
- "The src(%s in %s) and dst(%s in %s) are in differents AS",src,src_as->name,dst,dst_as->name);
+ "The src(%s in %s) and dst(%s in %s) are in differents AS",
+ src, src_as->name, dst, dst_as->name);
xbt_assert2(rc == dst_as,
- "The routing component of src and dst is not the same as the network elements belong (%s==%s)",rc->name,dst_as->name);
+ "The routing component of src and dst is not the same as the network elements belong (%s==%s)",
+ rc->name, dst_as->name);
}
static void parse_Sconfig(void)
{
- //TODO
- DEBUG0("WARNING tag config not yet implemented.");
+ //TODO
+ DEBUG0("WARNING tag config not yet implemented.");
}
static void routing_full_parse_Scluster(void)
{
- static int AX_ptr = 0;
-
- char *cluster_id = A_surfxml_cluster_id;
- char *cluster_prefix = A_surfxml_cluster_prefix;
- char *cluster_suffix = A_surfxml_cluster_suffix;
- char *cluster_radical = A_surfxml_cluster_radical;
- char *cluster_power = A_surfxml_cluster_power;
- char *cluster_bw = A_surfxml_cluster_bw;
- char *cluster_lat = A_surfxml_cluster_lat;
- char *cluster_bb_bw = A_surfxml_cluster_bb_bw;
- char *cluster_bb_lat = A_surfxml_cluster_bb_lat;
- char *host_id, *groups, *link_id;
- char *router_id, *link_router, *link_backbone, *route_src_dst;
- unsigned int iter;
- int start, end, i;
- xbt_dynar_t radical_elements;
- xbt_dynar_t radical_ends;
- #ifndef HAVE_PCRE_LIB
- xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);
- char *route_src,*route_dst;
- int j;
- #endif
-
- static unsigned int surfxml_buffer_stack_stack_ptr = 1;
- static unsigned int surfxml_buffer_stack_stack[1024];
-
- surfxml_buffer_stack_stack[0]= 0;
-
- surfxml_bufferstack_push(1);
-
- SURFXML_BUFFER_SET(AS_id, cluster_id);
+ static int AX_ptr = 0;
+
+ char *cluster_id = A_surfxml_cluster_id;
+ char *cluster_prefix = A_surfxml_cluster_prefix;
+ char *cluster_suffix = A_surfxml_cluster_suffix;
+ char *cluster_radical = A_surfxml_cluster_radical;
+ char *cluster_power = A_surfxml_cluster_power;
+ char *cluster_bw = A_surfxml_cluster_bw;
+ char *cluster_lat = A_surfxml_cluster_lat;
+ char *cluster_bb_bw = A_surfxml_cluster_bb_bw;
+ char *cluster_bb_lat = A_surfxml_cluster_bb_lat;
+ char *host_id, *groups, *link_id;
+ char *router_id, *link_router, *link_backbone, *route_src_dst;
+ unsigned int iter;
+ int start, end, i;
+ xbt_dynar_t radical_elements;
+ xbt_dynar_t radical_ends;
+#ifndef HAVE_PCRE_LIB
+ xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);
+ char *route_src, *route_dst;
+ int j;
+#endif
+
+ static unsigned int surfxml_buffer_stack_stack_ptr = 1;
+ static unsigned int surfxml_buffer_stack_stack[1024];
+
+ surfxml_buffer_stack_stack[0] = 0;
+
+ surfxml_bufferstack_push(1);
+
+ SURFXML_BUFFER_SET(AS_id, cluster_id);
#ifdef HAVE_PCRE_LIB
- SURFXML_BUFFER_SET(AS_routing, "RuleBased");
- DEBUG1("<AS id=\"%s\"\trouting=\"RuleBased\">",cluster_id);
+ SURFXML_BUFFER_SET(AS_routing, "RuleBased");
+ DEBUG1("<AS id=\"%s\"\trouting=\"RuleBased\">", cluster_id);
#else
- SURFXML_BUFFER_SET(AS_routing, "Full");
- DEBUG1("<AS id=\"%s\"\trouting=\"Full\">",cluster_id);
+ SURFXML_BUFFER_SET(AS_routing, "Full");
+ DEBUG1("<AS id=\"%s\"\trouting=\"Full\">", cluster_id);
+#endif
+ SURFXML_START_TAG(AS);
+
+ radical_elements = xbt_str_split(cluster_radical, ",");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+ radical_ends = xbt_str_split(groups, "-");
+ switch (xbt_dynar_length(radical_ends)) {
+ case 1:
+ surf_parse_get_int(&start,
+ xbt_dynar_get_as(radical_ends, 0, char *));
+ host_id = bprintf("%s_%d%s", cluster_prefix, start, cluster_suffix);
+#ifndef HAVE_PCRE_LIB
+ xbt_dynar_push_as(tab_elements_num, int, start);
+#endif
+ link_id = bprintf("%s_link_%d", cluster_id, start);
+
+ DEBUG2("<host\tid=\"%s\"\tpower=\"%s\"/>", host_id, cluster_power);
+ SURFXML_BUFFER_SET(host_id, host_id);
+ SURFXML_BUFFER_SET(host_power, cluster_power);
+ SURFXML_BUFFER_SET(host_availability, "1.0");
+ SURFXML_BUFFER_SET(host_availability_file, "");
+ A_surfxml_host_state = A_surfxml_host_state_ON;
+ SURFXML_BUFFER_SET(host_state_file, "");
+ SURFXML_START_TAG(host);
+ SURFXML_END_TAG(host);
+
+ DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,
+ cluster_bw, cluster_lat);
+ SURFXML_BUFFER_SET(link_id, link_id);
+ SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
+ SURFXML_BUFFER_SET(link_latency, cluster_lat);
+ SURFXML_BUFFER_SET(link_bandwidth_file, "");
+ SURFXML_BUFFER_SET(link_latency_file, "");
+ A_surfxml_link_state = A_surfxml_link_state_ON;
+ SURFXML_BUFFER_SET(link_state_file, "");
+ A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
+ SURFXML_START_TAG(link);
+ SURFXML_END_TAG(link);
+
+ break;
+
+ case 2:
+
+ surf_parse_get_int(&start,
+ xbt_dynar_get_as(radical_ends, 0, char *));
+ surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *));
+ DEBUG2("Create hosts and links from %d to %d", start, end);
+ for (i = start; i <= end; i++) {
+ host_id = bprintf("%s_%d%s", cluster_prefix, i, cluster_suffix);
+#ifndef HAVE_PCRE_LIB
+ xbt_dynar_push_as(tab_elements_num, int, i);
#endif
- SURFXML_START_TAG(AS);
-
- radical_elements = xbt_str_split(cluster_radical, ",");
- xbt_dynar_foreach(radical_elements, iter, groups)
- {
- radical_ends = xbt_str_split(groups, "-");
- switch (xbt_dynar_length(radical_ends))
- {
- case 1:
- surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
- host_id = bprintf("%s_%d%s", cluster_prefix, start, cluster_suffix);
- #ifndef HAVE_PCRE_LIB
- xbt_dynar_push_as(tab_elements_num, int, start);
- #endif
- link_id = bprintf("%s_link_%d", cluster_id, start);
-
- DEBUG2("<host\tid=\"%s\"\tpower=\"%s\"/>",host_id,cluster_power);
- SURFXML_BUFFER_SET(host_id, host_id);
- SURFXML_BUFFER_SET(host_power, cluster_power);
- SURFXML_BUFFER_SET(host_availability, "1.0");
- SURFXML_BUFFER_SET(host_availability_file, "");
- A_surfxml_host_state = A_surfxml_host_state_ON;
- SURFXML_BUFFER_SET(host_state_file, "");
- SURFXML_START_TAG(host);
- SURFXML_END_TAG(host);
-
- DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>",link_id,cluster_bw,cluster_lat);
- SURFXML_BUFFER_SET(link_id, link_id);
- SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
- SURFXML_BUFFER_SET(link_latency, cluster_lat);
- SURFXML_BUFFER_SET(link_bandwidth_file, "");
- SURFXML_BUFFER_SET(link_latency_file, "");
- A_surfxml_link_state = A_surfxml_link_state_ON;
- SURFXML_BUFFER_SET(link_state_file, "");
- A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
- SURFXML_START_TAG(link);
- SURFXML_END_TAG(link);
-
- break;
-
- case 2:
-
- surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
- surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *));
- DEBUG2("Create hosts and links from %d to %d",start,end);
- for (i = start; i <= end; i++)
- {
- host_id = bprintf("%s_%d%s", cluster_prefix, i, cluster_suffix);
- #ifndef HAVE_PCRE_LIB
- xbt_dynar_push_as(tab_elements_num, int, i);
- #endif
- link_id = bprintf("%s_link_%d", cluster_id, i);
-
- DEBUG2("<host\tid=\"%s\"\tpower=\"%s\"/>",host_id,cluster_power);
- SURFXML_BUFFER_SET(host_id, host_id);
- SURFXML_BUFFER_SET(host_power, cluster_power);
- SURFXML_BUFFER_SET(host_availability, "1.0");
- SURFXML_BUFFER_SET(host_availability_file, "");
- A_surfxml_host_state = A_surfxml_host_state_ON;
- SURFXML_BUFFER_SET(host_state_file, "");
- SURFXML_START_TAG(host);
- SURFXML_END_TAG(host);
-
- DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>",link_id,cluster_bw,cluster_lat);
- SURFXML_BUFFER_SET(link_id, link_id);
- SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
- SURFXML_BUFFER_SET(link_latency, cluster_lat);
- SURFXML_BUFFER_SET(link_bandwidth_file, "");
- SURFXML_BUFFER_SET(link_latency_file, "");
- A_surfxml_link_state = A_surfxml_link_state_ON;
- SURFXML_BUFFER_SET(link_state_file, "");
- A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
- SURFXML_START_TAG(link);
- SURFXML_END_TAG(link);
- }
- break;
-
- default:
- DEBUG0("Malformed radical");
- }
-
- xbt_dynar_free(&radical_ends);
- }
-
- DEBUG0(" ");
- router_id = bprintf("%s_%s_router%s",cluster_prefix,cluster_id,cluster_suffix);
- link_router = bprintf("%s_link_%s_router",cluster_id,cluster_id);
- link_backbone = bprintf("%s_backbone",cluster_id);
-
- DEBUG1("<router id=\"%s\"/>",router_id);
- SURFXML_BUFFER_SET(router_id, router_id);;
- SURFXML_START_TAG(router);
- SURFXML_END_TAG(router);
-
- DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>",link_router,cluster_bw,cluster_lat);
- SURFXML_BUFFER_SET(link_id, link_router);
- SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
- SURFXML_BUFFER_SET(link_latency, cluster_lat);
- SURFXML_BUFFER_SET(link_bandwidth_file, "");
- SURFXML_BUFFER_SET(link_latency_file, "");
- A_surfxml_link_state = A_surfxml_link_state_ON;
- SURFXML_BUFFER_SET(link_state_file, "");
- A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
- SURFXML_START_TAG(link);
- SURFXML_END_TAG(link);
-
- DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>",link_backbone,cluster_bb_bw,cluster_bb_lat);
- SURFXML_BUFFER_SET(link_id, link_backbone);
- SURFXML_BUFFER_SET(link_bandwidth, cluster_bb_bw);
- SURFXML_BUFFER_SET(link_latency, cluster_bb_lat);
- SURFXML_BUFFER_SET(link_bandwidth_file, "");
- SURFXML_BUFFER_SET(link_latency_file, "");
- A_surfxml_link_state = A_surfxml_link_state_ON;
- SURFXML_BUFFER_SET(link_state_file, "");
- A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
- SURFXML_START_TAG(link);
- SURFXML_END_TAG(link);
-
- char *new_suffix = bprintf("%s","");
-
- radical_elements = xbt_str_split(cluster_suffix, ".");
- xbt_dynar_foreach(radical_elements, iter, groups)
- {
- if(strcmp(groups,""))
- {
- new_suffix = bprintf("%s\\.%s",new_suffix,groups);
- }
- }
- route_src_dst = bprintf("%s_(.*)%s",cluster_prefix,new_suffix);
-
- DEBUG0(" ");
+ link_id = bprintf("%s_link_%d", cluster_id, i);
+
+ DEBUG2("<host\tid=\"%s\"\tpower=\"%s\"/>", host_id, cluster_power);
+ SURFXML_BUFFER_SET(host_id, host_id);
+ SURFXML_BUFFER_SET(host_power, cluster_power);
+ SURFXML_BUFFER_SET(host_availability, "1.0");
+ SURFXML_BUFFER_SET(host_availability_file, "");
+ A_surfxml_host_state = A_surfxml_host_state_ON;
+ SURFXML_BUFFER_SET(host_state_file, "");
+ SURFXML_START_TAG(host);
+ SURFXML_END_TAG(host);
+
+ DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_id,
+ cluster_bw, cluster_lat);
+ SURFXML_BUFFER_SET(link_id, link_id);
+ SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
+ SURFXML_BUFFER_SET(link_latency, cluster_lat);
+ SURFXML_BUFFER_SET(link_bandwidth_file, "");
+ SURFXML_BUFFER_SET(link_latency_file, "");
+ A_surfxml_link_state = A_surfxml_link_state_ON;
+ SURFXML_BUFFER_SET(link_state_file, "");
+ A_surfxml_link_sharing_policy =
+ A_surfxml_link_sharing_policy_SHARED;
+ SURFXML_START_TAG(link);
+ SURFXML_END_TAG(link);
+ }
+ break;
+
+ default:
+ DEBUG0("Malformed radical");
+ }
+
+ xbt_dynar_free(&radical_ends);
+ }
+
+ DEBUG0(" ");
+ router_id =
+ bprintf("%s_%s_router%s", cluster_prefix, cluster_id,
+ cluster_suffix);
+ link_router = bprintf("%s_link_%s_router", cluster_id, cluster_id);
+ link_backbone = bprintf("%s_backbone", cluster_id);
+
+ DEBUG1("<router id=\"%s\"/>", router_id);
+ SURFXML_BUFFER_SET(router_id, router_id);;
+ SURFXML_START_TAG(router);
+ SURFXML_END_TAG(router);
+
+ DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_router,
+ cluster_bw, cluster_lat);
+ SURFXML_BUFFER_SET(link_id, link_router);
+ SURFXML_BUFFER_SET(link_bandwidth, cluster_bw);
+ SURFXML_BUFFER_SET(link_latency, cluster_lat);
+ SURFXML_BUFFER_SET(link_bandwidth_file, "");
+ SURFXML_BUFFER_SET(link_latency_file, "");
+ A_surfxml_link_state = A_surfxml_link_state_ON;
+ SURFXML_BUFFER_SET(link_state_file, "");
+ A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
+ SURFXML_START_TAG(link);
+ SURFXML_END_TAG(link);
+
+ DEBUG3("<link\tid=\"%s\"\tbw=\"%s\"\tlat=\"%s\"/>", link_backbone,
+ cluster_bb_bw, cluster_bb_lat);
+ SURFXML_BUFFER_SET(link_id, link_backbone);
+ SURFXML_BUFFER_SET(link_bandwidth, cluster_bb_bw);
+ SURFXML_BUFFER_SET(link_latency, cluster_bb_lat);
+ SURFXML_BUFFER_SET(link_bandwidth_file, "");
+ SURFXML_BUFFER_SET(link_latency_file, "");
+ A_surfxml_link_state = A_surfxml_link_state_ON;
+ SURFXML_BUFFER_SET(link_state_file, "");
+ A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
+ SURFXML_START_TAG(link);
+ SURFXML_END_TAG(link);
+
+ char *new_suffix = bprintf("%s", "");
+
+ radical_elements = xbt_str_split(cluster_suffix, ".");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+ if (strcmp(groups, "")) {
+ new_suffix = bprintf("%s\\.%s", new_suffix, groups);
+ }
+ }
+ route_src_dst = bprintf("%s_(.*)%s", cluster_prefix, new_suffix);
+
+ DEBUG0(" ");
#ifdef HAVE_PCRE_LIB
- DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">",route_src_dst,route_src_dst);
- SURFXML_BUFFER_SET(route_src, route_src_dst);
- SURFXML_BUFFER_SET(route_dst, route_src_dst);
- SURFXML_START_TAG(route);
+ DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">", route_src_dst, route_src_dst);
+ SURFXML_BUFFER_SET(route_src, route_src_dst);
+ SURFXML_BUFFER_SET(route_dst, route_src_dst);
+ SURFXML_START_TAG(route);
- DEBUG1("<link:ctn\tid=\"%s_link_$1src\"/>",cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1src",cluster_id));
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
+ DEBUG1("<link:ctn\tid=\"%s_link_$1src\"/>", cluster_id);
+ SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1src", cluster_id));
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
- DEBUG1("<link:ctn\tid=\"%s_backbone\"/>",cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone",cluster_id));
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
+ DEBUG1("<link:ctn\tid=\"%s_backbone\"/>", cluster_id);
+ SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone", cluster_id));
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
- DEBUG1("<link:ctn\tid=\"%s_link_$1dst\"/>",cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1dst",cluster_id));
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
+ DEBUG1("<link:ctn\tid=\"%s_link_$1dst\"/>", cluster_id);
+ SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_link_$1dst", cluster_id));
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
- DEBUG0("</route>");
- SURFXML_END_TAG(route);
+ DEBUG0("</route>");
+ SURFXML_END_TAG(route);
#else
- for(i=0 ; i<=xbt_dynar_length(tab_elements_num) ; i++)
- {
- for(j=0 ; j<=xbt_dynar_length(tab_elements_num) ; j++)
- {
- if(i == xbt_dynar_length(tab_elements_num))
- {
- route_src = router_id;
- }
- else
- {
- route_src = bprintf("%s_%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,i,int),cluster_suffix);
- }
-
- if(j == xbt_dynar_length(tab_elements_num))
- {
- route_dst = router_id;
- }
- else
- {
- route_dst = bprintf("%s_%d%s",cluster_prefix,xbt_dynar_get_as(tab_elements_num,j,int),cluster_suffix);
- }
-
- DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">",route_src,route_dst);
- SURFXML_BUFFER_SET(route_src, route_src);
- SURFXML_BUFFER_SET(route_dst, route_dst);
- SURFXML_START_TAG(route);
-
- if(i == xbt_dynar_length(tab_elements_num))
- {
- route_src = link_router;
- }
- else
- {
- route_src = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,i,int));
- }
-
- if(j == xbt_dynar_length(tab_elements_num))
- {
- route_dst = link_router;
- }
- else
- {
- route_dst = bprintf("%s_link_%d",cluster_id,xbt_dynar_get_as(tab_elements_num,j,int));
- }
-
- DEBUG1("<link:ctn\tid=\"%s\"/>",route_src);
- SURFXML_BUFFER_SET(link_ctn_id, route_src);
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
-
- DEBUG1("<link:ctn\tid=\"%s_backbone\"/>",cluster_id);
- SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone",cluster_id));
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
-
- DEBUG1("<link:ctn\tid=\"%s\"/>",route_dst);
- SURFXML_BUFFER_SET(link_ctn_id, route_dst);
- SURFXML_START_TAG(link_ctn);
- SURFXML_END_TAG(link_ctn);
-
- DEBUG0("</route>");
- SURFXML_END_TAG(route);
- }
- }
- xbt_dynar_free(&tab_elements_num);
+ for (i = 0; i <= xbt_dynar_length(tab_elements_num); i++) {
+ for (j = 0; j <= xbt_dynar_length(tab_elements_num); j++) {
+ if (i == xbt_dynar_length(tab_elements_num)) {
+ route_src = router_id;
+ } else {
+ route_src =
+ bprintf("%s_%d%s", cluster_prefix,
+ xbt_dynar_get_as(tab_elements_num, i, int),
+ cluster_suffix);
+ }
+
+ if (j == xbt_dynar_length(tab_elements_num)) {
+ route_dst = router_id;
+ } else {
+ route_dst =
+ bprintf("%s_%d%s", cluster_prefix,
+ xbt_dynar_get_as(tab_elements_num, j, int),
+ cluster_suffix);
+ }
+
+ DEBUG2("<route\tsrc=\"%s\"\tdst=\"%s\">", route_src, route_dst);
+ SURFXML_BUFFER_SET(route_src, route_src);
+ SURFXML_BUFFER_SET(route_dst, route_dst);
+ SURFXML_START_TAG(route);
+
+ if (i == xbt_dynar_length(tab_elements_num)) {
+ route_src = link_router;
+ } else {
+ route_src =
+ bprintf("%s_link_%d", cluster_id,
+ xbt_dynar_get_as(tab_elements_num, i, int));
+ }
+
+ if (j == xbt_dynar_length(tab_elements_num)) {
+ route_dst = link_router;
+ } else {
+ route_dst =
+ bprintf("%s_link_%d", cluster_id,
+ xbt_dynar_get_as(tab_elements_num, j, int));
+ }
+
+ DEBUG1("<link:ctn\tid=\"%s\"/>", route_src);
+ SURFXML_BUFFER_SET(link_ctn_id, route_src);
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
+
+ DEBUG1("<link:ctn\tid=\"%s_backbone\"/>", cluster_id);
+ SURFXML_BUFFER_SET(link_ctn_id, bprintf("%s_backbone", cluster_id));
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
+
+ DEBUG1("<link:ctn\tid=\"%s\"/>", route_dst);
+ SURFXML_BUFFER_SET(link_ctn_id, route_dst);
+ SURFXML_START_TAG(link_ctn);
+ SURFXML_END_TAG(link_ctn);
+
+ DEBUG0("</route>");
+ SURFXML_END_TAG(route);
+ }
+ }
+ xbt_dynar_free(&tab_elements_num);
#endif
- DEBUG0("</AS>");
- SURFXML_END_TAG(AS);
- DEBUG0(" ");
+ DEBUG0("</AS>");
+ SURFXML_END_TAG(AS);
+ DEBUG0(" ");
- surfxml_bufferstack_pop(1);
+ surfxml_bufferstack_pop(1);
}
/*
/*
* calling parse_S_AS_lua with lua values
*/
-void routing_AS_init(const char* AS_id,const char* AS_routing)
+void routing_AS_init(const char *AS_id, const char *AS_routing)
{
- parse_S_AS_lua((char*)AS_id,(char*)AS_routing);
+ parse_S_AS_lua((char *) AS_id, (char *) AS_routing);
}
/*
*/
void routing_AS_end(const char *AS_id)
{
- parse_E_AS_lua((char*)AS_id);
+ parse_E_AS_lua((char *) AS_id);
}
/*
* add a host to the network element list
*/
-void routing_add_host(const char* host_id)
+void routing_add_host(const char *host_id)
{
- parse_S_host_lua((char*)host_id);
+ parse_S_host_lua((char *) host_id);
}
/*
* Set a new link on the actual list of link for a route or ASroute
*/
-void routing_add_link(const char* link_id)
+void routing_add_link(const char *link_id)
{
- parse_E_link_c_ctn_new_elem_lua((char*)link_id);
+ parse_E_link_c_ctn_new_elem_lua((char *) link_id);
}
/*
*Set the endpoints for a route
*/
-void routing_set_route(const char* src_id,const char *dst_id)
+void routing_set_route(const char *src_id, const char *dst_id)
{
- parse_S_route_new_and_endpoints_lua((char*)src_id,(char*)dst_id);
+ parse_S_route_new_and_endpoints_lua((char *) src_id, (char *) dst_id);
}
/*
*/
void routing_store_route(void)
{
- parse_E_route_store_route();
+ parse_E_route_store_route();
}
void surf_parse_reset_parser(void)
{
surf_parse_free_callbacks();
- STag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_platform_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_platform_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_link_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_link_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_link_ctn_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_link_ctn_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_process_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_process_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_argument_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_argument_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_trace_connect_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_trace_connect_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_trace_connect_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_trace_connect_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_ASroute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_ASroute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_bypassRoute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_bypassRoute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_cluster_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_cluster_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_ASroute_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_ASroute_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_bypassRoute_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_bypassRoute_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ STag_surfxml_cluster_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
+ ETag_surfxml_cluster_cb_list =
+ xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_config_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_config_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
}
void type##Tag_surfxml_##name(void) \
{ surfxml_call_cb_functions(type##Tag_surfxml_##name##_cb_list); }
- parse_method(E,platform);
-parse_method(S,host); parse_method(E,host);
-parse_method(S,router); parse_method(E,router);
-parse_method(S,link); parse_method(E,link);
-parse_method(S,route); parse_method(E,route);
-parse_method(S,link_ctn); parse_method(E,link_ctn);
-parse_method(S,process); parse_method(E,process);
-parse_method(S,argument); parse_method(E,argument);
-parse_method(S,prop); parse_method(E,prop);
-parse_method(S,trace); parse_method(E,trace);
-parse_method(S,trace_connect); parse_method(E,trace_connect);
-parse_method(S,random); parse_method(E,random);
-parse_method(S,AS); parse_method(E,AS);
-parse_method(S,ASroute); parse_method(E,ASroute);
-parse_method(S,bypassRoute); parse_method(E,bypassRoute);
-parse_method(S,cluster); parse_method(E,cluster);
-parse_method(S,config); parse_method(E,config);
+parse_method(E, platform);
+parse_method(S, host);
+parse_method(E, host);
+parse_method(S, router);
+parse_method(E, router);
+parse_method(S, link);
+parse_method(E, link);
+parse_method(S, route);
+parse_method(E, route);
+parse_method(S, link_ctn);
+parse_method(E, link_ctn);
+parse_method(S, process);
+parse_method(E, process);
+parse_method(S, argument);
+parse_method(E, argument);
+parse_method(S, prop);
+parse_method(E, prop);
+parse_method(S, trace);
+parse_method(E, trace);
+parse_method(S, trace_connect);
+parse_method(E, trace_connect);
+parse_method(S, random);
+parse_method(E, random);
+parse_method(S, AS);
+parse_method(E, AS);
+parse_method(S, ASroute);
+parse_method(E, ASroute);
+parse_method(S, bypassRoute);
+parse_method(E, bypassRoute);
+parse_method(S, cluster);
+parse_method(E, cluster);
+parse_method(S, config);
+parse_method(E, config);
/* Open and Close parse file */
if (!file) {
if (!warned) {
WARN0
- ("Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.");
+ ("Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.");
warned = 1;
}
return;
xbt_dynar_push(cb_list, &function);
}
-void surfxml_del_callback(xbt_dynar_t* p_cb_list, void_f_void_t function)
+void surfxml_del_callback(xbt_dynar_t * p_cb_list, void_f_void_t function)
{
xbt_dynar_t new_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
unsigned int it;
void_f_void_t func;
- xbt_dynar_foreach(*p_cb_list,it,func) {
- if( func != function )
+ xbt_dynar_foreach(*p_cb_list, it, func) {
+ if (func != function)
xbt_dynar_push(new_cb_list, &func);
}
xbt_dynar_free(p_cb_list);
trace_connect_list_link_avail = xbt_dict_new();
trace_connect_list_bandwidth = xbt_dict_new();
trace_connect_list_latency = xbt_dict_new();
-
+
surfxml_add_callback(STag_surfxml_random_cb_list, &init_randomness);
surfxml_add_callback(ETag_surfxml_random_cb_list, &add_randomness);
surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_Stag_trace);
surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_Etag_trace);
- surfxml_add_callback(STag_surfxml_trace_connect_cb_list, &parse_Stag_trace_connect);
+ surfxml_add_callback(STag_surfxml_trace_connect_cb_list,
+ &parse_Stag_trace_connect);
}
static void free_data(void)
{
char *value = NULL;
if (!current_property_set)
- current_property_set = xbt_dict_new(); // Maybe, it should be make a error
+ current_property_set = xbt_dict_new(); // Maybe, it should be make a error
value = xbt_strdup(A_surfxml_prop_value);
xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
}
trace = NULL;
else
trace =
- tmgr_trace_new_from_string(trace_id, surfxml_pcdata,
- trace_periodicity);
+ tmgr_trace_new_from_string(trace_id, surfxml_pcdata,
+ trace_periodicity);
}
xbt_dict_set(traces_set_list, trace_id, (void *) trace, NULL);
}
return power_scale;
}
-double random_min, random_max, random_mean, random_std_deviation, random_generator;
+double random_min, random_max, random_mean, random_std_deviation,
+ random_generator;
char *random_id;
static void init_randomness(void)
surf_parse_get_double(&random_min, A_surfxml_random_min);
surf_parse_get_double(&random_max, A_surfxml_random_max);
surf_parse_get_double(&random_mean, A_surfxml_random_mean);
- surf_parse_get_double(&random_std_deviation, A_surfxml_random_std_deviation);
+ surf_parse_get_double(&random_std_deviation,
+ A_surfxml_random_std_deviation);
random_generator = A_surfxml_random_generator;
}
static void add_randomness(void)
{
/* If needed aditional properties can be added by using the prop tag */
- random_data_t random = random_new(random_generator, 0, random_min, random_max, random_mean, random_std_deviation);
- xbt_dict_set(random_data_list, random_id, (void *) random, &xbt_free_ref);
+ random_data_t random =
+ random_new(random_generator, 0, random_min, random_max, random_mean,
+ random_std_deviation);
+ xbt_dict_set(random_data_list, random_id, (void *) random,
+ &xbt_free_ref);
}
/**
* create CPU resource via CPU Model
*/
void surf_host_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- return surf_cpu_model->extension.cpu.
- create_resource(name,power_peak,power_scale,power_trace,state_initial,state_trace,cpu_properties);
+ return surf_cpu_model->extension.cpu.create_resource(name, power_peak,
+ power_scale,
+ power_trace,
+ state_initial,
+ state_trace,
+ cpu_properties);
}
/**
*/
void surf_wsL07_host_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- surf_workstation_model->extension.workstation.
- cpu_create_resource(name,power_peak,power_scale,power_trace,state_initial,state_trace,cpu_properties);
+ surf_workstation_model->extension.workstation.cpu_create_resource(name,
+ power_peak,
+ power_scale,
+ power_trace,
+ state_initial,
+ state_trace,
+ cpu_properties);
}
+
/**
* create link resource via network Model
*/
void surf_link_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t policy,
- xbt_dict_t properties)
-{
- return surf_network_model->extension.network.
- create_resource(name,bw_initial,bw_trace,lat_initial,lat_trace,
- state_initial,state_trace,policy,properties);
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties)
+{
+ return surf_network_model->extension.network.create_resource(name,
+ bw_initial,
+ bw_trace,
+ lat_initial,
+ lat_trace,
+ state_initial,
+ state_trace,
+ policy,
+ properties);
}
/**
*/
void surf_wsL07_link_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
-{
- return surf_workstation_model->extension.workstation.
- link_create_resource(name,bw_initial,bw_trace,lat_initial,lat_trace,
- state_initial,state_trace,policy,properties);
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties)
+{
+ return surf_workstation_model->extension.workstation.
+ link_create_resource(name, bw_initial, bw_trace, lat_initial,
+ lat_trace, state_initial, state_trace, policy,
+ properties);
}
/**
*init new routing model component
*/
-void surf_AS_new(const char* AS_id, const char *AS_mode)
+void surf_AS_new(const char *AS_id, const char *AS_mode)
{
- routing_AS_init(AS_id,AS_mode);
+ routing_AS_init(AS_id, AS_mode);
}
-void surf_AS_finalize(const char* AS_id)
+void surf_AS_finalize(const char *AS_id)
{
- routing_AS_end(AS_id);
+ routing_AS_end(AS_id);
}
/*
* add host to the network element list
*/
-void surf_route_add_host(const char* host_id)
+void surf_route_add_host(const char *host_id)
{
- routing_add_host(host_id);
+ routing_add_host(host_id);
}
/**
* set route
*/
-void surf_routing_add_route(const char *src_id,const char *dst_id,xbt_dynar_t links_id)
-{
- unsigned int i;
- const char * link_id;
- routing_set_route(src_id,dst_id);
- xbt_dynar_foreach(links_id,i,link_id)
- {
- routing_add_link(link_id);
- }
+void surf_routing_add_route(const char *src_id, const char *dst_id,
+ xbt_dynar_t links_id)
+{
+ unsigned int i;
+ const char *link_id;
+ routing_set_route(src_id, dst_id);
+ xbt_dynar_foreach(links_id, i, link_id) {
+ routing_add_link(link_id);
+ }
- //store the route
- routing_store_route();
+ //store the route
+ routing_store_route();
}
/**
*/
void surf_add_host_traces(void)
{
- return surf_cpu_model->extension.cpu.add_traces();
+ return surf_cpu_model->extension.cpu.add_traces();
}
void surf_add_link_traces(void)
{
- return surf_network_model->extension.network.add_traces();
+ return surf_network_model->extension.network.add_traces();
}
void surf_wsL07_add_traces(void)
{
- return surf_workstation_model->extension.workstation.add_traces();
+ return surf_workstation_model->extension.workstation.add_traces();
}
-
}
xbt_dynar_push(trace->event_list, &event);
last_event =
- xbt_dynar_get_ptr(trace->event_list,
- xbt_dynar_length(trace->event_list) - 1);
+ xbt_dynar_get_ptr(trace->event_list,
+ xbt_dynar_length(trace->event_list) - 1);
}
if (last_event)
last_event->delta = periodicity;
tmgr_trace_t tmgr_trace_new(const char *filename)
{
- char *tstr = NULL;
+ char *tstr = NULL;
FILE *f = NULL;
tmgr_trace_t trace = NULL;
}
f = surf_fopen(filename, "r");
- xbt_assert2(f!=NULL, "Cannot open file '%s' (path=%s)", filename,
- xbt_str_join(surf_path,":"));
+ xbt_assert2(f != NULL, "Cannot open file '%s' (path=%s)", filename,
+ xbt_str_join(surf_path, ":"));
tstr = xbt_str_from_file(f);
fclose(f);
xbt_heap_t heap;
} s_tmgr_history_t;
-#endif /* _SURF_TMGR_PRIVATE_H */
+#endif /* _SURF_TMGR_PRIVATE_H */
surf_model_t surf_workstation_model = NULL;
-static workstation_CLM03_t workstation_new(const char *name,
- void *cpu)
+static workstation_CLM03_t workstation_new(const char *name, void *cpu)
{
workstation_CLM03_t workstation = xbt_new0(s_workstation_CLM03_t, 1);
char *name = NULL;
void *cpu = NULL;
- xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name, cpu) {
- workstation_new(name, cpu);
+ xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name,
+ cpu) {
+ workstation_new(name, cpu);
}
}
}
static void ws_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
}
static surf_action_t ws_execute(void *workstation, double size)
{
return surf_cpu_model->extension.cpu.
- execute(((workstation_CLM03_t) workstation)->cpu, size);
+ execute(((workstation_CLM03_t) workstation)->cpu, size);
}
static surf_action_t ws_action_sleep(void *workstation, double duration)
{
return surf_cpu_model->extension.cpu.
- sleep(((workstation_CLM03_t) workstation)->cpu, duration);
+ sleep(((workstation_CLM03_t) workstation)->cpu, duration);
}
static void ws_action_suspend(surf_action_t action)
DIE_IMPOSSIBLE;
}
-static void ws_action_set_max_duration(surf_action_t action, double duration)
+static void ws_action_set_max_duration(surf_action_t action,
+ double duration)
{
if (action->model_type == surf_network_model)
surf_network_model->set_max_duration(action, duration);
{
if (action->model_type == surf_network_model)
return surf_network_model->get_latency_limited(action);
- INFO0("You tried to ask if a non network action is limited by latency, aborting...");
+ INFO0
+ ("You tried to ask if a non network action is limited by latency, aborting...");
DIE_IMPOSSIBLE;
}
#endif
}
static surf_action_t ws_communicate(void *workstation_src,
- void *workstation_dst, double size,
- double rate)
+ void *workstation_dst, double size,
+ double rate)
{
workstation_CLM03_t src = (workstation_CLM03_t) workstation_src;
workstation_CLM03_t dst = (workstation_CLM03_t) workstation_dst;
return surf_network_model->extension.network.
- communicate(surf_resource_name(src->cpu), surf_resource_name(dst->cpu),
- size, rate);
+ communicate(surf_resource_name(src->cpu),
+ surf_resource_name(dst->cpu), size, rate);
}
static e_surf_resource_state_t ws_get_state(void *workstation)
{
return surf_cpu_model->extension.cpu.
- get_state(((workstation_CLM03_t) workstation)->cpu);
+ get_state(((workstation_CLM03_t) workstation)->cpu);
}
static double ws_get_speed(void *workstation, double load)
{
return surf_cpu_model->extension.cpu.
- get_speed(((workstation_CLM03_t) workstation)->cpu, load);
+ get_speed(((workstation_CLM03_t) workstation)->cpu, load);
}
static double ws_get_available_speed(void *workstation)
{
return surf_cpu_model->extension.cpu.
- get_available_speed(((workstation_CLM03_t)
- workstation)->cpu);
+ get_available_speed(((workstation_CLM03_t)
+ workstation)->cpu);
}
static surf_action_t ws_execute_parallel_task(int workstation_nb,
- void **workstation_list,
- double *computation_amount,
- double *communication_amount,
- double amount, double rate)
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double amount, double rate)
{
THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks */
}
/* returns an array of network_link_CM02_t */
static xbt_dynar_t ws_get_route(void *src, void *dst)
{
- return surf_network_model->extension.network.get_route(surf_resource_name(src),
- surf_resource_name(src));
+ return surf_network_model->extension.
+ network.get_route(surf_resource_name(src), surf_resource_name(src));
}
static double ws_get_link_bandwidth(const void *link)
surf_workstation_model->action_state_set = ws_action_state_set;
surf_workstation_model->model_private->resource_used = ws_resource_used;
- surf_workstation_model->model_private->share_resources = ws_share_resources;
+ surf_workstation_model->model_private->share_resources =
+ ws_share_resources;
surf_workstation_model->model_private->update_actions_state =
- ws_update_actions_state;
+ ws_update_actions_state;
surf_workstation_model->model_private->update_resource_state =
- ws_update_resource_state;
+ ws_update_resource_state;
surf_workstation_model->model_private->finalize = ws_finalize;
surf_workstation_model->suspend = ws_action_suspend;
surf_workstation_model->extension.workstation.get_state = ws_get_state;
surf_workstation_model->extension.workstation.get_speed = ws_get_speed;
surf_workstation_model->extension.workstation.get_available_speed =
- ws_get_available_speed;
+ ws_get_available_speed;
- surf_workstation_model->extension.workstation.communicate = ws_communicate;
+ surf_workstation_model->extension.workstation.communicate =
+ ws_communicate;
surf_workstation_model->extension.workstation.get_route = ws_get_route;
surf_workstation_model->extension.workstation.execute_parallel_task =
- ws_execute_parallel_task;
+ ws_execute_parallel_task;
surf_workstation_model->extension.workstation.get_link_bandwidth =
- ws_get_link_bandwidth;
+ ws_get_link_bandwidth;
surf_workstation_model->extension.workstation.get_link_latency =
- ws_get_link_latency;
- surf_workstation_model->extension.workstation.link_shared = ws_link_shared;
+ ws_get_link_latency;
+ surf_workstation_model->extension.workstation.link_shared =
+ ws_link_shared;
surf_workstation_model->extension.workstation.get_properties =
- ws_get_properties;
+ ws_get_properties;
}
for (i = 0; i < workstation_nb; i++) {
for (j = 0; j < workstation_nb; j++) {
- xbt_dynar_t route = global_routing->get_route(surf_resource_name(action->workstation_list[i]),
- surf_resource_name(action->workstation_list[j]));
+ xbt_dynar_t route =
+ global_routing->get_route(surf_resource_name
+ (action->workstation_list[i]),
+ surf_resource_name(action->
+ workstation_list
+ [j]));
double lat = 0.0;
lat += link->lat_current;
}
lat_current =
- MAX(lat_current,
- lat * action->communication_amount[i * workstation_nb + j]);
+ MAX(lat_current,
+ lat * action->communication_amount[i * workstation_nb +
+ j]);
}
}
}
xbt_swag_remove(action, action->state_set);
if (((surf_action_workstation_L07_t) action)->variable)
lmm_variable_free(ptask_maxmin_system,
- ((surf_action_workstation_L07_t) action)->variable);
+ ((surf_action_workstation_L07_t)
+ action)->variable);
free(((surf_action_workstation_L07_t) action)->workstation_list);
free(((surf_action_workstation_L07_t) action)->communication_amount);
free(((surf_action_workstation_L07_t) action)->computation_amount);
static void ptask_action_resume(surf_action_t action)
{
- surf_action_workstation_L07_t act = (surf_action_workstation_L07_t) action;
+ surf_action_workstation_L07_t act =
+ (surf_action_workstation_L07_t) action;
XBT_IN1("(%p)", act);
if (act->suspended != 2) {
return (((surf_action_workstation_L07_t) action)->suspended == 1);
}
-static void ptask_action_set_max_duration(surf_action_t action, double duration)
+static void ptask_action_set_max_duration(surf_action_t action,
+ double duration)
{ /* FIXME: should inherit */
XBT_IN2("(%p,%g)", action, duration);
action->max_duration = duration;
}
-static void ptask_action_set_priority(surf_action_t action, double priority)
+static void ptask_action_set_priority(surf_action_t action,
+ double priority)
{ /* FIXME: should inherit */
XBT_IN2("(%p,%g)", action, priority);
action->priority = priority;
surf_action_workstation_L07_t action = NULL;
xbt_swag_t running_actions =
- surf_workstation_model->states.running_action_set;
+ surf_workstation_model->states.running_action_set;
double min = generic_maxmin_share_resources(running_actions,
xbt_swag_offset(s_action,
variable),
surf_action_workstation_L07_t action = NULL;
surf_action_workstation_L07_t next_action = NULL;
xbt_swag_t running_actions =
- surf_workstation_model->states.running_action_set;
+ surf_workstation_model->states.running_action_set;
xbt_swag_foreach_safe(action, next_action, running_actions) {
deltap = delta;
SURF_RESOURCE_OFF))) {
DEBUG1("Action (%p) Failed!!", action);
action->generic_action.finish = surf_get_clock();
- surf_action_state_set((surf_action_t) action, SURF_ACTION_FAILED);
+ surf_action_state_set((surf_action_t) action,
+ SURF_ACTION_FAILED);
break;
}
}
}
static void ptask_update_resource_state(void *id,
- tmgr_trace_event_t event_type,
- double value, double date)
+ tmgr_trace_event_t event_type,
+ double value, double date)
{
cpu_L07_t cpu = id;
link_L07_t nw_link = id;
}
return;
} else if (cpu->type == SURF_WORKSTATION_RESOURCE_CPU) {
- DEBUG3("Updating cpu %s (%p) with value %g", surf_resource_name(cpu), cpu,
- value);
+ DEBUG3("Updating cpu %s (%p) with value %g", surf_resource_name(cpu),
+ cpu, value);
if (event_type == cpu->power_event) {
cpu->power_current = value;
lmm_update_constraint_bound(ptask_maxmin_system, cpu->constraint,
}
static surf_action_t ptask_execute_parallel_task(int workstation_nb,
- void **workstation_list,
- double *computation_amount,
- double *communication_amount,
- double amount, double rate)
+ void **workstation_list,
+ double
+ *computation_amount, double
+ *communication_amount,
+ double amount,
+ double rate)
{
surf_action_workstation_L07_t action = NULL;
int i, j;
for (i = 0; i < workstation_nb; i++) {
for (j = 0; j < workstation_nb; j++) {
link_L07_t link;
- xbt_dynar_t route = global_routing->get_route(surf_resource_name(workstation_list[i]),
- surf_resource_name(workstation_list[j]));
+ xbt_dynar_t route =
+ global_routing->get_route(surf_resource_name
+ (workstation_list[i]),
+ surf_resource_name(workstation_list
+ [j]));
double lat = 0.0;
if (communication_amount[i * workstation_nb + j] > 0)
xbt_dynar_foreach(route, cpt, link) {
lat += link->lat_current;
- xbt_dict_set(ptask_parallel_task_link_set, link->generic_resource.name,
- link, NULL);
+ xbt_dict_set(ptask_parallel_task_link_set,
+ link->generic_resource.name, link, NULL);
}
latency = MAX(latency, lat);
}
nb_host++;
action =
- surf_action_new(sizeof(s_surf_action_workstation_L07_t), amount,
- surf_workstation_model, 0);
- DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.", action,
- workstation_nb, nb_link);
+ surf_action_new(sizeof(s_surf_action_workstation_L07_t), amount,
+ surf_workstation_model, 0);
+ DEBUG3("Creating a parallel task (%p) with %d cpus and %d links.",
+ action, workstation_nb, nb_link);
action->suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
action->workstation_nb = workstation_nb;
action->rate = rate;
action->variable =
- lmm_variable_new(ptask_maxmin_system, action, 1.0,
- (action->rate > 0) ? action->rate : -1.0,
- workstation_nb + nb_link);
+ lmm_variable_new(ptask_maxmin_system, action, 1.0,
+ (action->rate > 0) ? action->rate : -1.0,
+ workstation_nb + nb_link);
if (action->latency > 0)
lmm_update_variable_weight(ptask_maxmin_system, action->variable, 0.0);
for (i = 0; i < workstation_nb; i++) {
for (j = 0; j < workstation_nb; j++) {
link_L07_t link;
- xbt_dynar_t route = global_routing->get_route(surf_resource_name(workstation_list[i]),
- surf_resource_name(workstation_list[j]));
+ xbt_dynar_t route =
+ global_routing->get_route(surf_resource_name
+ (workstation_list[i]),
+ surf_resource_name(workstation_list
+ [j]));
if (communication_amount[i * workstation_nb + j] == 0.0)
continue;
communication_amount[0] = 0.0;
computation_amount[0] = size;
- return ptask_execute_parallel_task(1, workstation_list, computation_amount,
- communication_amount, 1, -1);
+ return ptask_execute_parallel_task(1, workstation_list,
+ computation_amount,
+ communication_amount, 1, -1);
}
static surf_action_t ptask_communicate(void *src, void *dst, double size,
- double rate)
+ double rate)
{
void **workstation_list = xbt_new0(void *, 2);
double *computation_amount = xbt_new0(double, 2);
communication_amount[1] = size;
res = ptask_execute_parallel_task(2, workstation_list,
- computation_amount, communication_amount,
- 1, rate);
+ computation_amount,
+ communication_amount, 1, rate);
return res;
}
static xbt_dynar_t ptask_get_route(void *src, void *dst)
{
- return global_routing->get_route( surf_resource_name(src), surf_resource_name(dst));
+ return global_routing->get_route(surf_resource_name(src),
+ surf_resource_name(dst));
}
static double ptask_get_link_bandwidth(const void *link)
/**************************************/
static cpu_L07_t ptask_cpu_new(const char *name, double power_scale,
- double power_initial,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace, xbt_dict_t cpu_properties)
+ double power_initial,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
cpu_L07_t cpu = xbt_new0(s_cpu_L07_t, 1);
xbt_assert1(!surf_model_resource_by_name(surf_workstation_model, name),
- "Host '%s' declared several times in the platform file.", name);
+ "Host '%s' declared several times in the platform file.",
+ name);
cpu->generic_resource.model = surf_workstation_model;
cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
cpu->power_current = power_initial;
if (power_trace)
cpu->power_event =
- tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
cpu->state_current = state_initial;
if (state_trace)
cpu->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
cpu->constraint =
- lmm_constraint_new(ptask_maxmin_system, cpu,
- cpu->power_current * cpu->power_scale);
+ lmm_constraint_new(ptask_maxmin_system, cpu,
+ cpu->power_current * cpu->power_scale);
xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
surf_resource_free);
current_property_set = xbt_dict_new();
ptask_cpu_new(A_surfxml_host_id, power_scale, power_initial, power_trace,
- state_initial, state_trace, current_property_set);
+ state_initial, state_trace, current_property_set);
}
static void ptask_cpu_create_resource(char *name, double power_peak,
- double power_scale,
- tmgr_trace_t power_trace,
- e_surf_resource_state_t state_initial,
- tmgr_trace_t state_trace,
- xbt_dict_t cpu_properties)
+ double power_scale,
+ tmgr_trace_t power_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ xbt_dict_t cpu_properties)
{
- ptask_cpu_new(xbt_strdup(name),power_peak,power_scale,power_trace,
- state_initial,state_trace,cpu_properties);
+ ptask_cpu_new(xbt_strdup(name), power_peak, power_scale, power_trace,
+ state_initial, state_trace, cpu_properties);
}
static link_L07_t ptask_link_new(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties)
{
link_L07_t nw_link = xbt_new0(s_link_L07_t, 1);
- xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
- "Link '%s' declared several times in the platform file.", name);
+ xbt_assert1(!xbt_dict_get_or_null
+ (surf_network_model->resource_set, name),
+ "Link '%s' declared several times in the platform file.",
+ name);
nw_link->generic_resource.model = surf_workstation_model;
nw_link->generic_resource.properties = properties;
nw_link->bw_current = bw_initial;
if (bw_trace)
nw_link->bw_event =
- tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
+ tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
nw_link->state_current = state_initial;
nw_link->lat_current = lat_initial;
if (lat_trace)
nw_link->lat_event =
- tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
+ tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
if (state_trace)
nw_link->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
+ tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
nw_link->constraint =
- lmm_constraint_new(ptask_maxmin_system, nw_link, nw_link->bw_current);
+ lmm_constraint_new(ptask_maxmin_system, nw_link,
+ nw_link->bw_current);
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
else if (A_surfxml_link_state == A_surfxml_link_state_OFF)
state_initial_link = SURF_RESOURCE_OFF;
- if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
+ if (A_surfxml_link_sharing_policy ==
+ A_surfxml_link_sharing_policy_SHARED)
policy_initial_link = SURF_LINK_SHARED;
else if (A_surfxml_link_sharing_policy ==
A_surfxml_link_sharing_policy_FATPIPE)
current_property_set = xbt_dict_new();
ptask_link_new(name_link, bw_initial, bw_trace, lat_initial, lat_trace,
- state_initial_link, state_trace, policy_initial_link,
- current_property_set);
+ state_initial_link, state_trace, policy_initial_link,
+ current_property_set);
}
static void ptask_link_create_resource(char *name,
- double bw_initial,
- tmgr_trace_t bw_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
- tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t
+ policy, xbt_dict_t properties)
{
- ptask_link_new(name, bw_initial, bw_trace,
- lat_initial, lat_trace, state_initial, state_trace,policy, xbt_dict_new());
+ ptask_link_new(name, bw_initial, bw_trace,
+ lat_initial, lat_trace, state_initial, state_trace,
+ policy, xbt_dict_new());
}
/* Connect traces relative to cpu */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_L07_t host = surf_model_resource_by_name(surf_workstation_model, elm);
+ cpu_L07_t host =
+ surf_model_resource_by_name(surf_workstation_model, elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->state_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_L07_t host = surf_model_resource_by_name(surf_workstation_model, elm);
+ cpu_L07_t host =
+ surf_model_resource_by_name(surf_workstation_model, elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->power_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, host);
}
/* Connect traces relative to network */
xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_L07_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert1(link, "Link %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
- link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->state_event =
+ tmgr_history_add_trace(history, trace, 0.0, 0, link);
}
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_L07_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert1(link, "Link %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
link_L07_t link =
- xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+ xbt_dict_get_or_null(surf_network_model->resource_set, elm);
xbt_assert1(link, "Link %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
surf_workstation_model->get_remains = ptask_action_get_remains;
surf_workstation_model->name = "Workstation ptask_L07";
- surf_workstation_model->model_private->resource_used = ptask_resource_used;
- surf_workstation_model->model_private->share_resources = ptask_share_resources;
+ surf_workstation_model->model_private->resource_used =
+ ptask_resource_used;
+ surf_workstation_model->model_private->share_resources =
+ ptask_share_resources;
surf_workstation_model->model_private->update_actions_state =
- ptask_update_actions_state;
+ ptask_update_actions_state;
surf_workstation_model->model_private->update_resource_state =
- ptask_update_resource_state;
+ ptask_update_resource_state;
surf_workstation_model->model_private->finalize = ptask_finalize;
surf_workstation_model->extension.workstation.execute = ptask_execute;
surf_workstation_model->extension.workstation.sleep = ptask_action_sleep;
surf_workstation_model->extension.workstation.get_state =
- ptask_resource_get_state;
- surf_workstation_model->extension.workstation.get_speed = ptask_get_speed;
+ ptask_resource_get_state;
+ surf_workstation_model->extension.workstation.get_speed =
+ ptask_get_speed;
surf_workstation_model->extension.workstation.get_available_speed =
- ptask_get_available_speed;
- surf_workstation_model->extension.workstation.communicate = ptask_communicate;
- surf_workstation_model->extension.workstation.get_route = ptask_get_route;
+ ptask_get_available_speed;
+ surf_workstation_model->extension.workstation.communicate =
+ ptask_communicate;
+ surf_workstation_model->extension.workstation.get_route =
+ ptask_get_route;
surf_workstation_model->extension.workstation.execute_parallel_task =
- ptask_execute_parallel_task;
+ ptask_execute_parallel_task;
surf_workstation_model->extension.workstation.get_link_bandwidth =
- ptask_get_link_bandwidth;
+ ptask_get_link_bandwidth;
surf_workstation_model->extension.workstation.get_link_latency =
- ptask_get_link_latency;
- surf_workstation_model->extension.workstation.link_shared = ptask_link_shared;
+ ptask_get_link_latency;
+ surf_workstation_model->extension.workstation.link_shared =
+ ptask_link_shared;
surf_workstation_model->extension.workstation.get_properties =
- surf_resource_properties;
+ surf_resource_properties;
surf_workstation_model->extension.workstation.link_create_resource =
- ptask_link_create_resource;
+ ptask_link_create_resource;
surf_workstation_model->extension.workstation.cpu_create_resource =
- ptask_cpu_create_resource;
- surf_workstation_model->extension.workstation.add_traces = ptask_add_traces;
+ ptask_cpu_create_resource;
+ surf_workstation_model->extension.workstation.add_traces =
+ ptask_add_traces;
if (!ptask_maxmin_system)
ptask_maxmin_system = lmm_system_new();
routing_model_create(sizeof(link_L07_t),
ptask_link_new(xbt_strdup("__loopback__"),
- 498000000, NULL, 0.000015, NULL,
- SURF_RESOURCE_ON, NULL, SURF_LINK_FATPIPE,
- NULL));
+ 498000000, NULL, 0.000015, NULL,
+ SURF_RESOURCE_ON, NULL,
+ SURF_LINK_FATPIPE, NULL));
}
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 219 "xbt/swag.c"
+#line 224 "xbt/swag.c"
typedef struct {
/* No <dlfcn.h> header file. */
#if defined(HAVE_DLFCN_H)
- #undef HAVE_DLFCN_H
-#endif
+#undef HAVE_DLFCN_H
+#endif
/* Defined if the compiler has the <errno.h> header file. */
#if !defined(HAVE_ERRNO_H)
- #define HAVE_ERRNO_H 1
+#define HAVE_ERRNO_H 1
#endif
/* No <execinfo.h> header file. */
#if defined(HAVE_EXECINFO_H)
- #undef HAVE_EXECINFO_H
+#undef HAVE_EXECINFO_H
#endif
/* No <inttypes.h> header file. */
#if defined(HAVE_INTTYPES_H)
- #undef HAVE_INTTYPES_H
+#undef HAVE_INTTYPES_H
#endif
/* Defined if compiler has the <memory.h> header file. */
#if !defined(HAVE_MEMORY_H)
- #define HAVE_MEMORY_H 1
+#define HAVE_MEMORY_H 1
#endif
/* No <pthread.h> header file. */
#if defined(HAVE_PTHREAD_H)
- #undef HAVE_PTHREAD_H
+#undef HAVE_PTHREAD_H
#endif
/* No <stdint.h> header file. */
#if defined(HAVE_STDINT_H)
- #undef HAVE_STDINT_H
+#undef HAVE_STDINT_H
#endif
/* The compiler has the <stdlib.h> header file. */
#if !defined(HAVE_STDLIB_H)
- #define HAVE_STDLIB_H 1
+#define HAVE_STDLIB_H 1
#endif
/* No <strings.h> header file. */
#if defined(HAVE_STRINGS_H)
- #undef HAVE_STRINGS_H
+#undef HAVE_STRINGS_H
#endif
/* The compiler has the <string.h> header file. */
#if !defined(HAVE_STRING_H)
- #define HAVE_STRING_H 1
+#define HAVE_STRING_H 1
#endif
/* No <sys/socket.h> header file. */
#if defined(HAVE_SYS_SOCKET_H)
- #undef HAVE_SYS_SOCKET_H
+#undef HAVE_SYS_SOCKET_H
#endif
/* The compiler has <sys/stat.h> header file. */
#if !defined(HAVE_SYS_STAT_H)
- #define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_STAT_H 1
#endif
/* No <sys/time.h> header file. */
#if defined(HAVE_SYS_TIME_H)
- #undef HAVE_SYS_TIME_H 1
+#undef HAVE_SYS_TIME_H 1
#endif
/* The compiler has the <sys/types.h> header file. */
#if !defined(HAVE_SYS_TYPES_H)
- #define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_TYPES_H 1
#endif
/* No <unistd.h> header file. */
#if defined(HAVE_UNISTD_H)
- #undef HAVE_UNISTD_H
+#undef HAVE_UNISTD_H
#endif
/*
* Process the case of afx.h
*/
#if !defined(HAVE_WINDOWS_H)
- #define HAVE_WINDOWS_H 1
+#define HAVE_WINDOWS_H 1
#endif
/* The compiler has the <winsock2.h> header file. */
#if !defined(HAVE_WINSOCK2_H)
- #define HAVE_WINSOCK2_H
+#define HAVE_WINSOCK2_H
#endif
/*
* Trouble if winsock2.h exists ?
*/
#if !defined(HAVE_WINSOCK_H)
- #define HAVE_WINSOCK_H 1
+#define HAVE_WINSOCK_H 1
#endif
/* The compiler has the <signal.h> header file */
#if !defined(HAVE_SIGNAL_H)
- #define HAVE_SIGNAL_H 1
+#define HAVE_SIGNAL_H 1
#endif
/*
/* No `getcontext' function. */
#if defined(HAVE_GETCONTEXT)
- #undef HAVE_GETCONTEXT
+#undef HAVE_GETCONTEXT
#endif
/* No `getdtablesize' function. */
#if defined(HAVE_GETDTABLESIZE)
- #undef HAVE_GETDTABLESIZE
+#undef HAVE_GETDTABLESIZE
#endif
/* No `gettimeofday' function. */
#if defined(HAVE_GETTIMEOFDAY)
- #undef HAVE_GETTIMEOFDAY
+#undef HAVE_GETTIMEOFDAY
#endif
/* No `makecontext' function. */
#if defined(HAVE_MAKECONTEXT)
- #undef HAVE_MAKECONTEXT
+#undef HAVE_MAKECONTEXT
#endif
/* No 'popen' function. */
#if defined(HAVE_POPEN)
- #undef HAVE_POPEN
+#undef HAVE_POPEN
#endif
/* No `readv' function. */
#if defined(HAVE_READV)
- #undef HAVE_READV
+#undef HAVE_READV
#endif
/* No `setcontext' function. */
#if defined(HAVE_SETCONTEXT)
- #undef HAVE_SETCONTEXT
+#undef HAVE_SETCONTEXT
#endif
/* No 'signal' function */
#if defined(HAVE_SIGNAL)
- #undef HAVE_SIGNAL
+#undef HAVE_SIGNAL
#endif
/* The compiler has `snprintf' function. */
#if !defined(HAVE_SNPRINTF)
- #define HAVE_SNPRINTF 1
+#define HAVE_SNPRINTF 1
#endif
/* No `swapcontext' function. */
#if defined(HAVE_SWAPCONTEXT)
- #undef HAVE_SWAPCONTEXT
+#undef HAVE_SWAPCONTEXT
#endif
/* No `sysconf' function. */
#if defined(HAVE_SYSCONF)
- #undef HAVE_SYSCONF
+#undef HAVE_SYSCONF
#endif
/* No `usleep' function. */
#if defined(HAVE_USLEEP)
- #undef HAVE_USLEEP
+#undef HAVE_USLEEP
#endif
/* The compiler has the `vsnprintf' function. */
#if !defined(HAVE_VSNPRINTF)
- #define HAVE_VSNPRINTF 1
+#define HAVE_VSNPRINTF 1
#endif
/* enable the asprintf replacement */
#if !defined(NEED_ASPRINTF)
- #define NEED_ASPRINTF 1
+#define NEED_ASPRINTF 1
#endif
/*#ifdef NEED_ASPRINTF
/* enable the vasprintf replacement */
#if !defined(NEED_VASPRINTF)
- #define NEED_VASPRINTF 1
+#define NEED_VASPRINTF 1
#endif
/* "disable the snprintf replacement ( this function is broken on system v only" */
/* FIXME TO ANALYZE */
#if defined(PREFER_PORTABLE_SNPRINTF)
- #undef PREFER_PORTABLE_SNPRINTF
+#undef PREFER_PORTABLE_SNPRINTF
#endif
#if !defined(PREFER_PORTABLE_SNPRINTF)
- #define PREFER_PORTABLE_SNPRINTF
+#define PREFER_PORTABLE_SNPRINTF
#endif
/* The maximal size of any scalar on this arch */
#if !defined(SIZEOF_MAX)
- #define SIZEOF_MAX 8
+#define SIZEOF_MAX 8
#endif
/* Define to 1 if you have the ANSI C header files. */
#if !defined(STDC_HEADERS)
- #define STDC_HEADERS 1
+#define STDC_HEADERS 1
#endif
#if defined(TIME_WITH_SYS_TIME)
- #undef TIME_WITH_SYS_TIME
+#undef TIME_WITH_SYS_TIME
#endif
/*
/* Define to 1 if you have the `pthread' library (-lpthread). */
#if defined(HAVE_LIBPTHREAD)
- #undef HAVE_LIBPTHREAD
+#undef HAVE_LIBPTHREAD
#endif
/*
* package informations ?
*/
-
-
+
+
/* Defined if arrays in struct can straddle struct alignment boundaries. This
is like than the structure compaction above, but this time, the argument to
be compacted is an array whom each element would be normally compacted.
presenting this caracteristic so far. */
#if defined(GRAS_ARRAY_STRADDLE_STRUCT)
- #undef GRAS_ARRAY_STRADDLE_STRUCT
+#undef GRAS_ARRAY_STRADDLE_STRUCT
#endif
/* Defined if structures are compacted when possible. Consider this structure:
just after the int. If not, it has to be on the 8 bytes boundary imposed by
the double. For now, GRAS requires the structures to be compacted. */
#if defined(GRAS_STRUCT_COMPACT)
- #undef GRAS_STRUCT_COMPACT
+#undef GRAS_STRUCT_COMPACT
#endif
/* Name of package */
/*
* macro
*/
-
+
/* define if big endian */
#if !defined(GRAS_BIGENDIAN)
- #define GRAS_BIGENDIAN 0
+#define GRAS_BIGENDIAN 0
#endif
/* Defined if structures are compacted when possible. Consider this structure:
just after the int. If not, it has to be on the 8 bytes boundary imposed by
the double. For now, GRAS requires the structures to be compacted. */
#if defined(GRAS_STRUCT_COMPACT)
- #define GRAS_STRUCT_COMPACT 1
+#define GRAS_STRUCT_COMPACT 1
#endif
/* defines the GRAS architecture signature of this machine */
#if defined(GRAS_THISARCH)
- #undef GRAS_THISARCH
+#undef GRAS_THISARCH
#endif
#define GRAS_THISARCH 0
-
+
/* Path to the addr2line tool */
#if defined(ADDR2LINE)
- #undef ADDR2LINE
+#undef ADDR2LINE
#endif
#if !defined(HAVE_VA_COPY)
- #define HAVE_VA_COPY 1
+#define HAVE_VA_COPY 1
#endif
/* This macro is not defined in borland stdarg.h include file, adds it. */
-#define va_copy(dest,src) ((dest)=(src))
+#define va_copy(dest,src) ((dest)=(src))
/* Predefined possible va_copy() implementation (id: ASP) */
#define __VA_COPY_USE_ASP(d, s) do { *(d) = *(s); } while (0)
#define __VA_COPY_USE __VA_COPY_USE_C99
#ifndef _XBT_CALL
- #if defined(_XBT_DESIGNATED_DLL)
- #define _XBT_CALL __cdecl __export
- #elif defined(_RTLDLL)
- #define _XBT_CALL __cdecl __import
- #else
- #define _XBT_CALL __cdecl
- #endif
+#if defined(_XBT_DESIGNATED_DLL)
+#define _XBT_CALL __cdecl __export
+#elif defined(_RTLDLL)
+#define _XBT_CALL __cdecl __import
+#else
+#define _XBT_CALL __cdecl
+#endif
#endif
/* auto enable thread safety and exceptions: */
#ifndef _CPPUNWIND
- #define _XBT_HAS_NO_EXCEPTIONS
+#define _XBT_HAS_NO_EXCEPTIONS
#endif
#if defined ( __MT__ ) && !defined (_NOTHREADS) && !defined (_REENTRANT)
- #define _REENTRANT 1
+#define _REENTRANT 1
#endif
#if(__BORLANDC__>= 0x500)
- #define _XBT_HAS_NAMESPACES
+#define _XBT_HAS_NAMESPACES
#endif
#include <process.h>
/* no unistd.h header file. */
-#define YY_NO_UNISTD_H
+#define YY_NO_UNISTD_H
/*
* Replace winsock2.h,ws2tcpip.h and winsock.h header files */
#include <windows.h>
/* Choose setjmp as exception implementation */
#ifndef __EX_MCTX_SJLJ__
#define __EX_MCTX_SJLJ__
-#endif
+#endif
/* this is used in context managment. */
#ifdef CONTEXT_UCONTEXT
-#endif /* #ifndef __XBT_BORLAND_COMPILER_CONFIG_H__ */
+#endif /* #ifndef __XBT_BORLAND_COMPILER_CONFIG_H__ */
/* Borland compilers */
#if defined (__BORLANDC__)
#define _XBT_COMPILER_NAME "Borland C/C++"
- #define _XBT_COMPILER_VENDOR "Inprise Corporation"
+#define _XBT_COMPILER_VENDOR "Inprise Corporation"
#define _XBT_BORLAND_COMPILER 2
/* version macro : __BORLANDC__ */
/* version format : ? */
#define _XBT_COMPILER_VERSION __BORLANDC__
#define _XBT_COMPILER_VERSION_FORMAT "?"
- #undef _XBT_COMPILER_RESOLVED
- #define _XBT_COMPILER_RESOLVED 1
+#undef _XBT_COMPILER_RESOLVED
+#define _XBT_COMPILER_RESOLVED 1
#endif
/* Microsoft Visual C++ compiler */
#endif
#define _XBT_COMPILER_NAME "GCC"
- #define _XBT_COMPILER_VENDOR "GNU"
+#define _XBT_COMPILER_VENDOR "GNU"
#define _XBT_GCC_COMPILER 2
/* version macro : __GNUC_VERSION__ */
/* version format : VVRRPP (VV = Version, RR = Revision, PP = Patch) */
#define _XBT_COMPILER_VERSION __GNUC_VERSION__
#define _XBT_COMPILER_VERSION_FORMAT "VVRRPP (VV = Version, RR = Revision, PP = Patch)"
- #undef _XBT_COMPILER_RESOLVED
- #define _XBT_COMPILER_RESOLVED 1
+#undef _XBT_COMPILER_RESOLVED
+#define _XBT_COMPILER_RESOLVED 1
#endif
-#endif /* #ifndef __XBT_SELECT_FEATURES_COMPILER_H__ */
+#endif /* #ifndef __XBT_SELECT_FEATURES_COMPILER_H__ */
#include <win32/platform/select_platform_features.h>
#ifdef _WIN32_WINNT
- #if _WIN32_WINNT < 0x0400
- #undef _WIN32_WINNT
- #define _WIN32_WINNT 0x0400
- #endif
+#if _WIN32_WINNT < 0x0400
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
#else
- #define _WIN32_WINNT 0x0400
+#define _WIN32_WINNT 0x0400
#endif
/*
/* No <dlfcn.h> header file. */
#if defined(HAVE_DLFCN_H)
- #undef HAVE_DLFCN_H
-#endif
+#undef HAVE_DLFCN_H
+#endif
/* Defined if the compiler has the <errno.h> header file. */
#if !defined(HAVE_ERRNO_H)
- #define HAVE_ERRNO_H 1
+#define HAVE_ERRNO_H 1
#endif
/* No <execinfo.h> header file. */
#if defined(HAVE_EXECINFO_H)
- #undef HAVE_EXECINFO_H
+#undef HAVE_EXECINFO_H
#endif
/* No <inttypes.h> header file. */
#if defined(HAVE_INTTYPES_H)
- #undef HAVE_INTTYPES_H
+#undef HAVE_INTTYPES_H
#endif
/* Defined if compiler has the <memory.h> header file. */
#if !defined(HAVE_MEMORY_H)
- #define HAVE_MEMORY_H 1
+#define HAVE_MEMORY_H 1
#endif
/* No <pthread.h> header file. */
#if defined(HAVE_PTHREAD_H)
- #undef HAVE_PTHREAD_H
+#undef HAVE_PTHREAD_H
#endif
/* No <stdint.h> header file. */
#if defined(HAVE_STDINT_H)
- #undef HAVE_STDINT_H
+#undef HAVE_STDINT_H
#endif
/* The compiler has the <stdlib.h> header file. */
#if !defined(HAVE_STDLIB_H)
- #define HAVE_STDLIB_H 1
+#define HAVE_STDLIB_H 1
#endif
/* No <strings.h> header file. */
#if defined(HAVE_STRINGS_H)
- #undef HAVE_STRINGS_H
+#undef HAVE_STRINGS_H
#endif
/* The compiler has the <string.h> header file. */
#if !defined(HAVE_STRING_H)
- #define HAVE_STRING_H 1
+#define HAVE_STRING_H 1
#endif
/* No <sys/socket.h> header file. */
#if defined(HAVE_SYS_SOCKET_H)
- #undef HAVE_SYS_SOCKET_H
+#undef HAVE_SYS_SOCKET_H
#endif
/* The compiler has <sys/stat.h> header file. */
#if !defined(HAVE_SYS_STAT_H)
- #define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_STAT_H 1
#endif
/* No <sys/time.h> header file. */
#if defined(HAVE_SYS_TIME_H)
- #undef HAVE_SYS_TIME_H 1
+#undef HAVE_SYS_TIME_H 1
#endif
/* The compiler has the <sys/types.h> header file. */
#if !defined(HAVE_SYS_TYPES_H)
- #define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_TYPES_H 1
#endif
/* No <unistd.h> header file. */
#if defined(HAVE_UNISTD_H)
- #undef HAVE_UNISTD_H
+#undef HAVE_UNISTD_H
#endif
/* The compiler has the <signal.h> header file */
#if !defined(HAVE_SIGNAL_H)
- #define HAVE_SIGNAL_H 1
+#define HAVE_SIGNAL_H 1
#endif
/*
/* No `getcontext' function. */
#if defined(HAVE_GETCONTEXT)
- #undef HAVE_GETCONTEXT
+#undef HAVE_GETCONTEXT
#endif
/* No `getdtablesize' function. */
#if defined(HAVE_GETDTABLESIZE)
- #undef HAVE_GETDTABLESIZE
+#undef HAVE_GETDTABLESIZE
#endif
/* No `gettimeofday' function. */
#if defined(HAVE_GETTIMEOFDAY)
- #undef HAVE_GETTIMEOFDAY
+#undef HAVE_GETTIMEOFDAY
#endif
/* No `makecontext' function. */
#if defined(HAVE_MAKECONTEXT)
- #undef HAVE_MAKECONTEXT
+#undef HAVE_MAKECONTEXT
#endif
/* No 'popen' function. */
#if defined(HAVE_POPEN)
- #undef HAVE_POPEN
+#undef HAVE_POPEN
#endif
/* No `readv' function. */
#if defined(HAVE_READV)
- #undef HAVE_READV
+#undef HAVE_READV
#endif
/* No `setcontext' function. */
#if defined(HAVE_SETCONTEXT)
- #undef HAVE_SETCONTEXT
+#undef HAVE_SETCONTEXT
#endif
/* No 'signal' function */
#if defined(HAVE_SIGNAL)
- #undef HAVE_SIGNAL
+#undef HAVE_SIGNAL
#endif
/* "disable the snprintf replacement ( this function is broken on system v only" */
#ifdef PREFER_PORTABLE_SNPRINTF
-# undef PREFER_PORTABLE_SNPRINTF 1
+# undef PREFER_PORTABLE_SNPRINTF 1
#endif
/* The compiler has `snprintf' function. */
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400
# ifndef HAVE_SNPRINTF
# define HAVE_SNPRINTF 1
# ifndef PREFER_PORTABLE_SNPRINTF
# define snprintf _snprintf
# endif
# endif
-#else
+#else
# ifdef HAVE_SNPRINTF
- #undef HAVE_SNPRINTF
+#undef HAVE_SNPRINTF
# endif
#endif
/* No `swapcontext' function. */
#if defined(HAVE_SWAPCONTEXT)
- #undef HAVE_SWAPCONTEXT
+#undef HAVE_SWAPCONTEXT
#endif
/* No `sysconf' function. */
#if defined(HAVE_SYSCONF)
- #undef HAVE_SYSCONF
+#undef HAVE_SYSCONF
#endif
/* No `usleep' function. */
#if defined(HAVE_USLEEP)
- #undef HAVE_USLEEP
+#undef HAVE_USLEEP
#endif
/* The compiler has the `vsnprintf' function. */
#ifndef HAVE_VSNPRINTF
- #define HAVE_VSNPRINTF 1
+#define HAVE_VSNPRINTF 1
#endif
/* disable the asprintf replacement */
#ifndef NEED_ASPRINTF
- #define NEED_ASPRINTF
+#define NEED_ASPRINTF
#endif
/* disable the vasprintf replacement */
#ifndef NEED_VASPRINTF
- #define NEED_VASPRINTF
+#define NEED_VASPRINTF
#endif
/* The maximal size of any scalar on this arch */
#if !defined(SIZEOF_MAX)
- #define SIZEOF_MAX 8
+#define SIZEOF_MAX 8
#endif
/* Define to 1 if you have the ANSI C header files. */
#if !defined(STDC_HEADERS)
- #define STDC_HEADERS 1
+#define STDC_HEADERS 1
#endif
#if defined(TIME_WITH_SYS_TIME)
- #undef TIME_WITH_SYS_TIME
+#undef TIME_WITH_SYS_TIME
#endif
/*
/* Define to 1 if you have the `pthread' library (-lpthread). */
#if defined(HAVE_LIBPTHREAD)
- #undef HAVE_LIBPTHREAD
+#undef HAVE_LIBPTHREAD
#endif
/*
* package informations ?
*/
-
-
+
+
/* Defined if arrays in struct can straddle struct alignment boundaries. This
is like than the structure compaction above, but this time, the argument to
be compacted is an array whom each element would be normally compacted.
presenting this caracteristic so far. */
#if defined(GRAS_ARRAY_STRADDLE_STRUCT)
- #undef GRAS_ARRAY_STRADDLE_STRUCT
+#undef GRAS_ARRAY_STRADDLE_STRUCT
#endif
/* Defined if structures are compacted when possible. Consider this structure:
just after the int. If not, it has to be on the 8 bytes boundary imposed by
the double. For now, GRAS requires the structures to be compacted. */
#if defined(GRAS_STRUCT_COMPACT)
- #undef GRAS_STRUCT_COMPACT
+#undef GRAS_STRUCT_COMPACT
#endif
/* Name of package */
/*
* macro
*/
-
+
/* define if big endian */
#if !defined(GRAS_BIGENDIAN)
- #define GRAS_BIGENDIAN 0
+#define GRAS_BIGENDIAN 0
#endif
/* Defined if structures are compacted when possible. Consider this structure:
just after the int. If not, it has to be on the 8 bytes boundary imposed by
the double. For now, GRAS requires the structures to be compacted. */
#if defined(GRAS_STRUCT_COMPACT)
- #define GRAS_STRUCT_COMPACT 1
+#define GRAS_STRUCT_COMPACT 1
#endif
/* defines the GRAS architecture signature of this machine */
#if defined(GRAS_THISARCH)
- #undef GRAS_THISARCH
+#undef GRAS_THISARCH
#endif
#define GRAS_THISARCH 3
-
+
/* Path to the addr2line tool */
#if defined(ADDR2LINE)
- #undef ADDR2LINE
+#undef ADDR2LINE
#endif
#ifndef __VISUALC__
- #if !defined(HAVE_VA_COPY)
- #define HAVE_VA_COPY 1
- #endif
+#if !defined(HAVE_VA_COPY)
+#define HAVE_VA_COPY 1
+#endif
- /* This macro is not defined in borland stdarg.h include file, adds it. */
- #ifndef va_copy(dest,src)
- #define va_copy(dest,src) ((dest)=(src))
- #endif
+ /* This macro is not defined in borland stdarg.h include file, adds it. */
+#ifndef va_copy(dest,src)
+#define va_copy(dest,src) ((dest)=(src))
+#endif
- #ifndef __VA_COPY_USE_ASP(d, s)
- /* Predefined possible va_copy() implementation (id: ASP) */
- #define __VA_COPY_USE_ASP(d, s) do { *(d) = *(s); } while (0)
- #endif
+#ifndef __VA_COPY_USE_ASP(d, s)
+ /* Predefined possible va_copy() implementation (id: ASP) */
+#define __VA_COPY_USE_ASP(d, s) do { *(d) = *(s); } while (0)
+#endif
- #ifndef __VA_COPY_USE_ASS(d, s)
- /* Predefined possible va_copy() implementation (id: ASS) */
- #define __VA_COPY_USE_ASS(d, s) do { (d) = (s); } while (0)
- #endif
+#ifndef __VA_COPY_USE_ASS(d, s)
+ /* Predefined possible va_copy() implementation (id: ASS) */
+#define __VA_COPY_USE_ASS(d, s) do { (d) = (s); } while (0)
+#endif
- #ifndef __VA_COPY_USE_C99(d, s)
- /* Predefined possible va_copy() implementation (id: C99) */
- #define __VA_COPY_USE_C99(d, s) va_copy((d), (s))
- #endif
+#ifndef __VA_COPY_USE_C99(d, s)
+ /* Predefined possible va_copy() implementation (id: C99) */
+#define __VA_COPY_USE_C99(d, s) va_copy((d), (s))
+#endif
- #ifndef __VA_COPY_USE_CPP(d, s)
- /* Predefined possible va_copy() implementation (id: CPP) */
- #define __VA_COPY_USE_CPP(d, s) memcpy((void *)(d), (void *)(s), sizeof(*(s)))
- #endif
+#ifndef __VA_COPY_USE_CPP(d, s)
+ /* Predefined possible va_copy() implementation (id: CPP) */
+#define __VA_COPY_USE_CPP(d, s) memcpy((void *)(d), (void *)(s), sizeof(*(s)))
+#endif
- #ifndef __VA_COPY_USE_CPS(d, s)
- /* Predefined possible va_copy() implementation (id: CPS) */
- #define __VA_COPY_USE_CPS(d, s) memcpy((void *)&(d), (void *)&(s), sizeof(s))
- #endif
+#ifndef __VA_COPY_USE_CPS(d, s)
+ /* Predefined possible va_copy() implementation (id: CPS) */
+#define __VA_COPY_USE_CPS(d, s) memcpy((void *)&(d), (void *)&(s), sizeof(s))
+#endif
- #ifndef __VA_COPY_USE_GCB(d, s)
- /* Predefined possible va_copy() implementation (id: GCB) */
- #define __VA_COPY_USE_GCB(d, s) __builtin_va_copy((d), (s))
- #endif
+#ifndef __VA_COPY_USE_GCB(d, s)
+ /* Predefined possible va_copy() implementation (id: GCB) */
+#define __VA_COPY_USE_GCB(d, s) __builtin_va_copy((d), (s))
+#endif
- #ifndef __VA_COPY_USE_GCH(d, s)
- /* Predefined possible va_copy() implementation (id: GCH) */
- #define __VA_COPY_USE_GCH(d, s) __va_copy((d), (s))
- #endif
- /* Predefined possible va_copy() implementation (id: GCM) */
- #define __VA_COPY_USE_GCM(d, s) VA_COPY((d), (s))
+#ifndef __VA_COPY_USE_GCH(d, s)
+ /* Predefined possible va_copy() implementation (id: GCH) */
+#define __VA_COPY_USE_GCH(d, s) __va_copy((d), (s))
+#endif
+ /* Predefined possible va_copy() implementation (id: GCM) */
+#define __VA_COPY_USE_GCM(d, s) VA_COPY((d), (s))
- /* Optional va_copy() implementation activation */
- #ifndef HAVE_VA_COPY
- #define va_copy(d, s) __VA_COPY_USE(d, s)
- #endif
+ /* Optional va_copy() implementation activation */
+#ifndef HAVE_VA_COPY
+#define va_copy(d, s) __VA_COPY_USE(d, s)
+#endif
- /* Define to id of used va_copy() implementation */
- #ifndef __VA_COPY_USE
- #define __VA_COPY_USE __VA_COPY_USE_C99
- #endif
+ /* Define to id of used va_copy() implementation */
+#ifndef __VA_COPY_USE
+#define __VA_COPY_USE __VA_COPY_USE_C99
+#endif
#endif
/* xbt contexts are based on our threads implementation */
#ifndef _XBT_CALL
- #if defined(_XBT_DESIGNATED_DLL)
- #define _XBT_CALL __cdecl __export
- #elif defined(_RTLDLL)
- #define _XBT_CALL __cdecl __import
- #else
- #define _XBT_CALL __cdecl
- #endif
+#if defined(_XBT_DESIGNATED_DLL)
+#define _XBT_CALL __cdecl __export
+#elif defined(_RTLDLL)
+#define _XBT_CALL __cdecl __import
+#else
+#define _XBT_CALL __cdecl
+#endif
#endif
/* auto enable thread safety and exceptions: */
#ifndef _CPPUNWIND
- #define _XBT_HAS_NO_EXCEPTIONS
+#define _XBT_HAS_NO_EXCEPTIONS
#endif
#if defined ( __MT__ ) && !defined (_NOTHREADS) && !defined (_REENTRANT)
- #define _REENTRANT 1
+#define _REENTRANT 1
#endif
#include <process.h>
/* no unistd.h header file. */
-#define YY_NO_UNISTD_H
+#define YY_NO_UNISTD_H
/*
* Replace winsock2.h,ws2tcpip.h and winsock.h header files */
#include <windows.h>
/* Choose setjmp as exception implementation */
#ifndef __EX_MCTX_SJLJ__
#define __EX_MCTX_SJLJ__
-#endif
+#endif
typedef unsigned int uint32_t;
-#endif /* #ifndef __XBT_VISUALC_COMPILER_CONFIG_H__ */
+#endif /* #ifndef __XBT_VISUALC_COMPILER_CONFIG_H__ */
#if defined(_XBT_BORLAND_COMPILER)
- # include <win32/compiler/borland.h>
+# include <win32/compiler/borland.h>
#elif defined(__GNUC__)
- /* data comes from autoconf when using gnuc (cross-compiling?) */
- # include "gras_config.h"
- #ifndef _XBT_WIN32
- typedef unsigned int uint32_t;
- #endif
+ /* data comes from autoconf when using gnuc (cross-compiling?) */
+# include "gras_config.h"
+#ifndef _XBT_WIN32
+typedef unsigned int uint32_t;
+#endif
#elif defined(_XBT_VISUALC_COMPILER)
- # include <win32/compiler/visualc.h>
+# include <win32/compiler/visualc.h>
# else
- # error "Unknown compiler - please report the problems to the main simgrid mailing list (http://gforge.inria.fr/mail/?group_id=12)"
+# error "Unknown compiler - please report the problems to the main simgrid mailing list (http://gforge.inria.fr/mail/?group_id=12)"
#endif
typedef int socklen_t;
#define AC_SOCKET_INVALID ((unsigned int) ~0)
#ifdef SD_BOTH
- #define tcp_close(s) (shutdown( s, SD_BOTH ), closesocket(s))
+#define tcp_close(s) (shutdown( s, SD_BOTH ), closesocket(s))
#else
- #define tcp_close( s ) closesocket( s )
+#define tcp_close( s ) closesocket( s )
#endif
#ifndef _XBT_VISUALC_COMPILER
- #ifndef EWOULDBLOCK
- #define EWOULDBLOCK WSAEWOULDBLOCK
- #endif
- #ifndef EINPROGRESS
- #define EINPROGRESS WSAEINPROGRESS
- #endif
- #ifndef ETIMEDOUT
- #define ETIMEDOUT WSAETIMEDOUT
- #endif
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+#ifndef EINPROGRESS
+#define EINPROGRESS WSAEINPROGRESS
+#endif
+#ifndef ETIMEDOUT
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
#endif
#ifdef sock_errno
- #undef sock_errno
+#undef sock_errno
#endif
#define sock_errno WSAGetLastError()
#ifdef sock_errstr
- #undef sock_errstr
+#undef sock_errstr
#endif
#define sock_errstr(err) gras_wsa_err2string(err)
const char *gras_wsa_err2string(int errcode);
#ifdef S_IRGRP
- #undef S_IRGRP
+#undef S_IRGRP
#endif
#define S_IRGRP 0
#ifdef S_IWGRP
- #undef S_IWGRP
+#undef S_IWGRP
#endif
#define S_IWGRP 0
-#endif /* #ifndef __XBT_WIN32_CONFIG_H__ */
+#endif /* #ifndef __XBT_WIN32_CONFIG_H__ */
/*
* win32 or win64 (__XBT_WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC).
-*/
+*/
/* If the platform is not resolved _XBT_PLATFORM_ID is set to zero. */
#define _XBT_PLATFORM_ID 0
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
- #undef _XBT_PLATFORM_ID
- #define _XBT_WIN32_PLATFORM 1
- #define _XBT_PLATFORM_ID _XBT_WIN32_PLATFORM
- #define _XBT_PLATFORM_NAME "Windows 32 bits platform"
+#undef _XBT_PLATFORM_ID
+#define _XBT_WIN32_PLATFORM 1
+#define _XBT_PLATFORM_ID _XBT_WIN32_PLATFORM
+#define _XBT_PLATFORM_NAME "Windows 32 bits platform"
/*
* win64.
*/
#elif defined(_WIN64)
- #undef _XBT_PLATFORM_ID
- #ifdef _XBT_WIN32_PLATFORM
- #undef _XBT_WIN32_PLATFORM
- #endif
-
- #define _XBT_PLATFORM_NAME "Windows 64 bits platform"
- #define _XBT_WIN64_PLATFORM 2
- #define _XBT_PLATFORM_ID _XBT_WIN64_PLATFORM
+#undef _XBT_PLATFORM_ID
+#ifdef _XBT_WIN32_PLATFORM
+#undef _XBT_WIN32_PLATFORM
+#endif
+
+#define _XBT_PLATFORM_NAME "Windows 64 bits platform"
+#define _XBT_WIN64_PLATFORM 2
+#define _XBT_PLATFORM_ID _XBT_WIN64_PLATFORM
/*
* win16.
*/
#elif defined(_WIN16)
- #undef _XBT_PLATFORM_ID
- #define _XBT_WIN16_PLATFORM 3
- #define _XBT_PLATFORM_NAME "Windows 16 bits platform"
- #define _XBT_PLATFORM_ID _XBT_WIN16_PLATFORM
+#undef _XBT_PLATFORM_ID
+#define _XBT_WIN16_PLATFORM 3
+#define _XBT_PLATFORM_NAME "Windows 16 bits platform"
+#define _XBT_PLATFORM_ID _XBT_WIN16_PLATFORM
/*
* wince.
*/
#elif defined(UNDER_CE)
- #undef _XBT_PLATFORM_ID
- #define __XBT_WINCE_PLATFORM 4
- #define _XBT_PLATFORM_ID _XBT_WINCE_PLATFORM
- #define _XBT_PLATFORM_NAME "Windows CE bits platform"
+#undef _XBT_PLATFORM_ID
+#define __XBT_WINCE_PLATFORM 4
+#define _XBT_PLATFORM_ID _XBT_WINCE_PLATFORM
+#define _XBT_PLATFORM_NAME "Windows CE bits platform"
#elif defined(linux) || defined(__linux) || defined(__linux__)
/* linux. */
- #undef _XBT_PLATFORM_ID
- #define __XBT_LINUX_PLATFORM 5
- #define _XBT_PLATFORM_ID _XBT_LINUX_PLATFORM
- #define _XBT_PLATFORM_NAME "Linux platform"
-
+#undef _XBT_PLATFORM_ID
+#define __XBT_LINUX_PLATFORM 5
+#define _XBT_PLATFORM_ID _XBT_LINUX_PLATFORM
+#define _XBT_PLATFORM_NAME "Linux platform"
+
#elif defined (_XBT_ASSERT_CONFIG)
- // This must come last - generate an error if we don't
- // resolve the platform:
- #error "Unknown platform - please configure (simgrid.gforge.inria.fr/xbt/libs/config/config.htm#configuring) and report the results to the main simgrid mailing list (simgrid.gforge.inra.fr/more/mailing_lists.htm#main)"
+ // This must come last - generate an error if we don't
+ // resolve the platform:
+#error "Unknown platform - please configure (simgrid.gforge.inria.fr/xbt/libs/config/config.htm#configuring) and report the results to the main simgrid mailing list (simgrid.gforge.inra.fr/more/mailing_lists.htm#main)"
#endif
#if defined(_XBT_WIN32_PLATFORM) || defined(_XBT_WIN64_PLATFORM) || defined(_XBT_WIN16_PLATFORM) || defined(_XBT_WINCE_PLATFORM)
#ifndef _XBT_WIN32
- #define _XBT_WIN32
+#define _XBT_WIN32
#endif
#endif
#define _xbt_get_platform_name() _XBT_PLATFORM_NAME
/* Returns the platform id. */
-#define _xbt_get_platform_id() _XBT_PLATFORM_ID
+#define _xbt_get_platform_id() _XBT_PLATFORM_ID
/* Returns true if the platform is Windows 32 bits. */
#define _xbt_is_win32() (_XBT_PLATFORM_ID == 1)
-#endif /* #define __XBT_SELECT_PLATFORM_FEATURES_H__ */
+#endif /* #define __XBT_SELECT_PLATFORM_FEATURES_H__ */
e->bt_strings = xbt_new(char *, 1);
e->bt_strings[0] =
- bprintf("(binary '%s' not found the path)", xbt_binary_name);
+ bprintf("(binary '%s' not found the path)", xbt_binary_name);
return;
}
xbt_dynar_free(&path);
binary_name = xbt_strdup(xbt_binary_name);
}
cmd = curr =
- xbt_new(char,
- strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->used);
+ xbt_new(char,
+ strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->used);
curr += sprintf(curr, "%s -f -e %s ", ADDR2LINE, binary_name);
free(binary_name);
fgets_res = fgets(line_func, 1024, pipe);
if (fgets_res == NULL)
THROW2(system_error, 0,
- "Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
+ "Cannot run fgets to look for symbol %d, addr %s", i,
+ addrs[i]);
line_func[strlen(line_func) - 1] = '\0';
fgets_res = fgets(line_pos, 1024, pipe);
if (fgets_res == NULL)
THROW2(system_error, 0,
- "Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
+ "Cannot run fgets to look for symbol %d, addr %s", i,
+ addrs[i]);
line_pos[strlen(line_pos) - 1] = '\0';
if (strcmp("??", line_func)) {
DEBUG2("Found static symbol %s() at %s", line_func, line_pos);
- e->bt_strings[i] = bprintf("** In %s() at %s", line_func, line_pos);
+ e->bt_strings[i] =
+ bprintf("** In %s() at %s", line_func, line_pos);
} else {
/* Damn. The symbol is in a dynamic library. Let's get wild */
char *maps_name;
if (found) {
DEBUG3("%#lx in [%#lx-%#lx]", addr, first, last);
DEBUG0
- ("Symbol found, map lines not further displayed (even if looking for next ones)");
+ ("Symbol found, map lines not further displayed (even if looking for next ones)");
}
}
fclose(maps);
if (!found) {
VERB0
- ("Problem while reading the maps file. Following backtrace will be mangled.");
+ ("Problem while reading the maps file. Following backtrace will be mangled.");
DEBUG1("No dynamic. Static symbol: %s", backtrace_syms[i]);
e->bt_strings[i] = bprintf("** In ?? (%s)", backtrace_syms[i]);
continue;
/* check whether the trick worked */
if (strcmp("??", line_func)) {
DEBUG2("Found dynamic symbol %s() at %s", line_func, line_pos);
- e->bt_strings[i] = bprintf("** In %s() at %s", line_func, line_pos);
+ e->bt_strings[i] =
+ bprintf("** In %s() at %s", line_func, line_pos);
} else {
/* damn, nothing to do here. Let's print the raw address */
DEBUG1("Dynamic symbol not found. Raw address = %s",
/* Mask the bottom of the stack */
if (!strncmp("main", line_func, strlen("main")) ||
- !strncmp("xbt_thread_context_wrapper", line_func, strlen("xbt_thread_context_wrapper"))||
- !strncmp("smx_ctx_sysv_wrapper",line_func,strlen("smx_ctx_sysv_wrapper"))) {
+ !strncmp("xbt_thread_context_wrapper", line_func,
+ strlen("xbt_thread_context_wrapper"))
+ || !strncmp("smx_ctx_sysv_wrapper", line_func,
+ strlen("smx_ctx_sysv_wrapper"))) {
int j;
for (j = i + 1; j < e->used; j++)
/* get the pointers to debug help library exported functions */
fun_initialize =
- (fun_initialize_t) GetProcAddress(hlp_dbg_instance, "SymInitialize");
+ (fun_initialize_t) GetProcAddress(hlp_dbg_instance, "SymInitialize");
fun_cleanup =
- (fun_cleanup_t) GetProcAddress(hlp_dbg_instance, "SymCleanup");
+ (fun_cleanup_t) GetProcAddress(hlp_dbg_instance, "SymCleanup");
fun_function_table_access =
- (fun_function_table_access_t) GetProcAddress(hlp_dbg_instance,
- "SymFunctionTableAccess");
+ (fun_function_table_access_t) GetProcAddress(hlp_dbg_instance,
+ "SymFunctionTableAccess");
fun_get_line_from_addr =
- (fun_get_line_from_addr_t) GetProcAddress(hlp_dbg_instance,
- "SymGetLineFromAddr");
+ (fun_get_line_from_addr_t) GetProcAddress(hlp_dbg_instance,
+ "SymGetLineFromAddr");
fun_get_module_base =
- (fun_get_module_base_t) GetProcAddress(hlp_dbg_instance,
- "SymGetModuleBase");
+ (fun_get_module_base_t) GetProcAddress(hlp_dbg_instance,
+ "SymGetModuleBase");
fun_get_options =
- (fun_get_options_t) GetProcAddress(hlp_dbg_instance, "SymGetOptions");
+ (fun_get_options_t) GetProcAddress(hlp_dbg_instance,
+ "SymGetOptions");
fun_get_sym_from_addr =
- (fun_get_sym_from_addr_t) GetProcAddress(hlp_dbg_instance,
- "SymGetSymFromAddr");
+ (fun_get_sym_from_addr_t) GetProcAddress(hlp_dbg_instance,
+ "SymGetSymFromAddr");
fun_set_options =
- (fun_set_options_t) GetProcAddress(hlp_dbg_instance, "SymSetOptions");
+ (fun_set_options_t) GetProcAddress(hlp_dbg_instance,
+ "SymSetOptions");
fun_stack_walk =
- (fun_stack_walk_t) GetProcAddress(hlp_dbg_instance, "StackWalk");
+ (fun_stack_walk_t) GetProcAddress(hlp_dbg_instance, "StackWalk");
/* Check that everything worked well */
if (!fun_initialize ||
IMAGEHLP_SYMBOL *pSym;
unsigned long offset = 0;
IMAGEHLP_LINE line_info = { 0 };
- byte
- __buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) +
- sizeof(ULONG64) - 1) / sizeof(ULONG64)];
+ byte __buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) +
+ sizeof(ULONG64) - 1) / sizeof(ULONG64)];
CONTEXT context = { CONTEXT_FULL };
GetThreadContext(GetCurrentThread(), &context);
/* ebp points on stack base */
/* esp points on stack pointer, ie on last stacked element (current element) */
_asm call $ + 5
- _asm pop eax
- _asm mov context.Eip, eax
- _asm mov eax, esp
- _asm mov context.Esp, eax
- _asm mov context.Ebp, ebp
- if ((NULL == hlp_dbg_instance) || (size <= 0) || (NULL == buffer)) {
+ _asm pop eax
+ _asm mov context.Eip, eax
+ _asm mov eax, esp
+ _asm mov context.Esp, eax
+ _asm mov context.Ebp, ebp
+ if ((NULL == hlp_dbg_instance) || (size <= 0) || (NULL == buffer)) {
errno = EINVAL;
return 0;
}
unsigned long offset = 0;
IMAGEHLP_LINE line_info = { 0 };
IMAGEHLP_MODULE module = { 0 };
- byte
- __buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) +
- sizeof(ULONG64) - 1) / sizeof(ULONG64)];
+ byte __buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) +
+ sizeof(ULONG64) - 1) / sizeof(ULONG64)];
if ((NULL == hlp_dbg_instance) || (size <= 0) || (NULL == buffer)) {
errno = EINVAL;
if ((*fun_get_sym_from_addr)
(process_handle, stack_frame->AddrPC.Offset, &offset, pSym)) {
if ((*fun_get_line_from_addr)
- (process_handle, stack_frame->AddrPC.Offset, &offset, &line_info)) {
+ (process_handle, stack_frame->AddrPC.Offset, &offset,
+ &line_info)) {
strings[pos] =
- bprintf("** In %s() at %s:%d", pSym->Name, line_info.FileName,
- (int) line_info.LineNumber);
+ bprintf("** In %s() at %s:%d", pSym->Name,
+ line_info.FileName, (int) line_info.LineNumber);
} else {
strings[pos] = bprintf("** In %s()", pSym->Name);
}
} s_xbt_cfgelm_t, *xbt_cfgelm_t;
static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count] =
- { "int", "double", "string", "peer", "any" };
+ { "int", "double", "string", "peer", "any" };
/* Internal stuff used in cache to free a variable */
static void xbt_cfgelm_free(void *data);
size = xbt_dynar_length(variable->content);
printf
- ("%d_to_%d_%s. Actual size=%d. prerm=%p,postset=%p, List of values:\n",
- variable->min, variable->max, xbt_cfgelm_type_name[variable->type],
- size, variable->cb_rm, variable->cb_set);
+ ("%d_to_%d_%s. Actual size=%d. prerm=%p,postset=%p, List of values:\n",
+ variable->min, variable->max,
+ xbt_cfgelm_type_name[variable->type], size, variable->cb_rm,
+ variable->cb_set);
switch (variable->type) {
void
xbt_cfg_register(xbt_cfg_t * cfg,
- const char *name, const char *desc, e_xbt_cfgelm_type_t type,
- void *default_value, int min, int max, xbt_cfg_cb_t cb_set,
- xbt_cfg_cb_t cb_rm)
+ const char *name, const char *desc,
+ e_xbt_cfgelm_type_t type, void *default_value, int min,
+ int max, xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm)
{
xbt_cfgelm_t res;
res = xbt_new(s_xbt_cfgelm_t, 1);
DEBUG8("Register cfg elm %s (%s) (%d to %d %s (=%d) @%p in set %p)",
- name, desc, min, max, xbt_cfgelm_type_name[type], type, res, *cfg);
+ name, desc, min, max, xbt_cfgelm_type_name[type], type, res,
+ *cfg);
res->desc = xbt_strdup(desc);
res->type = type;
*(tok++) = '\0';
min = strtol(tok, &tok, 10);
- xbt_assert1(tok, "Invalid minimum in config element descriptor %s", entry);
+ xbt_assert1(tok, "Invalid minimum in config element descriptor %s",
+ entry);
xbt_assert2(strcmp(tok, "_to_"),
"Invalid config element descriptor : %s%s",
tok += strlen("_to_");
max = strtol(tok, &tok, 10);
- xbt_assert1(tok, "Invalid maximum in config element descriptor %s", entry);
+ xbt_assert1(tok, "Invalid maximum in config element descriptor %s",
+ entry);
xbt_assert2(*(tok++) == '_',
"Invalid config element descriptor: %s%s", entry,
xbt_dict_cursor_free(&cursor);
THROW4(mismatch_error, 0,
"Config elem %s needs at least %d %s, but there is only %d values.",
- name, variable->min, xbt_cfgelm_type_name[variable->type], size);
+ name, variable->min, xbt_cfgelm_type_name[variable->type],
+ size);
}
if (variable->max > 0 && variable->max < size) {
xbt_dict_cursor_free(&cursor);
THROW4(mismatch_error, 0,
"Config elem %s accepts at most %d %s, but there is %d values.",
- name, variable->max, xbt_cfgelm_type_name[variable->type], size);
+ name, variable->max, xbt_cfgelm_type_name[variable->type],
+ size);
}
}
}
static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg,
- const char *name, e_xbt_cfgelm_type_t type)
+ const char *name,
+ e_xbt_cfgelm_type_t type)
{
xbt_cfgelm_t res = NULL;
if (e.category == not_found_error) {
xbt_ex_free(e);
THROW1(not_found_error, 0,
- "Can't set the property '%s' since it's not registered", name);
+ "Can't set the property '%s' since it's not registered",
+ name);
}
RETHROW;
}
* This is useful to change the default value of a variable while allowing
* users to override it with command line arguments
*/
-void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val) {
+void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val)
+{
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
if (variable->isdefault)
- xbt_cfg_set_int(cfg, name,val);
+ xbt_cfg_set_int(cfg, name, val);
else
- DEBUG2("Do not override configuration variable '%s' with value '%d' because it was already set.",name,val);
+ DEBUG2
+ ("Do not override configuration variable '%s' with value '%d' because it was already set.",
+ name, val);
}
+
/** @brief Set an integer value to \a name within \a cfg if it wasn't changed yet
*
* This is useful to change the default value of a variable while allowing
* users to override it with command line arguments
*/
-void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val) {
+void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val)
+{
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
if (variable->isdefault)
xbt_cfg_set_double(cfg, name, val);
else
- DEBUG2("Do not override configuration variable '%s' with value '%lf' because it was already set.",name,val);
+ DEBUG2
+ ("Do not override configuration variable '%s' with value '%lf' because it was already set.",
+ name, val);
}
+
/** @brief Set a string value to \a name within \a cfg if it wasn't changed yet
*
* This is useful to change the default value of a variable while allowing
* users to override it with command line arguments
*/
-void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, const char* val) {
+void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name,
+ const char *val)
+{
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
if (variable->isdefault)
- xbt_cfg_set_string(cfg, name,val);
+ xbt_cfg_set_string(cfg, name, val);
else
- DEBUG2("Do not override configuration variable '%s' with value '%s' because it was already set.",name,val);
+ DEBUG2
+ ("Do not override configuration variable '%s' with value '%s' because it was already set.",
+ name, val);
}
+
/** @brief Set a peer value to \a name within \a cfg if it wasn't changed yet
*
* This is useful to change the default value of a variable while allowing
* users to override it with command line arguments
*/
-void xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name, const char* host, int port) {
+void xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name,
+ const char *host, int port)
+{
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer);
if (variable->isdefault)
xbt_cfg_set_peer(cfg, name, host, port);
else
- DEBUG3("Do not override configuration variable '%s' with value '%s:%d' because it was already set.",
- name,host,port);
+ DEBUG3
+ ("Do not override configuration variable '%s' with value '%s:%d' because it was already set.",
+ name, host, port);
}
/** @brief Set or add an integer value to \a name within \a cfg
xbt_dynar_set(variable->content, 0, &val);
} else {
- if (variable->max && xbt_dynar_length(variable->content) == variable->max)
+ if (variable->max
+ && xbt_dynar_length(variable->content) == variable->max)
THROW3(mismatch_error, 0,
"Cannot add value %f to the config element %s since it's already full (size=%d)",
val, name, variable->max);
VERB2("Configuration setting: %s=%s", name, val);
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
DEBUG5("Variable: %d to %d %s (=%d) @%p",
- variable->min, variable->max, xbt_cfgelm_type_name[variable->type],
- variable->type, variable);
+ variable->min, variable->max,
+ xbt_cfgelm_type_name[variable->type], variable->type, variable);
if (variable->max == 1) {
if (xbt_dynar_length(variable->content)) {
xbt_dynar_set(variable->content, 0, &newval);
} else {
- if (variable->max && xbt_dynar_length(variable->content) == variable->max)
+ if (variable->max
+ && xbt_dynar_length(variable->content) == variable->max)
THROW3(mismatch_error, 0,
"Cannot add value %s to the config element %s since it's already full (size=%d)",
name, val, variable->max);
*/
void
-xbt_cfg_set_peer(xbt_cfg_t cfg, const char *name, const char *peer, int port)
+xbt_cfg_set_peer(xbt_cfg_t cfg, const char *name, const char *peer,
+ int port)
{
xbt_cfgelm_t variable;
xbt_peer_t val = xbt_peer_new(peer, port);
xbt_dynar_set(variable->content, 0, &val);
} else {
- if (variable->max && xbt_dynar_length(variable->content) == variable->max)
+ if (variable->max
+ && xbt_dynar_length(variable->content) == variable->max)
THROW4(mismatch_error, 0,
"Cannot add value %s:%d to the config element %s since it's already full (size=%d)",
peer, port, name, variable->max);
*/
void
-xbt_cfg_rm_peer(xbt_cfg_t cfg, const char *name, const char *peer, int port)
+xbt_cfg_rm_peer(xbt_cfg_t cfg, const char *name, const char *peer,
+ int port)
{
xbt_cfgelm_t variable;
unsigned int cpt;
if (xbt_dynar_length(variable->content) > 1) {
WARN2
- ("You asked for the first value of the config element '%s', but there is %lu values",
- name, xbt_dynar_length(variable->content));
+ ("You asked for the first value of the config element '%s', but there is %lu values",
+ name, xbt_dynar_length(variable->content));
}
return xbt_dynar_get_as(variable->content, 0, int);
if (xbt_dynar_length(variable->content) > 1) {
WARN2
- ("You asked for the first value of the config element '%s', but there is %lu values\n",
- name, xbt_dynar_length(variable->content));
+ ("You asked for the first value of the config element '%s', but there is %lu values\n",
+ name, xbt_dynar_length(variable->content));
}
return xbt_dynar_get_as(variable->content, 0, double);
if (xbt_dynar_length(variable->content) > 1) {
WARN2
- ("You asked for the first value of the config element '%s', but there is %lu values\n",
- name, xbt_dynar_length(variable->content));
+ ("You asked for the first value of the config element '%s', but there is %lu values\n",
+ name, xbt_dynar_length(variable->content));
} else if (xbt_dynar_length(variable->content) == 0) {
return NULL;
}
* \warning the returned value is the actual content of the config set
*/
-void xbt_cfg_get_peer(xbt_cfg_t cfg, const char *name, char **peer, int *port)
+void xbt_cfg_get_peer(xbt_cfg_t cfg, const char *name, char **peer,
+ int *port)
{
xbt_cfgelm_t variable;
xbt_peer_t val;
if (xbt_dynar_length(variable->content) > 1) {
WARN2
- ("You asked for the first value of the config element '%s', but there is %lu values\n",
- name, xbt_dynar_length(variable->content));
+ ("You asked for the first value of the config element '%s', but there is %lu values\n",
+ name, xbt_dynar_length(variable->content));
}
val = xbt_dynar_get_as(variable->content, 0, xbt_peer_t);
xbt_dynar_t dyn;
xbt_cfg_t myset = make_set();
- xbt_cfg_set_parse(myset, "peername:veloce user:foo\nuser:bar\tuser:toto");
+ xbt_cfg_set_parse(myset,
+ "peername:veloce user:foo\nuser:bar\tuser:toto");
xbt_cfg_set_parse(myset, "speed:42");
xbt_cfg_check(myset);
dyn = xbt_cfg_get_dynar(myset, "user");
xbt_dynar_length(dyn));
if (strcmp(xbt_dynar_get_as(dyn, 0, char *), "foo"))
- xbt_test_fail1("Dynar[0] = %s, I expected foo",
- xbt_dynar_get_as(dyn, 0, char *));
+ xbt_test_fail1("Dynar[0] = %s, I expected foo",
+ xbt_dynar_get_as(dyn, 0, char *));
if (strcmp(xbt_dynar_get_as(dyn, 1, char *), "bar"))
- xbt_test_fail1("Dynar[1] = %s, I expected bar",
- xbt_dynar_get_as(dyn, 1, char *));
+ xbt_test_fail1("Dynar[1] = %s, I expected bar",
+ xbt_dynar_get_as(dyn, 1, char *));
if (strcmp(xbt_dynar_get_as(dyn, 2, char *), "toto"))
- xbt_test_fail1("Dynar[2] = %s, I expected toto",
- xbt_dynar_get_as(dyn, 2, char *));
+ xbt_test_fail1("Dynar[2] = %s, I expected toto",
+ xbt_dynar_get_as(dyn, 2, char *));
xbt_cfg_free(&myset);
}
xbt_cfg_free(&myset);
}
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
test, test->file, test->line, test->title,
test->failed ? "failed" : "not failed");
xbt_dynar_foreach(test->logs, it_log, log)
- xbt_test_log_dump(log);
+ xbt_test_log_dump(log);
} else
fprintf(stderr, " test=NULL\n");
}
(unit->enabled ? "enabled" : "disabled"));
if (unit->enabled)
xbt_dynar_foreach(unit->tests, it_test, test)
- xbt_test_test_dump(test);
+ xbt_test_test_dump(test);
} else {
fprintf(stderr, " unit=NULL\n");
}
if (!_xbt_test_suites)
_xbt_test_suites =
- xbt_dynar_new(sizeof(xbt_test_suite_t), xbt_test_suite_free);
+ xbt_dynar_new(sizeof(xbt_test_suite_t), xbt_test_suite_free);
va_start(ap, fmt);
vres = vasprintf(&suite->title, fmt, ap);
- suite->units = xbt_dynar_new(sizeof(xbt_test_unit_t), &xbt_test_unit_free);
+ suite->units =
+ xbt_dynar_new(sizeof(xbt_test_unit_t), &xbt_test_unit_free);
va_end(ap);
suite->name = name;
suite->enabled = 1;
if (_xbt_test_suites)
xbt_dynar_foreach(_xbt_test_suites, it_suite, suite)
- if (!strcmp(suite->name, name))
+ if (!strcmp(suite->name, name))
return suite;
va_start(ap, fmt);
suite->enabled ? "enabled" : "disabled");
if (suite->enabled)
xbt_dynar_foreach(suite->units, it_unit, unit)
- xbt_test_unit_dump(unit);
+ xbt_test_unit_dump(unit);
} else {
fprintf(stderr, "TESTSUITE IS NULL!\n");
}
suite_title[i++] = '\n';
suite_title[80] = '\0';
- sprintf(suite_title + 40 - (suite_len + 4) / 2, "[ %s ]", suite->title);
+ sprintf(suite_title + 40 - (suite_len + 4) / 2, "[ %s ]",
+ suite->title);
suite_title[40 + (suite_len + 5) / 2] = '=';
if (!suite->enabled)
snprintf(suite_title + 70, 11, " DISABLED ");
unit->test_expect = 0;
/* display unit title */
- vres = asprintf(&cp, " Unit: %s ......................................"
- "......................................", unit->title);
+ vres =
+ asprintf(&cp,
+ " Unit: %s ......................................"
+ "......................................", unit->title);
cp[70] = '\0';
fprintf(stderr, "%s", cp);
free(cp);
fprintf(stderr, " %s: %s [%s:%d]\n",
(test->ignored ? " SKIP"
: (test->expected_failure
- ? (test->failed ? "EFAIL" : "EPASS") : (test->failed ?
- " FAIL" :
- " PASS"))),
+ ? (test->
+ failed ? "EFAIL" : "EPASS") : (test->failed ?
+ " FAIL" :
+ " PASS"))),
test->title, file, line);
if ((test->expected_failure && !test->failed)
first = 0;
}
if (suite->unit_failed) {
- fprintf(stderr, "%s%d failed", (first ? "" : ", "), suite->unit_failed);
+ fprintf(stderr, "%s%d failed", (first ? "" : ", "),
+ suite->unit_failed);
first = 0;
}
if (suite->unit_ignore) {
first = 0;
}
if (suite->test_failed) {
- fprintf(stderr, "%s%d failed", (first ? "" : ", "), suite->test_failed);
+ fprintf(stderr, "%s%d failed", (first ? "" : ", "),
+ suite->test_failed);
first = 0;
}
if (suite->test_ignore) {
unsigned int it;
for (it = 0; it < xbt_dynar_length(_xbt_test_suites); it++) {
xbt_test_suite_t thissuite =
- xbt_dynar_get_as(_xbt_test_suites, it, xbt_test_suite_t);
+ xbt_dynar_get_as(_xbt_test_suites, it, xbt_test_suite_t);
if (!strcmp(suitename, thissuite->name)) {
/* Do not disable the whole suite when we just want to disable a child */
if (enabling || (unitname[0] == '\0'))
} else { /* act on one child only */
unsigned int it2_unit;
/* search it, first (we won't reuse it for external loop which gets broken) */
- for (it2_unit = 0; it2_unit < xbt_dynar_length(thissuite->units);
+ for (it2_unit = 0;
+ it2_unit < xbt_dynar_length(thissuite->units);
it2_unit++) {
xbt_test_unit_t thisunit =
- xbt_dynar_get_as(thissuite->units, it2_unit, xbt_test_unit_t);
+ xbt_dynar_get_as(thissuite->units, it2_unit,
+ xbt_test_unit_t);
if (!strcmp(thisunit->name, unitname)) {
thisunit->enabled = enabling;
break;
xbt_test_suite_t suite;
xbt_dynar_foreach(_xbt_test_suites, it_suite, suite)
- xbt_test_suite_dump(suite);
+ xbt_test_suite_dump(suite);
} else {
printf(" No suite defined.");
}
/* Run all the suites */
xbt_dynar_foreach(_xbt_test_suites, it_suite, suite)
- xbt_test_suite_run(suite);
+ xbt_test_suite_run(suite);
/* Display some more statistics */
fprintf(stderr, "\n\n TOTAL: Suites: %.0f%% ok (%d suites: ",
(double) _xbt_test_nb_suites) * 100.0)
: 100.0, _xbt_test_nb_suites);
if (_xbt_test_nb_suites != _xbt_test_suite_failed) {
- fprintf(stderr, "%d ok", _xbt_test_nb_suites - _xbt_test_suite_failed);
+ fprintf(stderr, "%d ok",
+ _xbt_test_nb_suites - _xbt_test_suite_failed);
first = 0;
}
if (_xbt_test_suite_failed) {
xbt_assert1(xbt_dynar_length(_xbt_test_current_unit->tests),
"Cannot expect the failure of a test before declaring it (broken unit: %s)",
_xbt_test_current_unit->title);
- test = xbt_dynar_getlast_as(_xbt_test_current_unit->tests, xbt_test_test_t);
+ test =
+ xbt_dynar_getlast_as(_xbt_test_current_unit->tests, xbt_test_test_t);
test->expected_failure = 1;
}
"Test skiped even before being declared (broken unit: %s)",
_xbt_test_current_unit->title);
- test = xbt_dynar_getlast_as(_xbt_test_current_unit->tests, xbt_test_test_t);
+ test =
+ xbt_dynar_getlast_as(_xbt_test_current_unit->tests, xbt_test_test_t);
test->ignored = 1;
}
xbt_test_fail0("EXPECTED FAILURE");
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
/**
* Returns the hash code of a string.
*/
-static XBT_INLINE unsigned int xbt_dict_hash_ext(const char *str, int str_len)
+static XBT_INLINE unsigned int xbt_dict_hash_ext(const char *str,
+ int str_len)
{
while (bp < be) {
/* multiply by the 32 bit FNV magic prime mod 2^32 */
hash +=
- (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
+ (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) +
+ (hash << 24);
/* xor the bottom with the current octet */
hash ^= (unsigned int) *bp++;
while (*str) {
/* multiply by the 32 bit FNV magic prime mod 2^32 */
hash +=
- (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
+ (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) +
+ (hash << 24);
/* xor the bottom with the current byte */
hash ^= (unsigned int) *str++;
register xbt_dictelm_t *pprev;
currcell =
- (xbt_dictelm_t *) xbt_realloc((char *) dict->table,
- newsize * sizeof(xbt_dictelm_t));
+ (xbt_dictelm_t *) xbt_realloc((char *) dict->table,
+ newsize * sizeof(xbt_dictelm_t));
memset(&currcell[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */
dict->table_size = --newsize;
dict->table = currcell;
* null terminated string.
*/
XBT_INLINE void xbt_dict_set(xbt_dict_t dict,
- const char *key, void *data, void_f_pvoid_t free_ctn)
+ const char *key, void *data,
+ void_f_pvoid_t free_ctn)
{
xbt_dict_set_ext(dict, key, strlen(key), data, free_ctn);
*
* Search the given \a key. Throws not_found_error when not found.
*/
-XBT_INLINE void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
+XBT_INLINE void *xbt_dict_get_ext(xbt_dict_t dict, const char *key,
+ int key_len)
{
/**
* \brief like xbt_dict_get_ext(), but returning NULL when not found
*/
-void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key, int key_len)
+void *xbt_dict_get_or_null_ext(xbt_dict_t dict, const char *key,
+ int key_len)
{
unsigned int hash_code = xbt_dict_hash_ext(key, key_len);
*
* Returns NULL if the object cannot be found
*/
-char *xbt_dict_get_key(xbt_dict_t dict, const void*data) {
+char *xbt_dict_get_key(xbt_dict_t dict, const void *data)
+{
int i;
xbt_dictelm_t current;
*
* Remove the entry associated with the given \a key (throws not_found)
*/
-XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
+XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
+ int key_len)
{
* of data, as long as its length is provided in \a key_len.
*/
XBT_INLINE void xbt_dicti_set(xbt_dict_t dict,
- uintptr_t key, uintptr_t data) {
+ uintptr_t key, uintptr_t data)
+{
- unsigned int hash_code = xbt_dict_hash_ext((void*)&key, sizeof(uintptr_t));
+ unsigned int hash_code =
+ xbt_dict_hash_ext((void *) &key, sizeof(uintptr_t));
xbt_dictelm_t current, previous = NULL;
xbt_assert(dict);
- DEBUG5("ADD %zu->%zu; hash = %d, size = %d, & = %d", key, data, hash_code,
- dict->table_size, hash_code & dict->table_size);
+ DEBUG5("ADD %zu->%zu; hash = %d, size = %d, & = %d", key, data,
+ hash_code, dict->table_size, hash_code & dict->table_size);
current = dict->table[hash_code & dict->table_size];
while (current != NULL &&
- (hash_code != current->hash_code || sizeof(uintptr_t) != current->key_len
- || (((uintptr_t)key) != ((uintptr_t)current->key)) )) {
+ (hash_code != current->hash_code
+ || sizeof(uintptr_t) != current->key_len
+ || (((uintptr_t) key) != ((uintptr_t) current->key)))) {
current = current->next;
}
if (current->content != NULL && current->free_f != NULL) {
current->free_f(current->content);
}
- current->content = (void*)data;
+ current->content = (void *) data;
current->free_f = NULL;
}
}
*
* Mixing uintptr_t keys with regular keys in the same dict is discouraged
*/
-XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key) {
+XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key)
+{
- unsigned int hash_code = xbt_dict_hash_ext(((void*)&key), sizeof(uintptr_t));
+ unsigned int hash_code =
+ xbt_dict_hash_ext(((void *) &key), sizeof(uintptr_t));
xbt_dictelm_t current;
xbt_assert(dict);
current = dict->table[hash_code & dict->table_size];
while (current != NULL &&
- (hash_code != current->hash_code || sizeof(uintptr_t) != current->key_len
- || (((uintptr_t)key) != ((uintptr_t)current->key)) )) {
+ (hash_code != current->hash_code
+ || sizeof(uintptr_t) != current->key_len
+ || (((uintptr_t) key) != ((uintptr_t) current->key)))) {
current = current->next;
}
if (current == NULL)
return 0;
- return (uintptr_t)(current->content);
+ return (uintptr_t) (current->content);
}
/** Remove a uintptr_t key from the dict */
-XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key) {
+XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key)
+{
- unsigned int hash_code = xbt_dict_hash_ext(((void*)&key), sizeof(uintptr_t));
+ unsigned int hash_code =
+ xbt_dict_hash_ext(((void *) &key), sizeof(uintptr_t));
xbt_dictelm_t current, previous = NULL;
current = dict->table[hash_code & dict->table_size];
while (current != NULL &&
- (hash_code != current->hash_code || sizeof(uintptr_t) != current->key_len
- || (((uintptr_t)key) != ((uintptr_t)current->key)) )) {
+ (hash_code != current->hash_code
+ || sizeof(uintptr_t) != current->key_len
+ || (((uintptr_t) key) != ((uintptr_t) current->key)))) {
previous = current; /* save the previous node */
current = current->next;
}
{
fputs(s, stdout);
}
+
/**
* \brief test if the dict is empty or not
*/
XBT_INLINE int xbt_dict_is_empty(xbt_dict_t dict)
{
- return (xbt_dict_size(dict) == 0);
+ return (xbt_dict_size(dict) == 0);
}
/**
* This is an internal XBT function called during the lib initialization.
* It can be used several times to recreate the mallocator, for example when you switch to MC mode
*/
-void xbt_dict_preinit(void) {
+void xbt_dict_preinit(void)
+{
if (dict_mallocator != NULL) {
/* Already created. I guess we want to switch to MC mode, so kill the previously created mallocator */
xbt_mallocator_free(dict_mallocator);
}
dict_mallocator = xbt_mallocator_new(256,
- dict_mallocator_new_f,
- dict_mallocator_free_f,
- dict_mallocator_reset_f);
+ dict_mallocator_new_f,
+ dict_mallocator_free_f,
+ dict_mallocator_reset_f);
dict_elm_mallocator = xbt_mallocator_new(256,
- dict_elm_mallocator_new_f,
- dict_elm_mallocator_free_f,
- dict_elm_mallocator_reset_f);
+ dict_elm_mallocator_new_f,
+ dict_elm_mallocator_free_f,
+ dict_elm_mallocator_reset_f);
}
/**
{
char *data = xbt_strdup(data_to_fill);
- xbt_test_log2("Add %s under %s", PRINTF_STR(data_to_fill), PRINTF_STR(key));
+ xbt_test_log2("Add %s under %s", PRINTF_STR(data_to_fill),
+ PRINTF_STR(key));
xbt_dict_set(head, key, data, &free);
if (XBT_LOG_ISENABLED(xbt_dict, xbt_log_priority_debug)) {
TRY {
data = xbt_dict_get(head, data);
- THROW1(unknown_error, 0, "Found something which shouldn't be there (%s)",
- data);
+ THROW1(unknown_error, 0,
+ "Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
length);
xbt_dict_foreach(dict, cursor, key, data)
- effective++;
+ effective++;
xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
effective, length);
static void count_check_get_key(xbt_dict_t dict, int length)
{
xbt_dict_cursor_t cursor;
- char *key,*key2;
+ char *key, *key2;
void *data;
int effective = 0;
- xbt_test_add1("Count elements (expecting %d), and test the getkey function", length);
+ xbt_test_add1
+ ("Count elements (expecting %d), and test the getkey function",
+ length);
xbt_test_assert2(xbt_dict_length(dict) == length,
"Announced length(%d) != %d.", xbt_dict_length(dict),
length);
xbt_dict_foreach(dict, cursor, key, data) {
effective++;
- key2 = xbt_dict_get_key(dict,data);
- xbt_assert2(!strcmp(key,key2),
- "The data was registered under %s instead of %s as expected",key2,key);
+ key2 = xbt_dict_get_key(dict, data);
+ xbt_assert2(!strcmp(key, key2),
+ "The data was registered under %s instead of %s as expected",
+ key2, key);
}
xbt_test_assert2(effective == length, "Effective length(%d) != %d.",
char *data;
-XBT_TEST_UNIT("basic", test_dict_basic,"Basic usage: change, retrieve, traverse")
+XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve, traverse")
{
xbt_test_add0("Traversal the null dictionary");
traverse(head);
xbt_dict_free(&head);
xbt_test_add0
- ("Remove each data manually (traversing the resulting dictionary each time)");
+ ("Remove each data manually (traversing the resulting dictionary each time)");
fill(&head);
debuged_remove(head, "12a");
traverse(head);
}
traverse(head);
- xbt_test_add0("Free dict, create new fresh one, and then reset the dict");
+ xbt_test_add0
+ ("Free dict, create new fresh one, and then reset the dict");
xbt_dict_free(&head);
fill(&head);
xbt_dict_reset(head);
xbt_dict_free(&head);
}
-static void debuged_addi(xbt_dict_t head, uintptr_t key, uintptr_t data) {
- uintptr_t stored_data = 0;
+static void debuged_addi(xbt_dict_t head, uintptr_t key, uintptr_t data)
+{
+ uintptr_t stored_data = 0;
xbt_test_log2("Add %zu under %zu", data, key);
xbt_dicti_set(head, key, data);
fflush(stdout);
}
stored_data = xbt_dicti_get(head, key);
- xbt_test_assert3(stored_data==data,
- "Retrieved data (%zu) is not what I just stored (%zu) under key %zu",stored_data,data,key);
+ xbt_test_assert3(stored_data == data,
+ "Retrieved data (%zu) is not what I just stored (%zu) under key %zu",
+ stored_data, data, key);
}
XBT_TEST_UNIT("dicti", test_dict_scalar, "Scalar data and key management")
for (i = 0; i < 10; i++) {
xbt_test_add2("CRASH test number %d (%d to go)", i + 1, 10 - i - 1);
- xbt_test_log0("Fill the struct, count its elems and frees the structure");
- xbt_test_log1("using 1000 elements with %d chars long randomized keys.",
- SIZEOFKEY);
+ xbt_test_log0
+ ("Fill the struct, count its elems and frees the structure");
+ xbt_test_log1
+ ("using 1000 elements with %d chars long randomized keys.",
+ SIZEOFKEY);
head = xbt_dict_new();
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
nb = 0;
}
/*xbt_dict_dump(head,(void (*)(void*))&printf); */
- xbt_test_add0("Count the elements (retrieving the key and data for each)");
+ xbt_test_add0
+ ("Count the elements (retrieving the key and data for each)");
i = countelems(head);
xbt_test_log1("There is %d elements", i);
"with get, key=%s != data=%s", key, (char *) data);
data = xbt_dict_get_ext(head, key, strlen(key));
xbt_test_assert2(!strcmp(key, (char *) data),
- "with get_ext, key=%s != data=%s", key, (char *) data);
+ "with get_ext, key=%s != data=%s", key,
+ (char *) data);
}
}
free(key);
xbt_test_add0("Generic multicache CRASH test");
- xbt_test_log4(" Fill the struct and frees it %d times, using %d elements, "
- "depth of multicache=%d, key size=%d",
- NB_TEST, NB_ELM, DEPTH, KEY_SIZE);
+ xbt_test_log4
+ (" Fill the struct and frees it %d times, using %d elements, "
+ "depth of multicache=%d, key size=%d", NB_TEST, NB_ELM, DEPTH,
+ KEY_SIZE);
for (l = 0; l < DEPTH; l++) {
key = xbt_malloc(KEY_SIZE);
xbt_dynar_free(&keys);
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
* @param dict on what to let the cursor iterate
* @param[out] cursor dest address
*/
-XBT_INLINE void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t * cursor)
+XBT_INLINE void xbt_dict_cursor_first(const xbt_dict_t dict,
+ xbt_dict_cursor_t * cursor)
{
DEBUG0("xbt_dict_cursor_first");
if (!*cursor) {
* @returns true if it's ok, false if there is no more data
*/
XBT_INLINE int xbt_dict_cursor_get_or_free(xbt_dict_cursor_t * cursor,
- char **key, void **data)
+ char **key, void **data)
{
xbt_dictelm_t current;
* @param free_ctn the function to free the new data
*/
XBT_INLINE void xbt_dict_cursor_set_data(xbt_dict_cursor_t cursor,
- void *data, void_f_pvoid_t free_ctn)
+ void *data,
+ void_f_pvoid_t free_ctn)
{
__cursor_not_null(cursor);
- if(cursor->current->free_f)
+ if (cursor->current->free_f)
cursor->current->free_f(cursor->current->content);
-
+
cursor->current->content = data;
cursor->current->free_f = free_ctn;
return;
}
-
-
-
{
xbt_dictelm_t element = xbt_mallocator_get(dict_elm_mallocator);
- element->dictielem = 0; /* please free the key on free */
+ element->dictielem = 0; /* please free the key on free */
element->key = xbt_new(char, key_len + 1);
- memcpy((void *)element->key, (void *)key, key_len);
+ memcpy((void *) element->key, (void *) key, key_len);
element->key[key_len] = '\0';
element->key_len = key_len;
return element;
}
-xbt_dictelm_t xbt_dictielm_new(uintptr_t key, unsigned int hash_code, uintptr_t content) {
+xbt_dictelm_t xbt_dictielm_new(uintptr_t key, unsigned int hash_code,
+ uintptr_t content)
+{
xbt_dictelm_t element = xbt_mallocator_get(dict_elm_mallocator);
- element->key = (void*)key;
+ element->key = (void *) key;
- element->dictielem = 1; /* please DONT free the key on free */
+ element->dictielem = 1; /* please DONT free the key on free */
element->key_len = sizeof(uintptr_t);
element->hash_code = hash_code;
- element->content = (void*)content;
+ element->content = (void *) content;
element->free_f = NULL;
element->next = NULL;
DEBUG2("xbt_multidict_set(%p,%d)", mdict, keys_len);
- for (i = 0, thislevel = mdict; i < keys_len - 1; i++, thislevel = nextlevel) {
+ for (i = 0, thislevel = mdict; i < keys_len - 1;
+ i++, thislevel = nextlevel) {
xbt_dynar_get_cpy(keys, i, &thiskey);
xbt_dynar_get_cpy(lens, i, &thislen);
/* make sure the dict of next level exists */
nextlevel = xbt_dict_new();
VERB1("Create a dict (%p)", nextlevel);
- xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict);
+ xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel,
+ &_free_dict);
}
}
DEBUG2("xbt_multidict_get(%p, %ld)", mdict, xbt_dynar_length(keys));
- for (i = 0, thislevel = mdict; i < keys_len - 1; i++, thislevel = nextlevel) {
+ for (i = 0, thislevel = mdict; i < keys_len - 1;
+ i++, thislevel = nextlevel) {
xbt_dynar_get_cpy(keys, i, &thiskey);
xbt_dynar_get_cpy(lens, i, &thislen);
*/
void
-xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens)
+xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys,
+ xbt_dynar_t lens)
{
xbt_dict_t thislevel, nextlevel = NULL;
int i;
xbt_assert0(xbt_dynar_length(keys),
"Can't remove a zero-long key set in a multidict");
- for (i = 0, thislevel = mdict; i < keys_len - 1; i++, thislevel = nextlevel) {
+ for (i = 0, thislevel = mdict; i < keys_len - 1;
+ i++, thislevel = nextlevel) {
xbt_dynar_get_cpy(keys, i, &thiskey);
xbt_dynar_get_cpy(lens, i, &thislen);
xbt_dictelm_t xbt_dictelm_new(const char *key, int key_len,
unsigned int hash_code, void *content,
void_f_pvoid_t free_f);
-xbt_dictelm_t xbt_dictielm_new(uintptr_t key, unsigned int hash_code, uintptr_t content);
+xbt_dictelm_t xbt_dictielm_new(uintptr_t key, unsigned int hash_code,
+ uintptr_t content);
void xbt_dictelm_free(xbt_dictelm_t element);
void xbt_dict_add_element(xbt_dict_t dict, xbt_dictelm_t element);
-#endif /* _XBT_DICT_PRIVATE_H_ */
+#endif /* _XBT_DICT_PRIVATE_H_ */
}
}
-static XBT_INLINE void _check_sloppy_inbound_idx(xbt_dynar_t dynar, int idx)
+static XBT_INLINE void _check_sloppy_inbound_idx(xbt_dynar_t dynar,
+ int idx)
{
if (idx > dynar->used) {
_dynar_unlock(dynar);
static void _dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op);
static XBT_INLINE
- void _xbt_clear_mem(void *const ptr, const unsigned long length)
+ void _xbt_clear_mem(void *const ptr, const unsigned long length)
{
memset(ptr, 0, length);
}
static XBT_INLINE
- void _xbt_dynar_expand(xbt_dynar_t const dynar, const unsigned long nb)
+ void _xbt_dynar_expand(xbt_dynar_t const dynar, const unsigned long nb)
{
const unsigned long old_size = dynar->size;
const unsigned long used_length = used * elmsize;
const unsigned long new_size =
- nb > (2 * (old_size + 1)) ? nb : (2 * (old_size + 1));
+ nb > (2 * (old_size + 1)) ? nb : (2 * (old_size + 1));
const unsigned long new_length = new_size * elmsize;
char *const new_data = (char *) xbt_malloc0(elmsize * new_size);
}
static XBT_INLINE
- void *_xbt_dynar_elm(const xbt_dynar_t dynar, const unsigned long idx)
+ void *_xbt_dynar_elm(const xbt_dynar_t dynar, const unsigned long idx)
{
char *const data = (char *) dynar->data;
const unsigned long elmsize = dynar->elmsize;
}
static XBT_INLINE
- void
+ void
_xbt_dynar_get_elm(void *const dst,
const xbt_dynar_t dynar, const unsigned long idx)
{
}
static XBT_INLINE
- void
+ void
_xbt_dynar_put_elm(const xbt_dynar_t dynar,
const unsigned long idx, const void *const src)
{
}
static XBT_INLINE
- void
+ void
_xbt_dynar_remove_at(xbt_dynar_t const dynar,
const unsigned long idx, void *const object)
{
if (nb_shift) {
offset = nb_shift * dynar->elmsize;
- memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + 1), offset);
+ memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + 1),
+ offset);
}
dynar->used--;
void xbt_dynar_dump(xbt_dynar_t dynar)
{
INFO5("Dynar dump: size=%lu; used=%lu; elmsize=%lu; data=%p; free_f=%p",
- dynar->size, dynar->used, dynar->elmsize, dynar->data, dynar->free_f);
+ dynar->size, dynar->used, dynar->elmsize, dynar->data,
+ dynar->free_f);
}
/** @brief Constructor
*
*/
xbt_dynar_t
-xbt_dynar_new_sync(const unsigned long elmsize, void_f_pvoid_t const free_f)
+xbt_dynar_new_sync(const unsigned long elmsize,
+ void_f_pvoid_t const free_f)
{
xbt_dynar_t res = xbt_dynar_new(elmsize, free_f);
res->mutex = xbt_mutex_init();
XBT_INLINE int xbt_dynar_is_empty(const xbt_dynar_t dynar)
{
- return (xbt_dynar_length(dynar) == 0);
+ return (xbt_dynar_length(dynar) == 0);
}
/** @brief Retrieve a copy of the Nth element of a dynar.
* \warning The returned value is the actual content of the dynar.
* Make a copy before fooling with it.
*/
-XBT_INLINE void *xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+XBT_INLINE void *xbt_dynar_get_ptr(const xbt_dynar_t dynar,
+ const unsigned long idx)
{
void *res;
*
* If you want to free the previous content, use xbt_dynar_replace().
*/
-XBT_INLINE void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void *const src)
+XBT_INLINE void xbt_dynar_set(xbt_dynar_t dynar, const int idx,
+ const void *const src)
{
_dynar_lock(dynar);
}
_dynar_unlock(dynar);
- THROW2(not_found_error, 0, "Element %p not part of dynar %p", elem, dynar);
+ THROW2(not_found_error, 0, "Element %p not part of dynar %p", elem,
+ dynar);
}
/** @brief Returns a boolean indicating whether the element is part of the dynar */
}
/** @brief Add an element at the end of the dynar */
-XBT_INLINE void xbt_dynar_push(xbt_dynar_t const dynar, const void *const src)
+XBT_INLINE void xbt_dynar_push(xbt_dynar_t const dynar,
+ const void *const src)
{
_dynar_lock(dynar);
/* checks done in xbt_dynar_insert_at_ptr */
- memcpy(_xbt_dynar_insert_at_ptr(dynar, dynar->used), src, dynar->elmsize);
+ memcpy(_xbt_dynar_insert_at_ptr(dynar, dynar->used), src,
+ dynar->elmsize);
_dynar_unlock(dynar);
}
*
* This is less efficient than xbt_dynar_push()
*/
-XBT_INLINE void xbt_dynar_unshift(xbt_dynar_t const dynar, const void *const src)
+XBT_INLINE void xbt_dynar_unshift(xbt_dynar_t const dynar,
+ const void *const src)
{
/* sanity checks done by insert_at */
* operation, so make sure your function don't call any function
* from xbt_dynar_* on it, or you'll get a deadlock.
*/
-XBT_INLINE void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
+XBT_INLINE void xbt_dynar_map(const xbt_dynar_t dynar,
+ void_f_pvoid_t const op)
{
_sanity_check_dynar(dynar);
*
* This function can be used while traversing without problem.
*/
-XBT_INLINE void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int *const cursor)
+XBT_INLINE void xbt_dynar_cursor_rm(xbt_dynar_t dynar,
+ unsigned int *const cursor)
{
_xbt_dynar_remove_at(dynar, (*cursor)--, NULL);
* Remark: if the elements stored in the dynar are structures, the compar_fn
* function has to retrieve the field to sort first.
*/
-XBT_INLINE void xbt_dynar_sort(xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn){
+XBT_INLINE void xbt_dynar_sort(xbt_dynar_t dynar,
+ int_f_cpvoid_cpvoid_t compar_fn)
+{
- _dynar_lock(dynar);
+ _dynar_lock(dynar);
- qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
+ qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
- _dynar_unlock(dynar);
+ _dynar_unlock(dynar);
}
#ifdef SIMGRID_TEST
xbt_dynar_foreach(d, cursor, i) {
xbt_assert0(0, "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1
- ("==== Push %d int, set them again 3 times, traverse them, shift them",
- NB_ELEM);
+ ("==== Push %d int, set them again 3 times, traverse them, shift them",
+ NB_ELEM);
/* Populate_ints [doxygen cruft] */
/* 1. Populate the dynar */
d = xbt_dynar_new(sizeof(int), NULL);
}
/* 5. Free the resources */
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Unshift/pop %d int", NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
i, cpt);
xbt_test_log2("Pop %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1
- ("==== Push %d int, insert 1000 int in the middle, shift everything",
- NB_ELEM);
+ ("==== Push %d int, insert 1000 int in the middle, shift everything",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt);
"The retrieved value is not the same than the injected one at the end (%d!=%d)",
i, cpt);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
- xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest", NB_ELEM);
+ xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++)
xbt_dynar_push_as(d, int, cpt);
"Remove a bad value. Got %d, expected %d", i, cpt);
DEBUG2("remove %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
}
/*******************************************************************************/
xbt_test_add0("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(int), NULL);
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert0(FALSE, "Damnit, there is something in the empty dynar");
+ xbt_test_assert0(FALSE,
+ "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Push/shift 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Unshift/pop 5000 doubles");
d = xbt_dynar_new(sizeof(double), NULL);
"The retrieved value is not the same than the injected one (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0
- ("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
+ ("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
d = xbt_dynar_new(sizeof(double), NULL);
for (cpt = 0; cpt < 5000; cpt++) {
d1 = (double) cpt;
"The retrieved value is not the same than the injected one at the end (%f!=%f)",
d1, d2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add0("==== Push 5000 double, remove 2000-4000. free the rest");
xbt_test_assert2(d1 == d2,
"Remove a bad value. Got %f, expected %f", d2, d1);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
}
xbt_test_add0("==== Traverse the empty dynar");
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
xbt_dynar_foreach(d, iter, s1) {
- xbt_test_assert0(FALSE, "Damnit, there is something in the empty dynar");
+ xbt_test_assert0(FALSE,
+ "Damnit, there is something in the empty dynar");
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",
NB_ELEM);
buf, s2);
free(s2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add1("==== Unshift, traverse and pop %d strings", NB_ELEM);
d = xbt_dynar_new(sizeof(char **), &xbt_free_ref);
free(s2);
}
/* 4. Free the resources */
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
xbt_test_add2
- ("==== Push %d strings, insert %d strings in the middle, shift everything",
- NB_ELEM, NB_ELEM / 5);
+ ("==== Push %d strings, insert %d strings in the middle, shift everything",
+ NB_ELEM, NB_ELEM / 5);
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
buf, s2);
free(s2);
}
- xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
- xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
- /* in your code is naturally the way to go outside a regression test */
+ xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */
+ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */
+ /* in your code is naturally the way to go outside a regression test */
- xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest", NB_ELEM,
- 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
+ xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",
+ NB_ELEM, 2 * (NB_ELEM / 5), 4 * (NB_ELEM / 5));
d = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
sprintf(buf, "%d", cpt);
}
-XBT_TEST_UNIT("synchronized int", test_dynar_sync_int,"Synchronized dynars of integers")
+XBT_TEST_UNIT("synchronized int", test_dynar_sync_int, "Synchronized dynars of integers")
{
/* Vars_decl [doxygen cruft] */
xbt_dynar_t d;
xbt_test_add0("==== Have a pusher and a popper on the dynar");
d = xbt_dynar_new_sync(sizeof(int), NULL);
- pusher = xbt_thread_create("pusher", pusher_f, d,0/*not joinable*/);
- poper = xbt_thread_create("poper", poper_f, d,0/*not joinable*/);
+ pusher = xbt_thread_create("pusher", pusher_f, d, 0 /*not joinable */ );
+ poper = xbt_thread_create("poper", poper_f, d, 0 /*not joinable */ );
xbt_thread_join(pusher);
xbt_thread_join(poper);
xbt_dynar_free(&d);
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
* \return the printable name of an error code
*
*/
-const char *xbt_error_name(xbt_error_t errcode) {
+const char *xbt_error_name(xbt_error_t errcode)
+{
switch (errcode) {
- case no_error: return "success";
- case old_mismatch_error: return "mismatch";
- case old_system_error: return "system";
- case old_network_error: return "network";
- case old_timeout_error: return "timeout";
- case old_thread_error: return "thread";
- case old_unknown_error: return "unclassified";
- default:
- return "SEVERE ERROR in error repporting module";
+ case no_error:
+ return "success";
+ case old_mismatch_error:
+ return "mismatch";
+ case old_system_error:
+ return "system";
+ case old_network_error:
+ return "network";
+ case old_timeout_error:
+ return "timeout";
+ case old_thread_error:
+ return "thread";
+ case old_unknown_error:
+ return "unclassified";
+ default:
+ return "SEVERE ERROR in error repporting module";
}
}
*
* If you want to pass arguments to the format, you can always write xbt_assert1(0,"fmt",args)
*/
-void xbt_die (const char *msg) {
- CRITICAL1("%s",msg);
+void xbt_die(const char *msg)
+{
+ CRITICAL1("%s", msg);
xbt_abort();
}
/** @brief Kill the program in silence */
-void xbt_abort(void) {
+void xbt_abort(void)
+{
abort();
}
/* the externally visible API */
XBT_EXPORT_NO_IMPORT(ex_ctx_cb_t) __xbt_ex_ctx = &__xbt_ex_ctx_default;
XBT_EXPORT_NO_IMPORT(ex_term_cb_t) __xbt_ex_terminate =
- &__xbt_ex_terminate_default;
+ &__xbt_ex_terminate_default;
- void xbt_ex_free(xbt_ex_t e)
+void xbt_ex_free(xbt_ex_t e)
{
int i;
cp3 = mallocex(SMALLAMOUNT);
strcpy(cp1, "foo");
strcpy(cp2, "bar");
- } TRY_CLEANUP { /*04 */
+ } TRY_CLEANUP { /*04 */
printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
if (cp3 != NULL)
free(cp3);
}
/* end_of_good_example */
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
/* Change raw libc symbols to file names and line numbers */
void xbt_ex_setup_backtrace(xbt_ex_t * e);
-#endif /* _XBT_EX_INTERFACE_H_ */
+#endif /* _XBT_EX_INTERFACE_H_ */
* These are internal XBT functions called by xbt_preinit/postexit().
* It can be used several times to recreate the mallocator, for example when you switch to MC mode
*/
-void xbt_fifo_preinit(void) {
+void xbt_fifo_preinit(void)
+{
if (item_mallocator != NULL) {
/* Already created. I guess we want to switch to MC mode, so kill the previously created mallocator */
xbt_mallocator_free(item_mallocator);
fifo_item_mallocator_reset_f);
}
-void xbt_fifo_postexit(void) {
+void xbt_fifo_postexit(void)
+{
if (item_mallocator != NULL) {
xbt_mallocator_free(item_mallocator);
item_mallocator = NULL;
/* return NULL; */
/* } */
-#endif /* _XBT_FIFO_PRIVATE_H */
+#endif /* _XBT_FIFO_PRIVATE_H */
return edge;
}
-xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src, xbt_node_t dst)
+xbt_edge_t xbt_graph_get_edge(xbt_graph_t g, xbt_node_t src,
+ xbt_node_t dst)
{
xbt_edge_t edge;
unsigned int cursor;
}
xbt_dynar_foreach(g->nodes, cursor, node)
- free(node);
+ free(node);
xbt_dynar_free(&(g->nodes));
xbt_dynar_foreach(g->edges, cursor, edge)
- free(edge);
+ free(edge);
xbt_dynar_free(&(g->edges));
if (graph_free_function)
(*graph_free_function) (g->data);
cursor = 0;
xbt_dynar_foreach(g->nodes, cursor, node)
- if (node == n)
+ if (node == n)
xbt_dynar_cursor_rm(g->nodes, &cursor);
xbt_dynar_free(&(n->in));
node->xbtdata = (void *) 1;
edge_list = node->out;
xbt_dynar_foreach(edge_list, cursor, e)
- xbt_heap_push(heap, e, -(e->length));
+ xbt_heap_push(heap, e, -(e->length));
while ((edge = xbt_heap_pop(heap))) {
if ((edge->src->xbtdata) && (edge->dst->xbtdata))
sorted = xbt_malloc(n * sizeof(xbt_node_t));
xbt_dynar_foreach(g->nodes, cursor, node)
- node->xbtdata = xbt_new0(int, 1);
+ node->xbtdata = xbt_new0(int, 1);
xbt_dynar_foreach(g->nodes, cursor, node)
- xbt_graph_depth_visit(g, node, sorted, &idx);
+ xbt_graph_depth_visit(g, node, sorted, &idx);
xbt_dynar_foreach(g->nodes, cursor, node) {
free(node->xbtdata);
if (__parse_node_label_and_data)
node->data = __parse_node_label_and_data(node, A_graphxml_node_label,
A_graphxml_node_data);
- xbt_graph_parse_get_double(&(node->position_x), A_graphxml_node_position_x);
- xbt_graph_parse_get_double(&(node->position_y), A_graphxml_node_position_y);
+ xbt_graph_parse_get_double(&(node->position_x),
+ A_graphxml_node_position_x);
+ xbt_graph_parse_get_double(&(node->position_y),
+ A_graphxml_node_position_y);
xbt_dict_set(parsed_nodes, A_graphxml_node_name, (void *) node, NULL);
}
} s_xbt_graph_t;
void xbt_floyd_algorithm(xbt_graph_t g, double *adj, double *d,
xbt_node_t * p);
-void xbt_graph_depth_visit(xbt_graph_t g, xbt_node_t n, xbt_node_t * sorted,
- int *idx);
+void xbt_graph_depth_visit(xbt_graph_t g, xbt_node_t n,
+ xbt_node_t * sorted, int *idx);
-#endif /* _XBT_GRAPH_PRIVATE_H */
+#endif /* _XBT_GRAPH_PRIVATE_H */
#define YY_RESTORE_YY_MORE_OFFSET
char *xbt_graph_parse_text;
/* Validating XML processor for src/xbt/graphxml.dtd.
- * Generated 2010/10/01 22:34:14.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
/* Validating XML processor for src/xbt/graphxml.dtd.
- * Generated 2010/10/01 22:34:14.
+ * Generated 2010/10/11 11:35:07.
*
* This program was generated with the FleXML XML processor generator.
* FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
{
if (!file) {
WARN0
- ("I hope you know what you're doing... you just gave me a NULL pointer!");
+ ("I hope you know what you're doing... you just gave me a NULL pointer!");
return;
}
if (!xbt_graph_input_buffer_stack)
xbt_graph_input_buffer_stack =
- xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
+ xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
if (!xbt_graph_file_to_parse_stack)
xbt_graph_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
xbt_graph_file_to_parse = fopen(file, "r"); /* FIXME should use something like surf_fopen */
xbt_assert1((xbt_graph_file_to_parse), "Unable to open \"%s\"\n", file);
xbt_graph_input_buffer =
- xbt_graph_parse__create_buffer(xbt_graph_file_to_parse, 10);
+ xbt_graph_parse__create_buffer(xbt_graph_file_to_parse, 10);
xbt_graph_parse__switch_to_buffer(xbt_graph_input_buffer);
xbt_graph_parse_lineno = 1;
}
*
* Creates a new heap.
*/
-XBT_INLINE xbt_heap_t xbt_heap_new(int init_size, void_f_pvoid_t const free_func)
+XBT_INLINE xbt_heap_t xbt_heap_new(int init_size,
+ void_f_pvoid_t const free_func)
{
xbt_heap_t H = xbt_new0(struct xbt_heap, 1);
H->size = init_size;
* \param update_callback function to call on each element to update its index when needed.
*/
XBT_INLINE void xbt_heap_set_update_callback(xbt_heap_t H,
- void (*update_callback) (void *, int))
+ void (*update_callback) (void
+ *,
+ int))
{
H->update_callback = update_callback;
}
if (count > size) {
H->size = 2 * size + 1;
H->items =
- (void *) realloc(H->items, (H->size) * sizeof(struct xbt_heapItem));
+ (void *) realloc(H->items,
+ (H->size) * sizeof(struct xbt_heapItem));
}
item = &(H->items[count - 1]);
if (H->count < H->size / 4 && H->size > 16) {
H->size = H->size / 2 + 1;
H->items =
- (void *) realloc(H->items, (H->size) * sizeof(struct xbt_heapItem));
+ (void *) realloc(H->items,
+ (H->size) * sizeof(struct xbt_heapItem));
}
- if(H->update_callback) H->update_callback(max, -1);
+ if (H->update_callback)
+ H->update_callback(max, -1);
return max;
}
struct xbt_heapItem tmp = H->items[i];
H->items[i] = H->items[greatest];
H->items[greatest] = tmp;
- if(H->update_callback) H->update_callback(CONTENT(H, i), i);
+ if (H->update_callback)
+ H->update_callback(CONTENT(H, i), i);
i = greatest;
} else {
- if(H->update_callback) H->update_callback(CONTENT(H, i), i);
+ if (H->update_callback)
+ H->update_callback(CONTENT(H, i), i);
return;
}
}
struct xbt_heapItem tmp = H->items[i];
H->items[i] = H->items[PARENT(i)];
H->items[PARENT(i)] = tmp;
- if(H->update_callback) H->update_callback(CONTENT(H, i), i);
+ if (H->update_callback)
+ H->update_callback(CONTENT(H, i), i);
i = PARENT(i);
}
- if(H->update_callback) H->update_callback(CONTENT(H, i), i);
+ if (H->update_callback)
+ H->update_callback(CONTENT(H, i), i);
return;
}
-
static void xbt_heap_maxHeapify(xbt_heap_t H);
static void xbt_heap_increaseKey(xbt_heap_t H, int i);
-#endif /* _XBT_HEAP_PRIVATE_H */
+#endif /* _XBT_HEAP_PRIVATE_H */
#include "xbt/dynar.h"
XBT_PUBLIC_DATA(int) (*xbt_pid) ();
-int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
+int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
/** \addtogroup XBT_log
*
welcome here, too.
- *//*' */
+ *//*' */
xbt_log_appender_t xbt_log_default_appender = NULL; /* set in log_init */
s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT) = {
NULL /*parent */ , NULL /* firstChild */ , NULL /* nextSibling */ ,
- "root", xbt_log_priority_uninitialized /* threshold */ ,
- 0 /* isThreshInherited */ ,
- NULL /* appender */ , NULL /* layout */ ,
- 0 /* additivity */
+ "root", xbt_log_priority_uninitialized /* threshold */ ,
+ 0 /* isThreshInherited */ ,
+ NULL /* appender */ , NULL /* layout */ ,
+ 0 /* additivity */
};
XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)");
/* create the default appender and install it in the root category,
which were already created (damnit. Too slow little beetle) */
-void xbt_log_preinit(void) {
+void xbt_log_preinit(void)
+{
xbt_log_default_appender = xbt_log_appender_file_new(NULL);
xbt_log_default_layout = xbt_log_layout_simple_new(NULL);
_XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
*
* xbt_log_control_set() is called on each string we got from cmd line
*/
-void xbt_log_init(int *argc, char **argv) {
+void xbt_log_init(int *argc, char **argv)
+{
int i, j;
char *opt;
if (strncmp(argv[i], "--log=", strlen("--log=")))
WARN2
- ("Option %.*s is deprecated and will disapear in the future. Use --log instead.",
- (int) (strchr(argv[i], '=') - argv[i]), argv[i]);
+ ("Option %.*s is deprecated and will disapear in the future. Use --log instead.",
+ (int) (strchr(argv[i], '=') - argv[i]), argv[i]);
opt = strchr(argv[i], '=');
opt++;
DEBUG2("Set %p as appender of category '%s'",
setting->appender, category->name);
}
-
#undef _xbt_log_cat_init
}
DEBUG3("Set %s (%s) as father of %s ",
category->parent->name,
(category->parent->threshold == xbt_log_priority_uninitialized ?
- "uninited" : xbt_log_priority_names[category->parent->threshold]),
+ "uninited" : xbt_log_priority_names[category->
+ parent->threshold]),
category->name);
xbt_log_parent_set(category, category->parent);
if (parent->threshold == xbt_log_priority_uninitialized) {
- _xbt_log_cat_init(parent, xbt_log_priority_uninitialized /* ignored */ );
+ _xbt_log_cat_init(parent,
+ xbt_log_priority_uninitialized /* ignored */ );
}
cat->threshold = parent->threshold;
*p -= 'a' - 'A';
}
}
- if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES") || !strcmp(neweq, "1")) {
+ if (!strcmp(neweq, "ON") || !strcmp(neweq, "YES")
+ || !strcmp(neweq, "1")) {
set->additivity = 1;
} else {
set->additivity = 0;
} else {
char buff[512];
snprintf(buff, min(512, eq - dot), "%s", dot + 1);
- THROW1(arg_error, 0, "Unknown setting of the log category: '%s'", buff);
+ THROW1(arg_error, 0, "Unknown setting of the log category: '%s'",
+ buff);
}
set->catname = (char *) xbt_malloc(dot - name + 1);
DEBUG1("Parse log settings '%s'", control_string);
/* Special handling of no_loc request, which asks for any file localization to be omitted (for tesh runs) */
- if (!strcmp(control_string,"no_loc")) {
- xbt_log_no_loc=1;
+ if (!strcmp(control_string, "no_loc")) {
+ xbt_log_no_loc = 1;
return;
}
/* some initialization if this is the first time that this get called */
xbt_log_category_t cat = NULL;
set = _xbt_log_parse_setting(str);
- cat = _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
+ cat =
+ _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set->catname);
if (cat) {
DEBUG0("Apply directly");
void xbt_log_layout_set(xbt_log_category_t cat, xbt_log_layout_t lay)
{
if (!cat->appender) {
- VERB1("No appender to category %s. Setting the file appender as default",
- cat->name);
+ VERB1
+ ("No appender to category %s. Setting the file appender as default",
+ cat->name);
xbt_log_appender_set(cat, xbt_log_appender_file_new(NULL));
}
if (cat->layout && cat != &_XBT_LOGV(root)) {
xbt_log_category_t parent);
-#endif /* LOG_PRIVATE_H */
+#endif /* LOG_PRIVATE_H */
#include "mallocator_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mallocator, xbt, "Mallocators");
-extern int _surf_do_model_check; /* kill mallocators when this is true */
+extern int _surf_do_model_check; /* kill mallocators when this is true */
/**
* \brief Constructor
xbt_assert0(new_f != NULL && free_f != NULL
&& reset_f != NULL, "invalid parameter");
- /* Let's force 0 size mallocator! (Dirty hack, blame Martin :) )*/
+ /* Let's force 0 size mallocator! (Dirty hack, blame Martin :) ) */
/* mallocators and memory mess introduced by model-checking do not mix well together:
* The mallocator will give standard memory when we are using raw memory (so these blocks are killed on restore)
*/
if (_surf_do_model_check)
size = 0;
-
+
m = xbt_new0(s_xbt_mallocator_t, 1);
VERB1("Create mallocator %p", m);
if (XBT_LOG_ISENABLED(xbt_mallocator, xbt_log_priority_verbose))
xbt_backtrace_display_current();
- m->objects = xbt_new0(void *, _surf_do_model_check?1:size);
+ m->objects = xbt_new0(void *, _surf_do_model_check ? 1 : size);
m->max_size = size;
m->current_size = 0;
m->new_f = new_f;
int i;
xbt_assert0(m != NULL, "Invalid parameter");
- VERB3("Frees mallocator %p (size:%d/%d)", m, m->current_size, m->max_size);
+ VERB3("Frees mallocator %p (size:%d/%d)", m, m->current_size,
+ m->max_size);
for (i = 0; i < m->current_size; i++) {
(*(m->free_f)) (m->objects[i]);
}
if (m->current_size < m->max_size) {
/* there is enough place to push the object */
DEBUG3
- ("Store deleted object in mallocator %p for further use (size:%d/%d)",
- m, m->current_size, m->max_size);
+ ("Store deleted object in mallocator %p for further use (size:%d/%d)",
+ m, m->current_size, m->max_size);
m->objects[m->current_size++] = object;
} else {
/* otherwise we don't have a choice, we must free the object */
void_f_pvoid_t reset_f; /* function to call when an object is released by the user */
} s_xbt_mallocator_t;
-#endif /* _XBT_MALLOCATOR_PRIVATE_H__ */
+#endif /* _XBT_MALLOCATOR_PRIVATE_H__ */
Boston, MA 02111-1307, USA. */
#include <sys/types.h>
-#include <fcntl.h> /* After sys/types.h, at least for dpx/2. */
+#include <fcntl.h> /* After sys/types.h, at least for dpx/2. */
#include <sys/stat.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* Prototypes for lseek */
+#include <unistd.h> /* Prototypes for lseek */
#endif
#include "mmprivate.h"
/* Forward declarations/prototypes for local functions */
-static struct mdesc *reuse (int fd);
+static struct mdesc *reuse(int fd);
/* Initialize access to a mmalloc managed region.
On failure returns NULL. */
-void * mmalloc_attach (int fd, void *baseaddr) {
+void *mmalloc_attach(int fd, void *baseaddr)
+{
struct mdesc mtemp;
struct mdesc *mdp;
- void* mbase;
+ void *mbase;
struct stat sbuf;
/* First check to see if FD is a valid file descriptor, and if so, see
obsolete version, or any other reason, then we fail to attach to
this file. */
- if (fd >= 0)
- {
- if (fstat (fd, &sbuf) < 0)
+ if (fd >= 0) {
+ if (fstat(fd, &sbuf) < 0)
return (NULL);
else if (sbuf.st_size > 0)
- return ((void*) reuse (fd));
+ return ((void *) reuse(fd));
}
/* If the user provided NULL BASEADDR then fail */
then initialize the fields that we know values for. */
mdp = &mtemp;
- memset ((char *) mdp, 0, sizeof (mtemp));
- strncpy (mdp -> magic, MMALLOC_MAGIC, MMALLOC_MAGIC_SIZE);
- mdp -> headersize = sizeof (mtemp);
- mdp -> version = MMALLOC_VERSION;
- mdp -> morecore = __mmalloc_mmap_morecore;
- mdp -> fd = fd;
- mdp -> base = mdp -> breakval = mdp -> top = baseaddr;
+ memset((char *) mdp, 0, sizeof(mtemp));
+ strncpy(mdp->magic, MMALLOC_MAGIC, MMALLOC_MAGIC_SIZE);
+ mdp->headersize = sizeof(mtemp);
+ mdp->version = MMALLOC_VERSION;
+ mdp->morecore = __mmalloc_mmap_morecore;
+ mdp->fd = fd;
+ mdp->base = mdp->breakval = mdp->top = baseaddr;
/* If we have not been passed a valid open file descriptor for the file
to map to, then we go for an anonymous map */
- if(mdp -> fd < 0)
- mdp -> flags |= MMALLOC_ANONYMOUS;
+ if (mdp->fd < 0)
+ mdp->flags |= MMALLOC_ANONYMOUS;
/* If we have not been passed a valid open file descriptor for the file
to map to, then open /dev/zero and use that to map to. */
fails, then close the file descriptor if it was opened by us, and arrange
to return a NULL. */
- if ((mbase = mdp -> morecore (mdp, sizeof (mtemp))) != NULL)
- {
- memcpy (mbase, mdp, sizeof (mtemp));
+ if ((mbase = mdp->morecore(mdp, sizeof(mtemp))) != NULL) {
+ memcpy(mbase, mdp, sizeof(mtemp));
// mdp = (struct mdesc *) mbase;
- }
- else
- {
+ } else {
abort();
// mdp = NULL;
}
- { /* create the mutex within that heap */
- void*old_heap=mmalloc_get_current_heap();
+ { /* create the mutex within that heap */
+ void *old_heap = mmalloc_get_current_heap();
mmalloc_set_current_heap(mbase);
- mdp->mutex =xbt_os_mutex_init();
+ mdp->mutex = xbt_os_mutex_init();
mmalloc_set_current_heap(old_heap);
}
- return ((void*) mbase);
+ return ((void *) mbase);
}
/* Given an valid file descriptor on an open file, test to see if that file
Returns a pointer to the malloc descriptor if successful, or NULL if
unsuccessful for some reason. */
-static struct mdesc *
-reuse (int fd)
+static struct mdesc *reuse(int fd)
{
struct mdesc mtemp;
struct mdesc *mdp = NULL;
- if (lseek (fd, 0L, SEEK_SET) != 0)
+ if (lseek(fd, 0L, SEEK_SET) != 0)
return NULL;
- if (read (fd, (char *) &mtemp, sizeof (mtemp)) != sizeof (mtemp))
+ if (read(fd, (char *) &mtemp, sizeof(mtemp)) != sizeof(mtemp))
return NULL;
- if (mtemp.headersize != sizeof (mtemp))
+ if (mtemp.headersize != sizeof(mtemp))
return NULL;
- if (strcmp (mtemp.magic, MMALLOC_MAGIC) != 0)
+ if (strcmp(mtemp.magic, MMALLOC_MAGIC) != 0)
return NULL;
if (mtemp.version > MMALLOC_VERSION)
return NULL;
mtemp.fd = fd;
- if (__mmalloc_remap_core (&mtemp) == mtemp.base)
- {
+ if (__mmalloc_remap_core(&mtemp) == mtemp.base) {
mdp = (struct mdesc *) mtemp.base;
- mdp -> fd = fd;
- mdp -> morecore = __mmalloc_mmap_morecore;
- mdp->mutex =xbt_os_mutex_init();
- if (mdp -> mfree_hook != NULL)
- {
- mmcheckf ((void*) mdp, (void (*) (void)) NULL, 1);
+ mdp->fd = fd;
+ mdp->morecore = __mmalloc_mmap_morecore;
+ mdp->mutex = xbt_os_mutex_init();
+ if (mdp->mfree_hook != NULL) {
+ mmcheckf((void *) mdp, (void (*)(void)) NULL, 1);
}
}
- { /* create the mutex within that heap */
- void*old_heap=mmalloc_get_current_heap();
+ { /* create the mutex within that heap */
+ void *old_heap = mmalloc_get_current_heap();
mmalloc_set_current_heap(mdp);
- mdp->mutex =xbt_os_mutex_init();
+ mdp->mutex = xbt_os_mutex_init();
mmalloc_set_current_heap(old_heap);
}
return (mdp);
}
-
/* 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. */
-#include <unistd.h> /* close */
+#include <unistd.h> /* close */
#include <sys/types.h>
#include "mmprivate.h"
region we are about to unmap, so we first make a local copy of it on the
stack and use the copy. */
-void*
-mmalloc_detach (void *md)
+void *mmalloc_detach(void *md)
{
struct mdesc mtemp;
- if (md != NULL)
- {
-
- mtemp = *(struct mdesc *) md;
- xbt_os_mutex_destroy(((struct mdesc*)md)->mutex);
-
- /* Now unmap all the pages associated with this region by asking for a
- negative increment equal to the current size of the region. */
-
- if ((mtemp.morecore (&mtemp, (char*)mtemp.base - (char*)mtemp.breakval)) == NULL)
- {
- /* Deallocating failed. Update the original malloc descriptor
- with any changes */
- *(struct mdesc *) md = mtemp;
- }
- else
- {
- if (mtemp.flags & MMALLOC_DEVZERO)
- {
- close (mtemp.fd);
- }
- md = NULL;
- }
+ if (md != NULL) {
+
+ mtemp = *(struct mdesc *) md;
+ xbt_os_mutex_destroy(((struct mdesc *) md)->mutex);
+
+ /* Now unmap all the pages associated with this region by asking for a
+ negative increment equal to the current size of the region. */
+
+ if ((mtemp.morecore(&mtemp,
+ (char *) mtemp.base - (char *) mtemp.breakval)) ==
+ NULL) {
+ /* Deallocating failed. Update the original malloc descriptor
+ with any changes */
+ *(struct mdesc *) md = mtemp;
+ } else {
+ if (mtemp.flags & MMALLOC_DEVZERO) {
+ close(mtemp.fd);
+ }
+ md = NULL;
}
+ }
return (md);
}
#include "mmprivate.h"
-int
-mmalloc_setkey (void *md, int keynum, void *key)
+int mmalloc_setkey(void *md, int keynum, void *key)
{
struct mdesc *mdp = (struct mdesc *) md;
int result = 0;
LOCK(mdp);
- if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
- {
- mdp -> keys [keynum] = key;
- result++;
- }
+ if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS)) {
+ mdp->keys[keynum] = key;
+ result++;
+ }
UNLOCK(mdp);
return (result);
}
-void*
-mmalloc_getkey (void *md, int keynum)
+void *mmalloc_getkey(void *md, int keynum)
{
struct mdesc *mdp = (struct mdesc *) md;
- void* keyval = NULL;
+ void *keyval = NULL;
- if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
- {
- keyval = mdp -> keys [keynum];
- }
+ if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS)) {
+ keyval = mdp->keys[keynum];
+ }
return (keyval);
}
/* 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. */
-#include <sys/types.h> /* GCC on HP/UX needs this before string.h. */
-#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
+#include <sys/types.h> /* GCC on HP/UX needs this before string.h. */
+#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
#include "mmprivate.h"
/* Allocate an array of NMEMB elements each SIZE bytes long.
The entire array is initialized to zeros. */
-void *
-mcalloc (void *md, register size_t nmemb, register size_t size)
+void *mcalloc(void *md, register size_t nmemb, register size_t size)
{
- register void* result;
+ register void *result;
- if ((result = mmalloc (md, nmemb * size)) != NULL)
- {
- memset (result, 0, nmemb * size);
- }
+ if ((result = mmalloc(md, nmemb * size)) != NULL) {
+ memset(result, 0, nmemb * size);
+ }
return (result);
}
/* Return memory to the heap.
Like `mfree' but don't call a mfree_hook if there is one. */
-void
-__mmalloc_free (struct mdesc *mdp, void *ptr)
+void __mmalloc_free(struct mdesc *mdp, void *ptr)
{
int type;
size_t block;
register size_t i;
struct list *prev, *next;
- block = BLOCK (ptr);
+ block = BLOCK(ptr);
- if ((char*)ptr < (char*)mdp->heapbase || block > mdp->heapsize ) {
+ if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) {
printf("Ouch, this pointer is not mine. I refuse to free it.\n");
return;
}
- type = mdp -> heapinfo[block].busy.type;
- switch (type)
- {
+ type = mdp->heapinfo[block].busy.type;
+ switch (type) {
case 0:
/* Get as many statistics as early as we can. */
- mdp -> heapstats.chunks_used--;
- mdp -> heapstats.bytes_used -=
- mdp -> heapinfo[block].busy.info.size * BLOCKSIZE;
- mdp -> heapstats.bytes_free +=
- mdp -> heapinfo[block].busy.info.size * BLOCKSIZE;
+ mdp->heapstats.chunks_used--;
+ mdp->heapstats.bytes_used -=
+ mdp->heapinfo[block].busy.info.size * BLOCKSIZE;
+ mdp->heapstats.bytes_free +=
+ mdp->heapinfo[block].busy.info.size * BLOCKSIZE;
/* Find the free cluster previous to this one in the free list.
- Start searching at the last block referenced; this may benefit
- programs with locality of allocation. */
- i = mdp -> heapindex;
- if (i > block)
- {
- while (i > block)
- {
- i = mdp -> heapinfo[i].free.prev;
+ Start searching at the last block referenced; this may benefit
+ programs with locality of allocation. */
+ i = mdp->heapindex;
+ if (i > block) {
+ while (i > block) {
+ i = mdp->heapinfo[i].free.prev;
}
- }
- else
- {
- do
- {
- i = mdp -> heapinfo[i].free.next;
+ } else {
+ do {
+ i = mdp->heapinfo[i].free.next;
}
while ((i != 0) && (i < block));
- i = mdp -> heapinfo[i].free.prev;
+ i = mdp->heapinfo[i].free.prev;
}
/* Determine how to link this block into the free list. */
- if (block == i + mdp -> heapinfo[i].free.size)
- {
+ if (block == i + mdp->heapinfo[i].free.size) {
/* Coalesce this block with its predecessor. */
- mdp -> heapinfo[i].free.size +=
- mdp -> heapinfo[block].busy.info.size;
+ mdp->heapinfo[i].free.size += mdp->heapinfo[block].busy.info.size;
block = i;
- }
- else
- {
+ } else {
/* Really link this block back into the free list. */
- mdp -> heapinfo[block].free.size =
- mdp -> heapinfo[block].busy.info.size;
- mdp -> heapinfo[block].free.next = mdp -> heapinfo[i].free.next;
- mdp -> heapinfo[block].free.prev = i;
- mdp -> heapinfo[i].free.next = block;
- mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev = block;
- mdp -> heapstats.chunks_free++;
+ mdp->heapinfo[block].free.size = mdp->heapinfo[block].busy.info.size;
+ mdp->heapinfo[block].free.next = mdp->heapinfo[i].free.next;
+ mdp->heapinfo[block].free.prev = i;
+ mdp->heapinfo[i].free.next = block;
+ mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev = block;
+ mdp->heapstats.chunks_free++;
}
/* Now that the block is linked in, see if we can coalesce it
- with its successor (by deleting its successor from the list
- and adding in its size). */
- if (block + mdp -> heapinfo[block].free.size ==
- mdp -> heapinfo[block].free.next)
- {
- mdp -> heapinfo[block].free.size
- += mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.size;
- mdp -> heapinfo[block].free.next
- = mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.next;
- mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev = block;
- mdp -> heapstats.chunks_free--;
+ with its successor (by deleting its successor from the list
+ and adding in its size). */
+ if (block + mdp->heapinfo[block].free.size ==
+ mdp->heapinfo[block].free.next) {
+ mdp->heapinfo[block].free.size
+ += mdp->heapinfo[mdp->heapinfo[block].free.next].free.size;
+ mdp->heapinfo[block].free.next
+ = mdp->heapinfo[mdp->heapinfo[block].free.next].free.next;
+ mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev = block;
+ mdp->heapstats.chunks_free--;
}
/* Now see if we can return stuff to the system. */
/* blocks = mdp -> heapinfo[block].free.size;
- if (blocks >= FINAL_FREE_BLOCKS && block + blocks == mdp -> heaplimit
- && mdp -> morecore (mdp, 0) == ADDRESS (block + blocks))
- {
- register size_t bytes = blocks * BLOCKSIZE;
- mdp -> heaplimit -= blocks;
- mdp -> morecore (mdp, -bytes);
- mdp -> heapinfo[mdp -> heapinfo[block].free.prev].free.next
- = mdp -> heapinfo[block].free.next;
- mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev
- = mdp -> heapinfo[block].free.prev;
- block = mdp -> heapinfo[block].free.prev;
- mdp -> heapstats.chunks_free--;
- mdp -> heapstats.bytes_free -= bytes;
- }*/
+ if (blocks >= FINAL_FREE_BLOCKS && block + blocks == mdp -> heaplimit
+ && mdp -> morecore (mdp, 0) == ADDRESS (block + blocks))
+ {
+ register size_t bytes = blocks * BLOCKSIZE;
+ mdp -> heaplimit -= blocks;
+ mdp -> morecore (mdp, -bytes);
+ mdp -> heapinfo[mdp -> heapinfo[block].free.prev].free.next
+ = mdp -> heapinfo[block].free.next;
+ mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev
+ = mdp -> heapinfo[block].free.prev;
+ block = mdp -> heapinfo[block].free.prev;
+ mdp -> heapstats.chunks_free--;
+ mdp -> heapstats.bytes_free -= bytes;
+ } */
/* Set the next search to begin at this block. */
- mdp -> heapindex = block;
+ mdp->heapindex = block;
break;
default:
/* Do some of the statistics. */
- mdp -> heapstats.chunks_used--;
- mdp -> heapstats.bytes_used -= 1 << type;
- mdp -> heapstats.chunks_free++;
- mdp -> heapstats.bytes_free += 1 << type;
+ mdp->heapstats.chunks_used--;
+ mdp->heapstats.bytes_used -= 1 << type;
+ mdp->heapstats.chunks_free++;
+ mdp->heapstats.bytes_free += 1 << type;
/* Get the address of the first free fragment in this block. */
prev = (struct list *)
- ((char*) ADDRESS(block) +
- ( mdp -> heapinfo[block].busy.info.frag.first << type));
+ ((char *) ADDRESS(block) +
+ (mdp->heapinfo[block].busy.info.frag.first << type));
- if (mdp -> heapinfo[block].busy.info.frag.nfree ==
- (BLOCKSIZE >> type) - 1)
- {
+ if (mdp->heapinfo[block].busy.info.frag.nfree ==
+ (BLOCKSIZE >> type) - 1) {
/* If all fragments of this block are free, remove them
- from the fragment list and free the whole block. */
+ from the fragment list and free the whole block. */
next = prev;
- for (i = 1; i < (size_t) (BLOCKSIZE >> type); ++i)
- {
- next = next -> next;
+ for (i = 1; i < (size_t) (BLOCKSIZE >> type); ++i) {
+ next = next->next;
}
- prev -> prev -> next = next;
- if (next != NULL)
- {
- next -> prev = prev -> prev;
+ prev->prev->next = next;
+ if (next != NULL) {
+ next->prev = prev->prev;
}
- mdp -> heapinfo[block].busy.type = 0;
- mdp -> heapinfo[block].busy.info.size = 1;
+ mdp->heapinfo[block].busy.type = 0;
+ mdp->heapinfo[block].busy.info.size = 1;
/* Keep the statistics accurate. */
- mdp -> heapstats.chunks_used++;
- mdp -> heapstats.bytes_used += BLOCKSIZE;
- mdp -> heapstats.chunks_free -= BLOCKSIZE >> type;
- mdp -> heapstats.bytes_free -= BLOCKSIZE;
+ mdp->heapstats.chunks_used++;
+ mdp->heapstats.bytes_used += BLOCKSIZE;
+ mdp->heapstats.chunks_free -= BLOCKSIZE >> type;
+ mdp->heapstats.bytes_free -= BLOCKSIZE;
- mfree ((void*) mdp, (void*) ADDRESS(block));
- }
- else if (mdp -> heapinfo[block].busy.info.frag.nfree != 0)
- {
+ mfree((void *) mdp, (void *) ADDRESS(block));
+ } else if (mdp->heapinfo[block].busy.info.frag.nfree != 0) {
/* If some fragments of this block are free, link this
- fragment into the fragment list after the first free
- fragment of this block. */
+ fragment into the fragment list after the first free
+ fragment of this block. */
next = (struct list *) ptr;
- next -> next = prev -> next;
- next -> prev = prev;
- prev -> next = next;
- if (next -> next != NULL)
- {
- next -> next -> prev = next;
+ next->next = prev->next;
+ next->prev = prev;
+ prev->next = next;
+ if (next->next != NULL) {
+ next->next->prev = next;
}
- ++mdp -> heapinfo[block].busy.info.frag.nfree;
- }
- else
- {
+ ++mdp->heapinfo[block].busy.info.frag.nfree;
+ } else {
/* No fragments of this block are free, so link this
- fragment into the fragment list and announce that
- it is the first free fragment of this block. */
+ fragment into the fragment list and announce that
+ it is the first free fragment of this block. */
prev = (struct list *) ptr;
- mdp -> heapinfo[block].busy.info.frag.nfree = 1;
- mdp -> heapinfo[block].busy.info.frag.first =
- RESIDUAL (ptr, BLOCKSIZE) >> type;
- prev -> next = mdp -> fraghead[type].next;
- prev -> prev = &mdp -> fraghead[type];
- prev -> prev -> next = prev;
- if (prev -> next != NULL)
- {
- prev -> next -> prev = prev;
+ mdp->heapinfo[block].busy.info.frag.nfree = 1;
+ mdp->heapinfo[block].busy.info.frag.first =
+ RESIDUAL(ptr, BLOCKSIZE) >> type;
+ prev->next = mdp->fraghead[type].next;
+ prev->prev = &mdp->fraghead[type];
+ prev->prev->next = prev;
+ if (prev->next != NULL) {
+ prev->next->prev = prev;
}
}
break;
/* Return memory to the heap. */
-void mfree (void *md, void *ptr) {
+void mfree(void *md, void *ptr)
+{
struct mdesc *mdp;
register struct alignlist *l;
if (ptr != NULL) {
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
LOCK(mdp);
- for (l = mdp -> aligned_blocks; l != NULL; l = l -> next) {
- if (l -> aligned == ptr) {
- l -> aligned = NULL; /* Mark the slot in the list as free. */
- ptr = l -> exact;
+ for (l = mdp->aligned_blocks; l != NULL; l = l->next) {
+ if (l->aligned == ptr) {
+ l->aligned = NULL; /* Mark the slot in the list as free. */
+ ptr = l->exact;
break;
}
}
- if (mdp -> mfree_hook != NULL) {
- (*mdp -> mfree_hook) (mdp, ptr);
+ if (mdp->mfree_hook != NULL) {
+ (*mdp->mfree_hook) (mdp, ptr);
} else {
- __mmalloc_free (mdp, ptr);
+ __mmalloc_free(mdp, ptr);
}
UNLOCK(mdp);
}
}
-
* under the terms of the license (GNU LGPL) which comes with this package. */
#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* Prototypes for lseek, sbrk (maybe) */
+#include <unistd.h> /* Prototypes for lseek, sbrk (maybe) */
#endif
#include "mcalloc.c"
#include "mfree.c"
#include "mmprivate.h"
-static void *__mmalloc_current_heap=NULL; /* The heap we are currently using. */
+static void *__mmalloc_current_heap = NULL; /* The heap we are currently using. */
#include "xbt_modinter.h"
-void* mmalloc_get_current_heap(void) {
+void *mmalloc_get_current_heap(void)
+{
return __mmalloc_current_heap;
}
-void mmalloc_set_current_heap(void *new_heap) {
- __mmalloc_current_heap=new_heap;
+
+void mmalloc_set_current_heap(void *new_heap)
+{
+ __mmalloc_current_heap = new_heap;
}
#ifdef MMALLOC_WANT_OVERIDE_LEGACY
-void *malloc(size_t n) {
+void *malloc(size_t n)
+{
#ifdef HAVE_MMAP
- if (!__mmalloc_current_heap) mmalloc_preinit();
+ if (!__mmalloc_current_heap)
+ mmalloc_preinit();
#endif
void *ret = mmalloc(__mmalloc_current_heap, n);
return ret;
}
-void *calloc(size_t nmemb, size_t size) {
+void *calloc(size_t nmemb, size_t size)
+{
size_t total_size = nmemb * size;
#ifdef HAVE_MMAP
- if (!__mmalloc_current_heap) mmalloc_preinit();
+ if (!__mmalloc_current_heap)
+ mmalloc_preinit();
#endif
void *ret = mmalloc(__mmalloc_current_heap, total_size);
/* Fill the allocated memory with zeroes to mimic calloc behaviour */
- memset(ret,'\0', total_size);
+ memset(ret, '\0', total_size);
return ret;
}
-void *realloc(void *p, size_t s) {
+void *realloc(void *p, size_t s)
+{
void *ret = NULL;
#ifdef HAVE_MMAP
- if (!__mmalloc_current_heap) mmalloc_preinit();
+ if (!__mmalloc_current_heap)
+ mmalloc_preinit();
#endif
if (s) {
- if (p)
- ret = mrealloc(__mmalloc_current_heap, p,s);
- else
- ret = mmalloc(__mmalloc_current_heap,s);
+ if (p)
+ ret = mrealloc(__mmalloc_current_heap, p, s);
+ else
+ ret = mmalloc(__mmalloc_current_heap, s);
} else {
- if (p)
- mfree(__mmalloc_current_heap,p);
+ if (p)
+ mfree(__mmalloc_current_heap, p);
}
return ret;
}
-void free(void *p) {
+void free(void *p)
+{
return mfree(__mmalloc_current_heap, p);
}
#endif
/* Make sure it works with md==NULL */
-#define HEAP_OFFSET 40960000 /* Safety gap from the heap's break address */
+#define HEAP_OFFSET 40960000 /* Safety gap from the heap's break address */
-void *mmalloc_get_default_md(void) {
+void *mmalloc_get_default_md(void)
+{
xbt_assert(__mmalloc_default_mdp);
return __mmalloc_default_mdp;
}
/* Initialize the default malloc descriptor. */
-void mmalloc_preinit(void) {
- if(!__mmalloc_default_mdp) __mmalloc_default_mdp = mmalloc_attach(-1, (char *)sbrk(0) + HEAP_OFFSET);
+void mmalloc_preinit(void)
+{
+ if (!__mmalloc_default_mdp)
+ __mmalloc_default_mdp =
+ mmalloc_attach(-1, (char *) sbrk(0) + HEAP_OFFSET);
xbt_assert(__mmalloc_default_mdp != NULL);
}
-void mmalloc_postexit(void) {
+
+void mmalloc_postexit(void)
+{
/* Do not detach the default mdp or ldl won't be able to free the memory it allocated since we're in memory */
// mmalloc_detach(__mmalloc_default_mdp);
}
/* 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. */
-#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
+#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
#include <stdio.h>
#include "mmprivate.h"
/* Prototypes for local functions */
-static int initialize (struct mdesc *mdp);
-static void* morecore (struct mdesc *mdp, size_t size);
-static void* align (struct mdesc *mdp, size_t size);
+static int initialize(struct mdesc *mdp);
+static void *morecore(struct mdesc *mdp, size_t size);
+static void *align(struct mdesc *mdp, size_t size);
/* Aligned allocation. */
-static void* align (struct mdesc *mdp, size_t size) {
- void* result;
+static void *align(struct mdesc *mdp, size_t size)
+{
+ void *result;
unsigned long int adj;
- result = mdp -> morecore (mdp, size);
- adj = RESIDUAL (result, BLOCKSIZE);
- if (adj != 0)
- {
+ result = mdp->morecore(mdp, size);
+ adj = RESIDUAL(result, BLOCKSIZE);
+ if (adj != 0) {
adj = BLOCKSIZE - adj;
- mdp -> morecore (mdp, adj);
- result = (char*) result + adj;
+ mdp->morecore(mdp, adj);
+ result = (char *) result + adj;
}
return (result);
}
/* Set everything up and remember that we have. */
-static int initialize (struct mdesc *mdp)
+static int initialize(struct mdesc *mdp)
{
- mdp -> heapsize = HEAP / BLOCKSIZE;
- mdp -> heapinfo = (malloc_info *)
- align (mdp, mdp -> heapsize * sizeof (malloc_info));
- if (mdp -> heapinfo == NULL)
- {
+ mdp->heapsize = HEAP / BLOCKSIZE;
+ mdp->heapinfo = (malloc_info *)
+ align(mdp, mdp->heapsize * sizeof(malloc_info));
+ if (mdp->heapinfo == NULL) {
return (0);
}
- memset ((void*)mdp -> heapinfo, 0, mdp -> heapsize * sizeof (malloc_info));
- mdp -> heapinfo[0].free.size = 0;
- mdp -> heapinfo[0].free.next = mdp -> heapinfo[0].free.prev = 0;
- mdp -> heapindex = 0;
- mdp -> heapbase = (void*) mdp -> heapinfo;
- mdp -> flags |= MMALLOC_INITIALIZED;
+ memset((void *) mdp->heapinfo, 0, mdp->heapsize * sizeof(malloc_info));
+ mdp->heapinfo[0].free.size = 0;
+ mdp->heapinfo[0].free.next = mdp->heapinfo[0].free.prev = 0;
+ mdp->heapindex = 0;
+ mdp->heapbase = (void *) mdp->heapinfo;
+ mdp->flags |= MMALLOC_INITIALIZED;
return (1);
}
/* Get neatly aligned memory, initializing or
growing the heap info table as necessary. */
-static void* morecore (struct mdesc *mdp, size_t size)
+static void *morecore(struct mdesc *mdp, size_t size)
{
- void* result;
+ void *result;
malloc_info *newinfo, *oldinfo;
size_t newsize;
- result = align (mdp, size);
- if (result == NULL)
- {
+ result = align(mdp, size);
+ if (result == NULL) {
return (NULL);
}
/* Check if we need to grow the info table. */
- if ((size_t) BLOCK ((char*) result + size) > mdp -> heapsize)
- {
- newsize = mdp -> heapsize;
- while ((size_t) BLOCK ((char*) result + size) > newsize)
- {
+ if ((size_t) BLOCK((char *) result + size) > mdp->heapsize) {
+ newsize = mdp->heapsize;
+ while ((size_t) BLOCK((char *) result + size) > newsize) {
newsize *= 2;
}
- newinfo = (malloc_info *) align (mdp, newsize * sizeof (malloc_info));
- if (newinfo == NULL)
- {
- mdp -> morecore (mdp, -size);
+ newinfo = (malloc_info *) align(mdp, newsize * sizeof(malloc_info));
+ if (newinfo == NULL) {
+ mdp->morecore(mdp, -size);
return (NULL);
}
- memset ((void*) newinfo, 0, newsize * sizeof (malloc_info));
- memcpy ((void*) newinfo, (void*) mdp -> heapinfo,
- mdp -> heapsize * sizeof (malloc_info));
- oldinfo = mdp -> heapinfo;
- newinfo[BLOCK (oldinfo)].busy.type = 0;
- newinfo[BLOCK (oldinfo)].busy.info.size
- = BLOCKIFY (mdp -> heapsize * sizeof (malloc_info));
- mdp -> heapinfo = newinfo;
- __mmalloc_free (mdp, (void*)oldinfo);
- mdp -> heapsize = newsize;
+ memset((void *) newinfo, 0, newsize * sizeof(malloc_info));
+ memcpy((void *) newinfo, (void *) mdp->heapinfo,
+ mdp->heapsize * sizeof(malloc_info));
+ oldinfo = mdp->heapinfo;
+ newinfo[BLOCK(oldinfo)].busy.type = 0;
+ newinfo[BLOCK(oldinfo)].busy.info.size
+ = BLOCKIFY(mdp->heapsize * sizeof(malloc_info));
+ mdp->heapinfo = newinfo;
+ __mmalloc_free(mdp, (void *) oldinfo);
+ mdp->heapsize = newsize;
}
- mdp -> heaplimit = BLOCK ((char*) result + size);
+ mdp->heaplimit = BLOCK((char *) result + size);
return (result);
}
/* Allocate memory from the heap. */
-void* mmalloc (void *md, size_t size) {
+void *mmalloc(void *md, size_t size)
+{
struct mdesc *mdp;
- void* result;
+ void *result;
size_t block, blocks, lastblocks, start;
register size_t i;
struct list *next;
* glibc malloc does not use this trick but return a constant pointer, but my hack is quicker to implement ;)
*/
if (size == 0)
- size=1;
+ size = 1;
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
LOCK(mdp);
// printf("(%s) Mallocing %d bytes on %p (default: %p)...",xbt_thread_self_name(),size,mdp,__mmalloc_default_mdp);fflush(stdout);
- if (mdp -> mmalloc_hook != NULL) {
- void * res = ((*mdp -> mmalloc_hook) (md, size));
+ if (mdp->mmalloc_hook != NULL) {
+ void *res = ((*mdp->mmalloc_hook) (md, size));
UNLOCK(mdp);
return res;
}
- if (!(mdp -> flags & MMALLOC_INITIALIZED)) {
- if (!initialize (mdp)) {
+ if (!(mdp->flags & MMALLOC_INITIALIZED)) {
+ if (!initialize(mdp)) {
UNLOCK(mdp);
return (NULL);
}
}
- if (size < sizeof (struct list)) {
- size = sizeof (struct list);
+ if (size < sizeof(struct list)) {
+ size = sizeof(struct list);
}
/* Determine the allocation policy based on the request size. */
- if (size <= BLOCKSIZE / 2)
- {
+ if (size <= BLOCKSIZE / 2) {
/* Small allocation to receive a fragment of a block.
- Determine the logarithm to base two of the fragment size. */
+ Determine the logarithm to base two of the fragment size. */
log = 1;
--size;
- while ((size /= 2) != 0)
- {
+ while ((size /= 2) != 0) {
++log;
}
/* Look in the fragment lists for a
- free fragment of the desired size. */
- next = mdp -> fraghead[log].next;
- if (next != NULL)
- {
+ free fragment of the desired size. */
+ next = mdp->fraghead[log].next;
+ if (next != NULL) {
/* There are free fragments of this size.
- Pop a fragment out of the fragment list and return it.
- Update the block's nfree and first counters. */
- result = (void*) next;
- next -> prev -> next = next -> next;
- if (next -> next != NULL)
- {
- next -> next -> prev = next -> prev;
+ Pop a fragment out of the fragment list and return it.
+ Update the block's nfree and first counters. */
+ result = (void *) next;
+ next->prev->next = next->next;
+ if (next->next != NULL) {
+ next->next->prev = next->prev;
}
- block = BLOCK (result);
- if (--mdp -> heapinfo[block].busy.info.frag.nfree != 0)
- {
- mdp -> heapinfo[block].busy.info.frag.first =
- RESIDUAL (next -> next, BLOCKSIZE) >> log;
+ block = BLOCK(result);
+ if (--mdp->heapinfo[block].busy.info.frag.nfree != 0) {
+ mdp->heapinfo[block].busy.info.frag.first =
+ RESIDUAL(next->next, BLOCKSIZE) >> log;
}
/* Update the statistics. */
- mdp -> heapstats.chunks_used++;
- mdp -> heapstats.bytes_used += 1 << log;
- mdp -> heapstats.chunks_free--;
- mdp -> heapstats.bytes_free -= 1 << log;
- }
- else
- {
+ mdp->heapstats.chunks_used++;
+ mdp->heapstats.bytes_used += 1 << log;
+ mdp->heapstats.chunks_free--;
+ mdp->heapstats.bytes_free -= 1 << log;
+ } else {
/* No free fragments of the desired size, so get a new block
- and break it into fragments, returning the first. */
+ and break it into fragments, returning the first. */
UNLOCK(mdp);
//printf("(%s) No free fragment...",xbt_thread_self_name());
- result = mmalloc (md, BLOCKSIZE);
+ result = mmalloc(md, BLOCKSIZE);
//printf("(%s) Fragment: %p...",xbt_thread_self_name(),result);
LOCK(mdp);
- if (result == NULL)
- {
+ if (result == NULL) {
UNLOCK(mdp);
return (NULL);
}
/* Link all fragments but the first into the free list. */
- for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i)
- {
- next = (struct list *) ((char*) result + (i << log));
- next -> next = mdp -> fraghead[log].next;
- next -> prev = &mdp -> fraghead[log];
- next -> prev -> next = next;
- if (next -> next != NULL)
- {
- next -> next -> prev = next;
+ for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) {
+ next = (struct list *) ((char *) result + (i << log));
+ next->next = mdp->fraghead[log].next;
+ next->prev = &mdp->fraghead[log];
+ next->prev->next = next;
+ if (next->next != NULL) {
+ next->next->prev = next;
}
}
/* Initialize the nfree and first counters for this block. */
- block = BLOCK (result);
- mdp -> heapinfo[block].busy.type = log;
- mdp -> heapinfo[block].busy.info.frag.nfree = i - 1;
- mdp -> heapinfo[block].busy.info.frag.first = i - 1;
-
- mdp -> heapstats.chunks_free += (BLOCKSIZE >> log) - 1;
- mdp -> heapstats.bytes_free += BLOCKSIZE - (1 << log);
- mdp -> heapstats.bytes_used -= BLOCKSIZE - (1 << log);
+ block = BLOCK(result);
+ mdp->heapinfo[block].busy.type = log;
+ mdp->heapinfo[block].busy.info.frag.nfree = i - 1;
+ mdp->heapinfo[block].busy.info.frag.first = i - 1;
+
+ mdp->heapstats.chunks_free += (BLOCKSIZE >> log) - 1;
+ mdp->heapstats.bytes_free += BLOCKSIZE - (1 << log);
+ mdp->heapstats.bytes_used -= BLOCKSIZE - (1 << log);
}
- }
- else
- {
+ } else {
/* Large allocation to receive one or more blocks.
- Search the free list in a circle starting at the last place visited.
- If we loop completely around without finding a large enough
- space we will have to get more memory from the system. */
+ Search the free list in a circle starting at the last place visited.
+ If we loop completely around without finding a large enough
+ space we will have to get more memory from the system. */
blocks = BLOCKIFY(size);
start = block = MALLOC_SEARCH_START;
- while (mdp -> heapinfo[block].free.size < blocks)
- {
- block = mdp -> heapinfo[block].free.next;
- if (block == start)
- {
+ while (mdp->heapinfo[block].free.size < blocks) {
+ block = mdp->heapinfo[block].free.next;
+ if (block == start) {
/* Need to get more from the system. Check to see if
- the new core will be contiguous with the final free
- block; if so we don't need to get as much. */
- block = mdp -> heapinfo[0].free.prev;
- lastblocks = mdp -> heapinfo[block].free.size;
- if (mdp -> heaplimit != 0 &&
- block + lastblocks == mdp -> heaplimit &&
- mdp -> morecore (mdp, 0) == ADDRESS(block + lastblocks) &&
- (morecore (mdp, (blocks - lastblocks) * BLOCKSIZE)) != NULL)
- {
+ the new core will be contiguous with the final free
+ block; if so we don't need to get as much. */
+ block = mdp->heapinfo[0].free.prev;
+ lastblocks = mdp->heapinfo[block].free.size;
+ if (mdp->heaplimit != 0 &&
+ block + lastblocks == mdp->heaplimit &&
+ mdp->morecore(mdp, 0) == ADDRESS(block + lastblocks) &&
+ (morecore(mdp, (blocks - lastblocks) * BLOCKSIZE)) != NULL) {
/* Which block we are extending (the `final free
- block' referred to above) might have changed, if
- it got combined with a freed info table. */
- block = mdp -> heapinfo[0].free.prev;
+ block' referred to above) might have changed, if
+ it got combined with a freed info table. */
+ block = mdp->heapinfo[0].free.prev;
- mdp -> heapinfo[block].free.size += (blocks - lastblocks);
- mdp -> heapstats.bytes_free +=
- (blocks - lastblocks) * BLOCKSIZE;
+ mdp->heapinfo[block].free.size += (blocks - lastblocks);
+ mdp->heapstats.bytes_free += (blocks - lastblocks) * BLOCKSIZE;
continue;
}
result = morecore(mdp, blocks * BLOCKSIZE);
- if (result == NULL)
- {
+ if (result == NULL) {
UNLOCK(mdp);
return (NULL);
}
- block = BLOCK (result);
- mdp -> heapinfo[block].busy.type = 0;
- mdp -> heapinfo[block].busy.info.size = blocks;
- mdp -> heapstats.chunks_used++;
- mdp -> heapstats.bytes_used += blocks * BLOCKSIZE;
+ block = BLOCK(result);
+ mdp->heapinfo[block].busy.type = 0;
+ mdp->heapinfo[block].busy.info.size = blocks;
+ mdp->heapstats.chunks_used++;
+ mdp->heapstats.bytes_used += blocks * BLOCKSIZE;
UNLOCK(mdp);
return (result);
}
}
/* At this point we have found a suitable free list entry.
- Figure out how to remove what we need from the list. */
+ Figure out how to remove what we need from the list. */
result = ADDRESS(block);
- if (mdp -> heapinfo[block].free.size > blocks)
- {
+ if (mdp->heapinfo[block].free.size > blocks) {
/* The block we found has a bit left over,
- so relink the tail end back into the free list. */
- mdp -> heapinfo[block + blocks].free.size
- = mdp -> heapinfo[block].free.size - blocks;
- mdp -> heapinfo[block + blocks].free.next
- = mdp -> heapinfo[block].free.next;
- mdp -> heapinfo[block + blocks].free.prev
- = mdp -> heapinfo[block].free.prev;
- mdp -> heapinfo[mdp -> heapinfo[block].free.prev].free.next
- = mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev
- = mdp -> heapindex = block + blocks;
- }
- else
- {
+ so relink the tail end back into the free list. */
+ mdp->heapinfo[block + blocks].free.size
+ = mdp->heapinfo[block].free.size - blocks;
+ mdp->heapinfo[block + blocks].free.next
+ = mdp->heapinfo[block].free.next;
+ mdp->heapinfo[block + blocks].free.prev
+ = mdp->heapinfo[block].free.prev;
+ mdp->heapinfo[mdp->heapinfo[block].free.prev].free.next
+ = mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev
+ = mdp->heapindex = block + blocks;
+ } else {
/* The block exactly matches our requirements,
- so just remove it from the list. */
- mdp -> heapinfo[mdp -> heapinfo[block].free.next].free.prev
- = mdp -> heapinfo[block].free.prev;
- mdp -> heapinfo[mdp -> heapinfo[block].free.prev].free.next
- = mdp -> heapindex = mdp -> heapinfo[block].free.next;
- mdp -> heapstats.chunks_free--;
+ so just remove it from the list. */
+ mdp->heapinfo[mdp->heapinfo[block].free.next].free.prev
+ = mdp->heapinfo[block].free.prev;
+ mdp->heapinfo[mdp->heapinfo[block].free.prev].free.next
+ = mdp->heapindex = mdp->heapinfo[block].free.next;
+ mdp->heapstats.chunks_free--;
}
- mdp -> heapinfo[block].busy.type = 0;
- mdp -> heapinfo[block].busy.info.size = blocks;
- mdp -> heapstats.chunks_used++;
- mdp -> heapstats.bytes_used += blocks * BLOCKSIZE;
- mdp -> heapstats.bytes_free -= blocks * BLOCKSIZE;
+ mdp->heapinfo[block].busy.type = 0;
+ mdp->heapinfo[block].busy.info.size = blocks;
+ mdp->heapstats.chunks_used++;
+ mdp->heapstats.bytes_used += blocks * BLOCKSIZE;
+ mdp->heapstats.bytes_free -= blocks * BLOCKSIZE;
}
//printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout);
UNLOCK(mdp);
* under the terms of the license (GNU LGPL) which comes with this package. */
#ifndef MAP_ANONYMOUS
- #define MAP_ANONYMOUS MAP_ANON
+#define MAP_ANONYMOUS MAP_ANON
#endif
#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* Prototypes for lseek */
+#include <unistd.h> /* Prototypes for lseek */
#endif
#include <stdio.h>
#include <fcntl.h>
static size_t pagesize;
#if NEED_DECLARATION_GETPAGESIZE
-extern int getpagesize (void);
+extern int getpagesize(void);
#endif
#define PAGE_ALIGN(addr) (void*) (((long)(addr) + pagesize - 1) & \
amount to either add to or subtract from the existing region. Works
like sbrk(), but using mmap(). */
-void*
-__mmalloc_mmap_morecore (struct mdesc *mdp, int size)
+void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
{
ssize_t test = 0;
- void* result = NULL;
- off_t foffset; /* File offset at which new mapping will start */
- size_t mapbytes; /* Number of bytes to map */
- void* moveto; /* Address where we wish to move "break value" to */
- void* mapto; /* Address we actually mapped to */
- char buf = 0; /* Single byte to write to extend mapped file */
+ void *result = NULL;
+ off_t foffset; /* File offset at which new mapping will start */
+ size_t mapbytes; /* Number of bytes to map */
+ void *moveto; /* Address where we wish to move "break value" to */
+ void *mapto; /* Address we actually mapped to */
+ char buf = 0; /* Single byte to write to extend mapped file */
if (pagesize == 0)
pagesize = getpagesize();
- if (size == 0)
- {
+ if (size == 0) {
/* Just return the current "break" value. */
- result = mdp -> breakval;
- }
- else if (size < 0)
- {
+ result = mdp->breakval;
+ } else if (size < 0) {
/* We are deallocating memory. If the amount requested would cause
- us to try to deallocate back past the base of the mmap'd region
- then do nothing, and return NULL. Otherwise, deallocate the
- memory and return the old break value. */
- if (((char*)mdp -> breakval) + size >= (char*)mdp -> base)
- {
- result = (void*) mdp -> breakval;
- mdp -> breakval = (char*) mdp->breakval + size;
- moveto = PAGE_ALIGN (mdp -> breakval);
- munmap (moveto, (size_t) (((char*)mdp -> top) - ((char*)moveto)) - 1);
- mdp -> top = moveto;
- }
- }
- else
- {
+ us to try to deallocate back past the base of the mmap'd region
+ then do nothing, and return NULL. Otherwise, deallocate the
+ memory and return the old break value. */
+ if (((char *) mdp->breakval) + size >= (char *) mdp->base) {
+ result = (void *) mdp->breakval;
+ mdp->breakval = (char *) mdp->breakval + size;
+ moveto = PAGE_ALIGN(mdp->breakval);
+ munmap(moveto,
+ (size_t) (((char *) mdp->top) - ((char *) moveto)) - 1);
+ mdp->top = moveto;
+ }
+ } else {
/* We are allocating memory. Make sure we have an open file
- descriptor if not working with anonymous memory. */
- if ( !(mdp->flags & MMALLOC_ANONYMOUS) && mdp -> fd < 0)
- {
- result = NULL;
- }
- else if ((char*)mdp -> breakval + size > (char*)mdp -> top)
- {
- /* The request would move us past the end of the currently
- mapped memory, so map in enough more memory to satisfy
- the request. This means we also have to grow the mapped-to
- file by an appropriate amount, since mmap cannot be used
- to extend a file. */
- moveto = PAGE_ALIGN ((char*)mdp -> breakval + size);
- mapbytes = (char*)moveto - (char*)mdp -> top;
- foffset = (char*)mdp -> top - (char*)mdp -> base;
-
- if( mdp -> fd > 0){
- /* FIXME: Test results of lseek() and write() */
- lseek (mdp -> fd, foffset + mapbytes - 1, SEEK_SET);
- test = write (mdp -> fd, &buf, 1);
+ descriptor if not working with anonymous memory. */
+ if (!(mdp->flags & MMALLOC_ANONYMOUS) && mdp->fd < 0) {
+ result = NULL;
+ } else if ((char *) mdp->breakval + size > (char *) mdp->top) {
+ /* The request would move us past the end of the currently
+ mapped memory, so map in enough more memory to satisfy
+ the request. This means we also have to grow the mapped-to
+ file by an appropriate amount, since mmap cannot be used
+ to extend a file. */
+ moveto = PAGE_ALIGN((char *) mdp->breakval + size);
+ mapbytes = (char *) moveto - (char *) mdp->top;
+ foffset = (char *) mdp->top - (char *) mdp->base;
+
+ if (mdp->fd > 0) {
+ /* FIXME: Test results of lseek() and write() */
+ lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET);
+ test = write(mdp->fd, &buf, 1);
}
-
- /* Let's call mmap. Note that it is possible that mdp->top
- is 0. In this case mmap will choose the address for us */
- mapto = mmap (mdp->top, mapbytes, PROT_READ | PROT_WRITE,
- MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) | MAP_FIXED,
- MAP_ANON_OR_FD(mdp), foffset);
-
- if (mapto != (void*) -1){
-
- if(mdp -> top == 0)
- mdp -> base = mdp -> breakval = mapto;
-
- mdp -> top = PAGE_ALIGN ((char*)mdp -> breakval + size);
- result = (void*) mdp -> breakval;
- mdp -> breakval = (char*)mdp->breakval + size;
+
+ /* Let's call mmap. Note that it is possible that mdp->top
+ is 0. In this case mmap will choose the address for us */
+ mapto = mmap(mdp->top, mapbytes, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) |
+ MAP_FIXED, MAP_ANON_OR_FD(mdp), foffset);
+
+ if (mapto != (void *) -1) {
+
+ if (mdp->top == 0)
+ mdp->base = mdp->breakval = mapto;
+
+ mdp->top = PAGE_ALIGN((char *) mdp->breakval + size);
+ result = (void *) mdp->breakval;
+ mdp->breakval = (char *) mdp->breakval + size;
}
- }
- else
- {
- result = (void*) mdp -> breakval;
- mdp -> breakval = (char*)mdp->breakval + size;
- }
+ } else {
+ result = (void *) mdp->breakval;
+ mdp->breakval = (char *) mdp->breakval + size;
+ }
}
return (result);
}
-void*
-__mmalloc_remap_core (struct mdesc *mdp)
+void *__mmalloc_remap_core(struct mdesc *mdp)
{
- void* base;
+ void *base;
/* FIXME: Quick hack, needs error checking and other attention. */
- base = mmap (mdp -> base, (char*)mdp -> top - (char*)mdp -> base,
- PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED,
- mdp -> fd, 0);
- return ((void*) base);
+ base = mmap(mdp->base, (char *) mdp->top - (char *) mdp->base,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE_OR_SHARED(mdp) | MAP_FIXED, mdp->fd, 0);
+ return ((void *) base);
}
-void*
-mmalloc_findbase (int size)
+void *mmalloc_findbase(int size)
{
int fd;
int flags;
- void* base = NULL;
+ void *base = NULL;
#ifdef MAP_ANONYMOUS
flags = MAP_PRIVATE | MAP_ANONYMOUS;
#else
flags = MAP_PRIVATE;
#endif
- fd = open ("/dev/zero", O_RDWR);
- if (fd != -1)
- {
- return ((void*) NULL);
- }
+ fd = open("/dev/zero", O_RDWR);
+ if (fd != -1) {
+ return ((void *) NULL);
+ }
#endif
- base = mmap (0, size, PROT_READ | PROT_WRITE, flags, fd, 0);
- if (base != (void*) -1)
- {
- munmap (base, (size_t) size);
- }
- if (fd != -1)
- {
- close (fd);
- }
- if (base == 0)
- {
- /* Don't allow mapping at address zero. We use that value
- to signal an error return, and besides, it is useful to
- catch NULL pointers if it is unmapped. Instead start
- at the next page boundary. */
- base = (void*)(long) getpagesize ();
- }
- else if (base == (void*) -1)
- {
- base = NULL;
- }
- return ((void*) base);
+ base = mmap(0, size, PROT_READ | PROT_WRITE, flags, fd, 0);
+ if (base != (void *) -1) {
+ munmap(base, (size_t) size);
+ }
+ if (fd != -1) {
+ close(fd);
+ }
+ if (base == 0) {
+ /* Don't allow mapping at address zero. We use that value
+ to signal an error return, and besides, it is useful to
+ catch NULL pointers if it is unmapped. Instead start
+ at the next page boundary. */
+ base = (void *) (long) getpagesize();
+ } else if (base == (void *) -1) {
+ base = NULL;
+ }
+ return ((void *) base);
}
can specify an alternate function to be called instead (and probably will
want to). */
-extern void abort (void);
+extern void abort(void);
/* Arbitrary magical numbers. */
-#define MAGICWORD (unsigned int) 0xfedabeeb /* Active chunk */
-#define MAGICWORDFREE (unsigned int) 0xdeadbeef /* Inactive chunk */
+#define MAGICWORD (unsigned int) 0xfedabeeb /* Active chunk */
+#define MAGICWORDFREE (unsigned int) 0xdeadbeef /* Inactive chunk */
#define MAGICBYTE ((char) 0xd7)
/* Each memory allocation is bounded by a header structure and a trailer
user's allocation area. The magic word can be tested to detect
buffer underruns and the magic byte can be tested to detect overruns. */
-struct hdr
- {
- size_t size; /* Exact size requested by user. */
- unsigned long int magic; /* Magic number to check header integrity. */
- };
+struct hdr {
+ size_t size; /* Exact size requested by user. */
+ unsigned long int magic; /* Magic number to check header integrity. */
+};
-static void checkhdr (struct mdesc *mdp, const struct hdr *hdr);
-static void mfree_check (void* md, void* ptr);
-static void* mmalloc_check (void* md, size_t size);
-static void* mrealloc_check (void* md, void* ptr, size_t size);
+static void checkhdr(struct mdesc *mdp, const struct hdr *hdr);
+static void mfree_check(void *md, void *ptr);
+static void *mmalloc_check(void *md, size_t size);
+static void *mrealloc_check(void *md, void *ptr, size_t size);
/* Check the magicword and magicbyte, and if either is corrupted then
call the emergency abort function specified for the heap in use. */
-static void
-checkhdr (struct mdesc *mdp, const struct hdr *hdr)
+static void checkhdr(struct mdesc *mdp, const struct hdr *hdr)
{
- if (hdr -> magic != MAGICWORD ||
- ((char *) &hdr[1])[hdr -> size] != MAGICBYTE)
- {
- (*mdp -> abortfunc)();
- }
+ if (hdr->magic != MAGICWORD ||
+ ((char *) &hdr[1])[hdr->size] != MAGICBYTE) {
+ (*mdp->abortfunc) ();
+ }
}
-static void
-mfree_check (void *md, void *ptr)
+static void mfree_check(void *md, void *ptr)
{
struct hdr *hdr = ((struct hdr *) ptr) - 1;
struct mdesc *mdp;
- mdp = MD_TO_MDP (md);
- checkhdr (mdp, hdr);
- hdr -> magic = MAGICWORDFREE;
- mdp -> mfree_hook = NULL;
- mfree (md, (void*)hdr);
- mdp -> mfree_hook = mfree_check;
+ mdp = MD_TO_MDP(md);
+ checkhdr(mdp, hdr);
+ hdr->magic = MAGICWORDFREE;
+ mdp->mfree_hook = NULL;
+ mfree(md, (void *) hdr);
+ mdp->mfree_hook = mfree_check;
}
-static void*
-mmalloc_check (void *md, size_t size)
+static void *mmalloc_check(void *md, size_t size)
{
struct hdr *hdr;
struct mdesc *mdp;
size_t nbytes;
- mdp = MD_TO_MDP (md);
- mdp -> mmalloc_hook = NULL;
- nbytes = sizeof (struct hdr) + size + 1;
- hdr = (struct hdr *) mmalloc (md, nbytes);
- mdp -> mmalloc_hook = mmalloc_check;
- if (hdr != NULL)
- {
- hdr -> size = size;
- hdr -> magic = MAGICWORD;
- hdr++;
- *((char *) hdr + size) = MAGICBYTE;
- }
- return ((void*) hdr);
+ mdp = MD_TO_MDP(md);
+ mdp->mmalloc_hook = NULL;
+ nbytes = sizeof(struct hdr) + size + 1;
+ hdr = (struct hdr *) mmalloc(md, nbytes);
+ mdp->mmalloc_hook = mmalloc_check;
+ if (hdr != NULL) {
+ hdr->size = size;
+ hdr->magic = MAGICWORD;
+ hdr++;
+ *((char *) hdr + size) = MAGICBYTE;
+ }
+ return ((void *) hdr);
}
-static void*
-mrealloc_check (void* md, void* ptr, size_t size)
+static void *mrealloc_check(void *md, void *ptr, size_t size)
{
struct hdr *hdr = ((struct hdr *) ptr) - 1;
struct mdesc *mdp;
size_t nbytes;
- mdp = MD_TO_MDP (md);
- checkhdr (mdp, hdr);
- mdp -> mfree_hook = NULL;
- mdp -> mmalloc_hook = NULL;
- mdp -> mrealloc_hook = NULL;
- nbytes = sizeof (struct hdr) + size + 1;
- hdr = (struct hdr *) mrealloc (md, (void*) hdr, nbytes);
- mdp -> mfree_hook = mfree_check;
- mdp -> mmalloc_hook = mmalloc_check;
- mdp -> mrealloc_hook = mrealloc_check;
- if (hdr != NULL)
- {
- hdr -> size = size;
- hdr++;
- *((char *) hdr + size) = MAGICBYTE;
- }
- return ((void*) hdr);
+ mdp = MD_TO_MDP(md);
+ checkhdr(mdp, hdr);
+ mdp->mfree_hook = NULL;
+ mdp->mmalloc_hook = NULL;
+ mdp->mrealloc_hook = NULL;
+ nbytes = sizeof(struct hdr) + size + 1;
+ hdr = (struct hdr *) mrealloc(md, (void *) hdr, nbytes);
+ mdp->mfree_hook = mfree_check;
+ mdp->mmalloc_hook = mmalloc_check;
+ mdp->mrealloc_hook = mrealloc_check;
+ if (hdr != NULL) {
+ hdr->size = size;
+ hdr++;
+ *((char *) hdr + size) = MAGICBYTE;
+ }
+ return ((void *) hdr);
}
/* Turn on default checking for mmalloc/mrealloc/mfree, for the heap specified
Returns non-zero if checking is successfully enabled, zero otherwise. */
-int
-mmcheckf (void *md, void (*func)(void), int force)
+int mmcheckf(void *md, void (*func) (void), int force)
{
struct mdesc *mdp;
int rtnval;
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
/* We can safely set or update the abort function at any time, regardless
of whether or not we successfully do anything else. */
- mdp -> abortfunc = (func != NULL ? func : abort);
+ mdp->abortfunc = (func != NULL ? func : abort);
/* If we haven't yet called mmalloc the first time for this heap, or if we
have hooks that were previously installed, then allow the hooks to be
initialized or updated. */
if (force ||
- !(mdp -> flags & MMALLOC_INITIALIZED) ||
- (mdp -> mfree_hook != NULL))
- {
- mdp -> mfree_hook = mfree_check;
- mdp -> mmalloc_hook = mmalloc_check;
- mdp -> mrealloc_hook = mrealloc_check;
- mdp -> flags |= MMALLOC_MMCHECK_USED;
- rtnval = 1;
- }
- else
- {
- rtnval = 0;
- }
+ !(mdp->flags & MMALLOC_INITIALIZED) || (mdp->mfree_hook != NULL)) {
+ mdp->mfree_hook = mfree_check;
+ mdp->mmalloc_hook = mmalloc_check;
+ mdp->mrealloc_hook = mrealloc_check;
+ mdp->flags |= MMALLOC_MMCHECK_USED;
+ rtnval = 1;
+ } else {
+ rtnval = 0;
+ }
return (rtnval);
}
/* This routine is for backwards compatibility only, in case there are
still callers to the original mmcheck function. */
-int
-mmcheck (void *md, void (*func) (void))
+int mmcheck(void *md, void (*func) (void))
{
int rtnval;
- rtnval = mmcheckf (md, func, 0);
+ rtnval = mmcheckf(md, func, 0);
return (rtnval);
}
#include "mmprivate.h"
-void *
-mmemalign (void *md, size_t alignment, size_t size)
+void *mmemalign(void *md, size_t alignment, size_t size)
{
- void* result;
+ void *result;
unsigned long int adj;
struct alignlist *l;
struct mdesc *mdp;
- if ((result = mmalloc (md, size + alignment - 1)) != NULL)
- {
- adj = RESIDUAL (result, alignment);
- if (adj != 0)
- {
- mdp = MD_TO_MDP (md);
- for (l = mdp -> aligned_blocks; l != NULL; l = l -> next)
- {
- if (l -> aligned == NULL)
- {
+ if ((result = mmalloc(md, size + alignment - 1)) != NULL) {
+ adj = RESIDUAL(result, alignment);
+ if (adj != 0) {
+ mdp = MD_TO_MDP(md);
+ for (l = mdp->aligned_blocks; l != NULL; l = l->next) {
+ if (l->aligned == NULL) {
/* This slot is free. Use it. */
break;
}
}
- if (l == NULL)
- {
- l = (struct alignlist *) mmalloc (md, sizeof (struct alignlist));
- if (l == NULL)
- {
- mfree (md, result);
+ if (l == NULL) {
+ l = (struct alignlist *) mmalloc(md, sizeof(struct alignlist));
+ if (l == NULL) {
+ mfree(md, result);
return (NULL);
}
- l -> next = mdp -> aligned_blocks;
- mdp -> aligned_blocks = l;
+ l->next = mdp->aligned_blocks;
+ mdp->aligned_blocks = l;
}
- l -> exact = result;
- result = l -> aligned = (char*) result + alignment - adj;
+ l->exact = result;
+ result = l->aligned = (char *) result + alignment - adj;
}
}
return (result);
# define MIN(A, B) ((A) < (B) ? (A) : (B))
#endif
-#define MMALLOC_MAGIC "mmalloc" /* Mapped file magic number */
-#define MMALLOC_MAGIC_SIZE 8 /* Size of magic number buf */
-#define MMALLOC_VERSION 1 /* Current mmalloc version */
-#define MMALLOC_KEYS 16 /* Keys for application use */
+#define MMALLOC_MAGIC "mmalloc" /* Mapped file magic number */
+#define MMALLOC_MAGIC_SIZE 8 /* Size of magic number buf */
+#define MMALLOC_VERSION 1 /* Current mmalloc version */
+#define MMALLOC_KEYS 16 /* Keys for application use */
/* The allocator divides the heap into blocks of fixed size; large
requests receive one or more whole blocks, and small requests
const char *xbt_thread_self_name(void);
/* Data structure giving per-block information. */
-typedef union
- {
- /* Heap information for a busy block. */
- struct
- {
- /* Zero for a large block, or positive giving the
- logarithm to the base two of the fragment size. */
- int type;
- union
- {
- struct
- {
- size_t nfree; /* Free fragments in a fragmented block. */
- size_t first; /* First free fragment of the block. */
- } frag;
- /* Size (in blocks) of a large cluster. */
- size_t size;
- } info;
- } busy;
- /* Heap information for a free block (that may be the first of
- a free cluster). */
- struct
- {
- size_t size; /* Size (in blocks) of a free cluster. */
- size_t next; /* Index of next free cluster. */
- size_t prev; /* Index of previous free cluster. */
- } free;
- } malloc_info;
+typedef union {
+ /* Heap information for a busy block. */
+ struct {
+ /* Zero for a large block, or positive giving the
+ logarithm to the base two of the fragment size. */
+ int type;
+ union {
+ struct {
+ size_t nfree; /* Free fragments in a fragmented block. */
+ size_t first; /* First free fragment of the block. */
+ } frag;
+ /* Size (in blocks) of a large cluster. */
+ size_t size;
+ } info;
+ } busy;
+ /* Heap information for a free block (that may be the first of
+ a free cluster). */
+ struct {
+ size_t size; /* Size (in blocks) of a free cluster. */
+ size_t next; /* Index of next free cluster. */
+ size_t prev; /* Index of previous free cluster. */
+ } free;
+} malloc_info;
/* List of blocks allocated with `mmemalign' (or `mvalloc'). */
-struct alignlist
- {
- struct alignlist *next;
- void* aligned; /* The address that mmemaligned returned. */
- void* exact; /* The address that malloc returned. */
- };
+struct alignlist {
+ struct alignlist *next;
+ void *aligned; /* The address that mmemaligned returned. */
+ void *exact; /* The address that malloc returned. */
+};
/* Doubly linked lists of free fragments. */
-struct list
- {
- struct list *next;
- struct list *prev;
- };
+struct list {
+ struct list *next;
+ struct list *prev;
+};
/* Statistics available to the user.
FIXME: By design, the internals of the malloc package are no longer
to be via some other mechanism, such as mmstat_<something> where the
return value is the <something> the user is interested in. */
-struct mstats
- {
- size_t bytes_total; /* Total size of the heap. */
- size_t chunks_used; /* Chunks allocated by the user. */
- size_t bytes_used; /* Byte total of user-allocated chunks. */
- size_t chunks_free; /* Chunks in the free list. */
- size_t bytes_free; /* Byte total of chunks in the free list. */
- };
+struct mstats {
+ size_t bytes_total; /* Total size of the heap. */
+ size_t chunks_used; /* Chunks allocated by the user. */
+ size_t bytes_used; /* Byte total of user-allocated chunks. */
+ size_t chunks_free; /* Chunks in the free list. */
+ size_t bytes_free; /* Byte total of chunks in the free list. */
+};
/* Internal structure that defines the format of the malloc-descriptor.
This gets written to the base address of the region that mmalloc is
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void* (*morecore) (struct mdesc *mdp, int size);
-
+ void *(*morecore) (struct mdesc * mdp, int size);
+
/* Pointer to the function that causes an abort when the memory checking
features are activated. By default this is set to abort(), but can
be set to another function by the application using mmalloc().
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void (*mfree_hook) (void* mdp, void* ptr);
+ void (*mfree_hook) (void *mdp, void *ptr);
/* Debugging hook for `malloc'.
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void* (*mmalloc_hook) (void* mdp, size_t size);
+ void *(*mmalloc_hook) (void *mdp, size_t size);
/* Debugging hook for realloc.
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void* (*mrealloc_hook) (void* mdp, void* ptr, size_t size);
+ void *(*mrealloc_hook) (void *mdp, void *ptr, size_t size);
/* Number of info entries. */
size_t heapsize;
/* Pointer to first block of the heap (base of the first block). */
- void* heapbase;
+ void *heapbase;
/* Current search index for the heap table. */
/* Search index in the info table. */
is the location where the bookkeeping data for mmap and for malloc
begins. */
- void* base;
+ void *base;
/* The current location in the memory region for this malloc heap which
represents the end of memory in use. */
- void* breakval;
+ void *breakval;
/* The end of the current memory region for this malloc heap. This is
the first location past the end of mapped memory. */
- void* top;
+ void *top;
/* Open file descriptor for the file to which this malloc heap is mapped.
This will always be a valid file descriptor, since /dev/zero is used
/* An array of keys to data within the mapped region, for use by the
application. */
- void* keys[MMALLOC_KEYS];
+ void *keys[MMALLOC_KEYS];
};
/* Bits to look at in the malloc descriptor flags word */
-#define MMALLOC_DEVZERO (1 << 0) /* Have mapped to /dev/zero */
-#define MMALLOC_ANONYMOUS (1 << 1) /* Use anonymous mapping */
-#define MMALLOC_INITIALIZED (1 << 2) /* Initialized mmalloc */
-#define MMALLOC_MMCHECK_USED (1 << 3) /* mmcheckf() called already */
+#define MMALLOC_DEVZERO (1 << 0) /* Have mapped to /dev/zero */
+#define MMALLOC_ANONYMOUS (1 << 1) /* Use anonymous mapping */
+#define MMALLOC_INITIALIZED (1 << 2) /* Initialized mmalloc */
+#define MMALLOC_MMCHECK_USED (1 << 3) /* mmcheckf() called already */
/* Internal version of `mfree' used in `morecore'. */
-extern void __mmalloc_free (struct mdesc *mdp, void* ptr);
+extern void __mmalloc_free(struct mdesc *mdp, void *ptr);
/* A default malloc descriptor for the single sbrk() managed region. */
/* Initialize the first use of the default malloc descriptor, which uses
an sbrk() region. */
-extern struct mdesc *__mmalloc_create_default_mdp (void);
+extern struct mdesc *__mmalloc_create_default_mdp(void);
/* Grow or shrink a contiguous mapped region using mmap().
Works much like sbrk(), only faster */
-extern void* __mmalloc_mmap_morecore (struct mdesc *mdp, int size);
+extern void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size);
/* Remap a mmalloc region that was previously mapped. */
-extern void* __mmalloc_remap_core (struct mdesc *mdp);
+extern void *__mmalloc_remap_core(struct mdesc *mdp);
/* Macro to convert from a user supplied malloc descriptor to pointer to the
internal malloc descriptor. If the user supplied descriptor is NULL, then
? __mmalloc_default_mdp \
: (struct mdesc *) (md))
-#endif /* __MMPRIVATE_H */
+#endif /* __MMPRIVATE_H */
None of the internal mmalloc structures should be externally visible
outside the library. */
-struct mstats
-mmstats (void *md)
+struct mstats mmstats(void *md)
{
struct mstats result;
struct mdesc *mdp;
- mdp = MD_TO_MDP (md);
- result.bytes_total =
- (char*) mdp -> top - (char*)mdp;
- result.chunks_used = mdp -> heapstats.chunks_used;
- result.bytes_used = mdp -> heapstats.bytes_used;
- result.chunks_free = mdp -> heapstats.chunks_free;
- result.bytes_free = mdp -> heapstats.bytes_free;
+ mdp = MD_TO_MDP(md);
+ result.bytes_total = (char *) mdp->top - (char *) mdp;
+ result.chunks_used = mdp->heapstats.chunks_used;
+ result.bytes_used = mdp->heapstats.bytes_used;
+ result.chunks_free = mdp->heapstats.chunks_free;
+ result.bytes_free = mdp->heapstats.bytes_free;
return (result);
}
#include <stdio.h>
#include "mmprivate.h"
-static void tr_break (void);
-static void tr_freehook (void*md, void*ptr);
-static void* tr_mallochook (void* md, size_t size);
-static void* tr_reallochook (void* md, void* ptr, size_t size);
+static void tr_break(void);
+static void tr_freehook(void *md, void *ptr);
+static void *tr_mallochook(void *md, size_t size);
+static void *tr_reallochook(void *md, void *ptr, size_t size);
#ifndef __GNU_LIBRARY__
-extern char *getenv ();
+extern char *getenv();
#endif
static FILE *mallstream;
-#if 0 /* FIXME: Disabled for now. */
+#if 0 /* FIXME: Disabled for now. */
static char mallenv[] = "MALLOC_TRACE";
-static char mallbuf[BUFSIZ]; /* Buffer for the output. */
+static char mallbuf[BUFSIZ]; /* Buffer for the output. */
#endif
/* Address to breakpoint on accesses to... */
-static void* mallwatch;
+static void *mallwatch;
/* Old hook values. */
-static void (*old_mfree_hook) (void* md, void* ptr);
-static void* (*old_mmalloc_hook) (void* md, size_t size);
-static void* (*old_mrealloc_hook) (void* md, void* ptr, size_t size);
+static void (*old_mfree_hook) (void *md, void *ptr);
+static void *(*old_mmalloc_hook) (void *md, size_t size);
+static void *(*old_mrealloc_hook) (void *md, void *ptr, size_t size);
/* This function is called when the block being alloc'd, realloc'd, or
freed has an address matching the variable "mallwatch". In a debugger,
set "mallwatch" to the address of interest, then put a breakpoint on
tr_break. */
-static void
-tr_break (void)
+static void tr_break(void)
{
}
-static void
-tr_freehook (void *md, void *ptr)
+static void tr_freehook(void *md, void *ptr)
{
struct mdesc *mdp;
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
/* Be sure to print it first. */
- fprintf (mallstream, "- %08lx\n", (unsigned long) ptr);
+ fprintf(mallstream, "- %08lx\n", (unsigned long) ptr);
if (ptr == mallwatch)
- tr_break ();
- mdp -> mfree_hook = old_mfree_hook;
- mfree (md, ptr);
- mdp -> mfree_hook = tr_freehook;
+ tr_break();
+ mdp->mfree_hook = old_mfree_hook;
+ mfree(md, ptr);
+ mdp->mfree_hook = tr_freehook;
}
-static void*
-tr_mallochook (void* md, size_t size)
+static void *tr_mallochook(void *md, size_t size)
{
- void* hdr;
+ void *hdr;
struct mdesc *mdp;
- mdp = MD_TO_MDP (md);
- mdp -> mmalloc_hook = old_mmalloc_hook;
- hdr = (void*) mmalloc (md, size);
- mdp -> mmalloc_hook = tr_mallochook;
+ mdp = MD_TO_MDP(md);
+ mdp->mmalloc_hook = old_mmalloc_hook;
+ hdr = (void *) mmalloc(md, size);
+ mdp->mmalloc_hook = tr_mallochook;
/* We could be printing a NULL here; that's OK. */
- fprintf (mallstream, "+ %p 0x%lx\n", hdr, (unsigned long)size);
+ fprintf(mallstream, "+ %p 0x%lx\n", hdr, (unsigned long) size);
if (hdr == mallwatch)
- tr_break ();
+ tr_break();
return (hdr);
}
-static void*
-tr_reallochook (void *md, void *ptr, size_t size)
+static void *tr_reallochook(void *md, void *ptr, size_t size)
{
- void* hdr;
+ void *hdr;
struct mdesc *mdp;
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
if (ptr == mallwatch)
- tr_break ();
-
- mdp -> mfree_hook = old_mfree_hook;
- mdp -> mmalloc_hook = old_mmalloc_hook;
- mdp -> mrealloc_hook = old_mrealloc_hook;
- hdr = (void*) mrealloc (md, ptr, size);
- mdp -> mfree_hook = tr_freehook;
- mdp -> mmalloc_hook = tr_mallochook;
- mdp -> mrealloc_hook = tr_reallochook;
+ tr_break();
+
+ mdp->mfree_hook = old_mfree_hook;
+ mdp->mmalloc_hook = old_mmalloc_hook;
+ mdp->mrealloc_hook = old_mrealloc_hook;
+ hdr = (void *) mrealloc(md, ptr, size);
+ mdp->mfree_hook = tr_freehook;
+ mdp->mmalloc_hook = tr_mallochook;
+ mdp->mrealloc_hook = tr_reallochook;
if (hdr == NULL)
/* Failed realloc. */
- fprintf (mallstream, "! %p 0x%lx\n", ptr, (unsigned long) size);
+ fprintf(mallstream, "! %p 0x%lx\n", ptr, (unsigned long) size);
else
- fprintf (mallstream, "< %p\n> %p 0x%lx\n", ptr,
- hdr, (unsigned long) size);
+ fprintf(mallstream, "< %p\n> %p 0x%lx\n", ptr,
+ hdr, (unsigned long) size);
if (hdr == mallwatch)
- tr_break ();
+ tr_break();
return hdr;
}
that the debugging user wants us to stop on. When patching mallwatch,
don't forget to set a breakpoint on tr_break! */
-int
-mmtrace (void)
+int mmtrace(void)
{
-#if 0 /* FIXME! This is disabled for now until we figure out how to
- maintain a stack of hooks per heap, since we might have other
- hooks (such as set by mmcheck/mmcheckf) active also. */
+#if 0 /* FIXME! This is disabled for now until we figure out how to
+ maintain a stack of hooks per heap, since we might have other
+ hooks (such as set by mmcheck/mmcheckf) active also. */
char *mallfile;
- mallfile = getenv (mallenv);
- if (mallfile != NULL || mallwatch != NULL)
- {
- mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "w");
- if (mallstream != NULL)
- {
- /* Be sure it doesn't mmalloc its buffer! */
- setbuf (mallstream, mallbuf);
- fprintf (mallstream, "= Start\n");
- old_mfree_hook = mdp -> mfree_hook;
- mdp -> mfree_hook = tr_freehook;
- old_mmalloc_hook = mdp -> mmalloc_hook;
- mdp -> mmalloc_hook = tr_mallochook;
- old_mrealloc_hook = mdp -> mrealloc_hook;
- mdp -> mrealloc_hook = tr_reallochook;
- }
+ mallfile = getenv(mallenv);
+ if (mallfile != NULL || mallwatch != NULL) {
+ mallstream = fopen(mallfile != NULL ? mallfile : "/dev/null", "w");
+ if (mallstream != NULL) {
+ /* Be sure it doesn't mmalloc its buffer! */
+ setbuf(mallstream, mallbuf);
+ fprintf(mallstream, "= Start\n");
+ old_mfree_hook = mdp->mfree_hook;
+ mdp->mfree_hook = tr_freehook;
+ old_mmalloc_hook = mdp->mmalloc_hook;
+ mdp->mmalloc_hook = tr_mallochook;
+ old_mrealloc_hook = mdp->mrealloc_hook;
+ mdp->mrealloc_hook = tr_reallochook;
}
-
-#endif /* 0 */
+ }
+#endif /* 0 */
return (1);
}
-
/* 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. */
-#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
+#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
#include "mmprivate.h"
new region. This module has incestuous knowledge of the
internals of both mfree and mmalloc. */
-void* mrealloc (void *md, void *ptr, size_t size) {
+void *mrealloc(void *md, void *ptr, size_t size)
+{
struct mdesc *mdp;
- void* result;
+ void *result;
int type;
size_t block, blocks, oldlimit;
if (size == 0) {
- mfree (md, ptr);
- return (mmalloc (md, 0));
+ mfree(md, ptr);
+ return (mmalloc(md, 0));
} else if (ptr == NULL) {
- return (mmalloc (md, size));
+ return (mmalloc(md, size));
}
- mdp = MD_TO_MDP (md);
+ mdp = MD_TO_MDP(md);
//printf("(%s)realloc %p to %d...",xbt_thread_self_name(),ptr,(int)size);
- if ((char*)ptr < (char*)mdp->heapbase || BLOCK(ptr) > mdp->heapsize ) {
- printf("FIXME. Ouch, this pointer is not mine. I will malloc it instead of reallocing it. (please report this bug)\n");
- result = mmalloc(md,size);
+ if ((char *) ptr < (char *) mdp->heapbase || BLOCK(ptr) > mdp->heapsize) {
+ printf
+ ("FIXME. Ouch, this pointer is not mine. I will malloc it instead of reallocing it. (please report this bug)\n");
+ result = mmalloc(md, size);
abort();
return result;
}
LOCK(mdp);
- if (mdp -> mrealloc_hook != NULL)
- {
+ if (mdp->mrealloc_hook != NULL) {
UNLOCK(mdp);
- return ((*mdp -> mrealloc_hook) (md, ptr, size));
+ return ((*mdp->mrealloc_hook) (md, ptr, size));
}
- block = BLOCK (ptr);
+ block = BLOCK(ptr);
- type = mdp -> heapinfo[block].busy.type;
- switch (type)
- {
+ type = mdp->heapinfo[block].busy.type;
+ switch (type) {
case 0:
/* Maybe reallocate a large block to a small fragment. */
- if (size <= BLOCKSIZE / 2)
- {
+ if (size <= BLOCKSIZE / 2) {
UNLOCK(mdp);
//printf("(%s) alloc large block...",xbt_thread_self_name());
- result = mmalloc (md, size);
- if (result != NULL)
- {
- memcpy (result, ptr, size);
- mfree (md, ptr);
+ result = mmalloc(md, size);
+ if (result != NULL) {
+ memcpy(result, ptr, size);
+ mfree(md, ptr);
return (result);
}
}
/* The new size is a large allocation as well;
- see if we can hold it in place. */
+ see if we can hold it in place. */
LOCK(mdp);
- blocks = BLOCKIFY (size);
- if (blocks < mdp -> heapinfo[block].busy.info.size)
- {
+ blocks = BLOCKIFY(size);
+ if (blocks < mdp->heapinfo[block].busy.info.size) {
/* The new size is smaller; return excess memory to the free list. */
//printf("(%s) return excess memory...",xbt_thread_self_name());
- mdp -> heapinfo[block + blocks].busy.type = 0;
- mdp -> heapinfo[block + blocks].busy.info.size
- = mdp -> heapinfo[block].busy.info.size - blocks;
- mdp -> heapinfo[block].busy.info.size = blocks;
- mfree (md, ADDRESS (block + blocks));
+ mdp->heapinfo[block + blocks].busy.type = 0;
+ mdp->heapinfo[block + blocks].busy.info.size
+ = mdp->heapinfo[block].busy.info.size - blocks;
+ mdp->heapinfo[block].busy.info.size = blocks;
+ mfree(md, ADDRESS(block + blocks));
result = ptr;
- }
- else if (blocks == mdp -> heapinfo[block].busy.info.size)
- {
+ } else if (blocks == mdp->heapinfo[block].busy.info.size) {
/* No size change necessary. */
result = ptr;
- }
- else
- {
+ } else {
/* Won't fit, so allocate a new region that will.
- Free the old region first in case there is sufficient
- adjacent free space to grow without moving. */
- blocks = mdp -> heapinfo[block].busy.info.size;
+ Free the old region first in case there is sufficient
+ adjacent free space to grow without moving. */
+ blocks = mdp->heapinfo[block].busy.info.size;
/* Prevent free from actually returning memory to the system. */
- oldlimit = mdp -> heaplimit;
- mdp -> heaplimit = 0;
- mfree (md, ptr);
- mdp -> heaplimit = oldlimit;
+ oldlimit = mdp->heaplimit;
+ mdp->heaplimit = 0;
+ mfree(md, ptr);
+ mdp->heaplimit = oldlimit;
UNLOCK(mdp);
- result = mmalloc (md, size);
+ result = mmalloc(md, size);
if (result == NULL) {
- mmalloc (md, blocks * BLOCKSIZE);
+ mmalloc(md, blocks * BLOCKSIZE);
return (NULL);
}
if (ptr != result)
- memmove (result, ptr, blocks * BLOCKSIZE);
+ memmove(result, ptr, blocks * BLOCKSIZE);
LOCK(mdp);
}
break;
default:
/* Old size is a fragment; type is logarithm
- to base two of the fragment size. */
+ to base two of the fragment size. */
if (size > (size_t) (1 << (type - 1)) && size <= (size_t) (1 << type)) {
/* The new size is the same kind of fragment. */
//printf("(%s) new size is same kind of fragment...",xbt_thread_self_name());
result = ptr;
} else {
/* The new size is different; allocate a new space,
- and copy the lesser of the new size and the old. */
+ and copy the lesser of the new size and the old. */
//printf("(%s) new size is different...",xbt_thread_self_name());
UNLOCK(mdp);
- result = mmalloc (md, size);
+ result = mmalloc(md, size);
if (result == NULL)
return (NULL);
- memcpy (result, ptr, MIN (size, (size_t) 1 << type));
- mfree (md, ptr);
+ memcpy(result, ptr, MIN(size, (size_t) 1 << type));
+ mfree(md, ptr);
}
break;
}
static size_t cache_pagesize;
#if NEED_DECLARATION_GETPAGESIZE
-extern int getpagesize PARAMS ((void));
+extern int getpagesize PARAMS((void));
#endif
-void*
-mvalloc (void *md, size_t size)
+void *mvalloc(void *md, size_t size)
{
- if (cache_pagesize == 0)
- {
- cache_pagesize = getpagesize ();
- }
+ if (cache_pagesize == 0) {
+ cache_pagesize = getpagesize();
+ }
- return (mmemalign (md, cache_pagesize, size));
+ return (mmemalign(md, cache_pagesize, size));
}
/* Useless prototype to make gcc happy */
-void* valloc (size_t size);
+void *valloc(size_t size);
-void* valloc (size_t size) {
- return mvalloc (NULL, size);
+void *valloc(size_t size)
+{
+ return mvalloc(NULL, size);
}
/* 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. */
-#include <unistd.h> /* Prototypes for sbrk (maybe) */
+#include <unistd.h> /* Prototypes for sbrk (maybe) */
-#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
+#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
#include "xbt.h"
#include "mmprivate.h"
-static void* sbrk_morecore (struct mdesc *mdp, int size);
+static void *sbrk_morecore(struct mdesc *mdp, int size);
#if NEED_DECLARATION_SBRK
-extern void* sbrk (int size);
+extern void *sbrk(int size);
#endif
/* The mmalloc() package can use a single implicit malloc descriptor
/* Use sbrk() to get more core. */
-static void*
-sbrk_morecore (mdp, size)
- struct mdesc *mdp;
- int size;
+static void *sbrk_morecore(mdp, size)
+struct mdesc *mdp;
+int size;
{
- void* result;
-
- if ((result = sbrk (size)) == (void*) -1)
- {
- result = NULL;
- }
- else
- {
- mdp -> breakval = (char*)mdp -> breakval + size;
- mdp -> top = (char*)mdp -> top + size;
- }
+ void *result;
+
+ if ((result = sbrk(size)) == (void *) -1) {
+ result = NULL;
+ } else {
+ mdp->breakval = (char *) mdp->breakval + size;
+ mdp->top = (char *) mdp->top + size;
+ }
return (result);
}
-
#define BUFFSIZE 204800
#define TESTSIZE 100
-int main() {
- void *A,*B;
- int fd1,fd2;
- void *heapA,*heapB;
- void * pointers[TESTSIZE];
+int main()
+{
+ void *A, *B;
+ int fd1, fd2;
+ void *heapA, *heapB;
+ void *pointers[TESTSIZE];
/*
unlink("heap1");
fd1=open("heap1",O_CREAT|O_RDWR,S_IRWXU|S_IRWXG|S_IRWXO);
assert(fd1>0);
*/
- heapA = mmalloc_attach(-1,sbrk(0) + BUFFSIZE);
- if (heapA==NULL) {
+ heapA = mmalloc_attach(-1, sbrk(0) + BUFFSIZE);
+ if (heapA == NULL) {
perror("attach 1 failed");
- fprintf(stderr,"bye\n");
+ fprintf(stderr, "bye\n");
exit(1);
}
- fprintf(stderr,"HeapA=%p\n",heapA);
-
+ fprintf(stderr, "HeapA=%p\n", heapA);
+
int i, size;
- for(i = 0; i < TESTSIZE; i++){
- size = rand () % 1000;
- pointers[i] = mmalloc(heapA,size);
- fprintf(stderr,"%d bytes allocated at %p\n",size, pointers[i]);
+ for (i = 0; i < TESTSIZE; i++) {
+ size = rand() % 1000;
+ pointers[i] = mmalloc(heapA, size);
+ fprintf(stderr, "%d bytes allocated at %p\n", size, pointers[i]);
}
char c;
- scanf("%c",&c);
+ scanf("%c", &c);
+
+ for (i = 0; i < TESTSIZE; i++) {
+ mfree(heapA, pointers[i]);
+ }
- for(i = 0; i < TESTSIZE; i++){
- mfree(heapA,pointers[i]);
- }
-
- fprintf(stderr,"Ok bye bye\n");
+ fprintf(stderr, "Ok bye bye\n");
return 0;
}
* if elm->name_len <= 0, it is recomputed. If >0, it's used as is;
* elm->ID is attributed automatically.
*/
-void xbt_set_add(xbt_set_t set, xbt_set_elm_t elm, void_f_pvoid_t free_func)
+void xbt_set_add(xbt_set_t set, xbt_set_elm_t elm,
+ void_f_pvoid_t free_func)
{
int found = 1;
if (found) {
if (elm == found_in_dict) {
DEBUG2
- ("Ignoring request to insert the same element twice (key %s ; id %d)",
- elm->name, elm->ID);
+ ("Ignoring request to insert the same element twice (key %s ; id %d)",
+ elm->name, elm->ID);
return;
} else {
elm->ID = found_in_dict->ID;
DEBUG2("Reinsertion of key %s (id %d)", elm->name, elm->ID);
- xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func);
+ xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm,
+ free_func);
xbt_dynar_set(set->dynar, elm->ID, &elm);
return;
}
* \param key name of the element to remove
* \param key_len length of \a name
*/
-void xbt_set_remove_by_name_ext(xbt_set_t set, const char *key, int key_len)
+void xbt_set_remove_by_name_ext(xbt_set_t set, const char *key,
+ int key_len)
{
xbt_set_elm_t elm = xbt_set_get_by_name_ext(set, key, key_len);
xbt_set_remove(set, elm);
if (!*cursor) {
DEBUG0("Create the cursor on first use");
*cursor = xbt_new(s_xbt_set_cursor_t, 1);
- xbt_assert0(*cursor, "Malloc error during the creation of the cursor");
+ xbt_assert0(*cursor,
+ "Malloc error during the creation of the cursor");
}
(*cursor)->set = set;
*
* \return true if it's ok, false if there is no more data
*/
-int xbt_set_cursor_get_or_free(xbt_set_cursor_t * curs, xbt_set_elm_t * elm)
+int xbt_set_cursor_get_or_free(xbt_set_cursor_t * curs,
+ xbt_set_elm_t * elm)
{
xbt_set_cursor_t cursor;
THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
key, elm->name);
if (strcmp(elm->name, elm->data))
- THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key, elm->name);
+ THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key,
+ elm->name);
fflush(stdout);
}
xbt_test_assert0(elm, "Dude ! Got a null elm during traversal!");
xbt_test_log3("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data);
xbt_test_assert2(!strcmp(elm->name, elm->data),
- "Key(%s) != value(%s). Abording", elm->name, elm->data);
+ "Key(%s) != value(%s). Abording", elm->name,
+ elm->data);
}
}
xbt_test_add1("Search %s (expected not to be found)", data);
TRY {
xbt_set_get_by_name(set, data);
- THROW1(unknown_error, 0, "Found something which shouldn't be there (%s)",
- data);
+ THROW1(unknown_error, 0,
+ "Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_test_assert1(elm->ID == 1, "elm->ID is %d but should be 1", elm->ID);
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
/*The function ffs doesn't exist for windows*/
#ifdef _XBT_WIN32
- int ffs(int bits)
- {
- int i;
- if (bits == 0)
- return (0);
- for (i = 1; ; i++, bits >>= 1)
- {
- if (bits & 1) break;
- }
- return (i);
- }
+int ffs(int bits)
+{
+ int i;
+ if (bits == 0)
+ return (0);
+ for (i = 1;; i++, bits >>= 1) {
+ if (bits & 1)
+ break;
+ }
+ return (i);
+}
#endif
/**
{
xbt_setset_elm_entry_t first_elm = NULL;
xbt_setset_t setset = xbt_new0(s_xbt_setset_t, 1);
- setset->elm_array = xbt_dynar_new(sizeof(u_xbt_setset_elm_entry_t), NULL);
+ setset->elm_array =
+ xbt_dynar_new(sizeof(u_xbt_setset_elm_entry_t), NULL);
setset->sets = xbt_fifo_new();
/* Expand the elements dynar to the size indicated by the user, */
/* then create the first element, get a pointer to it and add it to the */
/* free elements list */
- xbt_dynar_shrink(setset->elm_array, size);
- first_elm = (xbt_setset_elm_entry_t)xbt_dynar_push_ptr(setset->elm_array);
+ xbt_dynar_shrink(setset->elm_array, size);
+ first_elm =
+ (xbt_setset_elm_entry_t) xbt_dynar_push_ptr(setset->elm_array);
first_elm->free.next = 0;
return setset;
}
xbt_fifo_item_t item;
xbt_setset_set_t set;
xbt_dynar_free(&setset->elm_array);
- xbt_fifo_foreach(setset->sets, item, set, xbt_setset_set_t){
+ xbt_fifo_foreach(setset->sets, item, set, xbt_setset_set_t) {
xbt_setset_destroy_set(set);
}
xbt_fifo_free(setset->sets);
{
xbt_setset_elm_entry_t new_entry = NULL;
xbt_setset_elm_entry_t first_elm = NULL;
- xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
+ xbt_setset_elm_t e = (xbt_setset_elm_t) obj;
xbt_assert0(e->ID == 0, "Adding element with non NULL ID");
- first_elm = (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, 0);
-
+ first_elm =
+ (xbt_setset_elm_entry_t) xbt_dynar_get_ptr(setset->elm_array, 0);
+
/* Before create a new elm entry check if there is one in the free elm list. */
/* If there is not free elm entries, then create a new one */
- if(first_elm->free.next != 0){
+ if (first_elm->free.next != 0) {
e->ID = first_elm->free.next;
- new_entry = (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, first_elm->free.next);
+ new_entry =
+ (xbt_setset_elm_entry_t) xbt_dynar_get_ptr(setset->elm_array,
+ first_elm->free.next);
first_elm->free.next = new_entry->free.next;
- }else{
- new_entry = (xbt_setset_elm_entry_t)xbt_dynar_push_ptr(setset->elm_array);
- e->ID = xbt_dynar_length(setset->elm_array) - 1;
+ } else {
+ new_entry =
+ (xbt_setset_elm_entry_t) xbt_dynar_push_ptr(setset->elm_array);
+ e->ID = xbt_dynar_length(setset->elm_array) - 1;
}
new_entry->info.obj = e;
/* Remove an object from the setset */
void xbt_setset_elm_remove(xbt_setset_t setset, void *obj)
{
- xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
- xbt_setset_elm_entry_t e_entry = xbt_dynar_get_ptr(setset->elm_array, e->ID);
+ xbt_setset_elm_t e = (xbt_setset_elm_t) obj;
+ xbt_setset_elm_entry_t e_entry =
+ xbt_dynar_get_ptr(setset->elm_array, e->ID);
xbt_setset_elm_entry_t first_free = NULL;
/* Link the elm entry to the list of free ones */
/* WARNING: it must be a valid index! */
void *_xbt_setset_idx_to_obj(xbt_setset_t setset, unsigned long idx)
{
- xbt_setset_elm_entry_t e_entry = xbt_dynar_get_ptr(setset->elm_array, idx);
+ xbt_setset_elm_entry_t e_entry =
+ xbt_dynar_get_ptr(setset->elm_array, idx);
return e_entry->info.obj;
}
xbt_free(set->bitmap);
xbt_fifo_remove(set->setset->sets, set);
xbt_free(set);
-
+
return;
}
* \param set The set where the element is going to be added
* \param obj The element to add
*/
-void xbt_setset_set_insert(xbt_setset_set_t set, void* obj)
+void xbt_setset_set_insert(xbt_setset_set_t set, void *obj)
{
- xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
+ xbt_setset_elm_t e = (xbt_setset_elm_t) obj;
- if(e->ID == 0)
+ if (e->ID == 0)
xbt_setset_elm_add(set->setset, e);
-
+
/* Check if we need to expand the bitmap */
- if(set->size * BITS_INT - 1 < e->ID){
- set->bitmap = xbt_realloc(set->bitmap, (e->ID / BITS_INT + 1) * sizeof(int));
- memset(&set->bitmap[set->size], 0, ((e->ID / BITS_INT + 1) - set->size) * sizeof(int));
+ if (set->size * BITS_INT - 1 < e->ID) {
+ set->bitmap =
+ xbt_realloc(set->bitmap, (e->ID / BITS_INT + 1) * sizeof(int));
+ memset(&set->bitmap[set->size], 0,
+ ((e->ID / BITS_INT + 1) - set->size) * sizeof(int));
set->size = (e->ID / BITS_INT + 1);
}
_set_bit(e->ID, set->bitmap);
-
+
return;
}
* \param set The set from which the element is going to be removed
* \param obj The element to remove
*/
-void xbt_setset_set_remove(xbt_setset_set_t set, void* obj)
+void xbt_setset_set_remove(xbt_setset_set_t set, void *obj)
{
- xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
+ xbt_setset_elm_t e = (xbt_setset_elm_t) obj;
/* If the index of the object is between the bitmap then unset it, otherwise
do not do anything, because we already know it is not in the set */
- if(e->ID != 0 && e->ID <= set->size * BITS_INT)
+ if (e->ID != 0 && e->ID <= set->size * BITS_INT)
_unset_bit(e->ID, set->bitmap);
return;
{
int i;
/* Traverse the set and return the first element */
- for(i = 0; i < set->size; i++)
- if(set->bitmap[i] != 0)
- return _xbt_setset_idx_to_obj(set->setset,
- i * BITS_INT + ffs(set->bitmap[i]) - 1);
+ for (i = 0; i < set->size; i++)
+ if (set->bitmap[i] != 0)
+ return _xbt_setset_idx_to_obj(set->setset,
+ i * BITS_INT + ffs(set->bitmap[i]) -
+ 1);
return NULL;
}
void *xbt_setset_set_extract(xbt_setset_set_t set)
{
void *obj = xbt_setset_set_choose(set);
- if(obj){
+ if (obj) {
xbt_setset_set_remove(set, obj);
}
return obj;
* \param obj The element
* \return TRUE if the element \a obj belongs to set \a set
*/
-int xbt_setset_set_belongs(xbt_setset_set_t set, void* obj)
+int xbt_setset_set_belongs(xbt_setset_set_t set, void *obj)
{
- xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
- if(e->ID != 0 && e->ID <= set->size * BITS_INT){
+ xbt_setset_elm_t e = (xbt_setset_elm_t) obj;
+ if (e->ID != 0 && e->ID <= set->size * BITS_INT) {
return _is_bit_set(e->ID % BITS_INT, set->bitmap[e->ID / BITS_INT]);
}
return FALSE;
int xbt_setset_set_size(xbt_setset_set_t set)
{
int i, count = 0;
-
- for(i=0; i < set->size; i++)
+
+ for (i = 0; i < set->size; i++)
count += bitcount(set->bitmap[i]);
-
+
return count;
}
int i;
/* Increase the size of set1 if necessary */
- if(set1->size < set2->size){
+ if (set1->size < set2->size) {
xbt_realloc(set1->bitmap, set2->size * sizeof(unsigned int));
set1->size = set2->size;
}
- for(i=0; i < set1->size; i++)
- if(set2->bitmap[i] != 0)
+ for (i = 0; i < set1->size; i++)
+ if (set2->bitmap[i] != 0)
set1->bitmap[i] |= set2->bitmap[i];
return;
{
int i;
- for(i=0; i < MIN(set1->size, set2->size); i++)
- if(set2->bitmap[i] != 0)
+ for (i = 0; i < MIN(set1->size, set2->size); i++)
+ if (set2->bitmap[i] != 0)
set1->bitmap[i] ^= set2->bitmap[i];
return;
{
int i;
- for(i=0; i < MIN(set1->size, set2->size); i++)
- if(set1->bitmap[i] && set2->bitmap[i])
+ for (i = 0; i < MIN(set1->size, set2->size); i++)
+ if (set1->bitmap[i] && set2->bitmap[i])
set1->bitmap[i] &= set2->bitmap[i];
return;
}
/* Get a cursor pointing to the first element of the set */
-void xbt_setset_cursor_first(xbt_setset_set_t set, xbt_setset_cursor_t *cursor)
+void xbt_setset_cursor_first(xbt_setset_set_t set,
+ xbt_setset_cursor_t * cursor)
{
int i;
(*cursor) = xbt_new0(s_xbt_setset_cursor_t, 1);
(*cursor)->set = set;
-
- for(i = 0; i < set->size; i++){
- if(set->bitmap[i] != 0){
+
+ for (i = 0; i < set->size; i++) {
+ if (set->bitmap[i] != 0) {
(*cursor)->idx = i * BITS_INT + ffs(set->bitmap[i]) - 1;
- break;
+ break;
}
}
}
/* Get the data pointed by a cursor */
int xbt_setset_cursor_get_data(xbt_setset_cursor_t cursor, void **data)
{
- if(cursor->idx == 0){
+ if (cursor->idx == 0) {
xbt_free(cursor);
*data = NULL;
return FALSE;
- }else{
+ } else {
*data = _xbt_setset_idx_to_obj(cursor->set->setset, cursor->idx);
return TRUE;
}
unsigned int mask;
unsigned int data;
cursor->idx++;
- while(cursor->idx < cursor->set->size * BITS_INT){
- if((data = cursor->set->bitmap[cursor->idx / BITS_INT])){
+ while (cursor->idx < cursor->set->size * BITS_INT) {
+ if ((data = cursor->set->bitmap[cursor->idx / BITS_INT])) {
mask = 1 << cursor->idx % BITS_INT;
- while(mask){ /* FIXME: mask will never be 0! */
- if(data & mask){
+ while (mask) { /* FIXME: mask will never be 0! */
+ if (data & mask) {
return;
- }else{
+ } else {
cursor->idx++;
mask <<= 1;
}
}
- }else{
+ } else {
cursor->idx += BITS_INT;
}
}
- cursor->idx = 0;
+ cursor->idx = 0;
}
/* Check if the nth bit of an integer is set or not*/
*/
int bitcount(int v)
{
- v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
- v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
- return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; // count
+ v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
+ v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
+ return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; // count
}
} u_xbt_setset_elm_entry_t, *xbt_setset_elm_entry_t;
typedef struct s_xbt_setset_set {
- xbt_setset_t setset; /* setset that contains this set */
- unsigned int size; /* in integers */
- unsigned int *bitmap; /* the bit array */
+ xbt_setset_t setset; /* setset that contains this set */
+ unsigned int size; /* in integers */
+ unsigned int *bitmap; /* the bit array */
} s_xbt_setset_set_t;
typedef struct s_xbt_setset {
- xbt_dynar_t elm_array; /* of s_xbt_setset_elm_entry_t, to find elements by index */
- xbt_fifo_t sets; /* of s_xbt_setset_set_t, memberships in actual sets of setset */
+ xbt_dynar_t elm_array; /* of s_xbt_setset_elm_entry_t, to find elements by index */
+ xbt_fifo_t sets; /* of s_xbt_setset_set_t, memberships in actual sets of setset */
} s_xbt_setset_t;
typedef struct s_xbt_setset_cursor {
- int idx; /* Actual postition of the cursor (bit number) */
- xbt_setset_set_t set; /* The set associated to the cursor */
+ int idx; /* Actual postition of the cursor (bit number) */
+ xbt_setset_set_t set; /* The set associated to the cursor */
} s_xbt_setset_cursor_t;
/* Some internal functions */
/* Unset the nth bit of an array of integers */
void _unset_bit(unsigned int bit, unsigned int *bitmap);
-
-
-
-
-
-
-
#endif
/* some other values of possible interest: */
- /* #define breakeven_point 8 *//* VAX 4000 - vaxc */
- /* #define breakeven_point 19 *//* VAX 4000 - gcc 2.7.0 */
+ /* #define breakeven_point 8 *//* VAX 4000 - vaxc */
+ /* #define breakeven_point 19 *//* VAX 4000 - gcc 2.7.0 */
#ifndef breakeven_point
# define breakeven_point 6 /* some reasonable one-size-fits-all value */
int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
...);
#if !defined(NEED_SNPRINTF_ONLY)
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
+int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+ va_list ap);
#endif
#endif
#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
#if !defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */ ...)
+int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
+ ...)
{
va_list ap;
int str_l;
#endif
#if defined(NEED_SNPRINTF_ONLY)
-int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */ ...)
+int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args */
+ ...)
{
#else
-int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap)
+int portable_vsnprintf(char *str, size_t str_m, const char *fmt,
+ va_list ap)
{
#endif
/* Actually it uses 0x prefix even for a zero value. */
&& arg_sign != 0
#endif
- ) {
+ ) {
tmp[str_arg_l++] = '0';
tmp[str_arg_l++] = 'x';
}
* converting a zero value with a precision of zero is a null string.
* Actually HP returns all zeroes, and Linux returns "(nil)". */
#endif
- ) {
+ ) {
/* converted to null string */
/* When zero value is formatted with an explicit precision 0,
the resulting formatted string is empty (d, i, u, o, x, X, p). */
&& !(zero_padding_insertion_ind < str_arg_l
&& tmp[zero_padding_insertion_ind] == '0')
#endif
- ) { /* assure leading zero for alternate-form octal numbers */
+ ) { /* assure leading zero for alternate-form octal numbers */
if (!precision_specified || precision < num_of_digits + 1) {
/* precision is increased to force the first character to be zero,
except if a zero value is formatted with an explicit precision
}
xbt_swag_getPrev(obj, swag->offset) = swag->tail;
- xbt_swag_getNext(xbt_swag_getPrev(obj, swag->offset), swag->offset) = obj;
+ xbt_swag_getNext(xbt_swag_getPrev(obj, swag->offset), swag->offset) =
+ obj;
swag->tail = obj;
}
}
xbt_swag_getNext(obj, swag->offset) = swag->head;
- xbt_swag_getPrev(xbt_swag_getNext(obj, swag->offset), swag->offset) = obj;
+ xbt_swag_getPrev(xbt_swag_getNext(obj, swag->offset), swag->offset) =
+ obj;
swag->head = obj;
}
}
xbt_swag_getPrev(obj, swag->offset) = swag->tail;
- xbt_swag_getNext(xbt_swag_getPrev(obj, swag->offset), swag->offset) = obj;
+ xbt_swag_getNext(xbt_swag_getPrev(obj, swag->offset), swag->offset) =
+ obj;
swag->tail = obj;
}
xbt_swag_getNext(swag->tail, offset) = NULL;
xbt_swag_getPrev(obj, offset) = NULL;
} else { /* It's in the middle */
- xbt_swag_getNext(xbt_swag_getPrev(obj, offset), offset) = xbt_swag_getNext(obj, offset);
- xbt_swag_getPrev(xbt_swag_getNext(obj, offset), offset) = xbt_swag_getPrev(obj, offset);
+ xbt_swag_getNext(xbt_swag_getPrev(obj, offset), offset) =
+ xbt_swag_getNext(obj, offset);
+ xbt_swag_getPrev(xbt_swag_getNext(obj, offset), offset) =
+ xbt_swag_getPrev(obj, offset);
xbt_swag_getPrev(obj, offset) = xbt_swag_getNext(obj, offset) = NULL;
}
(swag->count)--;
xbt_swag_free(setB);
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
* License along with QueueUserAPCEx in the file COPYING.LIB;\r
* if not, write to the Free Software Foundation, Inc.,\r
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\r
- */\r
-\r
+ */ \r
+ \r
#include "win32_ucontext.h"\r
-\r
-int getcontext(ucontext_t *ucp)\r
-{\r
- int ret;\r
-\r
- /* Retrieve the full machine context */\r
- ucp->uc_mcontext.ContextFlags = CONTEXT_FULL;\r
- ret = GetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);\r
-\r
- return (ret == 0) ? -1: 0;\r
-}\r
-\r
-int setcontext(const ucontext_t *ucp)\r
-{\r
- int ret;\r
-\r
- /* Restore the full machine context (already set) */\r
- ret = SetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);\r
-\r
- return (ret == 0) ? -1: 0;\r
-}\r
-\r
-int makecontext(ucontext_t *ucp, void (*func)(), int argc, ...)\r
-{\r
- int i;\r
- va_list ap;\r
- char *sp;\r
-\r
- /* Stack grows down */\r
- sp = (char *) (size_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size;\r
-\r
- /* Reserve stack space for the arguments (maximum possible: argc*(8 bytes per argument)) */\r
- sp -= argc*8;\r
-\r
- if ( sp < (char *)ucp->uc_stack.ss_sp) {\r
- /* errno = ENOMEM;*/\r
- return -1;\r
- }\r
-\r
- /* Set the instruction and the stack pointer */\r
- ucp->uc_mcontext.Eip = (unsigned long) func;\r
- ucp->uc_mcontext.Esp = (unsigned long) sp - 4;\r
-\r
- /* Save/Restore the full machine context */\r
- ucp->uc_mcontext.ContextFlags = CONTEXT_FULL;\r
-\r
- /* Copy the arguments */\r
- va_start (ap, argc);\r
- for (i=0; i<argc; i++) {\r
- memcpy(sp, ap, 8);\r
- ap +=8;\r
- sp += 8;\r
- }\r
- va_end(ap);\r
-\r
- return 0;\r
-}\r
-\r
-int swapcontext(ucontext_t *oucp, const ucontext_t *ucp)\r
-{\r
- int ret;\r
-\r
- if ((oucp == NULL) || (ucp == NULL)) {\r
- /*errno = EINVAL;*/\r
- return -1;\r
- }\r
-\r
- ret = getcontext(oucp);\r
- if (ret == 0) {\r
- ret = setcontext(ucp);\r
- }\r
- return ret;\r
-}\r
+int getcontext(ucontext_t * ucp) \r
+{
+ \rint ret;
+ \r\r
+ /* Retrieve the full machine context */ \r
+ ucp->uc_mcontext.ContextFlags = CONTEXT_FULL;
+ \rret = GetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);
+ \rreturn (ret == 0) ? -1 : 0;
+\r}
+
+\r\rint setcontext(const ucontext_t * ucp) \r
+{
+ \rint ret;
+ \r\r
+ /* Restore the full machine context (already set) */ \r
+ ret = SetThreadContext(GetCurrentThread(), &ucp->uc_mcontext);
+ \rreturn (ret == 0) ? -1 : 0;
+\r}
+
+\r\rint makecontext(ucontext_t * ucp, void (*func) (), int argc, ...) \r
+{
+ \rint i;
+ \rva_list ap;
+ \rchar *sp;
+ \r\r
+ /* Stack grows down */ \r
+ sp = (char *) (size_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size;
+ \r\r
+ /* Reserve stack space for the arguments (maximum possible: argc*(8 bytes per argument)) */ \r
+ sp -= argc * 8;
+ \rif (sp < (char *) ucp->uc_stack.ss_sp) {
+ \r\r
+ /* errno = ENOMEM; */ \r
+ return -1;
+ \r}
+ \r\r
+ /* Set the instruction and the stack pointer */ \r
+ ucp->uc_mcontext.Eip = (unsigned long) func;
+ \rucp->uc_mcontext.Esp = (unsigned long) sp - 4;
+ \r\r
+ /* Save/Restore the full machine context */ \r
+ ucp->uc_mcontext.ContextFlags = CONTEXT_FULL;
+ \r\r
+ /* Copy the arguments */ \r
+ va_start(ap, argc);
+ \rfor (i = 0; i < argc; i++) {
+ \rmemcpy(sp, ap, 8);
+ \rap += 8;
+ \rsp += 8;
+ \r}
+ \rva_end(ap);
+ \rreturn 0;
+\r}
+
+\r\rint swapcontext(ucontext_t * oucp, const ucontext_t * ucp) \r
+{
+ \rint ret;
+ \rif ((oucp == NULL) || (ucp == NULL)) {
+ \r\r
+ /*errno = EINVAL; */ \r
+ return -1;
+ \r}
+ \rret = getcontext(oucp);
+ \rif (ret == 0) {
+ \rret = setcontext(ucp);
+ \r}
+ \rreturn ret;
+\r}
+
+\r\r\r
case 'c': /* category name; LOG4J compliant
should accept a precision postfix to show the hierarchy */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- ev->cat->name);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ ev->cat->name);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), ev->cat->name);
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), ev->cat->name);
check_overflow;
precision = -1;
}
break;
case 'p': /* priority name; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- xbt_log_priority_names[ev->priority]);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ xbt_log_priority_names[ev->priority]);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision),
- xbt_log_priority_names[ev->priority]);
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision),
+ xbt_log_priority_names[ev->priority]);
check_overflow;
precision = -1;
}
case 'h': /* host name; SimGrid extension */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- gras_os_myname());
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ gras_os_myname());
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), gras_os_myname());
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), gras_os_myname());
check_overflow;
precision = -1;
}
break;
case 't': /* thread name; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- xbt_thread_self_name());
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ xbt_thread_self_name());
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), xbt_thread_self_name());
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), xbt_thread_self_name());
check_overflow;
precision = -1;
}
break;
case 'P': /* process name; SimGrid extension */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- xbt_procname());
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ xbt_procname());
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), xbt_procname());
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), xbt_procname());
check_overflow;
precision = -1;
}
break;
case 'i': /* process PID name; SimGrid extension */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%d",
- (*xbt_getpid) ());
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%d",
+ (*xbt_getpid) ());
check_overflow;
} else {
- p +=
- sprintf(p, "%.*d",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), (*xbt_getpid) ());
+ p += sprintf(p, "%.*d",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), (*xbt_getpid) ());
check_overflow;
precision = -1;
}
case 'F': /* file name; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- ev->fileName);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ ev->fileName);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), ev->fileName);
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), ev->fileName);
check_overflow;
precision = -1;
}
break;
case 'l': /* location; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%d",
- ev->fileName, ev->lineNum);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%d",
+ ev->fileName, ev->lineNum);
check_overflow;
} else {
- p +=
- snprintf(p,
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), "%s:%d", ev->fileName,
- ev->lineNum);
+ p += snprintf(p,
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), "%s:%d", ev->fileName,
+ ev->lineNum);
check_overflow;
precision = -1;
}
break;
case 'L': /* line number; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%d",
- ev->lineNum);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%d",
+ ev->lineNum);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*d",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), ev->lineNum);
+ p += sprintf(p, "%.*d",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), ev->lineNum);
check_overflow;
precision = -1;
}
break;
case 'M': /* method (ie, function) name; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- ev->functionName);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ ev->functionName);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), ev->functionName);
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), ev->functionName);
check_overflow;
precision = -1;
}
xbt_backtrace_current(&e);
if (*q == 'B') {
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
- e.bt_strings[2] + 8);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s",
+ e.bt_strings[2] + 8);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), e.bt_strings[2] + 8);
+ p += sprintf(p, "%.*s",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), e.bt_strings[2] + 8);
check_overflow;
precision = -1;
}
} else {
for (i = 2; i < e.used; i++)
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s\n",
- e.bt_strings[i] + 8);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ "%s\n", e.bt_strings[i] + 8);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*s\n",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), e.bt_strings[i] + 8);
+ p += sprintf(p, "%.*s\n",
+ (int) MIN(XBT_LOG_BUFF_SIZE -
+ (p - ev->buffer), precision),
+ e.bt_strings[i] + 8);
check_overflow;
precision = -1;
}
xbt_ex_free(e);
}
#else
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- "(no backtrace on this arch)");
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ "(no backtrace on this arch)");
check_overflow;
#endif
break;
case 'd': /* date; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f",
- gras_os_time());
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f",
+ gras_os_time());
check_overflow;
} else {
- p +=
- sprintf(p, "%.*f",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), gras_os_time());
+ p += sprintf(p, "%.*f",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), gras_os_time());
check_overflow;
precision = -1;
}
break;
case 'r': /* application age; LOG4J compliant */
if (precision == -1) {
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f",
- gras_os_time() - format_begin_of_time);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f",
+ gras_os_time() - format_begin_of_time);
check_overflow;
} else {
- p +=
- sprintf(p, "%.*f",
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), gras_os_time() - format_begin_of_time);
+ p += sprintf(p, "%.*f",
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision),
+ gras_os_time() - format_begin_of_time);
check_overflow;
precision = -1;
}
case 'm': /* user-provided message; LOG4J compliant */
if (precision == -1) {
- p +=
- vsnprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), msg_fmt,
- ev->ap);
+ p += vsnprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), msg_fmt,
+ ev->ap);
check_overflow;
} else {
- p +=
- vsnprintf(p,
- (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
- precision), msg_fmt, ev->ap);
+ p += vsnprintf(p,
+ (int) MIN(XBT_LOG_BUFF_SIZE - (p - ev->buffer),
+ precision), msg_fmt, ev->ap);
check_overflow;
precision = -1;
}
if (format_begin_of_time < 0)
format_begin_of_time = gras_os_time();
-
+
return res;
}
if (strlen(xbt_procname()))
p += snprintf(p, 256 - (p - loc_buff), "%s:%s:(%d) ",
gras_os_myname(), xbt_procname(), (*xbt_getpid) ());
- p +=
- snprintf(p, 256 - (p - loc_buff), "%f] ",
- gras_os_time() - simple_begin_of_time);
- if (ev->priority != xbt_log_priority_info && xbt_log_no_loc==0)
- p +=
- snprintf(p, 256 - (p - loc_buff), "%s:%d: ", ev->fileName,
- ev->lineNum);
- p +=
- snprintf(p, 256 - (p - loc_buff), "[%s/%s] ", ev->cat->name,
- xbt_log_priority_names[ev->priority]);
+ p += snprintf(p, 256 - (p - loc_buff), "%f] ",
+ gras_os_time() - simple_begin_of_time);
+ if (ev->priority != xbt_log_priority_info && xbt_log_no_loc == 0)
+ p += snprintf(p, 256 - (p - loc_buff), "%s:%d: ", ev->fileName,
+ ev->lineNum);
+ p += snprintf(p, 256 - (p - loc_buff), "[%s/%s] ", ev->cat->name,
+ xbt_log_priority_names[ev->priority]);
xbt_strbuff_append(buff, loc_buff);
xbt_log_appender_t app)
{
char *p;
- const char *procname=NULL;
+ const char *procname = NULL;
xbt_assert0(ev->priority >= 0,
"Negative logging priority naturally forbidden");
xbt_assert1(ev->priority < sizeof(xbt_log_priority_names),
check_overflow;
/* Display the proc info if available */
- procname=xbt_procname();
+ procname = xbt_procname();
if (strlen(procname)) {
p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%s:(%d) ",
gras_os_myname(), procname, (*xbt_getpid) ());
}
/* Display the date */
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f] ",
- gras_os_time() - simple_begin_of_time);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%f] ",
+ gras_os_time() - simple_begin_of_time);
check_overflow;
/* Display file position if not INFO */
if (ev->priority != xbt_log_priority_info && !xbt_log_no_loc)
- p +=
- snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%d: ",
- ev->fileName, ev->lineNum);
+ p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%d: ",
+ ev->fileName, ev->lineNum);
/* Display category name */
p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "[%s/%s] ",
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/misc.h"
-#include "simgrid_config.h" /*HAVE_MMAP _XBT_WIN32*/
+#include "simgrid_config.h" /*HAVE_MMAP _XBT_WIN32 */
#include "time.h" /* to seed the random generator */
#include "xbt/sysdep.h"
static void xbt_postexit(void) _XBT_GNUC_DESTRUCTOR;
#ifdef _XBT_WIN32
- # undef _XBT_NEED_INIT_PRAGMA
+# undef _XBT_NEED_INIT_PRAGMA
#endif
#ifdef _XBT_NEED_INIT_PRAGMA
#include <windows.h>
/* Dummy prototype to make gcc happy */
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
+ LPVOID lpvReserved);
/* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */
/* and http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx */
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
+ LPVOID lpvReserved)
+{
if (fdwReason == DLL_PROCESS_ATTACH) {
xbt_preinit();
} else if (fdwReason == DLL_PROCESS_DETACH) {
#endif
-static void xbt_preinit(void) {
- #ifdef HAVE_MMAP
- mmalloc_preinit();
- #endif
+static void xbt_preinit(void)
+{
+#ifdef HAVE_MMAP
+ mmalloc_preinit();
+#endif
xbt_log_preinit();
/* Connect our log channels: that must be done manually under windows */
xbt_os_thread_mod_preinit();
}
-static void xbt_postexit(void) {
+static void xbt_postexit(void)
+{
xbt_os_thread_mod_postexit();
xbt_backtrace_postexit();
// FIXME it would be nice to assert that this function is called only once. But each gras process do call it...
xbt_initialized++;
- if (xbt_initialized >1)
+ if (xbt_initialized > 1)
return;
xbt_binary_name = xbt_strdup(argv[0]);
}
/** @brief Finalize the xbt mechanisms. */
-void xbt_exit() {
+void xbt_exit()
+{
WARN0("This function is deprecated, you shouldn't use it");
}
/* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */
/** @brief like free, but you can be sure that it is a function */
-XBT_PUBLIC(void) xbt_free_f(void *p) {
+XBT_PUBLIC(void) xbt_free_f(void *p)
+{
free(p);
}
{
unsigned int i, j;
- DEBUG10("Copy a %dx%d submatrix from %dx%d(of %dx%d) to %dx%d (of %dx%d)",
- lsize, rsize,
- lpos_src, rpos_src, src->lines, src->rows,
- lpos_dst, rpos_dst, dst->lines, dst->rows);
+ DEBUG10
+ ("Copy a %dx%d submatrix from %dx%d(of %dx%d) to %dx%d (of %dx%d)",
+ lsize, rsize, lpos_src, rpos_src, src->lines, src->rows, lpos_dst,
+ rpos_dst, dst->lines, dst->rows);
/* everybody knows that issue is between the chair and the screen (particulary in my office) */
xbt_assert(src->elmsize == dst->elmsize);
if (cpy_f) {
for (j = 0; j < lsize; j++)
xbt_matrix_get_as(dst, j + lpos_dst, i + rpos_dst, void *) =
- (*cpy_f) (xbt_matrix_get_ptr(src, j + rpos_src, i + lpos_src));
+ (*cpy_f) (xbt_matrix_get_ptr(src, j + rpos_src, i + lpos_src));
} else {
memcpy(xbt_matrix_get_ptr(dst, lpos_dst, i + rpos_dst),
xbt_matrix_get_ptr(src, lpos_src, i + rpos_src),
return res;
}
+
/**Â \brief Checks whether the matrix contains the sequence of numbers */
-int xbt_matrix_double_is_seq(xbt_matrix_t mat) {
+int xbt_matrix_double_is_seq(xbt_matrix_t mat)
+{
int i;
for (i = 0; i < mat->lines * mat->rows; i++) {
- double val = xbt_matrix_get_as(mat,i,0,double);
+ double val = xbt_matrix_get_as(mat, i, 0, double);
if (val != i)
return 0;
}
for (j = 0; j < C->rows; j++)
for (k = 0; k < B->lines; k++)
xbt_matrix_get_as(C, i, j, double) +=
- xbt_matrix_get_as(A, i, k, double) * xbt_matrix_get_as(B, k, j,
- double);
+ xbt_matrix_get_as(A, i, k, double) * xbt_matrix_get_as(B, k, j,
+ double);
}
}
-void xbt_os_thread_mod_postexit(void) {
+void xbt_os_thread_mod_postexit(void)
+{
/* FIXME: don't try to free our key on shutdown.
Valgrind detects no leak if we don't, and whine if we try to */
// int errcode;
case ETIMEDOUT:
THROW1(timeout_error, 0, "mutex %p not ready", mutex);
default:
- THROW2(system_error, errcode, "xbt_mutex_timedacquire(%p) failed: %s",
- mutex, strerror(errcode));
+ THROW2(system_error, errcode,
+ "xbt_mutex_timedacquire(%p) failed: %s", mutex,
+ strerror(errcode));
}
errcode = pthread_mutex_timedlock(&(mutex->m), &ts_end);
-#else /* Well, let's reimplement it since those lazy libc dudes didn't */
+#else /* Well, let's reimplement it since those lazy libc dudes didn't */
double start = xbt_os_time();
do {
errcode = pthread_mutex_trylock(&(mutex->m));
if (errcode == EBUSY)
errcode = ETIMEDOUT;
-#endif /* HAVE_MUTEX_TIMEDLOCK */
+#endif /* HAVE_MUTEX_TIMEDLOCK */
switch (errcode) {
case 0:
THROW1(system_error, errno, "sem_init() failed: %s", strerror(errno));
res->ps = &(res->s);
-#else /* damn, no sem_init(). Reimplement it */
+#else /* damn, no sem_init(). Reimplement it */
xbt_os_mutex_acquire(next_sem_ID_lock);
res->name = bprintf("/%d.%d", (*xbt_getpid) (), ++next_sem_ID);
/* Remove the name from the semaphore namespace: we never join on it */
if (sem_unlink(res->name) < 0)
- THROW1(system_error, errno, "sem_unlink() failed: %s", strerror(errno));
+ THROW1(system_error, errno, "sem_unlink() failed: %s",
+ strerror(errno));
#endif
case ETIMEDOUT:
THROW1(timeout_error, 0, "semaphore %p not ready", sem);
default:
- THROW2(system_error, errcode, "xbt_os_sem_timedacquire(%p) failed: %s",
- sem, strerror(errcode));
+ THROW2(system_error, errcode,
+ "xbt_os_sem_timedacquire(%p) failed: %s", sem,
+ strerror(errcode));
}
} else {
DEBUG2("sem_timedwait(%p,%p)", sem->ps, &ts_end);
errcode = sem_timedwait(sem->s, &ts_end);
-#else /* Okay, reimplement this function then */
+#else /* Okay, reimplement this function then */
double start = xbt_os_time();
do {
errcode = sem_trywait(sem->ps);
case ETIMEDOUT:
THROW2(timeout_error, delay,
- "semaphore %p wasn't signaled before timeout (%f)", sem, delay);
+ "semaphore %p wasn't signaled before timeout (%f)", sem,
+ delay);
default:
THROW3(system_error, errcode, "sem_timedwait(%p,%f) failed: %s", sem,
THROW0(arg_error, EINVAL, "Cannot destroy the NULL sempahore");
#ifdef HAVE_SEM_INIT
- if (sem_destroy(sem->ps)<0)
- THROW1(system_error, errno, "sem_destroy() failed: %s",
- strerror(errno));
+ if (sem_destroy(sem->ps) < 0)
+ THROW1(system_error, errno, "sem_destroy() failed: %s",
+ strerror(errno));
#else
if (sem_close(sem->ps) < 0)
THROW1(system_error, errno, "sem_close() failed: %s", strerror(errno));
void xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot get the value of the NULL semaphore");
+ THROW0(arg_error, EINVAL,
+ "Cannot get the value of the NULL semaphore");
if (sem_getvalue(&(sem->s), svalue) < 0)
- THROW1(system_error, errno, "sem_getvalue() failed: %s", strerror(errno));
+ THROW1(system_error, errno, "sem_getvalue() failed: %s",
+ strerror(errno));
}
/* ********************************* WINDOWS IMPLEMENTATION ************************************ */
{
if (WAIT_OBJECT_0 != WaitForSingleObject(thread->handle, INFINITE))
- THROW0(system_error, (int) GetLastError(), "WaitForSingleObject failed");
+ THROW0(system_error, (int) GetLastError(),
+ "WaitForSingleObject failed");
if (thread_return) {
if (!GetExitCodeThread(thread->handle, (DWORD *) (*thread_return)))
- THROW0(system_error, (int) GetLastError(), "GetExitCodeThread failed");
+ THROW0(system_error, (int) GetLastError(),
+ "GetExitCodeThread failed");
}
CloseHandle(thread->handle);
if (delay < 0) {
xbt_os_cond_wait(cond, mutex);
} else {
- DEBUG3("xbt_cond_timedwait(%p,%p,%lu)", &(cond->events), &(mutex->lock),
- end);
+ DEBUG3("xbt_cond_timedwait(%p,%p,%lu)", &(cond->events),
+ &(mutex->lock), end);
/* lock the threads counter and increment it */
EnterCriticalSection(&cond->waiters_count_lock);
/* wait failure */
if (WAIT_OBJECT_0 != WaitForSingleObject(sem->h, INFINITE))
- THROW1(system_error, GetLastError(), "WaitForSingleObject() failed: %s",
- strerror(GetLastError()));
+ THROW1(system_error, GetLastError(),
+ "WaitForSingleObject() failed: %s", strerror(GetLastError()));
EnterCriticalSection(&(sem->value_lock));
sem->value--;
LeaveCriticalSection(&(sem->value_lock));
void xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot get the value of the NULL semaphore");
+ THROW0(arg_error, EINVAL,
+ "Cannot get the value of the NULL semaphore");
EnterCriticalSection(&(sem->value_lock));
*svalue = sem->value;
tv.tv_sec = (long) (tm / 1000000L);
tv.tv_usec = (long) (tm % 1000000L);
-# endif /* windows version checker */
+# endif /* windows version checker */
-#else /* not windows, no gettimeofday => poor resolution */
+#else /* not windows, no gettimeofday => poor resolution */
return (double) (time(NULL));
-#endif /* HAVE_GETTIMEOFDAY? */
+#endif /* HAVE_GETTIMEOFDAY? */
return (double) (tv.tv_sec + tv.tv_usec / 1000000.0);
}
#elif _XBT_WIN32
Sleep((floor(sec) * 1000) + ((sec - floor(sec)) * 1000));
-#else /* don't have usleep. Use select to sleep less than one second */
+#else /* don't have usleep. Use select to sleep less than one second */
struct timeval timeout;
#endif
};
-xbt_os_timer_t xbt_os_timer_new(void) {
+xbt_os_timer_t xbt_os_timer_new(void)
+{
return xbt_new0(struct s_xbt_os_timer, 1);
}
-void xbt_os_timer_free(xbt_os_timer_t timer) {
+void xbt_os_timer_free(xbt_os_timer_t timer)
+{
free(timer);
}
-void xbt_os_timer_start(xbt_os_timer_t timer) {
+void xbt_os_timer_start(xbt_os_timer_t timer)
+{
#ifdef HAVE_POSIX_GETTIME
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&(timer->start));
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->start));
#elif defined(HAVE_GETTIMEOFDAY)
gettimeofday(&(timer->start), NULL);
#else
#endif
}
-void xbt_os_timer_stop(xbt_os_timer_t timer) {
+void xbt_os_timer_stop(xbt_os_timer_t timer)
+{
#ifdef HAVE_POSIX_GETTIME
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&(timer->stop));
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(timer->stop));
#elif defined(HAVE_GETTIMEOFDAY)
gettimeofday(&(timer->stop), NULL);
#else
((double) timer->start.tv_nsec)) / 1e9);
#elif defined(HAVE_GETTIMEOFDAY)
return ((double) timer->stop.tv_sec) - ((double) timer->start.tv_sec) +
- ((((double) timer->stop.tv_usec) -
- ((double) timer->start.tv_usec)) / 1000000.0);
+ ((((double) timer->stop.tv_usec) -
+ ((double) timer->start.tv_usec)) / 1000000.0);
#else
return (double) timer->stop - (double) timer->start;
#endif
#include "xbt/synchro.h"
#include "xbt/queue.h" /* this module */
#include "gras/virtu.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_queue, xbt, "Message exchanging queue");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_queue, xbt,
+ "Message exchanging queue");
typedef struct s_xbt_queue_ {
int capacity;
xbt_mutex_acquire(queue->mutex);
while (queue->capacity != 0
&& queue->capacity == xbt_dynar_length(queue->data)) {
- DEBUG2("Capacity of %p exceded (=%d). Waiting", queue, queue->capacity);
+ DEBUG2("Capacity of %p exceded (=%d). Waiting", queue,
+ queue->capacity);
xbt_cond_wait(queue->not_full, queue->mutex);
}
xbt_dynar_push(queue->data, src);
xbt_mutex_acquire(queue->mutex);
while (queue->capacity != 0
&& queue->capacity == xbt_dynar_length(queue->data)) {
- DEBUG2("Capacity of %p exceded (=%d). Waiting", queue, queue->capacity);
+ DEBUG2("Capacity of %p exceded (=%d). Waiting", queue,
+ queue->capacity);
xbt_cond_wait(queue->not_full, queue->mutex);
}
xbt_dynar_unshift(queue->data, src);
queue->capacity == xbt_dynar_length(queue->data)) {
xbt_mutex_release(queue->mutex);
- THROW2(timeout_error, 0, "Capacity of %p exceded (=%d), and delay = 0",
- queue, queue->capacity);
+ THROW2(timeout_error, 0,
+ "Capacity of %p exceded (=%d), and delay = 0", queue,
+ queue->capacity);
}
} else {
while (queue->capacity != 0 &&
queue->capacity == xbt_dynar_length(queue->data) &&
(delay < 0 || (xbt_time() - begin) <= delay)) {
- DEBUG2("Capacity of %p exceded (=%d). Waiting", queue, queue->capacity);
+ DEBUG2("Capacity of %p exceded (=%d). Waiting", queue,
+ queue->capacity);
TRY {
xbt_cond_timedwait(queue->not_full, queue->mutex,
delay < 0 ? -1 : delay - (xbt_time() - begin));
*
* @see #xbt_queue_unshift
*/
-void xbt_queue_unshift_timed(xbt_queue_t queue, const void *src, double delay)
+void xbt_queue_unshift_timed(xbt_queue_t queue, const void *src,
+ double delay)
{
double begin = xbt_time();
xbt_ex_t e;
queue->capacity == xbt_dynar_length(queue->data)) {
xbt_mutex_release(queue->mutex);
- THROW2(timeout_error, 0, "Capacity of %p exceded (=%d), and delay = 0",
- queue, queue->capacity);
+ THROW2(timeout_error, 0,
+ "Capacity of %p exceded (=%d), and delay = 0", queue,
+ queue->capacity);
}
} else {
while (queue->capacity != 0 &&
queue->capacity == xbt_dynar_length(queue->data) &&
(delay < 0 || (xbt_time() - begin) <= delay)) {
- DEBUG2("Capacity of %p exceded (=%d). Waiting", queue, queue->capacity);
+ DEBUG2("Capacity of %p exceded (=%d). Waiting", queue,
+ queue->capacity);
TRY {
xbt_cond_timedwait(queue->not_full, queue->mutex,
delay < 0 ? -1 : delay - (xbt_time() - begin));
* @see #xbt_queue_shift
*
*/
-void xbt_queue_shift_timed(xbt_queue_t queue, void *const dst, double delay)
+void xbt_queue_shift_timed(xbt_queue_t queue, void *const dst,
+ double delay)
{
double begin = xbt_time();
xbt_ex_t e;
res->userparam = param;
res->code = code;
DEBUG1("Create thread %p", res);
- res->os_thread = xbt_os_thread_create(name, xbt_thread_create_wrapper, res);
+ res->os_thread =
+ xbt_os_thread_create(name, xbt_thread_create_wrapper, res);
return res;
}
void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay)
{
DEBUG3("Wait cond %p, mutex %p for %f sec", cond, mutex, delay);
- xbt_os_cond_timedwait((xbt_os_cond_t) cond, (xbt_os_mutex_t) mutex, delay);
+ xbt_os_cond_timedwait((xbt_os_cond_t) cond, (xbt_os_mutex_t) mutex,
+ delay);
DEBUG3("Done waiting cond %p, mutex %p for %f sec", cond, mutex, delay);
}
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_thread_create)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_thread_create)");
}
void xbt_os_thread_exit(int *retcode)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_thread_exit)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_thread_exit)");
}
xbt_os_thread_t xbt_os_thread_self(void)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_thread_self)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_thread_self)");
}
void xbt_os_thread_yield(void)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_thread_yield)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_thread_yield)");
}
xbt_os_mutex_t xbt_os_mutex_init(void)
{
- /*
- xbt_backtrace_display_current();
- xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_init)");
- */
- return NULL;
+ /*
+ xbt_backtrace_display_current();
+ xbt_die
+ ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_init)");
+ */
+ return NULL;
}
void xbt_os_mutex_acquire(xbt_os_mutex_t mutex)
{
- /*
- xbt_backtrace_display_current();
- xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_acquire)");
- */
+ /*
+ xbt_backtrace_display_current();
+ xbt_die
+ ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_acquire)");
+ */
}
void xbt_os_mutex_release(xbt_os_mutex_t mutex)
{
- /*
- xbt_backtrace_display_current();
- xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_release)");
- */
+ /*
+ xbt_backtrace_display_current();
+ xbt_die
+ ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_release)");
+ */
}
void xbt_os_mutex_destroy(xbt_os_mutex_t mutex)
{
- /*
- xbt_backtrace_display_current();
- xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_destroy)");
- */
+ /*
+ xbt_backtrace_display_current();
+ xbt_die
+ ("No pthread in SG when compiled against the ucontext (xbt_os_mutex_destroy)");
+ */
}
xbt_os_cond_t xbt_os_cond_init(void)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_cond_init)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_cond_init)");
}
void xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_cond_wait)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_cond_wait)");
}
void xbt_os_cond_signal(xbt_os_cond_t cond)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_cond_signal)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_cond_signal)");
}
void xbt_os_cond_broadcast(xbt_os_cond_t cond)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_cond_broadcast)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_cond_broadcast)");
}
void xbt_os_cond_destroy(xbt_os_cond_t cond)
{
xbt_backtrace_display_current();
xbt_die
- ("No pthread in SG when compiled against the ucontext (xbt_os_cond_destroy)");
+ ("No pthread in SG when compiled against the ucontext (xbt_os_cond_destroy)");
}
#endif
#endif
void *userparam;
void *father_data;
/* stuff to allow other people to wait on me with xbt_thread_join */
- int joinable:1,done:1;
+ int joinable:1, done:1;
xbt_cond_t cond;
xbt_mutex_t mutex;
} s_xbt_thread_t;
static int xbt_thread_create_wrapper(int argc, char *argv[])
{
xbt_thread_t t =
- (xbt_thread_t) SIMIX_process_get_data(SIMIX_process_self());
+ (xbt_thread_t) SIMIX_process_get_data(SIMIX_process_self());
SIMIX_process_set_data(SIMIX_process_self(), t->father_data);
(*t->code) (t->userparam);
if (t->joinable) {
- t->done=1;
+ t->done = 1;
xbt_mutex_acquire(t->mutex);
xbt_cond_broadcast(t->cond);
xbt_mutex_release(t->mutex);
}
xbt_thread_t xbt_thread_create(const char *name, void_f_pvoid_t code,
- void *param,int joinable)
+ void *param, int joinable)
{
xbt_thread_t res = xbt_new0(s_xbt_thread_t, 1);
res->name = xbt_strdup(name);
void xbt_thread_join(xbt_thread_t thread)
{
xbt_mutex_acquire(thread->mutex);
- xbt_assert1(thread->joinable,"Cannot join on %p: wasn't created joinable",thread);
+ xbt_assert1(thread->joinable,
+ "Cannot join on %p: wasn't created joinable", thread);
if (!thread->done) {
- xbt_cond_wait(thread->cond,thread->mutex);
+ xbt_cond_wait(thread->cond, thread->mutex);
xbt_mutex_release(thread->mutex);
}
return p ? SIMIX_process_get_data(p) : NULL;
}
-void xbt_thread_yield(void) {
+void xbt_thread_yield(void)
+{
SIMIX_process_yield();
}
/***** condition related functions *****/
struct s_xbt_cond_ {
- s_smx_cond_t cond;
+ s_smx_cond_t cond;
};
xbt_cond_t xbt_cond_init(void)
for (i = 16; i < 80; i++)
sha->buf[i] =
- SRL(sha->buf[i - 3] ^ sha->buf[i - 8] ^ sha->
- buf[i - 14] ^ sha->buf[i - 16], 1);
+ SRL(sha->buf[i - 3] ^ sha->buf[i - 8] ^ sha->
+ buf[i - 14] ^ sha->buf[i - 16], 1);
A = sha->hash[0];
B = sha->hash[1];
"373ba8be29d4d95708bf7cd43038f4e409dcb439");
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
}
}
free(str_to_free);
- xbt_dynar_shrink(res,0);
+ xbt_dynar_shrink(res, 0);
return res;
}
xbt_dynar_free(&d);
XBT_TEST_SUITE("xbt_str", "String Handling");
-XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted,"test the function xbt_str_split_quoted")
+XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted")
{
xbt_dynar_t d;
char *s;
mytest("Empty", "", "");
mytest("Basic test", "toto tutu", "totoXXXtutu");
- mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu");
+ mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u",
+ "totoXXXtutu");
mytest("Protected space", "toto\\ tutu", "toto tutu");
mytest("Several spaces", "toto tutu", "totoXXXtutu");
mytest("LTriming", " toto tatu", "totoXXXtatu");
free(s); \
xbt_dynar_free(&d);
-XBT_TEST_UNIT("xbt_str_split_str", test_split_str,"test the function xbt_str_split_str")
+XBT_TEST_UNIT("xbt_str_split_str", test_split_str, "test the function xbt_str_split_str")
{
xbt_dynar_t d;
char *s;
mytest_str("String with no separator in it", "toto", "##", "toto");
mytest_str("Basic test", "toto##tutu", "##", "totoXXXtutu");
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
/** @brief Join a set of strings as a single string */
return (ssize_t) i;
}
-#endif /* HAVE_GETLINE */
+#endif /* HAVE_GETLINE */
/*
* Diff related functions
*/
static xbt_matrix_t diff_build_LCS(xbt_dynar_t da, xbt_dynar_t db)
{
- xbt_matrix_t C = xbt_matrix_new(xbt_dynar_length(da), xbt_dynar_length(db),
- sizeof(int), NULL);
+ xbt_matrix_t C =
+ xbt_matrix_new(xbt_dynar_length(da), xbt_dynar_length(db),
+ sizeof(int), NULL);
unsigned long i, j;
/* Compute the LCS */
for (j = 1; j < xbt_dynar_length(db); j++) {
if (!strcmp
- (xbt_dynar_get_as(da, i, char *), xbt_dynar_get_as(db, j, char *)))
- *((int *) xbt_matrix_get_ptr(C, i, j)) =
- xbt_matrix_get_as(C, i - 1, j - 1, int) + 1;
+ (xbt_dynar_get_as(da, i, char *),
+ xbt_dynar_get_as(db, j, char *)))
+ *((int *) xbt_matrix_get_ptr(C, i, j)) =
+ xbt_matrix_get_as(C, i - 1, j - 1, int) + 1;
else
*((int *) xbt_matrix_get_ptr(C, i, j)) =
- max(xbt_matrix_get_as(C, i, j - 1, int),
- xbt_matrix_get_as(C, i - 1, j, int));
+ max(xbt_matrix_get_as(C, i, j - 1, int),
+ xbt_matrix_get_as(C, i - 1, j, int));
}
return C;
}
xbt_dynar_push(res, &topush);
} else if (j >= 0 &&
(i <= 0 || j == 0
- || xbt_matrix_get_as(C, i, j - 1, int) >= xbt_matrix_get_as(C,
- i -
- 1,
- j,
- int)))
- {
+ || xbt_matrix_get_as(C, i, j - 1,
+ int) >= xbt_matrix_get_as(C, i - 1, j,
+ int))) {
diff_build_diff(res, C, da, db, i, j - 1);
topush = bprintf("+ %s", xbt_dynar_get_as(db, j, char *));
xbt_dynar_push(res, &topush);
} else if (i >= 0 &&
(j <= 0
|| xbt_matrix_get_as(C, i, j - 1, int) < xbt_matrix_get_as(C,
- i -
- 1, j,
+ i
+ -
+ 1,
+ j,
int)))
{
diff_build_diff(res, C, da, db, i - 1, j);
/** @brief creates a new string containing what can be read on a fd
*
*/
-char* xbt_str_from_file(FILE *file) {
+char *xbt_str_from_file(FILE * file)
+{
xbt_strbuff_t buff = xbt_strbuff_new();
char *res;
char bread[1024];
- memset(bread,0,1024);
+ memset(bread, 0, 1024);
while (!feof(file)) {
int got = fread(bread, 1, 1023, file);
bread[got] = '\0';
- xbt_strbuff_append(buff,bread);
+ xbt_strbuff_append(buff, bread);
}
res = buff->data;
if (needed_space > b->size) {
b->data =
- realloc(b->data, MAX(minimal_increment + b->used, needed_space));
+ realloc(b->data, MAX(minimal_increment + b->used, needed_space));
b->size = MAX(minimal_increment + b->used, needed_space);
}
strcpy(b->data + b->used, toadd);
/* ok, we now have the variable name. Search the dictionary for the substituted value */
value =
- xbt_dict_get_or_null_ext(patterns, beg_var, end_var - beg_var);
+ xbt_dict_get_or_null_ext(patterns, beg_var, end_var - beg_var);
/* DEBUG1("Deal with '%s'",b->data);
DEBUG4("Search for %.*s, found %s (default value = %s)\n",
end_var-beg_var,beg_var,
} else {
/* we have to extend the data area */
int tooshort =
- val_len - (end_subst - beg_subst) + 1 /*don't forget \0 */ ;
+ val_len - (end_subst - beg_subst) + 1 /*don't forget \0 */ ;
int newused = b->used + tooshort;
end += tooshort; /* update the pointer of the overall loop */
// DEBUG2("Too short (by %d chars; %d chars left in area)",val_len- (end_subst-beg_subst), b->size - b->used);
if (newused > b->size) {
/* We have to realloc the data area before (because b->size is too small). We have to update our pointers, too */
- char *newdata =
- realloc(b->data, b->used + MAX(minimal_increment, tooshort));
+ char *newdata = realloc(b->data,
+ b->used + MAX(minimal_increment,
+ tooshort));
int offset = newdata - b->data;
b->data = newdata;
b->size = b->used + MAX(minimal_increment, tooshort);
if (default_value)
free(default_value);
- end--; /* compensate the next end++*/
+ end--; /* compensate the next end++ */
}
break;
}
XBT_TEST_SUITE("xbt_strbuff", "String Buffers");
-XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute,"test the function xbt_strbuff_substitute")
+XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute")
{
xbt_test_add0("Empty");
mytest("", "", "");
xbt_test_add0("Value much longer, no braces, data before and after");
mytest("toto $t tata", "t=" force_resize, "toto " force_resize " tata");
xbt_test_add0("Value much longer, braces, data before and after");
- mytest("toto ${t} tata", "t=" force_resize, "toto " force_resize " tata");
+ mytest("toto ${t} tata", "t=" force_resize,
+ "toto " force_resize " tata");
xbt_test_add0("Escaped $");
mytest("\\$tutu", "tutu=t", "\\$tutu");
}
-#endif /* SIMGRID_TEST */
+#endif /* SIMGRID_TEST */
int rank;
void_f_int_pvoid_t function;
xbt_thread_t worker;
-} s_worker_data_t,*worker_data_t;
+} s_worker_data_t, *worker_data_t;
-static void worker_wait_n_free(void*w) {
- worker_data_t worker=*(worker_data_t*)w;
+static void worker_wait_n_free(void *w)
+{
+ worker_data_t worker = *(worker_data_t *) w;
xbt_thread_join(worker->worker);
xbt_free(worker);
}
-static void worker_wrapper(void *w) {
- worker_data_t me=(worker_data_t)w;
- (*me->function)(me->rank,xbt_dynar_get_ptr(me->data,me->rank));
+
+static void worker_wrapper(void *w)
+{
+ worker_data_t me = (worker_data_t) w;
+ (*me->function) (me->rank, xbt_dynar_get_ptr(me->data, me->rank));
}
-void xbt_dynar_dopar(xbt_dynar_t datas, void_f_int_pvoid_t function) {
- xbt_dynar_t workers = xbt_dynar_new(sizeof(worker_data_t),worker_wait_n_free);
+void xbt_dynar_dopar(xbt_dynar_t datas, void_f_int_pvoid_t function)
+{
+ xbt_dynar_t workers =
+ xbt_dynar_new(sizeof(worker_data_t), worker_wait_n_free);
unsigned int cursor;
void *data;
- if (xbt_dynar_length(datas)==0)
- return; /* nothing to do */
- if (xbt_dynar_length(datas)==1) {
+ if (xbt_dynar_length(datas) == 0)
+ return; /* nothing to do */
+ if (xbt_dynar_length(datas) == 1) {
/* don't start any new thread, do it directly */
- (*function)(0,xbt_dynar_get_ptr(datas,0));
+ (*function) (0, xbt_dynar_get_ptr(datas, 0));
return;
}
/* Start all workers */
- INFO1("Dopar for %ld elements",xbt_dynar_length(datas));
- xbt_dynar_foreach(datas,cursor,data){
- worker_data_t w = xbt_new0(s_worker_data_t,1);
+ INFO1("Dopar for %ld elements", xbt_dynar_length(datas));
+ xbt_dynar_foreach(datas, cursor, data) {
+ worker_data_t w = xbt_new0(s_worker_data_t, 1);
w->data = datas;
w->function = function;
- w->rank=cursor;
- xbt_dynar_push(workers,&w);
- w->worker = xbt_thread_create("dopar worker",worker_wrapper,w,1/*joinable*/);
+ w->rank = cursor;
+ xbt_dynar_push(workers, &w);
+ w->worker =
+ xbt_thread_create("dopar worker", worker_wrapper, w,
+ 1 /*joinable */ );
}
/* wait them all */
xbt_dynar_free(&workers);
XBT_LOG_EXTERNAL_CATEGORY(xbt_dyn);
XBT_LOG_DEFAULT_CATEGORY(xbt_dyn);
-static void add100(int rank,void *data) {
+static void add100(int rank, void *data)
+{
//INFO2("Thread%d: Add 100 to %d",rank,*(int*)data);
- *(int*)data +=100;
+ *(int *) data += 100;
}
XBT_TEST_UNIT("dopar", test_dynar_dopar, "do parallel on dynars of integers")
int i, cpt;
unsigned int cursor;
- xbt_test_add1("==== Push %d int, add 100 to each of them in parallel and check the results", NB_ELEM);
+ xbt_test_add1
+ ("==== Push %d int, add 100 to each of them in parallel and check the results",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */
xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_dopar(d,add100);
+ xbt_dynar_dopar(d, add100);
cpt = 100;
xbt_dynar_foreach(d, cursor, i) {
xbt_test_assert2(i == cpt,
xbt_dynar_free(&d);
}
-#endif /* SIMGRID_TEST */
-
-
+#endif /* SIMGRID_TEST */
void mmalloc_postexit(void);
-#endif /* XBT_MODINTER_H */
+#endif /* XBT_MODINTER_H */
free(s); \
xbt_dynar_free(&d);
-XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted,"test the function xbt_str_split_quoted")
+XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted")
{
xbt_dynar_t d;
char *s;
mytest("Empty", "", "");
mytest("Basic test", "toto tutu", "totoXXXtutu");
- mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu");
+ mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u",
+ "totoXXXtutu");
mytest("Protected space", "toto\\ tutu", "toto tutu");
mytest("Several spaces", "toto tutu", "totoXXXtutu");
mytest("LTriming", " toto tatu", "totoXXXtatu");
free(s); \
xbt_dynar_free(&d);
-XBT_TEST_UNIT("xbt_str_split_str", test_split_str,"test the function xbt_str_split_str")
+XBT_TEST_UNIT("xbt_str_split_str", test_split_str, "test the function xbt_str_split_str")
{
xbt_dynar_t d;
char *s;
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 293 "xbt/xbt_strbuff.c"
+#line 294 "xbt/xbt_strbuff.c"
#include "xbt/strbuff.h"
/* buffstr have 512 chars by default. Adding 1000 chars like this will force a resize, allowing us to test that b->used and b->size are consistent */
xbt_strbuff_free(sb);
}
-XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute,"test the function xbt_strbuff_substitute")
+XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute")
{
xbt_test_add0("Empty");
mytest("", "", "");
xbt_test_add0("Value much longer, no braces, data before and after");
mytest("toto $t tata", "t=" force_resize, "toto " force_resize " tata");
xbt_test_add0("Value much longer, braces, data before and after");
- mytest("toto ${t} tata", "t=" force_resize, "toto " force_resize " tata");
+ mytest("toto ${t} tata", "t=" force_resize,
+ "toto " force_resize " tata");
xbt_test_add0("Escaped $");
mytest("\\$tutu", "tutu=t", "\\$tutu");
/* GENERATED FILE, DO NOT EDIT */
/*******************************/
-#line 59 "xbt/xbt_synchro.c"
+#line 66 "xbt/xbt_synchro.c"
#define NB_ELEM 50
#include "xbt/synchro.h"
XBT_LOG_EXTERNAL_CATEGORY(xbt_dyn);
XBT_LOG_DEFAULT_CATEGORY(xbt_dyn);
-static void add100(int rank,void *data) {
+static void add100(int rank, void *data)
+{
//INFO2("Thread%d: Add 100 to %d",rank,*(int*)data);
- *(int*)data +=100;
+ *(int *) data += 100;
}
XBT_TEST_UNIT("dopar", test_dynar_dopar, "do parallel on dynars of integers")
int i, cpt;
unsigned int cursor;
- xbt_test_add1("==== Push %d int, add 100 to each of them in parallel and check the results", NB_ELEM);
+ xbt_test_add1
+ ("==== Push %d int, add 100 to each of them in parallel and check the results",
+ NB_ELEM);
d = xbt_dynar_new(sizeof(int), NULL);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
xbt_dynar_push_as(d, int, cpt); /* This is faster (and possible only with scalars) */
xbt_test_log2("Push %d, length=%lu", cpt, xbt_dynar_length(d));
}
- xbt_dynar_dopar(d,add100);
+ xbt_dynar_dopar(d, add100);
cpt = 100;
xbt_dynar_foreach(d, cursor, i) {
xbt_test_assert2(i == cpt,