X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/46bb5bc2cfc53b919b0e503b3f69b385a7c3a723..ec76f2d7b7da2edd64f97b920c1ca9795826e82f:/src/smpi/internals/smpi_process.cpp diff --git a/src/smpi/internals/smpi_process.cpp b/src/smpi/internals/smpi_process.cpp index 93c117b3de..29ac6f4a63 100644 --- a/src/smpi/internals/smpi_process.cpp +++ b/src/smpi/internals/smpi_process.cpp @@ -12,23 +12,10 @@ #include "src/mc/mc_replay.hpp" #include "src/msg/msg_private.hpp" #include "src/simix/smx_private.hpp" +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)"); -#define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1) - -static char* get_mailbox_name(char* str, int process_id) -{ - snprintf(str, MAILBOX_NAME_MAXLEN, "SMPI-%0*x", static_cast(sizeof(int) * 2), static_cast(process_id)); - return str; -} - -static char* get_mailbox_name_small(char* str, int process_id) -{ - snprintf(str, MAILBOX_NAME_MAXLEN, "small%0*x", static_cast(sizeof(int) * 2), static_cast(process_id)); - return str; -} - namespace simgrid{ namespace smpi{ @@ -38,10 +25,12 @@ using simgrid::s4u::ActorPtr; Process::Process(ActorPtr actor, msg_bar_t finalization_barrier) : finalization_barrier_(finalization_barrier) { - char name[MAILBOX_NAME_MAXLEN]; + std::stringstream mailboxname, mailboxname_small; process_ = actor; - mailbox_ = simgrid::s4u::Mailbox::byName(get_mailbox_name(name, process_->getPid())); - mailbox_small_ = simgrid::s4u::Mailbox::byName(get_mailbox_name_small(name, process_->getPid())); + mailboxname << std::string("SMPI-") << process_->getPid(); + mailboxname_small << std::string("small-") << process_->getPid(); + mailbox_ = simgrid::s4u::Mailbox::byName(mailboxname.str()); + mailbox_small_ = simgrid::s4u::Mailbox::byName(mailboxname_small.str()); mailboxes_mutex_ = xbt_mutex_init(); timer_ = xbt_os_timer_new(); state_ = SMPI_UNINITIALIZED; @@ -86,8 +75,8 @@ void Process::set_data(int* argc, char*** argv) argc_ = argc; argv_ = argv; // set the process attached to the mailbox - mailbox_small_->setReceiver(simgrid::s4u::Actor::self()); - XBT_DEBUG("<%lu> New process in the game: %p", process_->getPid(), process_); + mailbox_small_->setReceiver(process_); + XBT_DEBUG("<%lu> New process in the game: %p", process_->getPid(), process_.get()); } /** @brief Prepares the current process for termination. */