]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add recv and send data to particle cache
authorBruno <blais.bruno@gmail.com>
Wed, 10 Feb 2021 03:20:08 +0000 (22:20 -0500)
committerBruno <blais.bruno@gmail.com>
Wed, 10 Feb 2021 03:20:08 +0000 (22:20 -0500)
This adds teh recv and send data to the particle cache in order
to prevent dynamic reallocation of this vector, whose size is not
changing anyway. This can significantly (10%) increase performance
in some of our applications

include/deal.II/particles/partitioner.h
source/particles/particle_handler.cc

index 46ee1def562326f374a85633bb2e6b21a66f9564..f4361a3ae1fe6438da5f370c1c986d767a484821 100644 (file)
@@ -97,6 +97,18 @@ namespace Particles
       std::vector<typename std::multimap<internal::LevelInd,
                                          Particle<dim, spacedim>>::iterator>
         ghost_particles_iterators;
+
+      /**
+       * Vector of char that is used to organize the particle information to be
+       * sent to other processors
+       */
+      std::vector<char> send_data;
+
+      /**
+       * Vector of char that is used to organize the particle information to
+       * received from other processors
+       */
+      std::vector<char> recv_data;
     };
   } // namespace internal
 
index b135d69a4a2106411229740b1a3967d449e0cafd..4926f52ce33eb6aeb1619ec8a30fbe21b2ba2598 100644 (file)
@@ -1521,6 +1521,11 @@ namespace Particles
             n_recv_data[i] * individual_particle_data_size;
 
         ghost_particles_cache.neighbors = neighbors;
+
+        ghost_particles_cache.send_data.resize(
+          ghost_particles_cache.send_pointers.back());
+        ghost_particles_cache.recv_data.resize(
+          ghost_particles_cache.recv_pointers.back());
       }
 
     while (reinterpret_cast<std::size_t>(recv_data_it) -
@@ -1580,13 +1585,11 @@ namespace Particles
       ExcMessage(
         "This function is only implemented for parallel::TriangulationBase objects."));
 
-    std::vector<char> send_data;
+    std::vector<char> &send_data = ghost_particles_cache.send_data;
 
     // Fill data to send
     if (send_pointers.back() > 0)
       {
-        // Allocate space for sending particle data
-        send_data.resize(send_pointers.back());
         void *data = static_cast<void *>(&send_data.front());
 
         // Serialize the data sorted by receiving process
@@ -1599,8 +1602,7 @@ namespace Particles
             }
       }
 
-    // Set up the space for the received particle data
-    std::vector<char> recv_data(recv_pointers.back());
+    std::vector<char> &recv_data = ghost_particles_cache.recv_data;
 
     // Exchange the particle data between domains
     {

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.