Good candidate for concurrent hash map?

Good candidate for concurrent hash map?

Imagen de Ender1618

I have a dynamically growing 3D grid of pointers to objects (containers of 3D points, amongst other meta data). Each cell's pointer to container can be accessed by a 3D address I,J,K into the grid.

Essentially the 3D grid represents 3D space and points are added to n grid cells dependent on their spatial extents (all cells are of the same size). As the space is further explored points fall into new potential cells that do not yet exist in the grid, so the grid is expanded and new cell container objects are created to hold the new points.

I am currently trying to use read write mutexes (and other mechanisms) to provide concurrent cell object addition, read only access, and write access. So that multiple threads can (concurrently) read from multiple cells, threads can get write access to a cell and all other threads block when trying to access that cell, and other threads can be adding new cells on the fly. Btw the number of cells grow from 1 to potentially 100s of cells.

Would this be a good candidate for using a concurrent_hash_map, where the key is an IJK address, and the value is a pointer to one of my cell container objects? Can the map provide the kind of manipulation of the grid I described? Wondering if only 100's of cells is ok (I was reading 1000s are typical), if adding to the map can be handled safely, how to effectively hash IJKs, etc. Kinda vague question's I know. Or would another container would be more appropriate?

I am a newbie to TBB and any advice would be appreciated.

-Ryan

publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Raf Schietekat

This looks like a good match for concurrent_hash_map, with its accessor and const_accessor types assuming some of the functionality that you describe.

For hashing, the map expects maximum randomness in the lowest-significant bits, so perhaps you could right-shift each dimension to toss out any stride-related fixed bits and then just exclusive-or everything together, unless you have a lot of stuff happening on diagonals of course.

Inicie sesión para dejar un comentario.