]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Compress buffers before communicating.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jul 2017 18:58:51 +0000 (12:58 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jul 2017 22:16:54 +0000 (16:16 -0600)
This has already been done in distribute_dofs(). Also do it in renumber_dofs().

source/dofs/dof_handler_policy.cc

index b9121d5b2bd67adcab52a4f1e69ceb3bc141105f..0b1e5a3c5de43a96eaf06361876cb65be5f0906f 100644 (file)
@@ -4108,15 +4108,24 @@ namespace internal
         std::vector<IndexSet> locally_owned_dofs_per_processor(n_cpus,
                                                                IndexSet(dof_handler->n_dofs()));
         {
-          // Serialize our IndexSet
-          std::ostringstream oss;
-          my_locally_owned_dofs.block_write(oss);
-          std::string oss_str = oss.str();
-          std::vector<char> my_data (oss_str.begin(), oss_str.end());
+          // serialize our own IndexSet
+          std::vector<char> my_data;
+          {
+            boost::iostreams::filtering_ostream out;
+            out.push(boost::iostreams::gzip_compressor
+                     (boost::iostreams::gzip_params
+                      (boost::iostreams::gzip::best_compression)));
+            out.push(boost::iostreams::back_inserter(my_data));
+
+            boost::archive::binary_oarchive archive(out);
+
+            archive << my_locally_owned_dofs;
+            out.flush();
+          }
 
           // determine maximum size of IndexSet
           const unsigned int max_size
-            = Utilities::MPI::max (oss_str.size(), triangulation->get_communicator());
+            = Utilities::MPI::max (my_data.size(), triangulation->get_communicator());
 
           // as the MPI_Allgather call will be reading max_size elements, and
           // as this may be past the end of my_data, we need to increase the
@@ -4136,10 +4145,22 @@ namespace internal
               {
                 // copy the data previously received into a stringstream
                 // object and then read the IndexSet from it
-                std::stringstream strstr;
-                strstr.write(&buffer[i*max_size], max_size);
+                std::string decompressed_buffer;
+
+                // first decompress the buffer
+                {
+                  boost::iostreams::filtering_ostream decompressing_stream;
+                  decompressing_stream.push(boost::iostreams::gzip_decompressor());
+                  decompressing_stream.push(boost::iostreams::back_inserter(decompressed_buffer));
+
+                  decompressing_stream.write(&buffer[i*max_size], max_size);
+                }
+
+                // then restore the object from the buffer
+                std::istringstream in(decompressed_buffer);
+                boost::archive::binary_iarchive archive(in);
 
-                locally_owned_dofs_per_processor[i].block_read(strstr);
+                archive >> locally_owned_dofs_per_processor[i];
               }
         }
 

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.