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

PARALLEL SECTIONS FIRSTPRIVATE - bug

janusz_andrzejewski
287 Views

MODULE aM
IMPLICIT NONE

 CONTAINS
SUBROUTINE a1(n)
 INTEGER, INTENT(INOUT) :: n
  INTEGER :: i

 !$OMP PARALLEL SECTIONS FIRSTPRIVATE(n)
   !$OMP SECTION
      !$OMP PARALLEL DO
         DO i=1, n
         END DO
      !$OMP END PARALLEL DO
 !$OMP END PARALLEL SECTIONS

END SUBROUTINE a1

END MODULE aM

Program aa
USE aM
IMPLICIT NONE
  INTEGER :: n

  n=10
  CALL a1(n)

END

This program causes segmentation fault when compiled with -fopenmp switch.

These errors occur with ifort version 15.0.5 and 16.0.2. After removing FIRSTPRIVATE clause the program works fine

0 Kudos
3 Replies
Kevin_D_Intel
Employee
287 Views

Thank you for reporting this error. I need to consult with an OpenMP Developer about this. As written, it appears the seg-fault occurs from variable N being shared vs. private within the PARALLEL DO scope. The error can be avoided with an additional PRIVATE(n) clause on the inner PARALLEL DO, or just not declaring it as FIRSTPRIVATE in the outer PARALLEL scope.

0 Kudos
janusz_andrzejewski
287 Views

The second solution (i.e.. removing FIRSTPRIVATE clause) to this problem is OK (and I mentioned this).

But the first solution is incorrect. If you add PRIVATE(n) clause at the SECTIONS line, the value of the n is undefined for DO loop - so is incorrect from logical point of view. Just add for example -  print*,'i = ',i, n  - inside the body of the loop. Than program behaves in random way.

0 Kudos
Kevin_D_Intel
Employee
287 Views

My apologies. Thank you for the correction/clarification on using PRIVATE. I escalated the issue to our OpenMP Development team.

(Internal tracking id: DPD200382055)

0 Kudos
Reply