22cff118f7
... to diagnose potentially suboptimal choices regarding OpenACC parallelism. Not enabled by default: too noisy ("*potentially* suboptimal choices"); see XFAILed 'dg-bogus'es. gcc/c-family/ * c.opt (Wopenacc-parallelism): New. gcc/fortran/ * lang.opt (Wopenacc-parallelism): New. gcc/ * omp-offload.c (oacc_validate_dims): Implement '-Wopenacc-parallelism'. * doc/invoke.texi (-Wopenacc-parallelism): Document. gcc/testsuite/ * c-c++-common/goacc/diag-parallelism-1.c: New. * c-c++-common/goacc/acc-icf.c: Specify '-Wopenacc-parallelism', and match diagnostics, as appropriate. * c-c++-common/goacc/classify-kernels-unparallelized.c: Likewise. * c-c++-common/goacc/classify-kernels.c: Likewise. * c-c++-common/goacc/classify-parallel.c: Likewise. * c-c++-common/goacc/classify-routine.c: Likewise. * c-c++-common/goacc/classify-serial.c: Likewise. * c-c++-common/goacc/kernels-decompose-1.c: Likewise. * c-c++-common/goacc/kernels-decompose-2.c: Likewise. * c-c++-common/goacc/parallel-dims-1.c: Likewise. * c-c++-common/goacc/parallel-reduction.c: Likewise. * c-c++-common/goacc/pr70688.c: Likewise. * c-c++-common/goacc/routine-1.c: Likewise. * c-c++-common/goacc/routine-level-of-parallelism-2.c: Likewise. * c-c++-common/goacc/uninit-dim-clause.c: Likewise. * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise. * gfortran.dg/goacc/classify-kernels.f95: Likewise. * gfortran.dg/goacc/classify-parallel.f95: Likewise. * gfortran.dg/goacc/classify-routine.f95: Likewise. * gfortran.dg/goacc/classify-serial.f95: Likewise. * gfortran.dg/goacc/kernels-decompose-1.f95: Likewise. * gfortran.dg/goacc/kernels-decompose-2.f95: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. * gfortran.dg/goacc/routine-4.f90: Likewise. * gfortran.dg/goacc/routine-level-of-parallelism-1.f90: Likewise. * gfortran.dg/goacc/routine-module-mod-1.f90: Likewise. * gfortran.dg/goacc/routine-multiple-directives-1.f90: Likewise. * gfortran.dg/goacc/uninit-dim-clause.f95: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/firstprivate-1.c: Specify '-Wopenacc-parallelism', and match diagnostics, as appropriate. * testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/mode-transitions.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-reduction.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pr85381-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/private-variables.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/reduction-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/routine-wv-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/static-variable-1.c: Likewise. * testsuite/libgomp.oacc-fortran/optional-private.f90: Likewise. * testsuite/libgomp.oacc-fortran/par-reduction-2-1.f: Likewise. * testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise. * testsuite/libgomp.oacc-fortran/parallel-dims.f90: Likewise. * testsuite/libgomp.oacc-fortran/parallel-reduction.f90: Likewise. * testsuite/libgomp.oacc-fortran/pr84028.f90: Likewise. * testsuite/libgomp.oacc-fortran/private-variables.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-6.f90: Likewise. * testsuite/libgomp.oacc-fortran/routine-7.f90: Likewise. Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com> Co-Authored-By: Tom de Vries <vries@codesourcery.com> Co-Authored-By: Julian Brown <julian@codesourcery.com> Co-Authored-By: Kwok Cheung Yeung <kcy@codesourcery.com>
103 lines
2.2 KiB
Fortran
103 lines
2.2 KiB
Fortran
! { dg-do run }
|
|
|
|
! { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
|
|
! aspects of that functionality.
|
|
|
|
! subroutine reduction
|
|
|
|
program reduction
|
|
integer, parameter :: n = 40, c = 10
|
|
integer :: i, vsum, gs, ws, vs, cs, ns
|
|
|
|
call redsub_gang (gs, n, c)
|
|
call redsub_worker (ws, n, c)
|
|
call redsub_vector (vs, n, c)
|
|
call redsub_combined (cs, n, c)
|
|
call redsub_nested (ns, n, c)
|
|
|
|
vsum = 0
|
|
|
|
! Verify the results
|
|
do i = 1, n
|
|
vsum = vsum + c
|
|
end do
|
|
|
|
if (gs .ne. vsum) STOP 1
|
|
if (ws .ne. vsum) STOP 2
|
|
if (vs .ne. vsum) STOP 3
|
|
if (cs .ne. vsum) STOP 4
|
|
if (ns .ne. vsum) STOP 5
|
|
end program reduction
|
|
|
|
subroutine redsub_gang(sum, n, c)
|
|
integer :: sum, n, c
|
|
|
|
sum = 0
|
|
|
|
!$acc parallel copyin (n, c) num_gangs(n) copy(sum)
|
|
!$acc loop reduction(+:sum) gang
|
|
do i = 1, n
|
|
sum = sum + c
|
|
end do
|
|
!$acc end parallel
|
|
end subroutine redsub_gang
|
|
|
|
subroutine redsub_worker(sum, n, c)
|
|
integer :: sum, n, c
|
|
|
|
sum = 0
|
|
|
|
!$acc parallel copyin (n, c) num_workers(4) vector_length (32) copy(sum)
|
|
! { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-1 }
|
|
!$acc loop reduction(+:sum) worker
|
|
do i = 1, n
|
|
sum = sum + c
|
|
end do
|
|
!$acc end parallel
|
|
end subroutine redsub_worker
|
|
|
|
subroutine redsub_vector(sum, n, c)
|
|
integer :: sum, n, c
|
|
|
|
sum = 0
|
|
|
|
!$acc parallel copyin (n, c) vector_length(32) copy(sum)
|
|
!$acc loop reduction(+:sum) vector
|
|
do i = 1, n
|
|
sum = sum + c
|
|
end do
|
|
!$acc end parallel
|
|
end subroutine redsub_vector
|
|
|
|
subroutine redsub_combined(sum, n, c)
|
|
integer :: sum, n, c
|
|
|
|
sum = 0
|
|
|
|
!$acc parallel num_gangs (8) num_workers (4) vector_length(32) copy(sum)
|
|
!$acc loop reduction(+:sum) gang worker vector
|
|
do i = 1, n
|
|
sum = sum + c
|
|
end do
|
|
!$acc end parallel
|
|
end subroutine redsub_combined
|
|
|
|
subroutine redsub_nested(sum, n, c)
|
|
integer :: sum, n, c
|
|
integer :: ii, jj
|
|
|
|
ii = n / 10;
|
|
jj = 10;
|
|
sum = 0
|
|
|
|
!$acc parallel num_gangs (8) copy(sum)
|
|
!$acc loop reduction(+:sum) gang
|
|
do i = 1, ii
|
|
!$acc loop reduction(+:sum) vector
|
|
do j = 1, jj
|
|
sum = sum + c
|
|
end do
|
|
end do
|
|
!$acc end parallel
|
|
end subroutine redsub_nested
|