summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/reduction3.f90
blob: 89b9d1af695a928cd96c76a496f46b67da067fbe (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
102
103
! { dg-do run }
!$ use omp_lib

  integer (kind = 4) :: i, ia (6), n, cnt
  real :: r, ra (4)
  double precision :: d, da (5)
  logical :: v

  i = 1
  ia = 2
  r = 3
  ra = 4
  d = 5.5
  da = 6.5
  v = .false.
  cnt = -1

!$omp parallel num_threads (3) private (n) reduction (.or.:v) &
!$omp & reduction (max:i, ia, r, ra, d, da)
!$ if (i .ne. -huge(i)-1 .or. any (ia .ne. -huge(ia)-1)) v = .true.
!$ if (r .ge. -1.0d38 .or. any (ra .ge. -1.0d38)) v = .true.
!$ if (d .ge. -1.0d300 .or. any (da .ge. -1.0d300)) v = .true.
  n = omp_get_thread_num ()
  if (n .eq. 0) then
    cnt = omp_get_num_threads ()
    i = 4
    ia(3:5) = -2
    ia(1) = 7
    r = 5
    ra(1:2) = 6.5
    d = -2.5
    da(2:4) = 8.5
  else if (n .eq. 1) then
    i = 2
    ia(4:6) = 5
    r = 1
    ra(2:4) = -1.5
    d = 8.5
    da(1:3) = 2.5
  else
    i = 1
    ia = 1
    r = -1
    ra = -1
    d = 1
    da = -1
  end if
!$omp end parallel
  if (v) call abort
  if (cnt .eq. 3) then
    if (i .ne. 4 .or. any (ia .ne. (/7, 2, 2, 5, 5, 5/))) call abort
    if (r .ne. 5 .or. any (ra .ne. (/6.5, 6.5, 4., 4./))) call abort
    if (d .ne. 8.5 .or. any (da .ne. (/6.5, 8.5, 8.5, 8.5, 6.5/))) call abort
  end if

  i = 1
  ia = 2
  r = 3
  ra = 4
  d = 5.5
  da = 6.5
  v = .false.
  cnt = -1

!$omp parallel num_threads (3) private (n) reduction (.or.:v) &
!$omp & reduction (min:i, ia, r, ra, d, da)
!$ if (i .ne. 2147483647 .or. any (ia .ne. 2147483647)) v = .true.
!$ if (r .le. 1.0d38 .or. any (ra .le. 1.0d38)) v = .true.
!$ if (d .le. 1.0d300 .or. any (da .le. 1.0d300)) v = .true.
  n = omp_get_thread_num ()
  if (n .eq. 0) then
    cnt = omp_get_num_threads ()
    i = 4
    ia(3:5) = -2
    ia(1) = 7
    r = 5
    ra(1:2) = 6.5
    d = -2.5
    da(2:4) = 8.5
  else if (n .eq. 1) then
    i = 2
    ia(4:6) = 5
    r = 1
    ra(2:4) = -1.5
    d = 8.5
    da(1:3) = 2.5
  else
    i = 1
    ia = 1
    r = -1
    ra = 7
    ra(3) = -8.5
    d = 1
    da(1:4) = 6
  end if
!$omp end parallel
  if (v) call abort
  if (cnt .eq. 3) then
    if (i .ne. 1 .or. any (ia .ne. (/1, 1, -2, -2, -2, 1/))) call abort
    if (r .ne. -1 .or. any (ra .ne. (/4., -1.5, -8.5, -1.5/))) call abort
    if (d .ne. -2.5 .or. any (da .ne. (/2.5, 2.5, 2.5, 6., 6.5/))) call abort
  end if
end