Skip to content

concurrently iterating over a parallel_flat_hash_map #247

Answered by greg7mdp
vondele asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, this is definitely possible.
You can use with_submap or with_submap_m (see here ) - use the second version with _m if you mutate the submaps.

You can also use get_inner. I don't have it in a current example, but here is a code fragment:

template <class K, class V, size_t N, class Mutex>
using Map = phmap::parallel_flat_hash_map<K, V, phmap::priv::hash_default_hash<K>, phmap::priv::hash_default_eq<K>,
                                          phmap::priv::Allocator<phmap::priv::Pair<const K, V>>, N, Mutex>;

using OutputTable = Map<Bitset, double, 8, std::mutex>;

OutputTable test(const Table& table1, const Table& table2) {
   OutputTable table;

   #pragma omp parallel for // schedul…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@vondele
Comment options

Answer selected by vondele
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants