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

Allocation error in PARALLEL SECTIONS

arktos
Beginner
1,393 Views

Hello,

I have been able to parallelize (with a bit of help) about 80% of an old-ish F77
code and now the remaining odd bits have begun to appear more noticeable in
the running of the code.

In trying to parallelize the remaining bits which involve dissimilar tasks, I use
the SECTIONS construct. The work array allocations return non-zero status flags.
I wonder if anyone has any ideas on why this occurs.

The OS is OpenSuse 11.1 64 and the compiler ifort 11.0. The command line is

ifort -O3 -openmp -fpp -parallel


In the short extract from the code below, all error flags are returned non zero.
In serial mode this runs fine. The arrays being allocated are work arrays and
are relatively small.



[plain]     REAL*8, Allocatable ::  WL1(:), WL2(:), WL3(:), WL4(:)

...

!$OMP PARALLEL SECTIONS DEFAULT(SHARED)
!$OMP+ PRIVATE(WL1,WL2,WL3,WL4,IERR1,IERR2,IERR3,IERR4)


c - N1P2 = 66

allocate( WL1(4*N1P2), STAT = IERR1 )

allocate( WL2(4*N1P2), STAT = IERR2 )

allocate( WL3(4*N1P2), STAT = IERR3 )

allocate( WL4(4*N1P2), STAT = IERR4 )

IF(IERR1.ne.0 .OR. IERR2.ne.0 .OR. IERR3.ne.0 .OR. IERR3.ne.0)Then

Write(6,*)' ** ERROR: IERR1, IERR2, IERR3, IERR4 = ',
. IERR1, IERR2, IERR3, IERR4
STOP '-Allocation'

End If

!$OMP SECTION


stuff

deallocate(WL1)
deallocate(WL2)
deallocate(WL3)
deallocate(WL4)
!$OMP END PARALLEL SECTIONS



Suggestions?

Thanks.
--

[/plain]

0 Kudos
8 Replies
roddur
Beginner
1,393 Views
well, i am also a beginner and you may not consider me seriously, but 1 point that i can see is it is more easier to allocate and deallocate arrays outside the parallel region.....
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,393 Views

[cpp]!$OMP  PARALLEL SECTIONS  DEFAULT(SHARED) 
!$OMP+ PRIVATE(WL1,WL2,WL3,WL4,IERR1,IERR2,IERR3,IERR4) 

c -   N1P2 = 66 
      allocate( WL1(4*N1P2), STAT = IERR1 ) 
      allocate( WL2(4*N1P2), STAT = IERR2 ) 
      allocate( WL3(4*N1P2), STAT = IERR3 ) 
      allocate( WL4(4*N1P2), STAT = IERR4 ) 
      IF(IERR1.ne.0 .OR. IERR2.ne.0 .OR. IERR3.ne.0 .OR. IERR3.ne.0)Then 
        Write(6,*)' ** ERROR: IERR1, IERR2, IERR3, IERR4 = ', &
                              IERR1, IERR2, IERR3, IERR4 
        STOP '-Allocation' 
      End If 

stuff for section 1
 
      deallocate(WL1) 
      deallocate(WL2) 
      deallocate(WL3) 
      deallocate(WL4) 
 
!$OMP SECTION 
 

 
c -   N1P2 = 66 
 
      allocate( WL1(4*N1P2), STAT = IERR1 ) 
      allocate( WL2(4*N1P2), STAT = IERR2 ) 
      allocate( WL3(4*N1P2), STAT = IERR3 ) 
      allocate( WL4(4*N1P2), STAT = IERR4 ) 
      IF(IERR1.ne.0 .OR. IERR2.ne.0 .OR. IERR3.ne.0 .OR. IERR3.ne.0)Then 
        Write(6,*)' ** ERROR: IERR1, IERR2, IERR3, IERR4 = ', &
                              IERR1, IERR2, IERR3, IERR4 
        STOP '-Allocation' 
      End If 

