- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to parallelize my FORTAN code using OpenMP. There are local allocatable arrays in subroutines. I wonder if these local allocatable arrays are private or shared. The results seemed to tell that these arrays were private. But the Intel Inspector XE reported quite a few data race problems with these allocatable arrays.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are the allocations performed within a parallel region in the subroutine where the array descriptor is declared? If so, you willneed to declare the (unallocated)array descriptor private.
.OR.
Are the subroutines called from within a parallel region? (including nested calls begun in a parallel region).
If so, then are these subroutines compiled with -openmp .OR. attributed with RECURSIVE?
Recursive subroutines have the property where the array descriptor default placement is on the stack (you can override this with SAVE). -openmp has the effect of adding RECURSIVE to the subroutine (it wouldn't hurt to explicitly mark this subroutine as RECURSIVE).
Posting problem code samples may help us in diagnosing your problem.
Jim Dempsey
.OR.
Are the subroutines called from within a parallel region? (including nested calls begun in a parallel region).
If so, then are these subroutines compiled with -openmp .OR. attributed with RECURSIVE?
Recursive subroutines have the property where the array descriptor default placement is on the stack (you can override this with SAVE). -openmp has the effect of adding RECURSIVE to the subroutine (it wouldn't hurt to explicitly mark this subroutine as RECURSIVE).
Posting problem code samples may help us in diagnosing your problem.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The subroutine is called within a parallel region and the array is allocated and deallocated with the parallel region. The following sample code illustrates the problem. The 'recursive' flag wasn't used in compiling the code.
-------------------------
program main
integer :: i
!$OMP PARALLEL DO
do i = 1, 4
call sub(i)
enddo
!$OMP END PARALLEL DO
contains
subroutine sub(i)
integer :: i
integer, allocatable :: a(:)
allocate(a(3))
a = i
!$omp critical
write(*,*) a(1:3)
!$omp end critical
deallocate(a)
end subroutine
end program
-------------------------
program main
integer :: i
!$OMP PARALLEL DO
do i = 1, 4
call sub(i)
enddo
!$OMP END PARALLEL DO
contains
subroutine sub(i)
integer :: i
integer, allocatable :: a(:)
allocate(a(3))
a = i
!$omp critical
write(*,*) a(1:3)
!$omp end critical
deallocate(a)
end subroutine
end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The above should be fine. However you report it is not...
See what happens with
recursive subroutine sub(i)
or
subroutine sub(i)
integer :: i
integer, automatic,allocatable :: a(:)
The recursive should be implicit when compiled for OpenMP. Stick it on to see what happens.
Also "automatic" is Intel specific (non-portable) which forces the array descriptor to go on stack.
Is the error sensitive to optimization level?
Jim Dempsey
See what happens with
recursive subroutine sub(i)
or
subroutine sub(i)
integer :: i
integer, automatic,allocatable :: a(:)
The recursive should be implicit when compiled for OpenMP. Stick it on to see what happens.
Also "automatic" is Intel specific (non-portable) which forces the array descriptor to go on stack.
Is the error sensitive to optimization level?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the inspector message a report of a conflict (error) or performance issue. Allocate will use a critical section, but Inspector XE should special case allocation/deallocation.
Jim Dempsey
Jim Dempsey

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page