Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stop failing at applying simple regexps :p
authordegomme <augustin.degomme@unibas.ch>
Tue, 7 Mar 2017 11:35:33 +0000 (12:35 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Tue, 7 Mar 2017 11:35:33 +0000 (12:35 +0100)
src/smpi/smpi_comm.cpp
src/smpi/smpi_comm.hpp
src/smpi/smpi_group.cpp
src/smpi/smpi_group.hpp
src/smpi/smpi_topo.cpp
src/smpi/smpi_topo.hpp

index b996066..489af18 100644 (file)
@@ -55,17 +55,17 @@ namespace smpi{
 
 Comm::Comm(){}
 
-Comm::Comm(MPI_Group group, MPI_Topology topo) : _group(group), _topo(topo)
+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;
-  _non_uniform_map = nullptr;
-  _leaders_map = nullptr;
-  _is_blocked=0;
-  _attributes=nullptr;
+  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;
+  attributes_=nullptr;
 }
 
 void Comm::destroy()
@@ -74,7 +74,7 @@ void Comm::destroy()
     smpi_process_comm_world()->destroy();
     return;
   }
-  delete _topo; // there's no use count on topos
+  delete topo_; // there's no use count on topos
   this->unuse();
 }
 
@@ -86,14 +86,14 @@ int Comm::dup(MPI_Comm* newcomm){
   (*newcomm) = new simgrid::smpi::Comm(cp, this->topo());
   int ret = MPI_SUCCESS;
 
-  if(_attributes !=nullptr){
-    (*newcomm)->_attributes   = xbt_dict_new_homogeneous(nullptr);
+  if(attributes_ !=nullptr){
+    (*newcomm)->attributes_   = xbt_dict_new_homogeneous(nullptr);
     xbt_dict_cursor_t cursor = nullptr;
     char* key;
     int flag;
     void* value_in;
     void* value_out;
-    xbt_dict_foreach (_attributes, cursor, key, value_in) {
+    xbt_dict_foreach (attributes_, cursor, key, value_in) {
       smpi_comm_key_elem elem =
           static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, key, sizeof(int)));
       if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
@@ -105,7 +105,7 @@ int Comm::dup(MPI_Comm* newcomm){
           return ret;
         }
         if (flag)
-          xbt_dict_set_ext((*newcomm)->_attributes, key, sizeof(int), value_out, nullptr);
+          xbt_dict_set_ext((*newcomm)->attributes_, key, sizeof(int), value_out, nullptr);
       }
       }
     }
@@ -116,25 +116,25 @@ MPI_Group Comm::group()
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->group();
-  return _group;
+  return group_;
 }
 
 MPI_Topology Comm::topo() {
-  return _topo;
+  return topo_;
 }
 
 int Comm::size()
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->size();
-  return _group->size();
+  return group_->size();
 }
 
 int Comm::rank()
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->rank();
-  return _group->rank(smpi_process_index());
+  return group_->rank(smpi_process_index());
 }
 
 void Comm::get_name (char* name, int* len)
@@ -156,47 +156,47 @@ void Comm::set_leaders_comm(MPI_Comm leaders){
     smpi_process_comm_world()->set_leaders_comm(leaders);
     return;
   }
-  _leaders_comm=leaders;
+  leaders_comm_=leaders;
 }
 
 void Comm::set_intra_comm(MPI_Comm leaders){
-  _intra_comm=leaders;
+  intra_comm_=leaders;
 }
 
 int* Comm::get_non_uniform_map(){
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->get_non_uniform_map();
-  return _non_uniform_map;
+  return non_uniform_map_;
 }
 
 int* Comm::get_leaders_map(){
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->get_leaders_map();
-  return _leaders_map;
+  return leaders_map_;
 }
 
 MPI_Comm Comm::get_leaders_comm(){
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->get_leaders_comm();
-  return _leaders_comm;
+  return leaders_comm_;
 }
 
 MPI_Comm Comm::get_intra_comm(){
   if (this == MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD) 
     return smpi_process_get_comm_intra();
-  else return _intra_comm;
+  else return intra_comm_;
 }
 
 int Comm::is_uniform(){
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->is_uniform();
-  return _is_uniform;
+  return is_uniform_;
 }
 
 int Comm::is_blocked(){
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process_comm_world()->is_blocked();
-  return _is_blocked;
+  return is_blocked_;
 }
 
 MPI_Comm Comm::split(int color, int key)
