// ***** Reference count *****
friend XBT_PUBLIC void intrusive_ptr_add_ref(Actor * actor);
friend XBT_PUBLIC void intrusive_ptr_release(Actor * actor);
+ int get_refcount();
// ***** Actor creation *****
/** Retrieve a reference to myself */
std::atomic_int_fast32_t refcount_{0};
public:
+ int get_refcount() { return refcount_; }
friend void intrusive_ptr_add_ref(ActorImpl* actor)
{
// std::memory_order_relaxed ought to be enough here instead of std::memory_order_seq_cst
{
intrusive_ptr_release(actor->pimpl_);
}
+int Actor::get_refcount()
+{
+ return pimpl_->get_refcount();
+}
// ***** Actor methods *****
while (not actors_to_destroy.empty()) {
smx_actor_t actor = &actors_to_destroy.front();
actors_to_destroy.pop_front();
- XBT_DEBUG("Getting rid of %p", actor);
+ XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
intrusive_ptr_release(actor);
}
#if SIMGRID_HAVE_MC
}
const std::string name_;
- int size_;
+ unsigned int size_;
std::vector<simgrid::s4u::ActorPtr> present_processes_;
unsigned int finalized_ranks_ = 0;
MPI_Comm comm_world_;
void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::ActorPtr actor)
{
Instance& instance = smpi_instances.at(instance_id);
-
instance.present_processes_.push_back(actor);
instance.comm_world_->group()->set_mapping(actor, rank);
}
void smpi_deployment_unregister_process(const std::string& instance_id)
{
Instance& instance = smpi_instances.at(instance_id);
-
instance.finalized_ranks_++;
- if (instance.finalized_ranks_ == instance.present_processes_.size()) {
+
+ if (instance.finalized_ranks_ == instance.size_) {
instance.present_processes_.clear();
simgrid::smpi::Comm::destroy(instance.comm_world_);
smpi_instances.erase(instance_id);
MPI_Comm* smpi_deployment_comm_world(const std::string& instance_id)
{
- if (smpi_instances.empty()) { // no instance registered, we probably used smpirun.
+ if (smpi_instances
+ .empty()) { // no instance registered, we probably used smpirun. (FIXME: I guess this never happens for real)
return nullptr;
}
Instance& instance = smpi_instances.at(instance_id);
simgrid::smpi::ActorExt* smpi_process_remote(simgrid::s4u::ActorPtr actor)
{
+ if (actor.get() == nullptr)
+ return nullptr;
return process_data.at(actor.get());
}
}
});
simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::Actor const& actor) {
+ XBT_DEBUG("Delete the extension of actor %s", actor.get_cname());
auto it = process_data.find(&actor);
if (it != process_data.end()) {
delete it->second;
mut->unlock();
} else { /* the RECV flag was not set, so this is a send */
simgrid::smpi::ActorExt* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
+ xbt_assert(process, "Actor pid=%d is gone??", dst_);
int rank = src_;
if (TRACE_smpi_view_internals()) {
TRACE_smpi_send(rank, rank, dst_, tag_, size_);