i am trying to parallel my program using OpenMP and sometimes i feels that i am reaching a dead end.
I would like to share variables in a function member that i defined (and initialized) in the class. If i understood correctly, it is not possible doing #pragma omp parallel shared(foo)
of data members (e.g. int
, boost::multi_array
and std::vector
) of a class.
e.g.: using push_back() on a vector data member in the class.
updating values of a boost::multi_array
.
My question is if OpenMP is the right tools for it, or should i use boost::thread or tbb? or something else... what support C++ API
Reagrds
As the documentation states, shared
defines that an object is placed only once in the memory. For example if your foo
object contains a std::vector
of some type, it should be perfectly ok to push_back
items within the loop. But you should make sure, that your code is thread safe, either by atomic instructions or with mutex sections.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With