Bug 27395 - Problem with arrays in the OpenMP REDUCTION clause in Fortran
Summary: Problem with arrays in the OpenMP REDUCTION clause in Fortran
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2006-05-02 19:10 UTC by Benjamin Réveillé
Modified: 2006-05-03 13:07 UTC (History)
2 users (show)

See Also:
Host: i386-linux
Target: i386-linux
Build: i386-linux
Known to work:
Known to fail:
Last reconfirmed: 2006-05-02 19:37:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Réveillé 2006-05-02 19:10:38 UTC
Below  are 2 programs which test the REDUCTION clause for arrays in OpenMP. gfortran ICE's when trying to compile them.

gfortran information:
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)

Extra info:
1)  xlf 10.1 and pgi 6.1 compile array_reduction1.f90 and execute it correclty
     intel 8.1 compiles array_reduction1.f90 but aborts on execution

2) xlf 10.1, pgi 6.1 and  intel 8.1  compile array_reduction1.f90 and execute it correclty

The openMP 2.5 Specifications (p83 of http://www.openmp.org/drupal/mp-documents/spec25.pdf) "2.8.3.  Restrictions to the reduction clause": says : Fortran pointers, Cray pointers, assumed-size arrays and allocatable arrays may not appear in a reduction clause.

In both programs it seems that the arrays are acceptable candidates for reduction.

See http://gcc.gnu.org/ml/fortran/2006-05/msg00022.html for discussion about this bug report.

array_reduction1.f90
----------------------------------
program array_reduction1
   implicit none
   integer, parameter :: n=10,m=1000
   integer :: i
   integer, dimension(n) :: sumarray
   !
   call foo1(n,m,sumarray)
   do i=1,n
      print*,sumarray(i)
   end do
end program array_reduction1

subroutine foo1(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 foo1
----------------------------------
>> gfortran -fopenmp array_reduction1.f90
array_reduction1.f90: In function 'foo1':
array_reduction1.f90:13: 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.

array_reduction2.f90
----------------------------------
program array_reduction2
   implicit none
   integer, parameter :: n=10,m=1000
   integer :: i
   !
   call foo2(n,m)
end program array_reduction2

subroutine foo2(n,m)
   use omp_lib, only : omp_get_thread_num
   implicit none
   integer, intent(in) :: n,m
   !
   integer :: i,j
   integer, dimension(n) :: sumarray
   !
   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
   do i=1,n
      print*,sumarray(i)
   end do
end subroutine foo2
----------------------------------
>> gfortran -fopenmp array_reduction2.f90
array_reduction2.f90: In function 'foo2':
array_reduction2.f90:9: 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.
Comment 1 kargls 2006-05-02 19:30:50 UTC
Add openmp to keywords.
Comment 2 Jakub Jelinek 2006-05-03 12:51:38 UTC
Subject: Bug 27395

Author: jakub
Date: Wed May  3 12:51:33 2006
New Revision: 113494

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113494
Log:
	PR fortran/27395
	* gimplify.c (gimplify_scan_omp_clauses): Compare OMP_CLAUSE_CODE
	rather than TREE_CODE to OMP_CLAUSE_REDUCTION.  Set also GOVD_SEEN
	bit for OMP_CLAUSE_REDUCTION_PLACEHOLDER.

	* testsuite/libgomp.fortran/pr27395-1.f90: New test.
	* testsuite/libgomp.fortran/pr27395-2.f90: New test.

Added:
    trunk/libgomp/testsuite/libgomp.fortran/pr27395-1.f90
    trunk/libgomp/testsuite/libgomp.fortran/pr27395-2.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimplify.c
    trunk/libgomp/ChangeLog

Comment 3 Jakub Jelinek 2006-05-03 13:07:19 UTC
Fixed in SVN.