* [Patch] OpenMP/Fortran: Permit assumed-size arrays in uniform clause
@ 2022-07-29 9:47 Tobias Burnus
2022-07-29 10:33 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2022-07-29 9:47 UTC (permalink / raw)
To: gcc-patches, fortran
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
Testcase wise, the run-time testcase libgomp.fortran/examples-4/simd-2.f90
checks essentially the same, except that it uses an array-descriptor array
(assumed shape) while this testcase uses an assumed-size array.
I decided for an extra compile-time only testcase, but it could be also be
moved to libgomp as run-time test or the other test could be extended to
also test assumed-size arrays.
The OpenMP examples document contains two testcases which now pass,
but are reject without this patch:
- SIMD/sources/SIMD.2.f90 (for OpenMP 4.0)
- SIMD/sources/linear_modifier.3.f90 (for OpenMP 5.2)
OK for mainline?
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: omp-uniform.diff --]
[-- Type: text/x-patch, Size: 2011 bytes --]
OpenMP/Fortran: Permit assumed-size arrays in uniform clause
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Permit assumed-size arrays
in uniform clause.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/declare-simd-3.f90: New test.
gcc/fortran/openmp.cc | 3 ++-
gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 | 30 +++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index df9cdf43eb7..a7eb6c3e8f4 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -7386,7 +7386,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
|| code->op == EXEC_OACC_PARALLEL
|| code->op == EXEC_OACC_SERIAL))
check_array_not_assumed (n->sym, n->where, name);
- else if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE)
+ else if (list != OMP_LIST_UNIFORM
+ && n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE)
gfc_error ("Assumed size array %qs in %s clause at %L",
n->sym->name, name, &n->where);
if (n->sym->attr.in_namelist && !is_reduction)
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90
new file mode 100644
index 00000000000..b94587ef35a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-3.f90
@@ -0,0 +1,30 @@
+! { dg-do compile }
+
+module m
+ implicit none (type, external)
+contains
+ real function add(x, y, j) result(res)
+ !$omp declare simd(add) uniform(x, y) linear(j : 1) simdlen(4)
+ integer, value :: j
+ real, intent(in) :: x(*), y(*)
+ res = x(j) + y(j)
+ end function
+end module m
+
+program main
+ use m
+ implicit none (type, external)
+ real, allocatable :: A(:), B(:), C(:)
+ integer :: i, N
+ N = 128
+ A = [(3*i, i = 1, N)]
+ B = [(7*i, i = 1, N)]
+ allocate (C(N))
+
+ !$omp simd
+ do i = 1, N
+ C(i) = add(A, B, i)
+ end do
+
+ if (any (C /= [(10*i, i = 1, N)])) error stop
+end program main
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] OpenMP/Fortran: Permit assumed-size arrays in uniform clause
2022-07-29 9:47 [Patch] OpenMP/Fortran: Permit assumed-size arrays in uniform clause Tobias Burnus
@ 2022-07-29 10:33 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2022-07-29 10:33 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, fortran
On Fri, Jul 29, 2022 at 11:47:54AM +0200, Tobias Burnus wrote:
> Testcase wise, the run-time testcase libgomp.fortran/examples-4/simd-2.f90
> checks essentially the same, except that it uses an array-descriptor array
> (assumed shape) while this testcase uses an assumed-size array.
>
> I decided for an extra compile-time only testcase, but it could be also be
> moved to libgomp as run-time test or the other test could be extended to
> also test assumed-size arrays.
>
> The OpenMP examples document contains two testcases which now pass,
> but are reject without this patch:
> - SIMD/sources/SIMD.2.f90 (for OpenMP 4.0)
> - SIMD/sources/linear_modifier.3.f90 (for OpenMP 5.2)
>
> OK for mainline?
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-29 10:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 9:47 [Patch] OpenMP/Fortran: Permit assumed-size arrays in uniform clause Tobias Burnus
2022-07-29 10:33 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).