induction variable live-out from loop when var used before

Hello,

I’m pretty new to using the PGI accelerator compiler but have found a slight issue with the following (simplified)code:

  
ALLOCATE(some_arrays, Stat=jn)
  IF(jn /= 0)THEN
     WRITE (*,*) 'Alloc failed in simple_kernel - returning'
     RETURN
  END IF

!$ACC REGION copy(pta) copyin(ptb,umask,vmask) local(zgb,zga)
     DO jn = 1, kjpt

        DO jk=1, jpkm1, 1
           DO jj=1, jpjm1, 1
Set some array values here...  
          END DO
        END DO
     END DO
!$ACC END REGION

If I compile the code as shown I get:
Accelerator restriction: induction variable live-out from loop: jn
for each line inside my nested loop (of form blah(1,jj,jk,jn) = 1.0).
However, if I change the ALLOCATE statement to use ierr, say, instead of jn to check the status then these messages go away which is what I’d expect as the value of jn isn’t used after the accelerated region.

I’m using version 11.0 of pgf90 with cuda 3.1 on a 64-bit linux box.

Cheers,

Andy.[/code]

Hi Andy,

ALLOCATE isn’t a pure function, hence the compiler must assume that some other memory location could be using jn.

To work around this issue, either use a different variable for STAT or privatize jn:

!$ACC REGION copy(pta) copyin(ptb,umask,vmask) local(zgb,zga)
  !$ACC DO private(jn)
     DO jn = 1, kjpt 
...

Hope this helps,
Mat

Ah, I see - thanks Mat.