]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use dealii partitioner at less places
authorPeter Munch <peterrmuench@gmail.com>
Mon, 23 Mar 2020 10:06:00 +0000 (11:06 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 23 Mar 2020 10:06:00 +0000 (11:06 +0100)
include/deal.II/lac/la_sm_partitioner.h
include/deal.II/lac/la_sm_vector.templates.h

index 7973662c901fdb6be0e20aa9b3ed372cd81a9151..4bca93cc5d14bfe29b0504951f4374d90e34dc23 100644 (file)
@@ -70,6 +70,9 @@ namespace LinearAlgebra
       reinit(const IndexSet &is_locally_owned, const IndexSet &is_locally_ghost)
       {
         this->n_local_elements = is_locally_owned.n_elements();
+        this->n_ghost_elements = is_locally_ghost.n_elements();
+
+        this->n_mpi_processes_ = Utilities::MPI::n_mpi_processes(comm);
 
         std::vector<unsigned int> sm_ranks(
           Utilities::MPI::n_mpi_processes(comm_sm));
@@ -444,31 +447,52 @@ namespace LinearAlgebra
         compress_finish(data_this, data_others, buffer);
       }
 
+      std::size_t
+      local_size() const
+      {
+        return n_local_elements;
+      }
+
+      std::size_t
+      n_ghost_indices() const
+      {
+        return n_ghost_elements;
+      }
+
+      std::size_t
+      n_mpi_processes() const
+      {
+        return n_mpi_processes_;
+      }
+
     private:
       const MPI_Comm &comm;
       const MPI_Comm &comm_sm;
 
+      unsigned int n_mpi_processes_;
+
       unsigned int n_local_elements;
+      unsigned int n_ghost_elements;
 
       std::vector<unsigned int>            recv_remote_ranks;
       std::vector<types::global_dof_index> recv_remote_ptr = {0};
-      mutable std::vector<MPI_Request>     recv_remote_req;
+      mutable std::vector<MPI_Request>     recv_remote_req; // TODO: move
 
       std::vector<unsigned int>        recv_sm_ranks;
       std::vector<unsigned int>        recv_sm_ptr = {0};
-      mutable std::vector<MPI_Request> recv_sm_req;
+      mutable std::vector<MPI_Request> recv_sm_req; // TODO: move
       std::vector<unsigned int>        recv_sm_indices;
       std::vector<unsigned int>        recv_sm_offset;
 
       std::vector<unsigned int>        send_remote_ranks;
       std::vector<unsigned int>        send_remote_ptr = {0};
       std::vector<unsigned int>        send_remote_indices;
-      mutable std::vector<MPI_Request> send_remote_req;
+      mutable std::vector<MPI_Request> send_remote_req; // TODO: move
 
       std::vector<unsigned int>        send_sm_ranks;
       std::vector<unsigned int>        send_sm_ptr = {0};
       std::vector<unsigned int>        send_sm_indices;
-      mutable std::vector<MPI_Request> send_sm_req;
+      mutable std::vector<MPI_Request> send_sm_req; // TODO: move
       std::vector<unsigned int>        send_sm_offset;
     };
 
index 796cfff466c73c73f84d2e61700b4167cc468d90..28975551b390a41230a46aa6f16595c281500255 100644 (file)
@@ -192,7 +192,7 @@ namespace LinearAlgebra
           partitioner    = v.partitioner;
           partitioner_sm = v.partitioner_sm;
           const size_type new_allocated_size =
-            partitioner->local_size() + partitioner->n_ghost_indices();
+            partitioner_sm->local_size() + partitioner_sm->n_ghost_indices();
           resize_val(new_allocated_size,
                      partitioner_sm->get_sm_mpi_communicator());
         }
@@ -253,7 +253,8 @@ namespace LinearAlgebra
 
       // set vector size and allocate memory
       const size_type new_allocated_size =
-        this->partitioner->local_size() + this->partitioner->n_ghost_indices();
+        this->partitioner_sm->local_size() +
+        this->partitioner_sm->n_ghost_indices();
       resize_val(new_allocated_size, partitioner_sm->get_sm_mpi_communicator());
 
       // initialize to zero
@@ -295,7 +296,10 @@ namespace LinearAlgebra
         {
           dealii::internal::VectorOperations::
             functions<Number, Number, MemorySpaceType>::copy(
-              thread_loop_partitioner, partitioner->local_size(), v.data, data);
+              thread_loop_partitioner,
+              partitioner_sm->local_size(),
+              v.data,
+              data);
         }
     }
 
@@ -431,7 +435,7 @@ namespace LinearAlgebra
 
       thread_loop_partitioner = c.thread_loop_partitioner;
 
