[PR72741] Properly handle clauses specifying the level of parallelism for 'external' Fortran OpenACC routines (was: [gomp4] check for sufficient parallelism when calling acc routines in fortran)
Thomas Schwinge
thomas@codesourcery.com
Thu Mar 21 20:19:00 GMT 2019
Hi!
On Fri, 26 Aug 2016 08:16:43 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> This patch
(..., variants of which got re-submitted a few times, later on...)
> teaches the fortran FE how to verify that there is sufficient
> parallelism when calling acc routines inside acc loop. E.g. the fortran
> FE will now error if you call a gang routine from a vector loop, because
> there's no way for vector partitioned code to spawn new gangs with the
> OpenACC current execution model.
These proposed Fortran front end changes seemed strange to me: the
generic middle end OMP code is already doing such checking, and works for
other Fortran test cases. This should also work for the 'external' case
discussed here; see also the 'c-c++-common/goacc/routine-3-extern.c',
'c-c++-common/goacc/routine-4-extern.c' test cases I'm adding. Now that
I looked into these proposed changes in more detail, I found that indeed
the error is a different one than what/how it's getting addressed there,
and the solution is much simpler one.
> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/goacc/routine-nested-parallelism.f
> @@ -0,0 +1,340 @@
> +! Validate calls to ACC ROUTINES. Ensure that the loop containing the
> +! call has sufficient parallelism to for the routine.
> +
> + subroutine sub
> + implicit none
> + integer, parameter :: n = 100
> + integer :: a(n), i, j
> + external gangr, workerr, vectorr, seqr
> +!$acc routine (gangr) gang
> +!$acc routine (workerr) worker
> +!$acc routine (vectorr) vector
> +!$acc routine (seqr) seq
> +
> +!
> +! Test subroutine calls inside nested loops.
> +!
> +
> +!$acc parallel loop
> + do i = 1, n
> + !$acc loop
> + do j = 1, n
That "!$acc loop" directive is not considered; needs to be in the first
column.
> + call workerr (a, n)
> + end do
> + end do
> +!$acc end parallel loop
> +
> +!$acc parallel loop
> + do i = 1, n
> +!$acc loop gang
> + do j = 1, n
If this loop is using OpenACC 'gang' parallelism, then no parallelism is
available for the outer loop; the generic middle end OMP code diagnoses:
"warning: insufficient partitioning available to parallelize loop".
Similar in other such places.
> + call gangr (a, n) ! { dg-error "Insufficient ..ACC LOOP parallelism" }
The generic middle end OMP code diagnoses: "error: routine call uses same
OpenACC parallelism as containing loop". Similar in other such places.
> +[...]
> +!$acc parallel loop seq
> + do i = 1, n
> + call gangr (a, n) ! { dg-error "Insufficient ..ACC LOOP parallelism" }
> + end do
> +!$acc end parallel loop
That's not correct. The outer loop is tagged 'seq', so not parallelized,
and thus 'gang' parallelism is still available for the 'gangr' routine
call. Similar in other such places.
> +[...]
> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/goacc/routine-nested-parallelism.f90
That's the same as 'gfortran.dg/goacc/routine-nested-parallelism.f', just
differing in whitespace; file removed.
For good measure I also created a corresponding test case to "Check valid
calls to 'external' OpenACC routines", and also added
'-fopt-info-optimized-omp' scanning to both these new Fortran test cases.
Committed to trunk r269858 "[PR72741] Properly handle clauses specifying
the level of parallelism for 'external' Fortran OpenACC routines", see
attached.
Grüße
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-PR72741-Properly-handle-clauses-specifying-the.trunk.patch
Type: text/x-diff
Size: 42190 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190321/684161bd/attachment.bin>
More information about the Fortran
mailing list