Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29004 Discussions

Question about OpenMP attribute of index variables.

amat000
Beginner
201 Views

Hello,

I have a question about OpenMP attribute of index variables in a Region but not in constant.

The specification of OpenMP3.0 said,

2.9.1.2 Data-sharing Attribute Rules for Variables Referenced in a
Region but not in a Construct

Fortran
implied-do indices, forall indices, and other local variables declared in called
routines in the region are private.

I believe index i in the comp subroutine as follows should be private,  but it is shared.

       program test
       parameter (N=400)
       common/tmp/i,j,k
       real a(N,N),b(N,N),c(N,N)

!$omp parallel do
       do j=1,N
       do i=1,N
         a(i,j)=real(i)
         b(i,j)=real(i+j)
         c(i,j)=0.0
       enddo
       enddo
!$omp parallel do
       do j=1,N
       do k=1,N
          call comp(a,b,c,N)
       enddo
       enddo

       write(*,*) c(N,N)
       stop
       end

       subroutine comp(a,b,c,N)
       common/tmp/i,j,k
       real a(N,N),b(N,N),c(N,N)
       integer omp_get_thread_num
       do i=1,N
         write(omp_get_thread_num()+200,*) i
         c(i,j)=c(i,j)+a(i,k)*b(k,j)
       enddo
       return
       end

After this program was launched with 32 threads, I checked the head of fort.2?? files.
==> fort.223 <==
           1
         222
         223
         224
         225

The correct values are
           1
           2
           3
           4
           5

compiler version : Intel 64 13.0 Build 20120731
processors       : E7-8837@2.67GHz
OS               : SLES 11SP1
 
Could you check out this issue, please?

Best rergards,
Akiko MATSUMOTO

0 Kudos
0 Replies
Reply