From: Jean-Baptiste Hervé Date: Thu, 9 Aug 2012 09:15:16 +0000 (+0200) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3_8~177 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ea455d05da955345380048610887182a4b67b59a?hp=65d463b655c789ab91563756179b180893d3ea7a Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 55a834b612..b3eff4dd42 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -365,6 +365,8 @@ XBT_PUBLIC(void) simcall_rdv_destroy(smx_rdv_t rvp); XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name); XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host); XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv); +XBT_PUBLIC(smx_process_t) SIMIX_rdv_get_receiver(smx_rdv_t rdv); +XBT_PUBLIC(void) SIMIX_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process); XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void); diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index d8509ed30b..14b1540c4d 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -59,7 +59,7 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) void MSG_mailbox_set_async(const char *alias){ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias); - mailbox->permanent_receiver=SIMIX_process_self(); + SIMIX_rdv_set_receiver(mailbox, SIMIX_process_self()); XBT_VERB("%s mailbox set to receive eagerly for process %p\n",alias, SIMIX_process_self()); } diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index 6c9544580a..3c6c04db3a 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -16,7 +16,6 @@ #include "xbt/dict.h" #include "xbt/config.h" #include "instr/instr_private.h" - SG_BEGIN_DECL() /**************** datatypes **********************************/ diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 7737e92e0a..0ce248a02c 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -104,6 +104,26 @@ smx_action_t SIMIX_rdv_get_head(smx_rdv_t rdv) return xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo)); } +/** + * \brief get the receiver (process associated to the mailbox) + * \param rdv The rendez-vous point + * \return process The receiving process (NULL if not set) + */ +smx_process_t SIMIX_rdv_get_receiver(smx_rdv_t rdv) +{ + return rdv->permanent_receiver; +} + +/** + * \brief set the receiver of the rendez vous point to allow eager sends + * \param rdv The rendez-vous point + * \param process The receiving process + */ +void SIMIX_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process) +{ + rdv->permanent_receiver=process; +} + /** * \brief Pushes a communication action into a rendez-vous point * \param rdv The rendez-vous point diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 2bc6b976de..9ff9da7e0a 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -9,6 +9,7 @@ #include "mc/mc.h" #include "xbt/replay.h" #include +#include "surf/surf.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_base, smpi, "Logging specific to SMPI (base)"); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index cdbdc96c63..fcaaf23411 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -15,8 +15,6 @@ #include "simix/smx_private.h" -XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (kernel)"); @@ -67,7 +65,7 @@ void smpi_process_init(int *argc, char ***argv) (*argc)--; data->argc = argc; data->argv = argv; - data->mailbox_small->permanent_receiver=proc;// set the process attached to the mailbox + SIMIX_rdv_set_receiver(data->mailbox_small, proc);// set the process attached to the mailbox XBT_DEBUG("<%d> New process in the game: %p", index, proc); } } @@ -274,7 +272,8 @@ int MAIN__(void) } /* Connect log categories. See xbt/log.c */ - XBT_LOG_CONNECT(smpi); + XBT_LOG_CONNECT(smpi); /* Keep this line as soon as possible in this function: xbt_log_appender_file.c depends on it + DO NOT connect this in XBT or so, or it will be useless to xbt_log_appender_file.c */ XBT_LOG_CONNECT(smpi_base); XBT_LOG_CONNECT(smpi_bench); XBT_LOG_CONNECT(smpi_coll); diff --git a/src/xbt/xbt_log_appender_file.c b/src/xbt/xbt_log_appender_file.c index 57038c121a..8869cc21ec 100644 --- a/src/xbt/xbt_log_appender_file.c +++ b/src/xbt/xbt_log_appender_file.c @@ -1,39 +1,45 @@ -/* file_appender - a dumb log appender which simply prints to stdout */ +/* file_appender - a dumb log appender which simply prints to a file */ -/* Copyright (c) 2007-2011. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2012. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" #include "xbt/log_private.h" +#include "smpi/private.h" // to access bench_begin/end. Not ultraclean, I confess #include -/** - * The root category's default logging function. - */ - -extern const char *xbt_log_priority_names[8]; - +static void append_file(xbt_log_appender_t this_, char *str) { + fputs(str, (FILE *) this_->data); +} -static void append_file(xbt_log_appender_t this_appender, char *str) -{ - fputs(str, (FILE *) (this_appender->data)); +static void smpi_append_file(xbt_log_appender_t this_, char *str) { + smpi_bench_end(); + fputs(str, (FILE *) this_->data); + smpi_bench_begin(); } -static void free_(xbt_log_appender_t this_) -{ +static void free_(xbt_log_appender_t this_) { if (this_->data != stderr) fclose(this_->data); } +void __smpi_bench_dont (void); // Stupid prototype +void __smpi_bench_dont (void) { /* I'm only a place-holder in case we link without SMPI */; } +void smpi_bench_begin(void) __attribute__ ((weak, alias ("__smpi_bench_dont"))); +void smpi_bench_end(void) __attribute__ ((weak, alias ("__smpi_bench_dont"))); -xbt_log_appender_t xbt_log_appender_file_new(char *arg) -{ +XBT_LOG_EXTERNAL_CATEGORY(smpi); // To detect if SMPI is inited + +xbt_log_appender_t xbt_log_appender_file_new(char *arg) { + xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1); - res->do_append = append_file; + if (_XBT_LOGV(smpi).initialized) // HACK to detect if we run in SMPI mode. Relies on MAIN__ source disposition + res->do_append = smpi_append_file; + else + res->do_append = append_file; res->free_ = free_; if (arg) res->data = (void *) fopen(arg, "w"); diff --git a/src/xbt/xbt_main.c b/src/xbt/xbt_main.c index 2ca0ed635a..030dd348c4 100644 --- a/src/xbt/xbt_main.c +++ b/src/xbt/xbt_main.c @@ -23,6 +23,9 @@ XBT_LOG_NEW_CATEGORY(xbt, "All XBT categories (simgrid toolbox)"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling"); +XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); /* lives here even if that's a bit odd to solve linking issues: this is used in xbt_log_file_appender to detect whether SMPI is used (and thus whether we should unbench the writing to disk) */ + + char *xbt_binary_name = NULL; /* Mandatory to retrieve neat backtraces */ int xbt_initialized = 0;