Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Linux ifort OpenMP incorrect work-sharing distribution?

samlor
Beginner
439 Views
G'day All,
The simple program enclosed seems to indicate a problem in Linux ifort OpenMP compilation of parallel do loop work-sharing directives that distributes increasing numbers of iterations instead of spreading them evenly amongst threads when the loop index variable i is re-used in later loop statements inside a single directive. The problem does not occur in equivalent C code. Nor does it occur if i is declared private or a different variable j is used for the 2nd loop.
Am I doing something wrong or is this a bug? And, where/how should it be reported?
Regards,
Sam
Code:
$ cat incorrect.f
      program main
      integer i, j, omp_get_thread_num, omp_get_num_threads
!$omp parallel private(i)
!$omp do
      do i=1,omp_get_num_threads()
        print *, 'tid =', omp_get_thread_num(), 'i =', i
      enddo
!$omp end do
!$omp single
      do i=1,omp_get_num_threads()
        print *, 'tid =', omp_get_thread_num(), 'i =', i
      enddo
!$omp end single
!$omp end parallel
      end
$ cat correct.c
#include 

main ()  {
int i,j;
#pragma omp parallel private(i)
  {
#pragma omp for
  for (i=0; i !$omp single private(i)
$ ifort -openmp correct1.f -o correct1
correct1.f(4) : (col. 6) remark: OpenMP DEFINED LOOP WAS PARALLELIZED.
correct1.f(3) : (col. 6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
$ ./correct1
 tid =           0 i =           1
 tid =           1 i =           2
 tid =           2 i =           3
 tid =           3 i =           4
 tid =           0 i =           1
 tid =           0 i =           2
 tid =           0 i =           3
 tid =           0 i =           4
$ diff incorrect.f correct2.f

10,11c10,11
<       do i=1,omp_get_num_threads()
<         print *, 'tid =', omp_get_thread_num(), 'i =', i
---
>       do j=1,omp_get_num_threads()
>         print *, 'tid =', omp_get_thread_num(), 'j =', j
$ ifort -openmp correct2.f -o correct2
correct2.f(4) : (col. 6) remark: OpenMP DEFINED LOOP WAS PARALLELIZED.
correct2.f(3) : (col. 6) remark: OpenMP DEFINED REGION WAS PARALLELIZED.
$ ./correct2
 tid =           0 i =           1
 tid =           1 i =           2
 tid =           2 i =           3
 tid =           3 i =           4
 tid =           0 j =           1
 tid =           0 j =           2
 tid =           0 j =           3
 tid =           0 j =           4
$ 

Message Edited by samlor on 02-23-2006 09:36 AM

0 Kudos
1 Reply
jemmyhu
Beginner
439 Views
Hi Samlor, I have exactly the same problem as you posted here using Intel ifort 9.0 on SGI altix machine. Have you got the answer or solution to fix it? Thanks.
0 Kudos
Reply