stuff for section 2
 
      deallocate(WL1) 
      deallocate(WL2) 
      deallocate(WL3) 
      deallocate(WL4) 
 
!$OMP SECTION 

 
c -   N1P2 = 66 
 
      allocate( WL1(4*N1P2), STAT = IERR1 ) 
      allocate( WL2(4*N1P2), STAT = IERR2 ) 
      allocate( WL3(4*N1P2), STAT = IERR3 ) 
      allocate( WL4(4*N1P2), STAT = IERR4 ) 
      IF(IERR1.ne.0 .OR. IERR2.ne.0 .OR. IERR3.ne.0 .OR. IERR3.ne.0)Then 
        Write(6,*)' ** ERROR: IERR1, IERR2, IERR3, IERR4 = ', &
                              IERR1, IERR2, IERR3, IERR4 
        STOP '-Allocation' 
      End If 

stuff for section 3
 
      deallocate(WL1) 
      deallocate(WL2) 
      deallocate(WL3) 
      deallocate(WL4) 
 
!$OMP SECTION 
...
!$OMP END PARALLEL SECTIONS 
 
[/cpp]
Jim Dempsey
0 Kudos
arktos
Beginner
1,393 Views

Thank you.


The problem persists. The single SECTION construct below still
returns non-zero status flags.

[plain]!$OMP  PARALLEL SECTIONS  DEFAULT(SHARED)
!$OMP+ PRIVATE( WL1,WL2,WL3,WL4, IERR1,IERR2,IERR3,IERR4 )


      allocate( WL1(4*N1P2), STAT = IERR1 )

      allocate( WL2(4*N1P2), STAT = IERR2 )

      allocate( WL3(4*N1P2), STAT = IERR3 )

      allocate( WL4(4*N1P2), STAT = IERR4 )

      IF(IERR1.ne.0 .OR. IERR2.ne.0 .OR. IERR3.ne.0 .OR. IERR3.ne.0)Then
        Write(6,*)' ** ERROR: IERR1, IERR2, IERR3, IERR4 = ',
     .                                  IERR1, IERR2, IERR3, IERR4
        STOP '-Allocation'
      End If



 calculating stuff here 



      deallocate(WL1)
      deallocate(WL2)
      deallocate(WL3)
      deallocate(WL4)

!$OMP END PARALLEL SECTIONS
[/plain]


0 Kudos
jimdempseyatthecove
Honored Contributor III
1,393 Views

It is likely that the unallocated array descriptors are a) not on the stack, and/or b) not being duplicated as uninitialized within the parallel section.

Add ", automatic" to the declaration in the subroutine.
Then add COPYIN(WL1, WL2, WL3, WL4) to the !$OMP PARALLEL statement.

i.e. copy in the unallocated array descriptor.

If that fails, then place the contents of the parallel sections into seperate subroutines and then call them (pass in any required arguments), but place the arrays WL1, WL2, WL3, WL4 in the subroutines (add the ", automatic".

Jim Dempsey
0 Kudos
arktos
Beginner
1,393 Views

Jim,

Your suggestion to create separate subroutines and use SECTION for each separate call has worked.

Thanks again. You've been of great help.



0 Kudos
jimdempseyatthecove
Honored Contributor III
1,393 Views
Quoting - arktos

Jim,

Your suggestion to create separate subroutines and use SECTION for each separate call has worked.

Thanks again. You've been of great help.




Remember to rate the forum posts.
0 Kudos
arktos
Beginner
1,393 Views

Remember to rate the forum posts.



Oooooooooooooops! I pressed the wrong star rating in your earlier post. It does not allow me to undo it.

Can I correct it? (I put the correct rating in your later post but the previous one is still there.)

APOLOGIES JIM.
0 Kudos
Steven_L_Intel1
Employee
1,393 Views
It looks as if your corrected rating was used.
0 Kudos
Reply