From: Bruno Date: Wed, 10 Feb 2021 03:20:08 +0000 (-0500) Subject: Add recv and send data to particle cache X-Git-Tag: v9.3.0-rc1~468^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa51efbe3c4c17ebf5e831ceee35c729ec520d47;p=dealii.git Add recv and send data to particle cache 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 --- diff --git a/include/deal.II/particles/partitioner.h b/include/deal.II/particles/partitioner.h index 46ee1def56..f4361a3ae1 100644 --- a/include/deal.II/particles/partitioner.h +++ b/include/deal.II/particles/partitioner.h @@ -97,6 +97,18 @@ namespace Particles std::vector>::iterator> ghost_particles_iterators; + + /** + * Vector of char that is used to organize the particle information to be + * sent to other processors + */ + std::vector send_data; + + /** + * Vector of char that is used to organize the particle information to + * received from other processors + */ + std::vector recv_data; }; } // namespace internal diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index b135d69a4a..4926f52ce3 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -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(recv_data_it) - @@ -1580,13 +1585,11 @@ namespace Particles ExcMessage( "This function is only implemented for parallel::TriangulationBase objects.")); - std::vector send_data; + std::vector &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(&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 recv_data(recv_pointers.back()); + std::vector &recv_data = ghost_particles_cache.recv_data; // Exchange the particle data between domains {