From dc8479ac62b9888eb09d5936eb48eab0a268fcc8 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 6 Jan 2022 08:15:23 -0600 Subject: [PATCH] provide hash operator to tbb::concurrent_unordered_map --- .../matrix_free/matrix_free.templates.h | 35 ++++++++++++++++--- source/matrix_free/task_info.cc | 4 ++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index 061ea1c461..953195557b 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -916,13 +916,30 @@ namespace internal { #ifdef DEAL_II_WITH_TBB +# ifdef DEAL_II_TBB_WITH_ONEAPI + struct unsigned_int_pair_hash + { + std::size_t + operator()(const std::pair &pair) const + { + return std::hash()(pair.first) ^ + std::hash()(pair.second); + } + }; +# endif + inline void fill_index_subrange( const unsigned int begin, const unsigned int end, const std::vector> &cell_level_index, tbb::concurrent_unordered_map, - unsigned int> & map) + unsigned int +# ifdef DEAL_II_TBB_WITH_ONEAPI + , + unsigned_int_pair_hash +# endif + > &map) { if (cell_level_index.empty()) return; @@ -942,8 +959,13 @@ namespace internal const dealii::Triangulation & tria, const std::vector> &cell_level_index, const tbb::concurrent_unordered_map, - unsigned int> & map, - DynamicSparsityPattern &connectivity_direct) + unsigned int +# ifdef DEAL_II_TBB_WITH_ONEAPI + , + unsigned_int_pair_hash +# endif + > &map, + DynamicSparsityPattern & connectivity_direct) { std::vector new_indices; for (unsigned int cell = begin; cell < end; ++cell) @@ -1477,7 +1499,12 @@ namespace internal // step 1: build map between the index in the matrix-free context // and the one in the triangulation tbb::concurrent_unordered_map, - unsigned int> + unsigned int +# ifdef DEAL_II_TBB_WITH_ONEAPI + , + unsigned_int_pair_hash +# endif + > map; dealii::parallel::apply_to_subranges( 0, diff --git a/source/matrix_free/task_info.cc b/source/matrix_free/task_info.cc index 2a15805aa8..6fd05f036f 100644 --- a/source/matrix_free/task_info.cc +++ b/source/matrix_free/task_info.cc @@ -28,7 +28,9 @@ # include # include # include -# include +# ifndef DEAL_II_TBB_WITH_ONEAPI +# include +# endif #endif #include -- 2.39.5