Accelerator directives dislike Fortran CONTAINS statement?

Hi,

I’m accelerating some loops in a Fortran main program using PGI
directives. When I add a CONTAINS statement and a trivial
subroutine, I get error messages.

Can anyone advise, please? I’m using v10.6.0 of the compiler.

Cheers,

Alistair.

Here is my code:

PROGRAM test_trivial

  IMPLICIT NONE

  INTEGER, PARAMETER :: N = 10
  INTEGER :: u(N,N),i,j

  u = 0

!$acc region                                                                   \

  DO j = 1,N
     DO i = 1,N
        u(i,j) = u(i,j) + 1
     ENDDO
  ENDDO
!$acc end region                                                               \


#ifdef Use_contains
CONTAINS

  SUBROUTINE my_sub()

  END SUBROUTINE my_sub
#endif

END PROGRAM test_trivial

Here is the compiler output without the CONTAINS statement:

pgf90 -ta=nvidia,time -Minfo=accel test_trivial.F90
test_trivial:
     10, Generating copy(u(1:10,1:10))
         Generating compute capability 1.0 binary
         Generating compute capability 1.3 binary
     11, Loop is parallelizable
     12, Loop is parallelizable
         Accelerator kernel generated
         11, !$acc do parallel, vector(10)
         12, !$acc do parallel, vector(10)
             CC 1.0 : 6 registers; 24 shared, 20 constant, 0 local memory bytes\
; 100 occupancy                                                                 
             CC 1.3 : 6 registers; 24 shared, 20 constant, 0 local memory bytes\
; 100 occupancy

And here is the output with a CONTAINS statement:

pgf90 -ta=nvidia,time -Minfo=accel -DUse_contains test_trivial.F90
test_trivial:
     10, No parallel kernels found, accelerator region ignored
     11, Accelerator restriction: scalar variable live-out from loop: i
         Accelerator restriction: scalar variable live-out from loop: .dY0002
     13, Accelerator restriction: induction variable live-out from loop: j
         Accelerator restriction: induction variable live-out from loop: i
     14, Accelerator restriction: induction variable live-out from loop: i
         Accelerator restriction: induction variable live-out from loop: .dY000\
2
     15, Accelerator restriction: induction variable live-out from loop: j
         Accelerator restriction: induction variable live-out from loop: .dY000\
1

Hi Alistair,

Unfortunately, this is a known limitation. The problem is that the compiler must be conservative and assume that the main program’s variables are being using in the contained routine.

Our engineers are aware of the issue and are working on a solution. However, this support will not be available for awhile.

In the 10.8 compiler, a work around will be added where you can add your index variables to a ‘local’ or ‘private’ clause to remove the dependency.

Thanks,
Mat[/code]

Thanks. I’ll try and find a workaround in the meantime.