- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is an additional information for the issue.
icc correctly returns an error when the compilation if nested "omp parallel for" and "omp for" exists in the code.
So, the issue seems ifort specific.
======
$ cat test.c
#include <stdio.h>
#include <omp.h>
#define IMAX 4
#define JMAX 4
int main(int argc, char **argv)
{
int i, j;
int n[IMAX][JMAX];
#pragma omp parallel for
for (i=0; i<IMAX; i++) {
#pragma omp for
for (j=0; j<JMAX; j++) {
n
}
}
for (i=0; i<IMAX; i++) {
for (j=0; j<JMAX; j++) {
printf("%3d", n
if (j == JMAX-1)
printf("\n");
}
}
return 0;
}
$ icc --version
icc (ICC) 17.0.2 20170213
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
$ icc -fopenmp test.c
test.c(14): error: "for" region may not be closely nested inside a "parallel for" region
#pragma omp for
^
compilation aborted for test.c (code 2)
======
The code works fine with two "omp parallel for", this is expected result.
======
$ diff -pu test.c test2.c
--- test.c 2017-06-26 08:41:49.000000000 +0900
+++ test2.c 2017-06-26 08:41:22.000000000 +0900
@@ -11,7 +11,7 @@ int main(int argc, char **argv)
#pragma omp parallel for
for (i=0; i<IMAX; i++) {
- #pragma omp for
+ #pragma omp parallel for
for (j=0; j<JMAX; j++) {
[fukuoka@selene71 2]$ icc -fopenmp test2.c && echo ok
ok
[fukuoka@selene71 2]$ ./a.out
0 1 2 3
10 11 12 13
20 21 22 23
30 31 32 33
======
Best regards,
Daichi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your report! This issue is better to be reported via our Online Service Center at https://supporttickets.intel.com/
Instructions on how to file a ticket are available here:
https://software.intel.com/en-us/articles/how-to-create-a-support-request-at-online-service-center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Daichi,
Thank you for submitting the ticket with this report via Online Service Center.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page