Fortran OpenACC atomic "max" with more than two arguments

Hi,

I have a triple loop that finds the maximum value over a single dimension array.
The basic code is:

!$acc parallel loop collapse(3)
do k=1,nk
do j=1,nj
do i=1,ni
value1=<computation in all 3 dimensions>
value2=<computation in all 3 dimensions>
max1d(i)=max(max1d(i),value1,value2)
enddo
enddo
enddo

If I try to put an “acc atomic” before the max line, the compiler fails saying the atomic operation is not valid.

If I instead make a temporary scalar “maxv12=max(value1,value2)” and then have:

!$acc atomic
max1d(i)=max(max1d(i),maxv12)

than the compiler doesn’t complain and the code works fine.

Why can I not have more than two arguments in the “max” call for an atomic operation?

  • Ron

Hi Ron,

I talked with the engineer that did most of the atomic work and we agree that the max intrinsic should allow more than two items (see lines 2322 and 2332 of the OpenACC 3.1 standard). He is concerned that the performance may be poor (and why he didn’t implement it in the first place) but agreed to see what he can do.

I’ve added TPR #29460 to track.

-Mat