]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
WorskStream does not need to use a copy function.
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 25 Nov 2013 00:20:47 +0000 (00:20 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 25 Nov 2013 00:20:47 +0000 (00:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@31787 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/work_stream.h
deal.II/source/numerics/data_out.cc
deal.II/source/numerics/derivative_approximation.cc

index 71cadb7536047195758305bf50cdd4a9f44f6756..41f8a32a9ebf4fecbd504c6eaef86d154fdc56c2 100644 (file)
@@ -782,7 +782,7 @@ namespace WorkStream
            * and copy data objects this thread will use. The same considerations
            * apply as documented in the Implementation2::IteratorRangeToItemStream
            * class as well as in the paper by Turcksin, Kronbichler and Bangerth
-          * (see @ref workstream_paper).
+          * (see @ref workstream_paper).
            */
           Threads::ThreadLocalStorage<ScratchAndCopyDataList> *scratch_and_copy_data;
 
@@ -1169,6 +1169,9 @@ namespace WorkStream
    * the input stream that will be worked on by the worker and copier
    * functions one after the other on the same thread.
    *
+   * The last argument @p empty_copier can be set to true when the copier is
+   * empty. In this case, the copier is not used which can improve speed.
+   *
    * @note If your data objects are large, or their constructors are
    * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
    * copies of the <tt>ScratchData</tt> object and
@@ -1188,7 +1191,8 @@ namespace WorkStream
        const ScratchData                       &sample_scratch_data,
        const CopyData                          &sample_copy_data,
        const unsigned int queue_length = 2*multithread_info.n_threads(),
-       const unsigned int                       chunk_size = 8)
+       const unsigned int                       chunk_size = 8,
+       const bool                               empty_copier = false)
   {
     Assert (queue_length > 0,
             ExcMessage ("The queue length must be at least one, and preferably "
@@ -1238,19 +1242,36 @@ namespace WorkStream
                                        sample_copy_data);
 
 
-        internal::Implementation2::Worker<Iterator, ScratchData, CopyData> worker_filter (worker);
-        internal::Implementation2::Copier<Iterator, ScratchData, CopyData> copier_filter (copier);
+        if (empty_copier==false)
+          {
+            internal::Implementation2::Worker<Iterator, ScratchData, CopyData> worker_filter (worker);
+            internal::Implementation2::Copier<Iterator, ScratchData, CopyData> copier_filter (copier);
+
+            // now create a pipeline from these stages
+            tbb::pipeline assembly_line;
+            assembly_line.add_filter (iterator_range_to_item_stream);
+            assembly_line.add_filter (worker_filter);
+            assembly_line.add_filter (copier_filter);
 
-        // now create a pipeline from these stages
-        tbb::pipeline assembly_line;
-        assembly_line.add_filter (iterator_range_to_item_stream);
-        assembly_line.add_filter (worker_filter);
-        assembly_line.add_filter (copier_filter);
+            // and run it
+            assembly_line.run (queue_length);
+
+            assembly_line.clear ();
+          }
+        else
+          {
+            internal::Implementation2::Worker<Iterator, ScratchData, CopyData> worker_filter (worker);
 
-        // and run it
-        assembly_line.run (queue_length);
+            // now create a pipeline from these stages
+            tbb::pipeline assembly_line;
+            assembly_line.add_filter (iterator_range_to_item_stream);
+            assembly_line.add_filter (worker_filter);
 
-        assembly_line.clear ();
+            // and run it
+            assembly_line.run (queue_length);
+
+            assembly_line.clear ();
+          }
       }
 #endif
   }
@@ -1396,6 +1417,9 @@ namespace WorkStream
    * the input stream that will be worked on by the worker and copier
    * functions one after the other on the same thread.
    *
+   * The last argument @p empty_copier can be set to true when the copier is
+   * empty. In this case, the copier is not used which can improve speed.
+   *
    * @note If your data objects are large, or their constructors are
    * expensive, it is helpful to keep in mind that <tt>queue_length</tt>
    * copies of the <tt>ScratchData</tt> object and
@@ -1414,10 +1438,11 @@ namespace WorkStream
                                   ScratchData &,
                                   CopyData &),
        void (MainClass::*copier) (const CopyData &),
-       const ScratchData                    &sample_scratch_data,
-       const CopyData                       &sample_copy_data,
-       const unsigned int queue_length = 2*multithread_info.n_threads(),
-       const unsigned int chunk_size = 8)
+       const ScratchData                       &sample_scratch_data,
+       const CopyData                          &sample_copy_data,
+       const unsigned int queue_length =        2*multithread_info.n_threads(),
+       const unsigned int chunk_size =          8,
+       const bool                               empty_copier = false)
   {
     // forward to the other function
     run (begin, end,
@@ -1430,7 +1455,8 @@ namespace WorkStream
          sample_scratch_data,
          sample_copy_data,
          queue_length,
-         chunk_size);
+         chunk_size,
+         empty_copier);
   }
 
 }
index d242eaa816d6fabc34da0dd66954936a5dab17fd..00fb6c6df81835fdd11351e002333e0c92828cd8 100644 (file)
@@ -462,7 +462,8 @@ void DataOut<dim,DH>::build_patches (const Mapping<DH::dimension,DH::space_dimen
                     // given time (another 5% on the testcase discussed in
                     // @ref workstream_paper, on 32 cores) and if
                     8*multithread_info.n_threads(),
-                    64);
+                    64,
+         true);
 }
 
 
index e1358c3abbe939d7cd8a6cbc21ff11a43a3bd900..66c644751fe0132dd3b1928375d54c3a4fb34e11 100644 (file)
@@ -671,7 +671,8 @@ approximate_derivative (const Mapping<dim,spacedim>    &mapping,
                        std_cxx1x::cref(solution),component)),
     static_cast<std_cxx1x::function<void (internal::Assembler::CopyData const &)> >
       (internal::Assembler::copier),internal::Assembler::Scratch (),
-      internal::Assembler::CopyData ());
+      internal::Assembler::CopyData (),
+      2*multithread_info.n_threads(),8,true);
 }
 
 

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.