Fwd: Problem with OpenMP Reduction Clause
Andrew Pinski
pinskia@physics.uc.edu
Tue May 2 15:09:00 GMT 2006
FYI.
Begin forwarded message:
> From: "Benjamin Réveillé" <benjamin.reveille@gmail.com>
> Date: May 2, 2006 7:44:38 AM PDT
> To: fortran@gcc.gnu.org
> Subject: Problem with OpenMP Reduction Clause
>
> Hello
>
> I've stumbled onto a problem with the OpenMP REDUCTION clause
>
> Here is the reduced code array_reduction.f90
>
>
> ##########################################
> program array_reduction
> implicit none
> integer, parameter :: n=10,m=1000
> integer :: i
> integer, dimension(n) :: sumarray
> !
> call foo(n,m,sumarray)
> do i=1,n
> print*,sumarray(i)
> end do
> end program array_reduction
>
> subroutine foo(n,m,sumarray)
> use omp_lib, only : omp_get_thread_num
> implicit none
> integer, intent(in) :: n,m
> integer, dimension(n), intent(out) :: sumarray
> !
> integer :: i,j
> !
> sumarray(:)=0
> !$OMP PARALLEL DEFAULT(shared)
> print*,'hello from thread ',omp_get_thread_num()
> !$OMP DO PRIVATE(j,i), REDUCTION(+:sumarray)
> do j=1,m
> do i=1,n
> sumarray(i)=sumarray(i)+i
> end do
> end do
> !$OMP END DO
> !$OMP END PARALLEL
> end subroutine foo
> ##########################################
>
>
> pgi 6.1 and xlf10.1 both compile and execute with the following
> correct output:
> hello from thread 1
> hello from thread 0
> 1000
> 2000
> 3000
> 4000
> 5000
> 6000
> 7000
> 8000
> 9000
> 10000
>
>
> Intel 9.1 compiles but [Abort]s on execution.
>
> gfortran
> Using built-in specs.
> Target: i386-linux
> Configured with: ../gcc/configure
> --prefix=/cosmic/coudert/tmp/gfortran-20060502/irun
> --enable-languages=c,fortran --host=i386-linux
> --with-gmp=/cosmic/coudert/tmp/gfortran-20060502/gfortran_libs
> Thread model: posix
> gcc version 4.2.0 20060502 (experimental)
>
> gfortran segfault on compile (gfortran -fopenmp array_reduction.f90)
> with the following message:
> arrayreduction.f90: In function 'foo':
> arrayreduction.f90:14: internal compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
>
> My understanding (from following the mailing list) is that the
> segfault itself is a gfortran bug...
> Should I therefore file one ?
>
> My 2nd question is is the coding valid ??? From reading page 83 of the
> OpenMP 2.5 Specifications
> (http://www.openmp.org/drupal/mp-documents/spec25.pdf) I tend to think
> that sumarray is a valid array for the REDUCTION clause. I wonder
> still since INTEL compilers seem to have a problem with it too.
>
> Thanks for your help
More information about the Gcc
mailing list