Openmp 4.0 clause reduction(array)

General OpenMP discussion

Openmp 4.0 clause reduction(array)

Postby albertogutierrez » Wed Feb 19, 2014 2:26 am

This is correct in OpenMP 4.0

Code: Select all
#pragma omp for reduction(+ : result)
for(i=0;i<size;i++){
   result[i]=result[i]+1;
}


But this solution in compare to the clasical solution with privatizations clauses has good speed-ups??

I tested it and for a low work I get good result but in a real application??


Thanks.
albertogutierrez
 
Posts: 3
Joined: Tue Feb 18, 2014 9:35 am

Re: Openmp 4.0 clause reduction(array)

Postby MarkB » Wed Feb 19, 2014 5:39 am

Are you sure it's legal? The 4.0 spec says (on page 171, line 8) "Arrays may not appear in a reduction clause."
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Openmp 4.0 clause reduction(array)

Postby albertogutierrez » Wed Feb 19, 2014 9:29 am

I was thinking in Fortran.

In fortran it is legal, right? And the speedups are ideal or this clause with arrays is a wrong idea in real applications?

Sorry and thanks.
albertogutierrez
 
Posts: 3
Joined: Tue Feb 18, 2014 9:35 am

Re: Openmp 4.0 clause reduction(array)

Postby MarkB » Wed Feb 19, 2014 10:21 am

Yes, array reductions in Fortran are allowed (and were long before 4.0). Whether the performance is any good is of course implementation dependent, but I would expect it to at least match what you can achieve by hand. For large enough arrays, it is better to exploit the parallelism over the different elements of the array and hence avoid using locks/atomics. I would have thought it is fine to use them in a real app.
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Openmp 4.0 clause reduction(array)

Postby albertogutierrez » Thu Feb 20, 2014 3:39 am

OK! Thanks for the information!!
albertogutierrez
 
Posts: 3
Joined: Tue Feb 18, 2014 9:35 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 3 guests