X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/93ba9586352a457e9795a66ccd6f45f8525cb03f..cfb3987654b857620ba388fab9883a095debeb72:/src/kernel/activity/CommImpl.cpp diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 3a0b63c28e..25a76617e4 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -20,10 +20,27 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_network, kernel, "Kernel network-related synchronization"); namespace simgrid::kernel::activity { -xbt::signal CommImpl::on_start; -xbt::signal CommImpl::on_completion; -std::function CommImpl::copy_data_callback_ = &s4u::Comm::copy_pointer_callback; +unsigned CommImpl::next_id_ = 0; + +/* In stateful MC, we need to ignore some private memory that is not relevant to the application state */ +void CommImpl::setup_mc() +{ + MC_ignore(&CommImpl::next_id_, sizeof(CommImpl::next_id_)); +} + +CommImpl::CommImpl() +{ + MC_ignore((void*)&id_, sizeof(id_)); +} + +std::function CommImpl::copy_data_callback_ = [](kernel::activity::CommImpl* comm, + void* buff, size_t buff_size) { + xbt_assert((buff_size == sizeof(void*)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size); + if (comm->dst_buff_ != nullptr) // get_async provided a buffer + *(void**)(comm->dst_buff_) = buff; + comm->payload_ = buff; // Setup what will be retrieved by s4u::Comm::get_payload() +}; void CommImpl::set_copy_data_callback(const std::function& callback) { @@ -107,6 +124,8 @@ CommImpl::~CommImpl() } else if (mbox_) { mbox_->remove(this); } + + MC_unignore((void*)&id_, sizeof(id_)); } /** @brief Starts the simulation of a communication synchro. */ @@ -129,7 +148,6 @@ CommImpl* CommImpl::start() model_action_->set_category(get_tracing_category()); set_start_time(model_action_->get_start_time()); set_state(State::RUNNING); - on_start(*this); XBT_DEBUG("Starting communication %p from '%s' to '%s' (model action: %p; state: %s)", this, from_->get_cname(), to_->get_cname(), model_action_, get_state_str()); @@ -176,7 +194,7 @@ void CommImpl::copy_data() { size_t buff_size = src_buff_size_; /* If there is no data to copy then return */ - if (not src_buff_ || not dst_buff_ || copied_) + if (not src_buff_ || not dst_buff_size_ || copied_) return; XBT_DEBUG("Copying comm %p data from %s (%p) -> %s (%p) (%zu bytes)", this, @@ -467,7 +485,12 @@ void CommImpl::finish() XBT_DEBUG("CommImpl::finish() comm %p, state %s, src_proc %p, dst_proc %p, detached: %d", this, get_state_str(), src_actor_.get(), dst_actor_.get(), detached_); - on_completion(*this); + if (get_iface()) { + const auto& piface = static_cast(*get_iface()); + set_iface(nullptr); // reset iface to protect against multiple trigger of the on_completion signals + piface.fire_on_completion_for_real(); + piface.fire_on_this_completion_for_real(); + } /* Update synchro state */ if (src_timeout_ && src_timeout_->get_state() == resource::Action::State::FINISHED) @@ -486,6 +509,8 @@ void CommImpl::finish() xbt_assert(to_ && to_->is_on()); set_state(State::DONE); } + src_timeout_ = nullptr; + dst_timeout_ = nullptr; /* destroy the model actions associated with the communication activity */ clean_action();