#include <boost/intrusive_ptr.hpp>
namespace simgrid {
-namespace SMPI {
+namespace smpi {
class Group;
class Comm;
}
}
-typedef simgrid::SMPI::Group SMPI_Group;
-typedef simgrid::SMPI::Comm SMPI_Comm;
-typedef simgrid::SMPI::Topo SMPI_Topology;
-typedef simgrid::SMPI::Graph SMPI_Graph_topology;
-typedef simgrid::SMPI::Cart SMPI_Cart_topology;
-typedef simgrid::SMPI::Dist_Graph SMPI_Dist_Graph_topology;
+typedef simgrid::smpi::Group SMPI_Group;
+typedef simgrid::smpi::Comm SMPI_Comm;
+typedef simgrid::smpi::Topo SMPI_Topology;
+typedef simgrid::smpi::Graph SMPI_Graph_topology;
+typedef simgrid::smpi::Cart SMPI_Cart_topology;
+typedef simgrid::smpi::Dist_Graph SMPI_Dist_Graph_topology;
#else
int comm_keyval_id = 0;//avoid collisions
-simgrid::SMPI::Comm mpi_MPI_COMM_UNINITIALIZED;
+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
}
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_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();
#include "private.h"
namespace simgrid{
-namespace SMPI{
+namespace smpi{
class Comm {
xbt_assert(instance, "Error, unknown instance %s", instance_id);
if(instance->comm_world == MPI_COMM_NULL){
- MPI_Group group = new simgrid::SMPI::Group(instance->size);
- instance->comm_world = new simgrid::SMPI::Comm(group, nullptr);
+ MPI_Group group = new simgrid::smpi::Group(instance->size);
+ instance->comm_world = new simgrid::smpi::Comm(group, nullptr);
}
instance->present_processes++;
index_to_process_data[index]=instance->index+rank;
{
smpi_process_data_t data = smpi_process_data();
if(data->comm_self==MPI_COMM_NULL){
- MPI_Group group = new simgrid::SMPI::Group(1);
- data->comm_self = new simgrid::SMPI::Comm(group, nullptr);
+ MPI_Group group = new simgrid::smpi::Group(1);
+ data->comm_self = new simgrid::smpi::Comm(group, nullptr);
group->set_mapping(smpi_process_index(), 0);
}
//if the process was launched through smpirun script we generate a global mpi_comm_world
//if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance
if(smpirun){
- group = new simgrid::SMPI::Group(process_count);
- MPI_COMM_WORLD = new simgrid::SMPI::Comm(group, nullptr);
+ group = new simgrid::smpi::Group(process_count);
+ MPI_COMM_WORLD = new simgrid::smpi::Comm(group, nullptr);
MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast<void *>(process_count));
msg_bar_t bar = MSG_barrier_init(process_count);
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_group, smpi, "Logging specific to SMPI (group)");
-simgrid::SMPI::Group mpi_MPI_GROUP_EMPTY;
+simgrid::smpi::Group mpi_MPI_GROUP_EMPTY;
MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
namespace simgrid{
-namespace SMPI{
+namespace smpi{
Group::Group()
{
m_refcount=1; /* m_refcount: start > 0 so that this group never gets freed */
}
-Group::Group(int n)
+Group::Group(int n) : m_size(n)
{
int i;
-
- m_size = n;
m_rank_to_index_map = xbt_new(int, m_size);
m_index_to_rank_map = xbt_dict_new_homogeneous(xbt_free_f);
m_refcount = 1;
int Group::compare(MPI_Group group2)
{
int result;
- int i, index, rank, sz;
+ int i;
+ int index;
+ int rank;
+ int sz;
result = MPI_IDENT;
if (m_size != group2->size()) {
int Group::incl(int n, int* ranks, MPI_Group* newgroup)
{
- int i=0, index=0;
+ int i=0;
+ int index=0;
if (n == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else if (n == m_size) {
if (size1 == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::SMPI::Group(size1);
+ *newgroup = new simgrid::smpi::Group(size1);
size2 = this->size();
for (int i = 0; i < size2; i++) {
int proc1 = this->index(i);
if (size2 == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::SMPI::Group(size2);
+ *newgroup = new simgrid::smpi::Group(size2);
int j=0;
for (int i = 0; i < group2->size(); i++) {
int proc2 = group2->index(i);
if (newsize == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::SMPI::Group(newsize);
+ *newgroup = new simgrid::smpi::Group(newsize);
for (int i = 0; i < size2; i++) {
int proc1 = this->index(i);
int proc2 = group2->rank(proc1);
int Group::excl(int n, int *ranks, MPI_Group * newgroup){
int oldsize = m_size;
int newsize = oldsize - n;
- *newgroup = new simgrid::SMPI::Group(newsize);
+ *newgroup = new simgrid::smpi::Group(newsize);
int* to_exclude=xbt_new0(int, m_size);
for (int i = 0; i < oldsize; i++)
to_exclude[i]=0;
}
}
}
- *newgroup = new simgrid::SMPI::Group(newsize);
+ *newgroup = new simgrid::smpi::Group(newsize);
int j = 0;
for (int i = 0; i < n; i++) {
for (int rank = ranges[i][0]; /* First */
if (newsize == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::SMPI::Group(newsize);
+ *newgroup = new simgrid::smpi::Group(newsize);
int newrank = 0;
int oldrank = 0;
while (newrank < newsize) {
#include "private.h"
namespace simgrid{
-namespace SMPI{
+namespace smpi{
class Group {
private:
return MPI_SUCCESS;
}else{
group->use();
- *newcomm = new simgrid::SMPI::Comm(group, nullptr);
+ *newcomm = new simgrid::smpi::Comm(group, nullptr);
return MPI_SUCCESS;
}
}
} else if (ndims < 0 || (ndims > 0 && (dims == nullptr || periodic == nullptr)) || comm_cart == nullptr) {
return MPI_ERR_ARG;
} else{
- new simgrid::SMPI::Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
+ new simgrid::smpi::Cart(comm_old, ndims, dims, periodic, reorder, comm_cart);
return MPI_SUCCESS;
}
}
if (coords == nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (source == nullptr || dest == nullptr || direction < 0 ) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if(coords == nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if(maxdims <= 0 || dims == nullptr || periods == nullptr || coords == nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (ndims == nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (ndims < 1 || nnodes < 1) {
return MPI_ERR_DIMS;
}
- return simgrid::SMPI::Dims_create(nnodes, ndims, dims);
+ return simgrid::smpi::Dims_create(nnodes, ndims, dims);
}
int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
if (comm_new == nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* topo = static_cast<simgrid::SMPI::Cart*>(comm->topo());
+ simgrid::smpi::Cart* topo = static_cast<simgrid::smpi::Cart*>(comm->topo());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
- simgrid::SMPI::Cart* cart = topo->sub(remain_dims, comm_new);
+ simgrid::smpi::Cart* cart = topo->sub(remain_dims, comm_new);
if(cart==nullptr)
return MPI_ERR_ARG;
return MPI_SUCCESS;
namespace simgrid{
-namespace SMPI{
+namespace smpi{
Graph::~Graph()
return;
}
oldGroup = comm_old->group();
- newGroup = new simgrid::SMPI::Group(newSize);
+ newGroup = new simgrid::smpi::Group(newSize);
for (int i = 0 ; i < newSize ; i++) {
newGroup->set_mapping(oldGroup->index(i), i);
}
rank = rank % nranks;
}
- *comm_cart = new simgrid::SMPI::Comm(newGroup, this);
+ *comm_cart = new simgrid::smpi::Comm(newGroup, this);
} else {
if (rank == 0) {
- *comm_cart = new simgrid::SMPI::Comm(new simgrid::SMPI::Group(MPI_COMM_SELF->group()), this);
+ *comm_cart = new simgrid::smpi::Comm(new simgrid::smpi::Group(MPI_COMM_SELF->group()), this);
} else {
*comm_cart = MPI_COMM_NULL;
}
namespace simgrid{
-namespace SMPI{
+namespace smpi{
class Topo {
protected: