Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar is right: a std:vector is just fine here.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 25 Mar 2022 08:26:53 +0000 (09:26 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 25 Mar 2022 08:26:53 +0000 (09:26 +0100)
src/smpi/include/smpi_comm.hpp
src/smpi/mpi/smpi_comm.cpp

index 9310454..dee8666 100644 (file)
@@ -43,7 +43,7 @@ class Comm : public F2C, public Keyval{
   std::unordered_map<std::string, unsigned int> sent_messages_;
   std::unordered_map<std::string, unsigned int> recv_messages_;
   unsigned int collectives_count_ = 0;
-  std::unique_ptr<unsigned int[]> collectives_counts_; // for MPI_COMM_WORLD only
+  std::vector<unsigned int> collectives_counts_; // for MPI_COMM_WORLD only
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
index 83d6612..7a19277 100644 (file)
@@ -654,8 +654,8 @@ unsigned int Comm::get_collectives_count()
   if (this==MPI_COMM_UNINITIALIZED){
     return smpi_process()->comm_world()->get_collectives_count();
   }else if(this == MPI_COMM_WORLD || this == smpi_process()->comm_world()){
-    if (not collectives_counts_)
-      collectives_counts_ = std::make_unique<unsigned int[]>(this->size());
+    if (collectives_counts_.empty())
+      collectives_counts_.resize(this->size());
     return collectives_counts_[this->rank()];
   }else{
     return collectives_count_;
@@ -667,8 +667,8 @@ void Comm::increment_collectives_count()
    if (this==MPI_COMM_UNINITIALIZED){
     smpi_process()->comm_world()->increment_collectives_count();
   }else if (this == MPI_COMM_WORLD || this == smpi_process()->comm_world()){
-    if (not collectives_counts_)
-      collectives_counts_ = std::make_unique<unsigned int[]>(this->size());
+    if (collectives_counts_.empty())
+      collectives_counts_.resize(this->size());
     collectives_counts_[this->rank()]++;
   }else{
     collectives_count_++;