Comm::Comm(MPI_Group group, MPI_Topology topo) : group_(group), topo_(topo)
{
- refcount_=1;
- topoType_ = MPI_INVALID_TOPO;
- intra_comm_ = MPI_COMM_NULL;
- leaders_comm_ = MPI_COMM_NULL;
- is_uniform_=1;
+ refcount_ = 1;
+ topoType_ = MPI_INVALID_TOPO;
+ intra_comm_ = MPI_COMM_NULL;
+ leaders_comm_ = MPI_COMM_NULL;
+ is_uniform_ = 1;
non_uniform_map_ = nullptr;
- leaders_map_ = nullptr;
- is_blocked_=0;
+ leaders_map_ = nullptr;
+ is_blocked_ = 0;
}
void Comm::destroy(Comm* comm)
smpi_switch_data_segment(smpi_process()->index());
}
MPI_Group cp = new Group(this->group());
- (*newcomm) = new Comm(cp, this->topo());
- int ret = MPI_SUCCESS;
+ (*newcomm) = new Comm(cp, this->topo());
+ int ret = MPI_SUCCESS;
if (not attributes()->empty()) {
int flag;
if (non_uniform_map_ != nullptr)
xbt_free(non_uniform_map_);
if (leaders_map_ != nullptr)
- xbt_free(leaders_map_);
+ delete[] leaders_map_;
}
void Comm::unref(Comm* comm){
}
//identify neighbours in comm
//get the indexes of all processes sharing the same simix host
- xbt_swag_t process_list = sg_host_self()->extension<simgrid::simix::Host>()->process_list;
+ const auto& process_list = sg_host_self()->extension<simgrid::simix::Host>()->process_list;
int intra_comm_size = 0;
int min_index = INT_MAX; // the minimum index will be the leader
- smx_actor_t actor = nullptr;
- xbt_swag_foreach(actor, process_list)
- {
- int index = actor->pid - 1;
-
+ for (auto const& actor : process_list) {
+ int index = actor.pid - 1;
if (this->group()->rank(index) != MPI_UNDEFINED) {
intra_comm_size++;
// the process is in the comm
XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
MPI_Group group_intra = new Group(intra_comm_size);
int i = 0;
- actor = nullptr;
- xbt_swag_foreach(actor, process_list) {
- int index = actor->pid -1;
+ for (auto const& actor : process_list) {
+ int index = actor.pid - 1;
if(this->group()->rank(index)!=MPI_UNDEFINED){
group_intra->set_mapping(index, i);
i++;
MPI_Comm comm_intra = new Comm(group_intra, nullptr);
leader=min_index;
- int * leaders_map= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
- int * leader_list= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
- for(i=0; i<comm_size; i++){
- leader_list[i] = -1;
- }
+ int* leaders_map = new int[comm_size];
+ int* leader_list = new int[comm_size];
+ std::fill_n(leaders_map, comm_size, 0);
+ std::fill_n(leader_list, comm_size, -1);
Coll_allgather_mpich::allgather(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, this);
if(leaders_map_==nullptr){
leaders_map_= leaders_map;
}else{
- xbt_free(leaders_map);
+ delete[] leaders_map;
}
- int j=0;
int leader_group_size = 0;
for(i=0; i<comm_size; i++){
int already_done = 0;
- for (j = 0; j < leader_group_size; j++) {
+ for (int j = 0; j < leader_group_size; j++) {
if (leaders_map_[i] == leader_list[j]) {
already_done = 1;
}
}else{
is_blocked_=global_blocked;
}
- xbt_free(leader_list);
+ delete[] leader_list;
if(replaying)
smpi_process()->set_replaying(true);