From: bangerth Date: Tue, 1 Oct 2013 00:25:23 +0000 (+0000) Subject: Do some operations in parallel on tasks. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=daf4c31e82c6e8b4665976ae950c8982cbae37ee;p=dealii-svn.git Do some operations in parallel on tasks. git-svn-id: https://svn.dealii.org/trunk@31055 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/hp/dof_handler.cc b/deal.II/source/hp/dof_handler.cc index fdb3a42ae5..fa6d95cadd 100644 --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -2722,13 +2723,20 @@ namespace hp = std::vector (1, number_cache.locally_owned_dofs); - // update the cache used for cell dof indices and compress the data on the levels + // update the cache used for cell dof indices and compress the data on the levels. do + // the latter on separate tasks to gain parallelism, starting with the highest + // level (there is most to do there, so start it first) for (active_cell_iterator cell = begin_active(); cell != end(); ++cell) cell->update_cell_dof_indices_cache (); - for (unsigned int level=0; levelcompress_data (*finite_elements); + { + Threads::TaskGroup<> tg; + for (int level=levels.size()-1; level>=0; --level) + tg += Threads::new_task (&dealii::internal::hp::DoFLevel::compress_data, + *levels[level], *finite_elements); + tg.join_all (); + } // finally restore the user flags const_cast &>(*tria).load_user_flags(user_flags); @@ -2767,9 +2775,15 @@ namespace hp #endif // uncompress the internal storage scheme of dofs on cells - // so that we can access dofs in turns - for (unsigned int level=0; leveluncompress_data (*finite_elements); + // so that we can access dofs in turns. uncompress in parallel, starting + // with the most expensive levels (the highest ones) + { + Threads::TaskGroup<> tg; + for (int level=levels.size()-1; level>=0; --level) + tg += Threads::new_task (&dealii::internal::hp::DoFLevel::uncompress_data, + *levels[level], *finite_elements); + tg.join_all (); + } // do the renumbering renumber_dofs_internal (new_numbers, dealii::internal::int2type()); @@ -2780,8 +2794,13 @@ namespace hp cell->update_cell_dof_indices_cache (); // now re-compress the dof indices - for (unsigned int level=0; levelcompress_data (*finite_elements); + { + Threads::TaskGroup<> tg; + for (int level=levels.size()-1; level>=0; --level) + tg += Threads::new_task (&dealii::internal::hp::DoFLevel::compress_data, + *levels[level], *finite_elements); + tg.join_all (); + } }