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