Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

omp parallel do + omp do should be rejected when compilation time

$
0
0

Hi,

The following simple nested OpenMP program(omp parallel do + omp do) can be compiled only with intel compiler.

=====

$ cat test.f90
program test
  implicit none

  integer,parameter :: imax=4, jmax=4
  integer :: i, j
  integer :: n(imax,jmax)

  !$omp parallel do
  do j=1,jmax
     !$omp do
     do i=1,imax
        n(i,j) = 10*i+j
     end do
  end do

  do i=1,imax
     write(6,*) (n(i,j),j=1,jmax)
  end do

  stop
end program test

$ ifort -fopenmp test.f90 && echo ok
ok

=====

Though the compilation finishes successfully, the execution hangs.

=====
$ ./a.out
^Cforrtl: error (69): process interrupted (SIGINT) <-- hang, therefore ctrl+C
Image              PC                Routine            Line        Source
a.out              000000000047F8D1  Unknown               Unknown  Unknown

=====

If I use GNU fortran compiler or PGI compiler, it fails when the compilation time, I think this is the expected behavior.

=====

$ gfortran --version
GNU Fortran (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
$ gfortran -fopenmp test.f90
test.f90:10:0:

      !$omp do
 ^
Error: work-sharing region may not be closely nested inside of work-sharing, critical, ordered, master or explicit task region

$ pgfortran --version

pgfortran 16.1-0 64-bit target on x86-64 Linux -tp sandybridge
The Portland Group - PGI Compilers and Tools
Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.

$ pgfortran -mp test.f90
PGF90-S-0155-Illegal context for DO (test.f90: 10)
  0 inform,   0 warnings,   1 severes, 0 fatal for test

=====

The code works fine with omp parallel do + omp parallel do for any compiler, this is also expected.

=====

$ diff -pu test.f90 test2.f90
--- test.f90    2017-06-23 16:15:39.000000000 +0900
+++ test2.f90   2017-06-23 16:15:34.000000000 +0900
@@ -7,7 +7,7 @@ program test

   !$omp parallel do
   do j=1,jmax
-     !$omp do
+     !$omp parallel do
      do i=1,imax
         n(i,j) = 10*i+j
      end do

[fukuoka@selene71 1]$ ifort -fopenmp test2.f90 -o test2
[fukuoka@selene71 1]$ ./test2
          11          12          13          14
          21          22          23          24
          31          32          33          34
          41          42          43          44
[fukuoka@selene71 1]$ gfortran -fopenmp test2.f90 -o test2.gfortran
[fukuoka@selene71 1]$ ./test2.gfortran
          11          12          13          14
          21          22          23          24
          31          32          33          34
          41          42          43          44
[fukuoka@selene71 1]$ pgfortran -mp test2.f90 -o test2.pgfortran
[fukuoka@selene71 1]$ ./test2.pgfortran
           11           12           13           14
           21           22           23           24
           31           32           33           34
           41           42           43           44
FORTRAN STOP

=====

 

So, I think intel compiler should return an error when the compilation time if nested omp parallel do + omp do appears in the code, it is better than the hang.

 

Best regards.

Daichi

Thread Topic: 

Bug Report

Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>