• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for OS216


Commit MetaInfo

Revisión1dfa89b0355520ca501054726f25de9733796f48 (tree)
Tiempo2020-06-25 22:06:12
AutorKwok Cheung Yeung <kcy@code...>
CommiterKwok Cheung Yeung

Log Message

fortran: Apply if clause to all sub-constructs in combined OpenMP constructs

The unmodified 'if' clause should be applied to all the sub-constructs that
accept an 'if' clause in a combined OpenMP construct, and not just to the
'parallel' sub-construct.

2020-06-25 Kwok Cheung Yeung <kcy@codesourcery.com>

gcc/fortran/

* trans-openmp.c (gfc_split_omp_clauses): Add if clause
to target and simd sub-constructs.

gcc/testsuite/

* gfortran.dg/gomp/combined-if.f90: New.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>

Cambiar Resumen

Diferencia incremental

--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -4748,7 +4748,7 @@ gfc_split_omp_clauses (gfc_code *code,
47484748 clausesa[GFC_OMP_SPLIT_TARGET].if_exprs[OMP_IF_TARGET]
47494749 = code->ext.omp_clauses->if_exprs[OMP_IF_TARGET];
47504750 /* And this is copied to all. */
4751- clausesa[GFC_OMP_SPLIT_PARALLEL].if_expr
4751+ clausesa[GFC_OMP_SPLIT_TARGET].if_expr
47524752 = code->ext.omp_clauses->if_expr;
47534753 }
47544754 if (mask & GFC_OMP_MASK_TEAMS)
@@ -4832,6 +4832,9 @@ gfc_split_omp_clauses (gfc_code *code,
48324832 /* Duplicate collapse. */
48334833 clausesa[GFC_OMP_SPLIT_SIMD].collapse
48344834 = code->ext.omp_clauses->collapse;
4835+ /* And this is copied to all. */
4836+ clausesa[GFC_OMP_SPLIT_SIMD].if_expr
4837+ = code->ext.omp_clauses->if_expr;
48354838 }
48364839 if (mask & GFC_OMP_MASK_TASKLOOP)
48374840 {
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90
@@ -0,0 +1,110 @@
1+! { dg-do compile }
2+! { dg-additional-options "-fdump-tree-omplower" }
3+
4+module combined_if
5+ implicit none
6+
7+ integer, parameter :: N = 100
8+ integer, parameter :: LIMIT = 60
9+ integer :: i, j
10+ integer, dimension(N) :: a = (/ (i, i = 1,N) /)
11+contains
12+ subroutine test_parallel_loop_simd
13+ do j = 1, N
14+ !$omp parallel do simd if(j .lt. LIMIT)
15+ do i = 1, N
16+ a(i) = a(i) + 1
17+ end do
18+ end do
19+ end subroutine
20+
21+ ! TODO: This currently fails with an internal compiler error
22+ ! (PR 95869)
23+ !subroutine test_target_parallel
24+ ! do j = 1, N
25+ ! !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N))
26+ ! do i = 1, N
27+ ! a(i) = a(i) + 1
28+ ! end do
29+ ! !$omp end target parallel
30+ ! end do
31+ !end subroutine
32+
33+ subroutine test_target_parallel_loop
34+ do j = 1, N
35+ !$omp target parallel do if(j .lt. LIMIT) map(tofrom: a(1:N))
36+ do i = 1, N
37+ a(i) = a(i) + 1
38+ end do
39+ end do
40+ end subroutine
41+
42+ subroutine test_target_parallel_loop_simd
43+ do j = 1, N
44+ !$omp target parallel do simd if(j .lt. LIMIT) map(tofrom: a(1:N))
45+ do i = 1, N
46+ a(i) = a(i) + 1
47+ end do
48+ end do
49+ end subroutine
50+
51+ subroutine test_target_simd
52+ do j = 1, N
53+ !$omp target simd if(j .lt. LIMIT) map(tofrom: a(1:N))
54+ do i = 1, N
55+ a(i) = a(i) + 1
56+ end do
57+ end do
58+ end subroutine
59+
60+ subroutine test_target_teams
61+ do j = 1, N
62+ !$omp target teams if(j .lt. LIMIT) map(tofrom: a(1:N))
63+ do i = 1, N
64+ a(i) = a(i) + 1
65+ end do
66+ !$omp end target teams
67+ end do
68+ end subroutine
69+
70+ subroutine test_target_teams_distribute
71+ do j = 1, N
72+ !$omp target teams distribute if(j .lt. LIMIT) map(tofrom: a(1:N))
73+ do i = 1, N
74+ a(i) = a(i) + 1
75+ end do
76+ end do
77+ end subroutine
78+
79+ subroutine test_target_teams_distibute_simd
80+ do j = 1, N
81+ !$omp target teams distribute simd if(j .lt. LIMIT) map(tofrom: a(1:N))
82+ do i = 1, N
83+ a(i) = a(i) + 1
84+ end do
85+ end do
86+ end subroutine
87+
88+ subroutine test_target_teams_distribute_parallel_loop
89+ do j = 1, N
90+ !$omp target teams distribute parallel do if(j .lt. LIMIT) map(tofrom: a(1:N))
91+ do i = 1, N
92+ a(i) = a(i) + 1
93+ end do
94+ end do
95+ end subroutine
96+
97+ subroutine test_target_teams_distribute_parallel_loop_simd
98+ do j = 1, N
99+ !$omp target teams distribute parallel do simd if(j .lt. LIMIT) map(tofrom: a(1:N))
100+ do i = 1, N
101+ a(i) = a(i) + 1
102+ end do
103+ end do
104+ end subroutine
105+
106+end module
107+
108+! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 8 "omplower" } }
109+! { dg-final { scan-tree-dump-times "(?n)#pragma omp simd.* if\\(" 7 "omplower" } }
110+! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 5 "omplower" } }