shared() vector<int> w/ disjoint accesses


Could you let me know what the performance consequences of doing something like this are?

vector A(100);

#pragma omp parallel for shared(A)
for (int i=0; i < 100; i++) {
A = i*i;

In particular, what I would like to know is whether or not your implementation of OpenMP will recognise that there are no dependencies here, and optimise accordingly.

…for that matter, would the use of an STL structure introduce a dependency here (like something along the lines of bounds checking… although I’m pretty sure the array notation for vector doesn’t do bounds checking)?



Hi Mark,

One of your C++ engineers gave the following response:

The #omp pragma directive does not make dependency checks on the
code in question. It is up to the user to make sure that there are
no conflicting dependencies. The STL library does not introduce any
dependencies in this case

Code is generated for parallel execution as a result of the OMP pragma.

Other, non MP optimizations may occur as a result of -fast or -Minline,
or other optimization flags. In this case, the call to operator vector
does prohibit further some optimization at this time.

Hope this helps,

Hrm… yes it does.