问题
Can we use TBB concurrent_vector with openmp?
Will concurrent updates be allowed?
回答1:
Yes, TBB's concurrent data structures are meant to be thread-safe, which means whatever threading paradigms, such as OpenMP, TBB, Cilk, PPL, and etc, are okay to use TBB's concurrent data structures. This is because concurrent_vector
is simply a data structure class rather than threading-related control code.
Furthermore, TBB's mutex can be also used within OpenMP, Cilk, and PPL.
回答2:
Per Section 1.11 of the concurrent_vector page on the Intel site, incremental growth, limited growth, and pushing of new objects onto the vector are all thread-safe operations.
The introduction also says that adding new elements does not invalidate existing iterators.
All these combined mean that you should be able to safely multithread access to the concurrent_vector with openmp.
来源:https://stackoverflow.com/questions/7683204/tbb-concurrent-vector-with-openmp