GCC with patches for OS216
Revisión | 1dfa89b0355520ca501054726f25de9733796f48 (tree) |
---|---|
Tiempo | 2020-06-25 22:06:12 |
Autor | Kwok Cheung Yeung <kcy@code...> |
Commiter | Kwok Cheung Yeung |
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>
@@ -4748,7 +4748,7 @@ gfc_split_omp_clauses (gfc_code *code, | ||
4748 | 4748 | clausesa[GFC_OMP_SPLIT_TARGET].if_exprs[OMP_IF_TARGET] |
4749 | 4749 | = code->ext.omp_clauses->if_exprs[OMP_IF_TARGET]; |
4750 | 4750 | /* And this is copied to all. */ |
4751 | - clausesa[GFC_OMP_SPLIT_PARALLEL].if_expr | |
4751 | + clausesa[GFC_OMP_SPLIT_TARGET].if_expr | |
4752 | 4752 | = code->ext.omp_clauses->if_expr; |
4753 | 4753 | } |
4754 | 4754 | if (mask & GFC_OMP_MASK_TEAMS) |
@@ -4832,6 +4832,9 @@ gfc_split_omp_clauses (gfc_code *code, | ||
4832 | 4832 | /* Duplicate collapse. */ |
4833 | 4833 | clausesa[GFC_OMP_SPLIT_SIMD].collapse |
4834 | 4834 | = 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; | |
4835 | 4838 | } |
4836 | 4839 | if (mask & GFC_OMP_MASK_TASKLOOP) |
4837 | 4840 | { |
@@ -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" } } |