OpenMP_DeclareTargetPrivateVar.f90 1.82 KB
Newer Older
Budiardja, Reuben's avatar
Budiardja, Reuben committed
1
2
3
4
5
6
7
8
9
10
!-- This is a reproducer of an issue observed in an ECP application.
!   The issue seems to stem from a declared target array variables
!   being used as arguments to nested declared-target 
!   subroutines. The error happens at the linking stage.

!-- There could be two possible distinct issues here with CCE.
!   The first one is as written in the code. 
!   The second one shows up when '!$OMP private' in gpuomp_routine() 
!   is commented out. It triggers a different linking error.

11
12
13
14
15
module comm
  implicit none
  real, dimension ( : ), allocatable :: &
     cmaxa, cmaxb
  !$OMP declare target ( cmaxa, cmaxb )
Budiardja, Reuben's avatar
Budiardja, Reuben committed
16
17
  integer :: &
    ncmax
18
19
end module comm

Budiardja, Reuben's avatar
Budiardja, Reuben committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

module ext_module
  implicit none
contains
  subroutine ext_routine ( d1, cmaxa, cmaxb, size )
    implicit none
    real, intent ( inout ) :: &
      d1
    integer, intent ( in ) :: &
      size
    real, dimension ( : ) :: &
      cmaxa ( size ), cmaxb ( size )
    !$OMP declare target
  end subroutine ext_routine
end module ext_module


37
38
39
module gpuomp
  implicit none
contains
Budiardja, Reuben's avatar
Budiardja, Reuben committed
40
41
  subroutine gpuomp_routine ( d1 )
    use comm, only: cmaxa, cmaxb, ncmax
42
    real, intent ( inout ) :: &
Budiardja, Reuben's avatar
Budiardja, Reuben committed
43
      d1
44
45
    integer :: &
      iV
Budiardja, Reuben's avatar
Budiardja, Reuben committed
46
      
47
48
49
    !$OMP target teams distribute parallel do &
    !$OMP private ( cmaxa, cmaxb )
    do iV = 1, 3200
Budiardja, Reuben's avatar
Budiardja, Reuben committed
50
      call gpuomp_routine2 ( d1, cmaxa, cmaxb, ncmax )
51
52
53
54
    end do
    !$OMP end target teams distribute parallel do
  end subroutine gpuomp_routine
  
Budiardja, Reuben's avatar
Budiardja, Reuben committed
55
56
  subroutine gpuomp_routine2 ( d1, cmaxa, cmaxb, size )
    use ext_module
57
    real, intent ( inout ) :: &
Budiardja, Reuben's avatar
Budiardja, Reuben committed
58
      d1
59
    integer, intent ( in ) :: &
Budiardja, Reuben's avatar
Budiardja, Reuben committed
60
      size
61
    real, dimension ( : ) :: &
Budiardja, Reuben's avatar
Budiardja, Reuben committed
62
      cmaxa, cmaxb
63
64
    !$OMP declare target
    
Budiardja, Reuben's avatar
Budiardja, Reuben committed
65
    call ext_routine ( d1, cmaxa, cmaxb, size )
66
67
68
69
70
71
  end subroutine gpuomp_routine2

end module gpuomp


program test
Budiardja, Reuben's avatar
Budiardja, Reuben committed
72
!-- Dummy 'main' program so that we can link.
73
end program test