Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Hash Map: Doxygen and Reserve?

Sensei_S_
Beginner
304 Views

Dear all, I have two very simple questions.

The first is this: am I missing the doxygen documentation for concurrent_hash_map? The only documentation I've seen is this: http://www.threadingbuildingblocks.org/docs/help/tbb_userguide/concurrent_hash_map.htm

The second is: how can I reserve memory? The std::unordered_map gives me std::unordered_map::reserve, but TBB's implementation seems to provide only a protected method... and I'd really like to avoid subclassing for just this simple task. But maybe there's a way I'm not aware of.

Thanks!

0 Kudos
2 Replies
RafSchietekat
Valued Contributor III
304 Views

How about using rehash() instead?

(Added) There's also a Reference Manual, but the doxygen content unfortunately hides under tbb::interface5::concurrent_hash_map (so you always have to check those interface... versions).

(Added) For completeness: you reserve for "buckets", not for "memory" (there will still be allocations for elements); don't overlook the constructor that allows you to reserve in advance; don't subclass concurrent_hash_map in the hope of using reserve() as in std::unordered_map (it doesn't have the same effect).

(2014-06-18 Correction: ordered_map->unordered_map)

0 Kudos
Sensei_S_
Beginner
304 Views

Raf Schietekat wrote:

How about using rehash() instead?

(Added) There's also a Reference Manual, but the doxygen content unfortunately hides under tbb::interface5::concurrent_hash_map (so you always have to check those interface... versions).

Thanks, Raf, I didn't see that! I wonder why it is hidden down there, honestly, I never looked into those namespaces...

Raf Schietekat wrote:

(Added) For completeness: you reserve for "buckets", not for "memory" (there will still be allocations for elements); don't overlook the constructor that allows you to reserve in advance; don't subclass concurrent_hash_map in the hope of using reserve() as in std::ordered_map (it doesn't have the same effect).

Ok, I won't subclass it.

Thanks, as always you're really helpful!

0 Kudos
Reply