Let's suppose that I want want to populate in parallel a std::vector
object in an ordered way, like this:
std::vector<T> v;
#pragma omp parallel for ordered
for (int i=0;i<n;i++){
T result = //some expensive fun here...
#pragma omp ordered
v.push_back(result);
}
As you can see, the instruction v.push_back(result)
doesn't depend on i
.
My question is: v
will still be populated in an ordered way according to i
?