summaryrefslogtreecommitdiffstats
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-05-17 11:01:04 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-05-17 11:01:04 +0200
commit4f94c38a9237b728b3a3f76c169b5b47f6c45187 (patch)
tree2ec7b560f303f268bb602613d6ea0d3eff96e428 /libgomp
parenttree-optimization/105618 - restore load sinking (diff)
downloadgcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.tar.gz
gcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.tar.bz2
gcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.tar.xz
OpenMP: Add omp_all_memory support to Fortran
Fortran part to the C/C++/backend implementation r13-337-g7f78783dbedca0183d193e475262ca3c489fd365 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory. * openmp.cc (gfc_match_omp_variable_list, gfc_match_omp_depend_sink, gfc_match_omp_clauses, resolve_omp_clauses): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Likewise. * resolve.cc (resolve_symbol): Reject it as symbol. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1): Set omp_all_memory to 'Y'. * testsuite/libgomp.fortran/depend-5.f90: New test. * testsuite/libgomp.fortran/depend-6.f90: New test. * testsuite/libgomp.fortran/depend-7.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: New test. * gfortran.dg/gomp/all-memory-2.f90: New test. * gfortran.dg/gomp/all-memory-3.f90: New test.
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/libgomp.texi4
-rw-r--r--libgomp/testsuite/libgomp.fortran/depend-5.f90121
-rw-r--r--libgomp/testsuite/libgomp.fortran/depend-6.f90126
-rw-r--r--libgomp/testsuite/libgomp.fortran/depend-7.f90113
4 files changed, 362 insertions, 2 deletions
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index b5e5fbb8cca..d9d86f36a50 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -274,7 +274,7 @@ The OpenMP 4.5 specification is fully supported.
274@multitable @columnfractions .60 .10 .25 274@multitable @columnfractions .60 .10 .25
275@headitem Description @tab Status @tab Comments 275@headitem Description @tab Status @tab Comments
276@item OpenMP directive as C++ attribute specifiers @tab Y @tab 276@item OpenMP directive as C++ attribute specifiers @tab Y @tab
277@item @code{omp_all_memory} reserved locator @tab N @tab 277@item @code{omp_all_memory} reserved locator @tab Y @tab
278@item @emph{target_device trait} in OpenMP Context @tab N @tab 278@item @emph{target_device trait} in OpenMP Context @tab N @tab
279@item @code{target_device} selector set in context selectors @tab N @tab 279@item @code{target_device} selector set in context selectors @tab N @tab
280@item C/C++'s @code{declare variant} directive: elision support of 280@item C/C++'s @code{declare variant} directive: elision support of
@@ -283,7 +283,7 @@ The OpenMP 4.5 specification is fully supported.
283 @code{append_args} @tab N @tab 283 @code{append_args} @tab N @tab
284@item @code{dispatch} construct @tab N @tab 284@item @code{dispatch} construct @tab N @tab
285@item device-specific ICV settings the environment variables @tab N @tab 285@item device-specific ICV settings the environment variables @tab N @tab
286@item assume directive @tab N @tab 286@item @code{assume} directive @tab N @tab
287@item @code{nothing} directive @tab Y @tab 287@item @code{nothing} directive @tab Y @tab
288@item @code{error} directive @tab Y @tab 288@item @code{error} directive @tab Y @tab
289@item @code{masked} construct @tab Y @tab 289@item @code{masked} construct @tab Y @tab
diff --git a/libgomp/testsuite/libgomp.fortran/depend-5.f90 b/libgomp/testsuite/libgomp.fortran/depend-5.f90
new file mode 100644
index 00000000000..a350e793623
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/depend-5.f90
@@ -0,0 +1,121 @@
1! { dg-additional-sources my-usleep.c }
2! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
3
4module m
5 implicit none
6
7 interface
8 subroutine usleep(t) bind(C, name="my_usleep")
9 use iso_c_binding
10 integer(c_int), value :: t
11 end subroutine
12 end interface
13
14contains
15subroutine test (ifval)
16 logical, value :: ifval
17 integer :: a(0:7), b(0:7), i
18
19 do i = 0, 7
20 a(i) = i
21 b(i) = 2 * i
22 end do
23 !$omp parallel
24 block
25 !$omp single
26 block
27 !$omp task shared(a) depend(in: a(0))
28 block
29 call usleep (5000)
30 a(0) = 42
31 end block
32 !$omp task shared(a) depend(out: a(1))
33 block
34 call usleep (5000)
35 a(1) = 43
36 end block
37 !$omp task shared(a) depend(inout: a(2))
38 block
39 call usleep (5000)
40 a(2) = 44
41 end block
42 !$omp task shared(a) depend(mutexinoutset: a(3))
43 block
44 call usleep (5000)
45 a(3) = 45
46 end block
47 !$omp task shared(a)
48 block
49 call usleep (15000)
50 a(4) = 46
51 end block
52 !$omp task shared(b) depend(in: b(0))
53 block
54 call usleep (5000)
55 b(0) = 47
56 end block
57 !$omp task shared(b) depend(in: b(4))
58 block
59 call usleep (5000)
60 b(4) = 48
61 end block
62 ! None of the above tasks depend on each other.
63 ! The following task depends on all but the a(4) = 46; one.
64 !$omp task shared(a, b) depend(out: omp_all_memory) private(i) if(ifval)
65 block
66 if (a(0) /= 42 .or. a(1) /= 43 .or. a(2) /= 44 .or. a(3) /= 45 &
67 .or. a(5) /= 5 .or. a(6) /= 6 .or. a(7) /= 7 &
68 .or. b(0) /= 47 .or. b(1) /= 2 .or. b(2) /= 4 .or. b(3) /= 6 &
69 .or. b(4) /= 48 .or. b(5) /= 10 .or. b(6) /= 12 .or. b(7) /= 14) &
70 error stop
71 do i = 0, 7
72 if (i /= 4) &
73 a(i) = 3 * i + 7
74 end do
75 do i = 0, 7
76 b(i) = 4 * i - 7
77 end do
78 end block
79 ! The following task depends on both b(0) = 47; and
80 ! above omp_all_memory tasks, but as the latter depends on
81 ! the former, effectively it is dependent just on the omp_all_memory
82 ! task.
83 !$omp task shared(b) depend(inout: b(0))
84 block
85 call usleep (5000)
86 b(0) = 49
87 end block
88 ! The following task depends on all the above except a(4) = 46; one,
89 ! but it can be reduced to dependency on the above omp_all_memory
90 ! one and b(0) = 49; one.
91 !$omp task shared(a, b) depend(inout: b(7), omp_all_memory, b(6)) &
92 !$omp& private(i) if(ifval)
93 block
94 do i = 0, 7
95 if (i /= 4) then
96 if (a(i) /= 3 * i + 7) &
97 error stop
98 a(i) = 5 * i + 50
99 end if
100 end do
101 if (b(0) /= 49) &
102 error stop
103 b(0) = 6 * i + 57
104 do i = 1, 7
105 if (b(i) /= 4 * i - 7) &
106 error stop
107 b(i) = 6 * i + 57
108 end do
109 end block
110 !$omp taskwait
111 if (a(4) /= 46) &
112 error stop
113 end block ! end single
114 end block ! end parallel
115end
116end module m
117
118use m
119call test(.true.)
120call test(.false.)
121end
diff --git a/libgomp/testsuite/libgomp.fortran/depend-6.f90 b/libgomp/testsuite/libgomp.fortran/depend-6.f90
new file mode 100644
index 00000000000..edea8571bba
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/depend-6.f90
@@ -0,0 +1,126 @@
1! { dg-additional-sources my-usleep.c }
2! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
3
4module m
5 use omp_lib
6 implicit none
7
8 interface
9 subroutine usleep(t) bind(C, name="my_usleep")
10 use iso_c_binding
11 integer(c_int), value :: t
12 end subroutine
13 end interface
14
15contains
16subroutine test (ifval)
17 logical, value :: ifval
18 integer :: a(0:7), b(0:7), i
19 integer(omp_depend_kind) d1, d2
20 !$omp depobj (d1) depend(inout: omp_all_memory)
21 !$omp depobj (d2) depend(out: omp_all_memory)
22 do i = 0, 7
23 a(i) = i
24 b(i) = 2 * i
25 end do
26 !$omp parallel
27 block
28 !$omp single
29 block
30 !$omp task shared(a) depend(in: a(0))
31 block
32 call usleep (5000)
33 a(0) = 42
34 end block
35 !$omp task shared(a) depend(out: a(1))
36 block
37 call usleep (5000)
38 a(1) = 43
39 end block
40 !$omp task shared(a) depend(inout: a(2))
41 block
42 call usleep (5000)
43 a(2) = 44
44 end block
45 !$omp task shared(a) depend(mutexinoutset: a(3))
46 block
47 call usleep (5000)
48 a(3) = 45
49 end block
50 !$omp task shared(a)
51 block
52 call usleep (15000)
53 a(4) = 46
54 end block
55 !$omp task shared(b) depend(in: b(0))
56 block
57 call usleep (5000)
58 b(0) = 47
59 end block
60 !$omp task shared(b) depend(in: b(4))
61 block
62 call usleep (5000)
63 b(4) = 48
64 end block
65 ! None of the above tasks depend on each other.
66 ! The following task depends on all but the a(4) = 46; one.
67 !$omp task shared(a, b) depend(depobj: d1) private(i) if(ifval)
68 block
69 if (a(0) /= 42 .or. a(1) /= 43 .or. a(2) /= 44 .or. a(3) /= 45 &
70 .or. a(5) /= 5 .or. a(6) /= 6 .or. a(7) /= 7 &
71 .or. b(0) /= 47 .or. b(1) /= 2 .or. b(2) /= 4 .or. b(3) /= 6 &
72 .or. b(4) /= 48 .or. b(5) /= 10 .or. b(6) /= 12 .or. b(7) /= 14) &
73 error stop
74 do i = 0, 7
75 if (i /= 4) &
76 a(i) = 3 * i + 7
77 end do
78 do i = 0, 7
79 b(i) = 4 * i - 7
80 end do
81 end block
82 ! The following task depends on both b(0) = 47; and
83 ! above omp_all_memory tasks, but as the latter depends on
84 ! the former, effectively it is dependent just on the omp_all_memory
85 ! task.
86 !$omp task shared(b) depend(inout: b(0))
87 block
88 call usleep (5000)
89 b(0) = 49
90 end block
91 ! The following task depends on all the above except a(4) = 46; one,
92 ! but it can be reduced to dependency on the above omp_all_memory
93 ! one and b(0) = 49; one.
94 !$omp task shared(a, b) depend(inout: b(6)) depend(depobj: d2) &
95 !$omp& depend(out: b(7)) private(i) if(ifval)
96 block
97 do i = 0, 7
98 if (i /= 4) then
99 if (a(i) /= 3 * i + 7) &
100 error stop
101 a(i) = 5 * i + 50
102 end if
103 end do
104 if (b(0) /= 49) &
105 error stop
106 b(0) = 6 * i + 57
107 do i = 1, 7
108 if (b(i) /= 4 * i - 7) &
109 error stop
110 b(i) = 6 * i + 57
111 end do
112 end block
113 !$omp taskwait
114 if (a(4) /= 46) &
115 error stop
116 end block
117 end block
118 !$omp depobj (d2) destroy
119 !$omp depobj (d1) destroy
120end
121end module m
122
123use m
124call test (.true.)
125call test (.false.)
126end
diff --git a/libgomp/testsuite/libgomp.fortran/depend-7.f90 b/libgomp/testsuite/libgomp.fortran/depend-7.f90
new file mode 100644
index 00000000000..d3f3988f0da
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/depend-7.f90
@@ -0,0 +1,113 @@
1! { dg-additional-sources my-usleep.c }
2! { dg-prune-output "command-line option '-fintrinsic-modules-path=.*' is valid for Fortran but not for C" }
3
4program main
5 implicit none
6
7 interface
8 subroutine usleep(t) bind(C, name="my_usleep")
9 use iso_c_binding
10 integer(c_int), value :: t
11 end subroutine
12 end interface
13
14 integer :: a(0:7), b(0:7), i
15
16 do i = 0, 7
17 a(i) = i
18 b(i) = 2 * i
19 end do
20
21 !$omp parallel
22 block
23 !$omp single
24 block
25 !$omp task shared(a) depend(in: a(0))
26 block
27 call usleep (5000)
28 a(0) = 42
29 end block
30 !$omp task shared(a) depend(out: a(1))
31 block
32 call usleep (5000)
33 a(1) = 43
34 end block
35 !$omp task shared(a) depend(inout: a(2))
36 block
37 call usleep (5000)
38 a(2) = 44
39 end block
40 !$omp task shared(a) depend(mutexinoutset: a(3))
41 block
42 call usleep (5000)
43 a(3) = 45
44 end block
45 !$omp task shared(a)
46 block
47 call usleep (15000)
48 a(4) = 46
49 end block
50 !$omp task shared(b) depend(in: b(0))
51 block
52 call usleep (5000)
53 b(0) = 47
54 end block
55 !$omp task shared(b) depend(in: b(4))
56 block
57 call usleep (5000)
58 b(4) = 48
59 end block
60 ! None of the above tasks depend on each other.
61 ! The following task depends on all but the a(4) = 46; one.
62 !$omp task shared(a, b) depend(iterator (j=0:7), inout: omp_all_memory) private(i)
63 block
64 if (a(0) /= 42 .or. a(1) /= 43 .or. a(2) /= 44 .or. a(3) /= 45 &
65 .or. a(5) /= 5 .or. a(6) /= 6 .or. a(7) /= 7 &
66 .or. b(0) /= 47 .or. b(1) /= 2 .or. b(2) /= 4 .or. b(3) /= 6 &
67 .or. b(4) /= 48 .or. b(5) /= 10 .or. b(6) /= 12 .or. b(7) /= 14) &
68 error stop
69 do i = 0, 7
70 if (i /= 4) &
71 a(i) = 3 * i + 7
72 end do
73 do i = 0, 7
74 b(i) = 4 * i - 7
75 end do
76 end block
77 ! The following task depends on both b(0) = 47; and
78 ! above omp_all_memory tasks, but as the latter depends on
79 ! the former, effectively it is dependent just on the omp_all_memory
80 ! task.
81 !$omp task shared(b) depend(inout: b(0))
82 block
83 call usleep (5000)
84 b(0) = 49
85 end block
86 ! The following task depends on all the above except a(4) = 46; one,
87 ! but it can be reduced to dependency on the above omp_all_memory
88 ! one and b(0) = 49; one.
89 !$omp task shared(a, b) depend(inout: b(7)) depend(iterator(j=4:5), out: omp_all_memory) &
90 !$omp& depend(inout: b(6)) private(i)
91 block
92 do i = 0, 7
93 if (i /= 4) then
94 if (a(i) /= 3 * i + 7) &
95 error stop
96 a(i) = 5 * i + 50
97 end if
98 end do
99 if (b(0) /= 49) &
100 error stop
101 b(0) = 6 * i + 57
102 do i = 1, 7
103 if (b(i) /= 4 * i - 7) &
104 error stop
105 b(i) = 6 * i + 57
106 end do
107 end block
108 !$omp taskwait
109 if (a(4) /= 46) &
110 error stop
111 end block
112 end block
113end program