X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0b63f78dc217b79305cef05bd2200069d3e24475..85e1d2c205ca99512b48bceca0f16677a401e233:/src/smpi/internals/smpi_process.cpp diff --git a/src/smpi/internals/smpi_process.cpp b/src/smpi/internals/smpi_process.cpp index 29ac6f4a63..b4f2dd887d 100644 --- a/src/smpi/internals/smpi_process.cpp +++ b/src/smpi/internals/smpi_process.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2018. 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. */ @@ -12,7 +12,6 @@ #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)"); @@ -23,17 +22,13 @@ using simgrid::s4u::Actor; using simgrid::s4u::ActorPtr; Process::Process(ActorPtr actor, msg_bar_t finalization_barrier) - : finalization_barrier_(finalization_barrier) + : finalization_barrier_(finalization_barrier), process_(actor) { - std::stringstream mailboxname, mailboxname_small; - process_ = actor; - 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; + mailbox_ = simgrid::s4u::Mailbox::byName("SMPI-" + std::to_string(process_->getPid())); + mailbox_small_ = simgrid::s4u::Mailbox::byName("small-" + std::to_string(process_->getPid())); + mailboxes_mutex_ = xbt_mutex_init(); + timer_ = xbt_os_timer_new(); + state_ = SMPI_UNINITIALIZED; if (MC_is_active()) MC_ignore_heap(timer_, xbt_os_timer_size()); @@ -55,11 +50,21 @@ Process::Process(ActorPtr actor, msg_bar_t finalization_barrier) #endif } +Process::~Process() +{ + if (comm_self_ != MPI_COMM_NULL) + simgrid::smpi::Comm::destroy(comm_self_); + if (comm_intra_ != MPI_COMM_NULL) + simgrid::smpi::Comm::destroy(comm_intra_); + xbt_os_timer_free(timer_); + xbt_mutex_destroy(mailboxes_mutex_); +} + void Process::set_data(int* argc, char*** argv) { instance_id_ = std::string((*argv)[1]); - comm_world_ = smpi_deployment_comm_world(instance_id_.c_str()); - msg_bar_t barrier = smpi_deployment_finalization_barrier(instance_id_.c_str()); + comm_world_ = smpi_deployment_comm_world(instance_id_); + msg_bar_t barrier = smpi_deployment_finalization_barrier(instance_id_); if (barrier != nullptr) // don't overwrite the current one if the instance has none finalization_barrier_ = barrier; @@ -76,14 +81,14 @@ void Process::set_data(int* argc, char*** argv) argv_ = argv; // set the process attached to the mailbox mailbox_small_->setReceiver(process_); - XBT_DEBUG("<%lu> New process in the game: %p", process_->getPid(), process_.get()); + XBT_DEBUG("<%ld> SMPI process has been initialized: %p", process_->getPid(), process_.get()); } /** @brief Prepares the current process for termination. */ void Process::finalize() { state_ = SMPI_FINALIZED; - XBT_DEBUG("<%lu> Process left the game", process_->getPid()); + XBT_DEBUG("<%ld> Process left the game", process_->getPid()); // This leads to an explosion of the search graph which cannot be reduced: if(MC_is_active() || MC_record_replay_is_active()) @@ -182,7 +187,7 @@ int Process::papi_event_set() return papi_event_set_; } -papi_counter_t& smpi_process_papi_counters() +papi_counter_t& Process::papi_counters() { return papi_counter_data_; } @@ -237,14 +242,6 @@ msg_bar_t Process::finalization_barrier(){ return finalization_barrier_; } -int Process::return_value(){ - return return_value_; -} - -void Process::set_return_value(int val){ - return_value_=val; -} - void Process::init(int *argc, char ***argv){ if (smpi_process_count() == 0) { @@ -265,19 +262,18 @@ void Process::init(int *argc, char ***argv){ // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved // this up here so that I can set the privatized region before the switch. Process* process = smpi_process_remote(proc); - int my_proc_id = proc->getPid(); - if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){ + if (smpi_privatize_global_variables == SmpiPrivStrategies::Mmap) { /* Now using the segment index of this process */ process->set_privatized_region(smpi_init_global_memory_segment_process()); /* Done at the process's creation */ - SMPI_switch_data_segment(my_proc_id); + SMPI_switch_data_segment(proc); } process->set_data(argc, argv); } - xbt_assert(smpi_process(), - "smpi_process() returned nullptr. You probably gave a nullptr parameter to MPI_Init. " - "Although it's required by MPI-2, this is currently not supported by SMPI."); + xbt_assert(smpi_process(), "smpi_process() returned nullptr. You probably gave a nullptr parameter to MPI_Init. " + "Although it's required by MPI-2, this is currently not supported by SMPI. " + "Please use MPI_Init(&argc, &argv) as usual instead."); } }