@@ -284,34 +284,34 @@ void Comm::use(){
     smpi_process_comm_world()->use();
     return;
   }
-  _group->use();
-  _refcount++;
+  group_->use();
+  refcount_++;
 }
 
 void Comm::cleanup_attributes(){
-  if(_attributes !=nullptr){
+  if(attributes_ !=nullptr){
     xbt_dict_cursor_t cursor = nullptr;
     char* key;
     void* value;
     int flag;
-    xbt_dict_foreach (_attributes, cursor, key, value) {
+    xbt_dict_foreach (attributes_, cursor, key, value) {
       smpi_comm_key_elem elem = static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, key));
       if (elem != nullptr && elem->delete_fn != nullptr)
         elem->delete_fn(this, atoi(key), value, &flag);
     }
-    xbt_dict_free(&_attributes);
+    xbt_dict_free(&attributes_);
   }
 }
 
 void Comm::cleanup_smp(){
-  if (_intra_comm != MPI_COMM_NULL)
-    _intra_comm->unuse();
-  if (_leaders_comm != MPI_COMM_NULL)
-    _leaders_comm->unuse();
-  if (_non_uniform_map != nullptr)
-    xbt_free(_non_uniform_map);
-  if (_leaders_map != nullptr)
-    xbt_free(_leaders_map);
+  if (intra_comm_ != MPI_COMM_NULL)
+    intra_comm_->unuse();
+  if (leaders_comm_ != MPI_COMM_NULL)
+    leaders_comm_->unuse();
+  if (non_uniform_map_ != nullptr)
+    xbt_free(non_uniform_map_);
+  if (leaders_map_ != nullptr)
+    xbt_free(leaders_map_);
 }
 
 void Comm::unuse(){
@@ -319,10 +319,10 @@ void Comm::unuse(){
     smpi_process_comm_world()->unuse();
     return;
   }
-  _refcount--;
-  _group->unuse();
+  refcount_--;
+  group_->unuse();
 
-  if(_refcount==0){
+  if(refcount_==0){
     this->cleanup_smp();
     this->cleanup_attributes();
     delete this;
@@ -401,8 +401,8 @@ void Comm::init_smp(){
      smpi_switch_data_segment(smpi_process_index());
    }
 
-  if(_leaders_map==nullptr){
-    _leaders_map= leaders_map;
+  if(leaders_map_==nullptr){
+    leaders_map_= leaders_map;
   }else{
     xbt_free(leaders_map);
   }
@@ -411,12 +411,12 @@ void Comm::init_smp(){
   for(i=0; i<comm_size; i++){
       int already_done=0;
       for(j=0;j<leader_group_size; j++){
-        if(_leaders_map[i]==leader_list[j]){
+        if(leaders_map_[i]==leader_list[j]){
             already_done=1;
         }
       }
       if(already_done==0){
-        leader_list[leader_group_size]=_leaders_map[i];
+        leader_list[leader_group_size]=leaders_map_[i];
         leader_group_size++;
       }
   }
@@ -463,13 +463,13 @@ void Comm::init_smp(){
       }
     }
     if(is_uniform==0 && this->is_uniform()!=0){
-        _non_uniform_map= non_uniform_map;
+        non_uniform_map_= non_uniform_map;
     }else{
         xbt_free(non_uniform_map);
     }
-    _is_uniform=is_uniform;
+    is_uniform_=is_uniform;
   }
-  smpi_coll_tuned_bcast_mpich(&(_is_uniform),1, MPI_INT, 0, comm_intra );
+  smpi_coll_tuned_bcast_mpich(&(is_uniform_),1, MPI_INT, 0, comm_intra );
 
   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());
@@ -491,10 +491,10 @@ void Comm::init_smp(){
 
   if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD){
     if(this->rank()==0){
-        _is_blocked=global_blocked;
+        is_blocked_=global_blocked;
     }
   }else{
-    _is_blocked=global_blocked;
+    is_blocked_=global_blocked;
   }
   xbt_free(leader_list);
   
@@ -516,10 +516,10 @@ int Comm::attr_delete(int keyval){
         return ret;
     }
   }
-  if(_attributes==nullptr)
+  if(attributes_==nullptr)
     return MPI_ERR_ARG;
 
-  xbt_dict_remove_ext(_attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
+  xbt_dict_remove_ext(attributes_, reinterpret_cast<const char*>(&keyval), sizeof(int));
   return MPI_SUCCESS;
 }
 
@@ -528,13 +528,13 @@ int Comm::attr_get(int keyval, void* attr_value, int* flag){
     static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
   if(elem==nullptr)
     return MPI_ERR_ARG;
-  if(_attributes==nullptr){
+  if(attributes_==nullptr){
     *flag=0;
     return MPI_SUCCESS;
   }
   try {
     *static_cast<void**>(attr_value) =
-        xbt_dict_get_ext(_attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
+        xbt_dict_get_ext(attributes_, reinterpret_cast<const char*>(&keyval), sizeof(int));
     *flag=1;
   }
   catch (xbt_ex& ex) {
@@ -558,10 +558,10 @@ int Comm::attr_put(int keyval, void* attr_value){
     if(ret!=MPI_SUCCESS) 
       return ret;
   }
-  if(_attributes==nullptr)
-    _attributes = xbt_dict_new_homogeneous(nullptr);
+  if(attributes_==nullptr)
+    attributes_ = xbt_dict_new_homogeneous(nullptr);
 
-  xbt_dict_set_ext(_attributes,  reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, nullptr);
+  xbt_dict_set_ext(attributes_,  reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, nullptr);
   return MPI_SUCCESS;
 }
 
index 70eb47a..700c9de 100644 (file)
@@ -15,18 +15,18 @@ namespace smpi{
 class Comm {
 
   private:
-    MPI_Group _group;
-    MPIR_Topo_type _topoType
-    MPI_Topology _topo; // to be replaced by an union
-    int _refcount;
-    MPI_Comm _leaders_comm;//inter-node communicator
-    MPI_Comm _intra_comm;//intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
+    MPI_Group group_;
+    MPIR_Topo_type topoType_
+    MPI_Topology topo_; // to be replaced by an union
+    int refcount_;
+    MPI_Comm leaders_comm_;//inter-node communicator
+    MPI_Comm intra_comm_;//intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
     //use an intracomm stored in the process data instead
-    int* _leaders_map; //who is the leader of each process
-    int _is_uniform;
-    int* _non_uniform_map; //set if smp nodes have a different number of processes allocated
-    int _is_blocked;// are ranks allocated on the same smp node contiguous ?
-    xbt_dict_t _attributes;
+    int* leaders_map_; //who is the leader of each process
+    int is_uniform_;
+    int* non_uniform_map_; //set if smp nodes have a different number of processes allocated
+    int is_blocked_;// are ranks allocated on the same smp node contiguous ?
+    xbt_dict_t attributes_;
 
   public:
     Comm();
index f4c3d96..7507c65 100644 (file)
@@ -15,20 +15,20 @@ namespace smpi{
 
 Group::Group()
 {
-  _size=0;                            /* size */
-  _rank_to_index_map=nullptr;                         /* _rank_to_index_map */
-  _index_to_rank_map=nullptr;                         /* _index_to_rank_map */
-  _refcount=1;                            /* _refcount: start > 0 so that this group never gets freed */
+  size_=0;                            /* size */
+  rank_to_index_map_=nullptr;                         /* rank_to_index_map_ */
+  index_to_rank_map_=nullptr;                         /* index_to_rank_map_ */
+  refcount_=1;                            /* refcount_: start > 0 so that this group never gets freed */
 }
 
-Group::Group(int n) : _size(n)
+Group::Group(int n) : size_(n)
 {
   int i;
-  _rank_to_index_map = xbt_new(int, _size);
-  _index_to_rank_map = xbt_dict_new_homogeneous(xbt_free_f);
-  _refcount = 1;
-  for (i = 0; i < _size; i++) {
-    _rank_to_index_map[i] = MPI_UNDEFINED;
+  rank_to_index_map_ = xbt_new(int, size_);
+  index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
+  refcount_ = 1;
+  for (i = 0; i < size_; i++) {
+    rank_to_index_map_[i] = MPI_UNDEFINED;
   }
 }
 
@@ -42,26 +42,26 @@ Group::Group(MPI_Group origin)
   if(origin != MPI_GROUP_NULL
             && origin != MPI_GROUP_EMPTY)
     {
-      _size = origin->size();
-      _rank_to_index_map = xbt_new(int, _size);
-      _index_to_rank_map = xbt_dict_new_homogeneous(xbt_free_f);
-      _refcount = 1;
-      for (i = 0; i < _size; i++) {
-        _rank_to_index_map[i] = origin->_rank_to_index_map[i];
+      size_ = origin->size();
+      rank_to_index_map_ = xbt_new(int, size_);
+      index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
+      refcount_ = 1;
+      for (i = 0; i < size_; i++) {
+        rank_to_index_map_[i] = origin->rank_to_index_map_[i];
       }
 
-      xbt_dict_foreach(origin->_index_to_rank_map, cursor, key, ptr_rank) {
+      xbt_dict_foreach(origin->index_to_rank_map_, cursor, key, ptr_rank) {
         int * cp = static_cast<int*>(xbt_malloc(sizeof(int)));
         *cp=*reinterpret_cast<int*>(ptr_rank);
-        xbt_dict_set(_index_to_rank_map, key, cp, nullptr);
+        xbt_dict_set(index_to_rank_map_, key, cp, nullptr);
       }
     }
 }
 
 Group::~Group()
 {
-  xbt_free(_rank_to_index_map);
-  xbt_dict_free(&_index_to_rank_map);
+  xbt_free(rank_to_index_map_);
+  xbt_dict_free(&index_to_rank_map_);
 }
 
 void Group::destroy()
@@ -75,14 +75,14 @@ void Group::set_mapping(int index, int rank)
 {
   int * val_rank;
 
-  if (rank < _size) {
-    _rank_to_index_map[rank] = index;
+  if (rank < size_) {
+    rank_to_index_map_[rank] = index;
     if (index!=MPI_UNDEFINED ) {
       val_rank = static_cast<int *>(xbt_malloc(sizeof(int)));
       *val_rank = rank;
 
       char * key = bprintf("%d", index);
-      xbt_dict_set(_index_to_rank_map, key, val_rank, nullptr);
+      xbt_dict_set(index_to_rank_map_, key, val_rank, nullptr);
       xbt_free(key);
     }
   }
@@ -92,8 +92,8 @@ int Group::index(int rank)
 {
   int index = MPI_UNDEFINED;
 
-  if (0 <= rank && rank < _size) {
-    index = _rank_to_index_map[rank];
+  if (0 <= rank && rank < size_) {
+    index = rank_to_index_map_[rank];
   }
   return index;
 }
@@ -104,7 +104,7 @@ int Group::rank(int index)
   if (this==MPI_GROUP_EMPTY)
     return MPI_UNDEFINED;
   char * key = bprintf("%d", index);
-  ptr_rank = static_cast<int*>(xbt_dict_get_or_null(_index_to_rank_map, key));
+  ptr_rank = static_cast<int*>(xbt_dict_get_or_null(index_to_rank_map_, key));
   xbt_free(key);
 
   if (ptr_rank==nullptr)
@@ -114,23 +114,23 @@ int Group::rank(int index)
 
 int Group::use()
 {
-  _refcount++;
-  return _refcount;
+  refcount_++;
+  return refcount_;
 }
 
 int Group::unuse()
 {
-  _refcount--;
-  if (_refcount <= 0) {
+  refcount_--;
+  if (refcount_ <= 0) {
     delete this;
     return 0;
   }
-  return _refcount;
+  return refcount_;
 }
 
 int Group::size()
 {
-  return _size;
+  return size_;
 }
 
 int Group::compare(MPI_Group group2)
@@ -142,7 +142,7 @@ int Group::compare(MPI_Group group2)
   int sz;
 
   result = MPI_IDENT;
-  if (_size != group2->size()) {
+  if (size_ != group2->size()) {
     result = MPI_UNEQUAL;
   } else {
     sz = group2->size();
@@ -167,7 +167,7 @@ int Group::incl(int n, int* ranks, MPI_Group* newgroup)
   int index=0;
   if (n == 0) {
     *newgroup = MPI_GROUP_EMPTY;
-  } else if (n == _size) {
+  } else if (n == size_) {
     *newgroup = this;
     if(this!= MPI_COMM_WORLD->group()
               && this != MPI_COMM_SELF->group()
@@ -185,7 +185,7 @@ int Group::incl(int n, int* ranks, MPI_Group* newgroup)
 
 int Group::group_union(MPI_Group group2, MPI_Group* newgroup)
 {
-  int size1 = _size;
+  int size1 = size_;
   int size2 = group2->size();
   for (int i = 0; i < size2; i++) {
     int proc2 = group2->index(i);
@@ -240,8 +240,8 @@ int Group::intersection(MPI_Group group2, MPI_Group* newgroup)
 
 int Group::difference(MPI_Group group2, MPI_Group* newgroup)
 {
-  int newsize = _size;
-  int size2 = _size;
+  int newsize = size_;
+  int size2 = size_;
   for (int i = 0; i < size2; i++) {
     int proc1 = this->index(i);
     int proc2 = group2->rank(proc1);
@@ -265,10 +265,10 @@ int Group::difference(MPI_Group group2, MPI_Group* newgroup)
 }
 
 int Group::excl(int n, int *ranks, MPI_Group * newgroup){
-  int oldsize = _size;
+  int oldsize = size_;
   int newsize = oldsize - n;
   *newgroup = new simgrid::smpi::Group(newsize);
-  int* to_exclude=xbt_new0(int, _size);
+  int* to_exclude=xbt_new0(int, size_);
   for (int i     = 0; i < oldsize; i++)
     to_exclude[i]=0;
   for (int i            = 0; i < n; i++)
@@ -290,7 +290,7 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
   int newsize = 0;
   for (int i = 0; i < n; i++) {
     for (int rank = ranges[i][0];                    /* First */
-         rank >= 0 && rank < _size; /* Last */
+         rank >= 0 && rank < size_; /* Last */
          ) {
       newsize++;
       if(rank == ranges[i][1]){/*already last ?*/
@@ -310,7 +310,7 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
   int j     = 0;
   for (int i = 0; i < n; i++) {
     for (int rank = ranges[i][0];                    /* First */
-         rank >= 0 && rank < _size; /* Last */
+         rank >= 0 && rank < size_; /* Last */
          ) {
       int index = this->index(rank);
       (*newgroup)->set_mapping(index, j);
@@ -332,10 +332,10 @@ int Group::range_incl(int n, int ranges[][3], MPI_Group * newgroup){
 }
 
 int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
-  int newsize = _size;
+  int newsize = size_;
   for (int i = 0; i < n; i++) {
     for (int rank = ranges[i][0];                    /* First */
-         rank >= 0 && rank < _size; /* Last */
+         rank >= 0 && rank < size_; /* Last */
          ) {
       newsize--;
       if(rank == ranges[i][1]){/*already last ?*/
@@ -360,7 +360,7 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
     while (newrank < newsize) {
       int add = 1;
       for (int i = 0; i < n; i++) {
-        for (int rank = ranges[i][0]; rank >= 0 && rank < _size;) {
+        for (int rank = ranges[i][0]; rank >= 0 && rank < size_;) {
           if(rank==oldrank){
             add = 0;
             break;
index 8fa5e60..f7c2572 100644 (file)
@@ -14,10 +14,10 @@ namespace smpi{
 
 class Group {
   private:
-    int _size;
-    int *_rank_to_index_map;
-    xbt_dict_t _index_to_rank_map;
-    int _refcount;
+    int size_;
+    int *rank_to_index_map_;
+    xbt_dict_t index_to_rank_map_;
+    int refcount_;
   public:
 
     Group();
index 7b102ed..4021d19 100644 (file)
@@ -21,16 +21,16 @@ namespace smpi{
 
 Graph::~Graph() 
 {
-  delete[] _index;
-  delete[] _edges;
+  delete[] index_;
+  delete[] edges_;
 }
 
 Dist_Graph::~Dist_Graph() 
 {
-  delete[] _in;
-  delete[] _in_weights;
-  delete[] _out;
-  delete[] _out_weights;
+  delete[] in_;
+  delete[] in_weights_;
+  delete[] out_;
+  delete[] out_weights_;
 }
 
 /*******************************************************************************
@@ -38,18 +38,18 @@ Dist_Graph::~Dist_Graph()
  ******************************************************************************/
 Cart::~Cart() 
 {
-  delete[] _dims;
-  delete[] _periodic;
-  delete[] _position;
+  delete[] dims_;
+  delete[] periodic_;
+  delete[] position_;
 }
 
 Cart::Cart(int ndims)
 {
-  _nnodes = 0;
-  _ndims = ndims;
-  _dims = new int[ndims];
-  _periodic = new int[ndims];
-  _position = new int[ndims];
+  nnodes_ = 0;
+  ndims_ = ndims;
+  dims_ = new int[ndims];
+  periodic_ = new int[ndims];
+  position_ = new int[ndims];
 }
 
 /* reorder is ignored, don't know what would be the consequences of a dumb reordering but neither do I see the point of
@@ -76,16 +76,16 @@ Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder,
       newGroup->set_mapping(oldGroup->index(i), i);
     }
 
-    _nnodes = newSize;
+    nnodes_ = newSize;
 
     //  FIXME : code duplication... See coords
     nranks = newSize;
     for (int i=0; i<ndims; i++) {
-      _dims[i] = dims[i];
-     _periodic[i] = periods[i];
+      dims_[i] = dims[i];
+     periodic_[i] = periods[i];
       nranks = nranks / dims[i];
       /* FIXME: nranks could be zero (?) */
-      _position[i] = rank / nranks;
+      position_[i] = rank / nranks;
       rank = rank % nranks;
     }
 
@@ -97,11 +97,11 @@ Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder,
       *comm_cart = MPI_COMM_NULL;
     }
   }
-  _comm=*comm_cart;
+  comm_=*comm_cart;
 }
 
 Cart* Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
-  int oldNDims = _ndims;
+  int oldNDims = ndims_;
   int j = 0;
   int *newDims = nullptr;
   int *newPeriodic = nullptr;
@@ -122,19 +122,19 @@ Cart* Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
     // that should not segfault
     for (int i = 0 ; j < newNDims ; i++) {
       if(remain_dims[i]) {
-        newDims[j] =_dims[i];
-        newPeriodic[j] =_periodic[i];
+        newDims[j] =dims_[i];
+        newPeriodic[j] =periodic_[i];
         j++;
       }
     }
   }
-  return new Cart(_comm, newNDims, newDims, newPeriodic, 0, newcomm);
+  return new Cart(comm_, newNDims, newDims, newPeriodic, 0, newcomm);
 }
 
 int Cart::coords(int rank, int maxdims, int coords[]) {
-  int nnodes = _nnodes;
-  for (int i = 0; i< _ndims; i++ ) {
-    nnodes    = nnodes /_dims[i];
+  int nnodes = nnodes_;
+  for (int i = 0; i< ndims_; i++ ) {
+    nnodes    = nnodes /dims_[i];
     coords[i] = rank / nnodes;
     rank      = rank % nnodes;
   }
@@ -142,17 +142,17 @@ int Cart::coords(int rank, int maxdims, int coords[]) {
 }
 
 int Cart::get(int maxdims, int* dims, int* periods, int* coords) {
-  int ndims=_ndims < maxdims ?_ndims : maxdims;
+  int ndims=ndims_ < maxdims ?ndims_ : maxdims;
   for(int i = 0 ; i < ndims ; i++) {
-    dims[i] =_dims[i];
-    periods[i] =_periodic[i];
-    coords[i] =_position[i];
+    dims[i] =dims_[i];
+    periods[i] =periodic_[i];
+    coords[i] =position_[i];
   }
   return MPI_SUCCESS;
 }
 
 int Cart::rank(int* coords, int* rank) {
-  int ndims =_ndims;
+  int ndims =ndims_;
   int coord;
   *rank = 0;
   int multiplier = 1;
@@ -163,19 +163,19 @@ int Cart::rank(int* coords, int* rank) {
     /* The user can give us whatever coordinates he wants. If one of them is out of range, either this dimension is
      * periodic, and we consider the equivalent coordinate inside the bounds, or it's not and then it's an error
      */
-    if (coord >=_dims[i]) {
-      if (_periodic[i] ) {
-        coord = coord %_dims[i];
+    if (coord >=dims_[i]) {
+      if (periodic_[i] ) {
+        coord = coord %dims_[i];
       } else {
         // Should I do that ?
         *rank = -1;
         return MPI_ERR_ARG;
       }
     } else if (coord <  0) {
-      if(_periodic[i]) {
-        coord = coord %_dims[i];
+      if(periodic_[i]) {
+        coord = coord %dims_[i];
         if (coord)
-          coord =_dims[i] + coord;
+          coord =dims_[i] + coord;
       } else {
         *rank = -1;
         return MPI_ERR_ARG;
@@ -183,29 +183,29 @@ int Cart::rank(int* coords, int* rank) {
     }
 
     *rank += multiplier * coord;
-    multiplier *=_dims[i];
+    multiplier *=dims_[i];
   }
   return MPI_SUCCESS;
 }
 
 int Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) {
 
-  int position[_ndims];
+  int position[ndims_];
 
-  if(_ndims == 0) {
+  if(ndims_ == 0) {
     return MPI_ERR_ARG;
   }
-  if (_ndims < direction) {
+  if (ndims_ < direction) {
     return MPI_ERR_DIMS;
   }
 
-  this->coords(_comm->rank(),_ndims, position);
+  this->coords(comm_->rank(),ndims_, position);
   position[direction] += disp;
 
   if(position[direction] < 0 ||
-      position[direction] >=_dims[direction]) {
-    if(_periodic[direction]) {
-      position[direction] %=_dims[direction];
+      position[direction] >=dims_[direction]) {
+    if(periodic_[direction]) {
+      position[direction] %=dims_[direction];
       this->rank(position, rank_dest);
     } else {
       *rank_dest = MPI_PROC_NULL;
@@ -214,10 +214,10 @@ int Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) {
     this->rank(position, rank_dest);
   }
 
-  position[direction] = _position[direction] - disp;
-  if(position[direction] < 0 || position[direction] >=_dims[direction]) {
-    if(_periodic[direction]) {
-      position[direction] %=_dims[direction];
+  position[direction] = position_[direction] - disp;
+  if(position[direction] < 0 || position[direction] >=dims_[direction]) {
+    if(periodic_[direction]) {
+      position[direction] %=dims_[direction];
       this->rank(position, rank_source);
     } else {
       *rank_source = MPI_PROC_NULL;
@@ -230,7 +230,7 @@ int Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) {
 }
 
 int Cart::dim_get(int *ndims) {
-  *ndims =_ndims;
+  *ndims =ndims_;
   return MPI_SUCCESS;
 }
 
index 8927ec4..a7a5b55 100644 (file)
@@ -15,17 +15,17 @@ namespace smpi{
 
 class Topo {
   protected:
-  MPI_Comm _comm;
+  MPI_Comm comm_;
 };
 
 
 class Cart: public Topo {
   private:
-    int _nnodes;
-    int _ndims;
-    int *_dims;
-    int *_periodic;
-    int *_position;
+    int nnodes_;
+    int ndims_;
+    int *dims_;
+    int *periodic_;
+    int *position_;
   public:
     Cart(int ndims);
     ~Cart();
@@ -41,10 +41,10 @@ class Cart: public Topo {
 
 class Graph: public Topo {
   private:
-    int _nnodes;
-    int _nedges;
-    int *_index;
-    int *_edges;
+    int nnodes_;
+    int nedges_;
+    int *index_;
+    int *edges_;
   public:
     Graph();
     ~Graph();
@@ -52,13 +52,13 @@ class Graph: public Topo {
 
 class Dist_Graph: public Topo {
   private:
-    int _indegree;
-    int *_in;
-    int *_in_weights;
-    int _outdegree;
-    int *_out;
-    int *_out_weights;
-    int _is_weighted;
+    int indegree_;
+    int *in_;
+    int *in_weights_;
+    int outdegree_;
+    int *out_;
+    int *out_weights_;
+    int is_weighted_;
   public:
     Dist_Graph();
     ~Dist_Graph();