Force array to be shared in OpenACC

Hello.

I’m trying to use CUDA pointers in a simple OpenACC region.

Following is the code.

!$ACC DATA PRESENT(cuAxialRay)
!$ACC KERNELS
DO ipin = 1, nxy
  DO izf = myzbf, myzef
    rhsq = 1.0 / (cuAxialRay%LenSeg(izf) ** 2)
    idx = (izf - myzbf) * ng + (ipin - 1) * ng * nzf
	DO ig = 1, ng
      phisSlopef(idx + ig) = phimf(ig, izf, ipin) * rhsq
    ENDDO
  ENDDO
ENDDO
!$ACC END KERNELS
!$ACC END DATA

phisSlopef and phimf are both CUDA pointers.

When I try to compile the code section, compiler says:

214, Generating present(cuaxialray)
216, Parallelization would require privatization of array phisslopef(:)
217, Parallelization would require privatization of array phisslopef(:)
Accelerator kernel generated
Generating Tesla code
220, Parallelization would require privatization of array phisslopef(:)

But the loop is safe from data-race, so I want phisslopef to be public.

How do I force it?

Hi CNJ,

But the loop is safe from data-race, so I want phisslopef to be public.
How do I force it?

You would add the “independent” clause to the loop directive to assert to the compiler that the loop does not contain dependencies.

!$ACC DATA PRESENT(cuAxialRay) 
!$ACC KERNELS 
!$ACC LOOP INDPENDENT
DO ipin = 1, nxy 
  DO izf = myzbf, myzef 
    rhsq = 1.0 / (cuAxialRay%LenSeg(izf) ** 2) 
    idx = (izf - myzbf) * ng + (ipin - 1) * ng * nzf 
!$ACC LOOP INDPENDENT
   DO ig = 1, ng 
      phisSlopef(idx + ig) = phimf(ig, izf, ipin) * rhsq 
    ENDDO 
  ENDDO 
ENDDO 
!$ACC END KERNELS 
!$ACC END DATA

-Mat