From 9bb937303e1a8fc989b868f3fb3b780cc84ef25d Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Mon, 25 Nov 2013 00:20:47 +0000 Subject: [PATCH] WorskStream does not need to use a copy function. git-svn-id: https://svn.dealii.org/trunk@31787 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/work_stream.h | 60 +++++++++++++------ deal.II/source/numerics/data_out.cc | 3 +- .../numerics/derivative_approximation.cc | 3 +- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/deal.II/include/deal.II/base/work_stream.h b/deal.II/include/deal.II/base/work_stream.h index 71cadb7536..41f8a32a9e 100644 --- a/deal.II/include/deal.II/base/work_stream.h +++ b/deal.II/include/deal.II/base/work_stream.h @@ -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 *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 queue_length * copies of the ScratchData 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 worker_filter (worker); - internal::Implementation2::Copier copier_filter (copier); + if (empty_copier==false) + { + internal::Implementation2::Worker worker_filter (worker); + internal::Implementation2::Copier 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 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 queue_length * copies of the ScratchData 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); } } diff --git a/deal.II/source/numerics/data_out.cc b/deal.II/source/numerics/data_out.cc index d242eaa816..00fb6c6df8 100644 --- a/deal.II/source/numerics/data_out.cc +++ b/deal.II/source/numerics/data_out.cc @@ -462,7 +462,8 @@ void DataOut::build_patches (const Mapping &mapping, std_cxx1x::cref(solution),component)), static_cast > (internal::Assembler::copier),internal::Assembler::Scratch (), - internal::Assembler::CopyData ()); + internal::Assembler::CopyData (), + 2*multithread_info.n_threads(),8,true); } -- 2.39.5