- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My apologies. Thank you for the correction/clarification on using PRIVATE. I escalated the issue to our OpenMP Development team.
(Internal tracking id: DPD200382055)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page