From: Daniel Arndt Date: Sun, 22 Sep 2019 05:00:21 +0000 (-0400) Subject: Move worker and copier X-Git-Tag: v9.2.0-rc1~1038^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=421816e2ebbf4b53a5d8ffb4184d4844ef9e3460;p=dealii.git Move worker and copier --- diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index b9ab377ea2..55de132df6 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2819,9 +2819,7 @@ namespace DoFTools #endif } - WorkStream::run( - coarse_grid.begin_active(), - coarse_grid.end(), + auto worker = [coarse_component, &coarse_grid, &coarse_to_fine_grid_map, @@ -2836,7 +2834,9 @@ namespace DoFTools coarse_grid.get_fe(), coarse_to_fine_grid_map, parameter_dofs); - }, + }; + + auto copier = [coarse_component, &coarse_grid, &weight_mapping, @@ -2848,9 +2848,14 @@ namespace DoFTools weight_mapping, is_called_in_parallel, weights); - }, - scratch, - copy_data); + }; + + WorkStream::run(coarse_grid.begin_active(), + coarse_grid.end(), + worker, + copier, + scratch, + copy_data); #ifdef DEAL_II_WITH_MPI for (std::size_t i = 0; diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index 2feb97861f..57f168ff53 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -807,36 +807,37 @@ DataOut::build_patches( update_flags, cell_to_patch_index_map); + auto worker = [this, n_subdivisions, curved_cell_region]( + const std::pair *cell_and_index, + internal::DataOutImplementation::ParallelData< + DoFHandlerType::dimension, + DoFHandlerType::space_dimension> &scratch_data, + // this function doesn't actually need a copy data object -- + // it just writes everything right into the output array + int) { + this->build_one_patch(cell_and_index, + scratch_data, + n_subdivisions, + curved_cell_region); + }; + // now build the patches in parallel if (all_cells.size() > 0) - WorkStream::run( - all_cells.data(), - all_cells.data() + all_cells.size(), - [this, n_subdivisions, curved_cell_region]( - const std::pair *cell_and_index, - internal::DataOutImplementation::ParallelData< - DoFHandlerType::dimension, - DoFHandlerType::space_dimension> &scratch_data, - // this function doesn't actually need a copy data object -- it just - // writes everything right into the output array - int) { - this->build_one_patch(cell_and_index, - scratch_data, - n_subdivisions, - curved_cell_region); - }, - // no copy-local-to-global function needed here - std::function(), - thread_data, - /* dummy CopyData object = */ 0, - // experimenting shows that we can make things run a bit - // faster if we increase the number of cells we work on - // per item (i.e., WorkStream's chunk_size argument, - // about 10% improvement) and the items in flight at any - // given time (another 5% on the testcase discussed in - // @ref workstream_paper, on 32 cores) and if - 8 * MultithreadInfo::n_threads(), - 64); + WorkStream::run(all_cells.data(), + all_cells.data() + all_cells.size(), + worker, + // no copy-local-to-global function needed here + std::function(), + thread_data, + /* dummy CopyData object = */ 0, + // experimenting shows that we can make things run a bit + // faster if we increase the number of cells we work on + // per item (i.e., WorkStream's chunk_size argument, + // about 10% improvement) and the items in flight at any + // given time (another 5% on the testcase discussed in + // @ref workstream_paper, on 32 cores) and if + 8 * MultithreadInfo::n_threads(), + 64); }