From 98bbaf42bf16cc40faee7ddca28c0369144f3d95 Mon Sep 17 00:00:00 2001 From: degomme Date: Tue, 7 Mar 2017 11:09:49 +0100 Subject: [PATCH 1/1] please sonar --- include/smpi/forward.hpp | 14 ++++++------- src/smpi/smpi_comm.cpp | 40 +++++++++++++++++------------------- src/smpi/smpi_comm.hpp | 2 +- src/smpi/smpi_deployment.cpp | 4 ++-- src/smpi/smpi_global.cpp | 8 ++++---- src/smpi/smpi_group.cpp | 28 +++++++++++++------------ src/smpi/smpi_group.hpp | 2 +- src/smpi/smpi_pmpi.cpp | 20 +++++++++--------- src/smpi/smpi_topo.cpp | 8 ++++---- src/smpi/smpi_topo.hpp | 2 +- 10 files changed, 64 insertions(+), 64 deletions(-) diff --git a/include/smpi/forward.hpp b/include/smpi/forward.hpp index 81292da68b..b4f89bfac2 100644 --- a/include/smpi/forward.hpp +++ b/include/smpi/forward.hpp @@ -11,7 +11,7 @@ #include namespace simgrid { -namespace SMPI { +namespace smpi { class Group; class Comm; @@ -23,12 +23,12 @@ class Dist_Graph; } } -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 diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index c8c156906e..d72817b93c 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -24,7 +24,7 @@ xbt_dict_t smpi_comm_keyvals = nullptr; 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 @@ -51,16 +51,14 @@ static int smpi_compare_rankmap(const void *a, const void *b) } 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; @@ -73,7 +71,7 @@ Comm::Comm(MPI_Group group, MPI_Topology topo) 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(); } @@ -82,8 +80,8 @@ int Comm::dup(MPI_Comm* newcomm){ 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){ @@ -140,7 +138,7 @@ int Comm::rank() 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; @@ -151,7 +149,7 @@ void Comm::get_name (char* name, int* len) 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; } @@ -239,7 +237,7 @@ MPI_Comm Comm::split(int color, int key) 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 */ } @@ -251,7 +249,7 @@ MPI_Comm Comm::split(int color, int key) 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++; } @@ -272,12 +270,12 @@ MPI_Comm Comm::split(int color, int key) 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++; } @@ -310,7 +308,7 @@ void Comm::cleanup_smp(){ void Comm::unuse(){ if (this == MPI_COMM_UNINITIALIZED) - return smpi_process_comm_world()->unuse(); + smpi_process_comm_world()->unuse(); m_refcount--; m_group->unuse(); @@ -333,7 +331,7 @@ void Comm::init_smp(){ 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(); @@ -367,7 +365,7 @@ void Comm::init_smp(){ } } 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) { @@ -378,7 +376,7 @@ void Comm::init_smp(){ } } - 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(xbt_malloc0(sizeof(int)*comm_size)); @@ -414,14 +412,14 @@ void Comm::init_smp(){ } 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); @@ -431,7 +429,7 @@ void Comm::init_smp(){ 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(); diff --git a/src/smpi/smpi_comm.hpp b/src/smpi/smpi_comm.hpp index e8773ecd4c..42444058e5 100644 --- a/src/smpi/smpi_comm.hpp +++ b/src/smpi/smpi_comm.hpp @@ -10,7 +10,7 @@ #include "private.h" namespace simgrid{ -namespace SMPI{ +namespace smpi{ class Comm { diff --git a/src/smpi/smpi_deployment.cpp b/src/smpi/smpi_deployment.cpp index d854e78f45..f652e42a24 100644 --- a/src/smpi/smpi_deployment.cpp +++ b/src/smpi/smpi_deployment.cpp @@ -69,8 +69,8 @@ void smpi_deployment_register_process(const char* instance_id, int rank, int ind 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; diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 6dffca85ab..4190569e45 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -352,8 +352,8 @@ MPI_Comm smpi_process_comm_self() { 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); } @@ -604,8 +604,8 @@ void smpi_global_init() //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(process_count)); msg_bar_t bar = MSG_barrier_init(process_count); diff --git a/src/smpi/smpi_group.cpp b/src/smpi/smpi_group.cpp index 1d2619d3ef..8d22f492c3 100644 --- a/src/smpi/smpi_group.cpp +++ b/src/smpi/smpi_group.cpp @@ -7,11 +7,11 @@ #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() { @@ -21,11 +21,9 @@ 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; @@ -138,7 +136,10 @@ int Group::size() 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()) { @@ -162,7 +163,8 @@ int Group::compare(MPI_Group group2) 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) { @@ -195,7 +197,7 @@ int Group::group_union(MPI_Group group2, MPI_Group* newgroup) 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); @@ -222,7 +224,7 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup) 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); @@ -250,7 +252,7 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup) 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); @@ -265,7 +267,7 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup) 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; @@ -304,7 +306,7 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){ } } } - *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 */ @@ -352,7 +354,7 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){ 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) { diff --git a/src/smpi/smpi_group.hpp b/src/smpi/smpi_group.hpp index 466d7c2f47..cdc736253c 100644 --- a/src/smpi/smpi_group.hpp +++ b/src/smpi/smpi_group.hpp @@ -10,7 +10,7 @@ #include "private.h" namespace simgrid{ -namespace SMPI{ +namespace smpi{ class Group { private: diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 6002014fed..81d520da7a 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -525,7 +525,7 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) return MPI_SUCCESS; }else{ group->use(); - *newcomm = new simgrid::SMPI::Comm(group, nullptr); + *newcomm = new simgrid::smpi::Comm(group, nullptr); return MPI_SUCCESS; } } @@ -2306,7 +2306,7 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int } 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; } } @@ -2318,7 +2318,7 @@ int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) { if (coords == nullptr) { return MPI_ERR_ARG; } - simgrid::SMPI::Cart* topo = static_cast(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2332,7 +2332,7 @@ int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* d if (source == nullptr || dest == nullptr || direction < 0 ) { return MPI_ERR_ARG; } - simgrid::SMPI::Cart* topo = static_cast(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2352,7 +2352,7 @@ int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) { if(coords == nullptr) { return MPI_ERR_ARG; } - simgrid::SMPI::Cart* topo = static_cast(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2366,7 +2366,7 @@ int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coor if(maxdims <= 0 || dims == nullptr || periods == nullptr || coords == nullptr) { return MPI_ERR_ARG; } - simgrid::SMPI::Cart* topo = static_cast(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2380,7 +2380,7 @@ int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) { if (ndims == nullptr) { return MPI_ERR_ARG; } - simgrid::SMPI::Cart* topo = static_cast(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2394,7 +2394,7 @@ int PMPI_Dims_create(int nnodes, int ndims, int* dims) { 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) { @@ -2404,11 +2404,11 @@ 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(comm->topo()); + simgrid::smpi::Cart* topo = static_cast(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; diff --git a/src/smpi/smpi_topo.cpp b/src/smpi/smpi_topo.cpp index 39a1a62da3..34189dcb61 100644 --- a/src/smpi/smpi_topo.cpp +++ b/src/smpi/smpi_topo.cpp @@ -16,7 +16,7 @@ static int getfactors(int num, int *nfators, int **factors); namespace simgrid{ -namespace SMPI{ +namespace smpi{ Graph::~Graph() @@ -71,7 +71,7 @@ Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, 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); } @@ -89,10 +89,10 @@ Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, 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; } diff --git a/src/smpi/smpi_topo.hpp b/src/smpi/smpi_topo.hpp index 6fadde1355..ab16147fde 100644 --- a/src/smpi/smpi_topo.hpp +++ b/src/smpi/smpi_topo.hpp @@ -11,7 +11,7 @@ namespace simgrid{ -namespace SMPI{ +namespace smpi{ class Topo { protected: -- 2.20.1