-/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2022. 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. */
std::string Comm::name() const
{
int size;
- char name[MPI_MAX_NAME_STRING+1];
- this->get_name(name, &size);
+ std::array<char, MPI_MAX_NAME_STRING + 1> name;
+ this->get_name(name.data(), &size);
if (name[0]=='\0')
return std::string("MPI_Comm");
else
- return std::string(name);
+ return std::string(name.data());
}
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_uniform();
- return is_uniform_ != 0;
+ return is_uniform_;
}
bool Comm::is_blocked() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_blocked();
- return is_blocked_ != 0;
+ return is_blocked_;
}
bool Comm::is_smp_comm() const
simgrid::smpi::Info::unref(comm->info_);
if(comm->errhandlers_!=nullptr){
for (int i=0; i<comm->size(); i++)
- if (comm->errhandlers_[i]!=MPI_ERRHANDLER_NULL)
+ if (comm->errhandlers_[i]!=MPI_ERRHANDLER_NULL)
simgrid::smpi::Errhandler::unref(comm->errhandlers_[i]);
delete[] comm->errhandlers_;
} else if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
simgrid::smpi::Errhandler::unref(comm->errhandler_);
+ if(comm->collectives_counts_!=nullptr)
+ delete[] comm->collectives_counts_;
}
Group::unref(comm->group_);
if(comm->refcount_==0)
// Are the nodes uniform ? = same number of process/node
int my_local_size=comm_intra->size();
+ int is_uniform;
if(comm_intra->rank()==0) {
- int is_uniform = 1;
+ is_uniform = 1;
auto* non_uniform_map = xbt_new0(int, leader_group_size);
allgather__ring(&my_local_size, 1, MPI_INT,
non_uniform_map, 1, MPI_INT, leader_comm);
}else{
xbt_free(non_uniform_map);
}
- is_uniform_=is_uniform;
}
- bcast__scatter_LR_allgather(&is_uniform_, 1, MPI_INT, 0, comm_intra);
+ bcast__scatter_LR_allgather(&is_uniform, 1, MPI_INT, 0, comm_intra);
+ is_uniform_ = (is_uniform != 0);
// we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(s4u::Actor::self());
int global_blocked;
allreduce__default(&is_blocked, &global_blocked, 1, MPI_INT, MPI_LAND, this);
- if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD){
- if(this->rank()==0){
- is_blocked_ = global_blocked;
- }
- }else{
- is_blocked_=global_blocked;
- }
+ if ((MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED && this != MPI_COMM_WORLD) || this->rank() == 0)
+ is_blocked_ = (global_blocked != 0);
delete[] leader_list;
if(replaying)
MPI_Info Comm::info()
{
- if (info_ == MPI_INFO_NULL)
- info_ = new Info();
- info_->ref();
return info_;
}
errhandler_->ref();
return errhandler_;
} else {
- if(errhandlers_==nullptr)
- return MPI_ERRORS_ARE_FATAL;
- else {
+ if(errhandlers_==nullptr){
+ if (_smpi_cfg_default_errhandler_is_error)
+ return MPI_ERRORS_ARE_FATAL;
+ else
+ return MPI_ERRORS_RETURN;
+ } else {
if(errhandlers_[this->rank()] != MPI_ERRHANDLER_NULL)
errhandlers_[this->rank()]->ref();
return errhandlers_[this->rank()];
}
}
+static inline std::string hash_message(int src, int dst, int tag){
+ return std::to_string(tag) + '_' + std::to_string(src) + '_' + std::to_string(dst);
+}
+
+unsigned int Comm::get_sent_messages_count(int src, int dst, int tag)
+{
+ return sent_messages_[hash_message(src, dst, tag)];
+}
+
+void Comm::increment_sent_messages_count(int src, int dst, int tag)
+{
+ sent_messages_[hash_message(src, dst, tag)]++;
+}
+
+unsigned int Comm::get_received_messages_count(int src, int dst, int tag)
+{
+ return recv_messages_[hash_message(src, dst, tag)];
+}
+
+void Comm::increment_received_messages_count(int src, int dst, int tag)
+{
+ recv_messages_[hash_message(src, dst, tag)]++;
+}
+
+unsigned int Comm::get_collectives_count()
+{
+ if (this==MPI_COMM_UNINITIALIZED){
+ return smpi_process()->comm_world()->get_collectives_count();
+ }else if(this == MPI_COMM_WORLD || this == smpi_process()->comm_world()){
+ if(collectives_counts_==nullptr)
+ collectives_counts_=new unsigned int[this->size()]{0};
+ return collectives_counts_[this->rank()];
+ }else{
+ return collectives_count_;
+ }
+}
+
+void Comm::increment_collectives_count()
+{
+ if (this==MPI_COMM_UNINITIALIZED){
+ smpi_process()->comm_world()->increment_collectives_count();
+ }else if (this == MPI_COMM_WORLD || this == smpi_process()->comm_world()){
+ if(collectives_counts_==nullptr)
+ collectives_counts_=new unsigned int[this->size()]{0};
+ collectives_counts_[this->rank()]++;
+ }else{
+ collectives_count_++;
+ }
+}
+
} // namespace smpi
} // namespace simgrid