aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/allocators-2.f90
blob: c42fbd31e3e11725e4cb67f820021b7a4a8c3aa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
! { dg-additional-options "-fopenmp-allocators" }
module m
  implicit none (type, external)
  type t
    integer, allocatable :: Acomp, Bcomp(:)
  end type t

contains

subroutine intent_out(aa, bb, cc, dd, ee, ff)
  integer, allocatable,intent(out) :: aa, bb(:)
  type(t), intent(out) :: cc, dd(4)
  type(t), allocatable, intent(out) :: ee, ff(:)
end

subroutine q(qa, qb, qc, qd, qe, qf)
  integer, allocatable :: qa, qb(:)
  type(t) :: qc, qd(4)
  type(t), allocatable :: qe, qf(:)
  call intent_out (qa, qb, qc, qd, qe, qf)
end subroutine q

subroutine r
  integer, allocatable :: r1, r2(:)
  type(t) :: r3, r4(4)
  type(t), allocatable :: r5, r6(:)

  call q(r1,r2,r3,r4,r5,r6)

  allocate(r1,r2(3))
  allocate(r5,r6(4))
  allocate(r3%Acomp, r3%Bcomp(2))
  allocate(r4(2)%Acomp, r4(2)%Bcomp(2))
  allocate(r5%Acomp, r5%Bcomp(2))
  allocate(r6(3)%Acomp, r6(3)%Bcomp(2))
  !$omp allocate align(128)
  allocate(r4(3)%Acomp, r4(3)%Bcomp(2), &
           r6(1)%Acomp, r6(1)%Bcomp(2))
  if (mod (loc (r4(3)%Acomp), 128) /= 0) stop 1
  if (mod (loc (r4(3)%Bcomp), 128) /= 0) stop 2
  if (mod (loc (r6(1)%Acomp), 128) /= 0) stop 3
  if (mod (loc (r6(1)%Bcomp), 128) /= 0) stop 3
  call q(r1,r2,r3,r4,r5,r6)

  !$omp allocate align(64)
  allocate(r1,r2(3))
  if (mod (loc (r1), 64) /= 0) stop 1
  if (mod (loc (r2), 64) /= 0) stop 1
  !$omp allocate align(64)
  allocate(r5,r6(4))
  if (mod (loc (r5), 64) /= 0) stop 1
  if (mod (loc (r6), 64) /= 0) stop 1
  !$omp allocate align(64)
  allocate(r3%Acomp, r3%Bcomp(2))
  if (mod (loc (r3%Acomp), 64) /= 0) stop 1
  if (mod (loc (r3%Bcomp), 64) /= 0) stop 1
  !$omp allocate align(64)
  allocate(r4(2)%Acomp, r4(2)%Bcomp(2))
  if (mod (loc (r4(2)%Acomp), 64) /= 0) stop 1
  if (mod (loc (r4(2)%Bcomp), 64) /= 0) stop 1
  !$omp allocate align(64)
  allocate(r5%Acomp, r5%Bcomp(2))
  if (mod (loc (r5%Acomp), 64) /= 0) stop 1
  if (mod (loc (r5%Bcomp), 64) /= 0) stop 1
  !$omp allocate align(64)
  allocate(r6(3)%Acomp, r6(3)%Bcomp(2))
  if (mod (loc (r6(3)%Acomp), 64) /= 0) stop 1
  if (mod (loc (r6(3)%Bcomp), 64) /= 0) stop 1
  !$omp allocate align(128)
  allocate(r4(3)%Acomp, r4(3)%Bcomp(2), &
           r6(1)%Acomp, r6(1)%Bcomp(2))
  if (mod (loc (r4(3)%Acomp), 128) /= 0) stop 1
  if (mod (loc (r4(3)%Bcomp), 128) /= 0) stop 2
  if (mod (loc (r6(1)%Acomp), 128) /= 0) stop 3
  if (mod (loc (r6(1)%Bcomp), 128) /= 0) stop 3
  call q(r1,r2,r3,r4,r5,r6)
end subroutine r
end

subroutine s
  use m, only : t
  implicit none (type, external)
  type(t) :: xx
  integer :: i, iiiiii
  i = 4
  !$omp allocate
  allocate(xx%Acomp, xx%Bcomp(4))
  deallocate(xx%Acomp, xx%Bcomp)

  !$omp allocate
  allocate(xx%Acomp, xx%Bcomp(4))
  xx = t(1, [1,2])
end

program main
  use m, only: r
  implicit none (type, external)
  external s
  call s
  call r
end