Unable to deallocate allocatable array in openmp

Unable to deallocate allocatable array in openmp

Hi, guys. I'm a new hand of openmp. I encounter some problems related to deallocating allocatable array in openmp loop.

The main reason is the array is too large. An example code is following:

program omptest
use omp_lib
implicit none
INTEGER :: I,k,J
integer,pointer :: b(:)


!$OMP PARALLEL DO PRIVATE(i,b,k) 
DO I=1,2490000
   allocate(b(67214259))
   k=OMP_get_thread_num()
   deallocate(b)
END DO
!$OMP END PARALLEL DO 
END PROGRAM

When the maximum bound of i is large, like 2490000, the program will break at deallocate(b)

I have also tried this version:(to make b as a threadprivate variable) but it is still useless

module da
implicit none
integer,allocatable,save :: b(:)
!$omp threadprivate(a,b)
contains
 subroutine ji(i)
 integer :: i
 allocate(b(672142590))
 end subroutine
end module

program omptest
use omp_lib
use da
implicit none
INTEGER :: I,k,J


!$OMP PARALLEL DO PRIVATE(i,k) 
DO I=1,2490000
   call ji(i)
   k=OMP_get_thread_num()
   deallocate(b)
END DO
!$OMP END PARALLEL DO 

I guess it might because of the size of heap. I have tried to divide I into 10 parts, and makes parallel computing separately( serially) but it is still no use.

Could any body help me to find out the solution? Thank you very much!

My development environment is VS2012 update 4+Intel cluster studio xe 2013 sp1

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You are asking wrong forum.  Intel Open Source runtime library has nothing with Fortran allocation/deallocation.  You would better ask this question on Intel Fortran Compiler forum.

I can only guess that allocate/deallocate may be not thread safe.  To check, try to put allocate and deallocate into critical section and see if the error disappears.  Again, it is better to ask Fortran compiler experts about this.

Regards,
Andrey

Leave a Comment

Please sign in to add a comment. Not a member? Join today