[Bug fortran/87255] New: Different semantics of OpenMP combined construct and nested constructs
ben at rockshrub dot de
gcc-bugzilla@gcc.gnu.org
Sat Sep 8 17:59:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87255
Bug ID: 87255
Summary: Different semantics of OpenMP combined construct and
nested constructs
Product: gcc
Version: 8.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ben at rockshrub dot de
Target Milestone: ---
This was reported on the OpenMP Forum as a difference between gfortran and the
Intel Fortran compiler here
http://forum.openmp.org/forum/viewtopic.php?f=3&t=2055
However, I think gfortran incorrectly compiles the OpenMP combined "parallel
do" construct, evaluating the loop bounds outside of the parallel context. An
OpenMP "do" construct directly nested inside an OpenMP "parallel" construct
seems to evaluate the loop bounds inside the parallel context as one would
expect. The OpenMP API 4.5 states in section 2.11 that the two (combined
construct and nested constructs) should have identical semantics.
GCC version, configure/build options, system type:
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/8.2.0/libexec/gcc/x86_64-apple-darwin17.7.0/8.2.0/lto-wrapper
Target: x86_64-apple-darwin17.7.0
Configured with: ../configure --build=x86_64-apple-darwin17.7.0
--prefix=/usr/local/Cellar/gcc/8.2.0
--libdir=/usr/local/Cellar/gcc/8.2.0/lib/gcc/8
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-8
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC
8.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--disable-nls
Thread model: posix
gcc version 8.2.0 (Homebrew GCC 8.2.0)
Command line that triggers the bug:
$ gfortran -Wall -Wextra -fopenmp num_threads_as_loop_bounds.f90
(no compiler output/error messages)
Contents of num_threads_as_loop_bounds.f90:
program test
use omp_lib
implicit none
integer :: i
print *, "Combined construct:"
!$omp parallel do
do i = 1, omp_get_num_threads()
print *, i
end do
!$omp end parallel do
print *, "Nested constructs:"
!$omp parallel
!$omp do
do i = 1, omp_get_num_threads()
print *, i
end do
!$omp end do
!$omp end parallel
end program
Expected program output:
Combined construct:
1
3
4
2
Nested constructs:
2
3
4
1
Actual program output:
Combined construct:
1
Nested constructs:
2
3
4
1
More information about the Gcc-bugs
mailing list