-      const size_type this_size = partitioner->local_size();
+      const size_type this_size = partitioner_sm->local_size();
       if (this_size > 0)
         {
           dealii::internal::VectorOperations::
@@ -500,8 +504,8 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::zero_out_ghosts() const
     {
       if (data.values != nullptr)
-        std::fill_n(data.values.get() + partitioner->local_size(),
-                    partitioner->n_ghost_indices(),
+        std::fill_n(data.values.get() + partitioner_sm->local_size(),
+                    partitioner_sm->n_ghost_indices(),
                     Number());
 
       vector_is_ghosted = false;
@@ -652,7 +656,7 @@ namespace LinearAlgebra
 
       dealii::internal::VectorOperations::
         functions<Number, Number, MemorySpaceType>::subtract_vector(
-          thread_loop_partitioner, partitioner->local_size(), v.data, data);
+          thread_loop_partitioner, partitioner_sm->local_size(), v.data, data);
 
       if (vector_is_ghosted)
         update_ghost_values();
@@ -693,7 +697,11 @@ namespace LinearAlgebra
 
       dealii::internal::VectorOperations::
         functions<Number, Number, MemorySpaceType>::add_av(
-          thread_loop_partitioner, partitioner->local_size(), a, v.data, data);
+          thread_loop_partitioner,
+          partitioner_sm->local_size(),
+          a,
+          v.data,
+          data);
     }
 
 
@@ -772,7 +780,7 @@ namespace LinearAlgebra
       dealii::internal::VectorOperations::
         functions<Number, Number, MemorySpaceType>::sadd_xav(
           thread_loop_partitioner,
-          partitioner->local_size(),
+          partitioner_sm->local_size(),
           x,
           a,
           v.data,
@@ -876,7 +884,11 @@ namespace LinearAlgebra
 
       dealii::internal::VectorOperations::
         functions<Number, Number, MemorySpaceType>::equ_au(
-          thread_loop_partitioner, partitioner->local_size(), a, v.data, data);
+          thread_loop_partitioner,
+          partitioner_sm->local_size(),
+          a,
+          v.data,
+          data);
 
 
       if (vector_is_ghosted)
@@ -920,11 +932,12 @@ namespace LinearAlgebra
       if (PointerComparison::equal(this, &v))
         return norm_sqr_local();
 
-      AssertDimension(partitioner->local_size(), v.partitioner->local_size());
+      AssertDimension(partitioner_sm->local_size(),
+                      v.partitioner_sm->local_size());
 
       return dealii::internal::VectorOperations::
         functions<Number, Number2, MemorySpaceType>::dot(
-          thread_loop_partitioner, partitioner->local_size(), v.data, data);
+          thread_loop_partitioner, partitioner_sm->local_size(), v.data, data);
     }
 
 
@@ -940,9 +953,9 @@ namespace LinearAlgebra
       const VectorType &v = dynamic_cast<const VectorType &>(vv);
 
       Number local_result = inner_product_local(v);
-      if (partitioner->n_mpi_processes() > 1)
+      if (partitioner_sm->n_mpi_processes() > 1)
         return Utilities::MPI::sum(local_result,
-                                   partitioner->get_mpi_communicator());
+                                   partitioner_sm->get_mpi_communicator());
       else
         return local_result;
     }
@@ -958,7 +971,7 @@ namespace LinearAlgebra
 
       dealii::internal::VectorOperations::
         functions<Number, Number, MemorySpaceType>::norm_2(
-          thread_loop_partitioner, partitioner->local_size(), sum, data);
+          thread_loop_partitioner, partitioner_sm->local_size(), sum, data);
 
       AssertIsFinite(sum);
 
@@ -1012,9 +1025,9 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::norm_sqr() const
     {
       real_type local_result = norm_sqr_local();
-      if (partitioner->n_mpi_processes() > 1)
+      if (partitioner_sm->n_mpi_processes() > 1)
         return Utilities::MPI::sum(local_result,
-                                   partitioner->get_mpi_communicator());
+                                   partitioner_sm->get_mpi_communicator());
       else
         return local_result;
     }
@@ -1058,7 +1071,7 @@ namespace LinearAlgebra
     {
       real_type max = 0.;
 
-      const size_type local_size = partitioner->local_size();
+      const size_type local_size = partitioner_sm->local_size();
       internal::la_parallel_vector_templates_functions<
         Number,
         MemorySpaceType>::linfty_norm_local(data, local_size, max);
@@ -1073,9 +1086,9 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::linfty_norm() const
     {
       const real_type local_result = linfty_norm_local();
-      if (partitioner->n_mpi_processes() > 1)
+      if (partitioner_sm->n_mpi_processes() > 1)
         return Utilities::MPI::max(local_result,
-                                   partitioner->get_mpi_communicator());
+                                   partitioner_sm->get_mpi_communicator());
       else
         return local_result;
     }
@@ -1089,7 +1102,7 @@ namespace LinearAlgebra
       const Vector<Number, MemorySpaceType> &v,
       const Vector<Number, MemorySpaceType> &w)
     {
-      const size_type vec_size = partitioner->local_size();
+      const size_type vec_size = partitioner_sm->local_size();
       AssertDimension(vec_size, v.local_size());
       AssertDimension(vec_size, w.local_size());
 
@@ -1121,9 +1134,9 @@ namespace LinearAlgebra
       const VectorType &w = dynamic_cast<const VectorType &>(ww);
 
       Number local_result = add_and_dot_local(a, v, w);
-      if (partitioner->n_mpi_processes() > 1)
+      if (partitioner_sm->n_mpi_processes() > 1)
         return Utilities::MPI::sum(local_result,
-                                   partitioner->get_mpi_communicator());
+                                   partitioner_sm->get_mpi_communicator());
       else
         return local_result;
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.