openmp dynamically allocated array reduction?

All,

I’m struggling with how to do a reduction (integer +=) on a dynamically allocated array and with an initialized.

Basically, I could do this manually be creating a copy of the vector, one for each thread; initialize and update the copy in each thread and then in the end merge the copies in a binary fashion.

Is this supported in OpenMP 4.5 and the PGI compiler?

Here is a sketch of the code where the A is the destination array
allocated elsewhere with n elements.


#pragma omp parallel for … reduction(+:A[n])
for {
A += …;
}

So, the compiler would create a local copy per thread of size n, initialize it to, say zero (is there an initializer for this?) and merge.

I know it is possibly not very efficient, but it would be handy.

Thanks,

Pedro

Hi Pedro,

Apologizes for the late response.

Is this supported in OpenMP 4.5 and the PGI compiler?

Currently, PGI does not support all of OpenMP 4.5 including array reductions. Also, we are not planning on adding this support in the near future. Like you, we’re concerned about the efficiency of this feature but do see it’s usefulness.

I have added a feature request (TPR#26579) to track. Plus it’s helpful for our managers with prioritization to know what features our users are looking for.

Best Regards,
Mat