checking for theshold value on whole array with OpenACC

Hi,

I want to check for some threshold value on a 3d array. The original fortran code look like that:

IF (ANY(a(:,:,:)<0.0D0)) ltest=.TRUE.

I’ve translated this as follows with OpenACC:

    !$acc parallel vector_length(64) reduction(.or.:ltest)
    do k=1,n3
     !$acc loop gang
     do j=1,n2
        !$acc loop vector
        do i=1,n1 
           if (a(i,j,k)<0.0D0) ltest=.TRUE.          
        end do
     end  do
  end do
    !$acc end parallel

Do you have any suggestion for a better implementation ?

Thanks,

Xavier

Hi Xavier,

For the basic code, I can’t think of anything better. Personally, I’d use the “kernels” construct instead of “parallel” and not set the schedule. After starting testing across multiple devices, letting the compiler set the schedule for each device, allows for greater performance portability.

  • Mat