From 4eb3cb2821f70450894d8fd57749e3349b72ad4f Mon Sep 17 00:00:00 2001 From: turcksin Date: Wed, 2 Oct 2013 17:00:47 +0000 Subject: [PATCH] Now when WorkStream uses graph coloring and that there are not enough elements in a color, the elements are aggregated and copied serially. git-svn-id: https://svn.dealii.org/trunk@31070 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/work_stream.h | 59 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/deal.II/include/deal.II/base/work_stream.h b/deal.II/include/deal.II/base/work_stream.h index 5c7b05d500..bccc4b8896 100644 --- a/deal.II/include/deal.II/base/work_stream.h +++ b/deal.II/include/deal.II/base/work_stream.h @@ -918,7 +918,11 @@ namespace WorkStream * * The @p get_conflict_indices argument, is a function * that given an iterator computes the conflict indices - * necessary for the graph_coloring. + * necessary for the graph_coloring. Graph coloring is + * necessary to be able to copy the data in parallel. If + * the number of elements in some colors is less than + * @p chunk_size time multithread_info.n_default_threads, + * these elements are aggregated and copied serially. * * The @p queue_length argument indicates * the number of items that can be live @@ -974,23 +978,58 @@ namespace WorkStream // color the graph std::vector > coloring = graph_coloring::make_graph_coloring( begin,end,get_conflict_indices); + + // colors that do not have cells, i.e., less than chunk_size times + // multithread_info.n_default_threads, are gathered and the copier is + // called serially. + const unsigned int serial_limit(chunk_size*multithread_info.n_default_threads); + std::vector serial_copying; for (unsigned int color=0; color + iterator_range_to_item_stream (coloring[color].begin(), coloring[color].end(), + queue_length, + chunk_size, + sample_scratch_data, + sample_copy_data); + + internal::Worker worker_filter (worker); + internal::Copier copier_filter (copier,false); + + // 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 (); + } + } + + // use the serial copier for all the colors that do not have enough cells + if (serial_copying.size()!=0) + { internal::IteratorRangeToItemStream - iterator_range_to_item_stream (coloring[color].begin(), coloring[color].end(), + iterator_range_to_item_stream (serial_copying.begin(), serial_copying.end(), queue_length, chunk_size, sample_scratch_data, sample_copy_data); internal::Worker worker_filter (worker); - internal::Copier copier_filter (copier,false); + internal::Copier copier_filter (copier,true); - // 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); @@ -1121,7 +1160,11 @@ namespace WorkStream * * The @p get_conflict_indices argument, is a function * that given an iterator computes the conflict indices - * necessary for the graph_coloring. + * necessary for the graph_coloring. Graph coloring is + * necessary to be able to copy the data in parallel. If + * the number of elements in some colors is less than + * @p chunk_size time multithread_info.n_default_threads, + * these elements are aggregated and copied serially. * * The @p queue_length argument indicates * the number of items that can be live -- 2.39.5