xbt_dict_t smpi_comm_keyvals = nullptr;
int comm_keyval_id = 0;//avoid collisions
+
+simgrid::smpi::Comm mpi_MPI_COMM_UNINITIALIZED;
+MPI_Comm MPI_COMM_UNINITIALIZED=&mpi_MPI_COMM_UNINITIALIZED;
+
/* Support for cartesian topology was added, but there are 2 other types of topology, graph et dist graph. In order to
* support them, we have to add a field MPIR_Topo_type, and replace the MPI_Topology field by an union. */
}
namespace simgrid{
-namespace SMPI{
+namespace smpi{
+
+Comm::Comm(){}
-Comm::Comm(MPI_Group group, MPI_Topology topo)
+Comm::Comm(MPI_Group group, MPI_Topology topo) : m_group(group), m_topo(topo)
{
- m_group = group;
m_refcount=1;
m_topoType = MPI_INVALID_TOPO;
- m_topo = topo;
m_intra_comm = MPI_COMM_NULL;
m_leaders_comm = MPI_COMM_NULL;
m_is_uniform=1;
void Comm::destroy()
{
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->destroy();
- smpi_topo_destroy(m_topo); // there's no use count on topos
+ smpi_process_comm_world()->destroy();
+ delete m_topo; // there's no use count on topos
this->unuse();
}
if(smpi_privatize_global_variables){ //we need to switch as the called function may silently touch global variables
smpi_switch_data_segment(smpi_process_index());
}
- MPI_Group cp = new simgrid::SMPI::Group(this->group());
- (*newcomm) = new simgrid::SMPI::Comm(cp, this->topo());
+ MPI_Group cp = new simgrid::smpi::Group(this->group());
+ (*newcomm) = new simgrid::smpi::Comm(cp, this->topo());
int ret = MPI_SUCCESS;
if(m_attributes !=nullptr){
void Comm::get_name (char* name, int* len)
{
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->get_name(name, len);
+ smpi_process_comm_world()->get_name(name, len);
if(this == MPI_COMM_WORLD) {
strncpy(name, "WORLD",5);
*len = 5;
void Comm::set_leaders_comm(MPI_Comm leaders){
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->set_leaders_comm(leaders);
+ smpi_process_comm_world()->set_leaders_comm(leaders);
m_leaders_comm=leaders;
}
rankmap[2 * count + 1] = recvbuf[2 * i + 1];
count++;
qsort(rankmap, count, 2 * sizeof(int), &smpi_compare_rankmap);
- group_out = new simgrid::SMPI::Group(count);
+ group_out = new simgrid::smpi::Group(count);
if (i == 0) {
group_root = group_out; /* Save root's group */
}
int reqs = 0;
for (int j = 0; j < count; j++) {
if(rankmap[2 * j] != 0) {
- group_snd[reqs]=new simgrid::SMPI::Group(group_out);
+ group_snd[reqs]=new simgrid::smpi::Group(group_out);
requests[reqs] = smpi_mpi_isend(&(group_snd[reqs]), 1, MPI_PTR, rankmap[2 * j], system_tag, this);
reqs++;
}
smpi_mpi_recv(&group_out, 1, MPI_PTR, 0, system_tag, this, MPI_STATUS_IGNORE);
} /* otherwise, exit with group_out == nullptr */
}
- return group_out!=nullptr ? new simgrid::SMPI::Comm(group_out, nullptr) : MPI_COMM_NULL;
+ return group_out!=nullptr ? new simgrid::smpi::Comm(group_out, nullptr) : MPI_COMM_NULL;
}
void Comm::use(){
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->use();
+ smpi_process_comm_world()->use();
m_group->use();
m_refcount++;
}
void Comm::unuse(){
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->unuse();
+ smpi_process_comm_world()->unuse();
m_refcount--;
m_group->unuse();
int leader = -1;
if (this == MPI_COMM_UNINITIALIZED)
- return smpi_process_comm_world()->init_smp();
+ smpi_process_comm_world()->init_smp();
int comm_size = this->size();
}
}
XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
- MPI_Group group_intra = new simgrid::SMPI::Group(intra_comm_size);
+ MPI_Group group_intra = new simgrid::smpi::Group(intra_comm_size);
i=0;
process = nullptr;
xbt_swag_foreach(process, process_list) {
}
}
- MPI_Comm comm_intra = new simgrid::SMPI::Comm(group_intra, nullptr);
+ MPI_Comm comm_intra = new simgrid::smpi::Comm(group_intra, nullptr);
leader=min_index;
int * leaders_map= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
}
qsort(leader_list, leader_group_size, sizeof(int),compare_ints);
- MPI_Group leaders_group = new simgrid::SMPI::Group(leader_group_size);
+ MPI_Group leaders_group = new simgrid::smpi::Group(leader_group_size);
MPI_Comm leader_comm = MPI_COMM_NULL;
if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && this!=MPI_COMM_WORLD){
//create leader_communicator
for (i=0; i< leader_group_size;i++)
leaders_group->set_mapping(leader_list[i], i);
- leader_comm = new simgrid::SMPI::Comm(leaders_group, nullptr);
+ leader_comm = new simgrid::smpi::Comm(leaders_group, nullptr);
this->set_leaders_comm(leader_comm);
this->set_intra_comm(comm_intra);
leaders_group->set_mapping(leader_list[i], i);
if(this->get_leaders_comm()==MPI_COMM_NULL){
- leader_comm = new simgrid::SMPI::Comm(leaders_group, nullptr);
+ leader_comm = new simgrid::smpi::Comm(leaders_group, nullptr);
this->set_leaders_comm(leader_comm);
}else{
leader_comm=this->get_leaders_comm();