[Omp] allocatable memory and array in subroutine are not private - segfault issue

Meadows, Lawrence F lawrence.f.meadows at intel.com
Sat Nov 17 12:33:07 PST 2007


I responded to this on the forum. Also note that the forum will replace
this mailing list shortly. In any case, you might check my comments
there. Also, you are clearly missing a lot of code here (the fragment
you sent won't compile) and it isn't at all clear what you expect the
nested do loops to compute.

-- Larry 

>-----Original Message-----
>From: omp-bounces at openmp.org [mailto:omp-bounces at openmp.org] 
>On Behalf Of Micha Feigin
>Sent: Saturday, November 17, 2007 1:39 AM
>To: omp at openmp.org
>Subject: [Omp] allocatable memory and array in subroutine are 
>not private - segfault issue
>
>I am having a problem with prallelizing some code. It seems to 
>be according to
>spec but still causes errors.
>
>I have a function called from within a parallel do loop which 
>among other
>things has several small arrays and some allocated and 
>deallocated memory. The
>spec seems to say that all that memory is private but it seems 
>that different
>instances of that function (different threads) stomp each 
>others memory.
>
>I haven't managed to make a minimal example since this depends 
>on timing issues
>apparantly but here are the relevant parts of the code (after 
>cutting out what
>I believe to be unrelated). This is run under linux and shows 
>a problem with
>both the intel compiler and gfortran and is run under intel 
>core 2 duo in 64
>bit mode.
>
>There is one omp do loop directive near the start, the 
>problematic function is EigenVecs.
>The two points of problem when using more then one thread
>1. the call to dsaupd (arpack eigenvalue calculation) tell me 
>that the input values are
>    wrong (don't know which one because the error comes from 
>farther). Not on the first
>    run of the loop, but a bit later
>2. I get a segmentation fault with the two deallocate 
>directives one line up from the end.
>    Removing them solves the segfault so there is some double 
>deallocation going on
>
>seems to me that the arrays/allocatable objects are forced to 
>shared for some reason
>
>the code:
>-----------
>
>integer function PeronaMalikIteration(in, out, pprms, eprms)
>
>real*8, allocatable :: v(:, :), d(:)
>
>!$omp parallel shared(in, out, eprms, pprms) private(ret, col, 
>row, v, d)
>
>allocate(v(eprms%ldv, eprms%ncv), d(eprms%neigs))
>
>!$omp do schedule(dynamic, 1)
>
>do col = 1,n
>do row = 1,n
>ret = EigenVecs(in, v, d, pprms, eprms)
>end do
>end do
>!$omp end do nowait
>
>deallocate(v, d)
>
>!$omp end parallel
>
>end function PeronaMalikIteration
>
>! ------------------------------------------------------
>! calculate eigenvectors
>! ------------------------------------------------------
>integer function EigenVecs(img, v, d, pprms, eprms)
>
>type(PeronaParams), intent(IN) :: pprms
>type(EigParams), intent(IN) :: eprms
>
>real*8, intent(IN) :: img(eprms%windowSz, eprms%windowSz), &
>v(eprms%ldv, eprms%ncv), d(eprms%neigs)
>
>! Algorithm parameters
>! Relative Tolerance, set to default - machine precision
>real*8 :: tol = 0.0d0
>real*8 :: sigma = 0.0d0
>
>! Algorithm variables
>integer :: ido, lworkl, info
>integer, dimension(11) :: iparam, ipntr
>real*8, allocatable, dimension(:) :: resid, workd, workl
>!DEC$ ATTRIBUTES ALIGN: 16 :: resid, workd, workl
>logical :: rvec = .true.
>logical, allocatable, dimension(:) :: select
>character(len=1) :: B = 'I'
>character(len=2) :: which = 'LA'
>
>! Set parameter values
>! Default return, no error
>EigenVecs = 0
>! Initial parameters to the dsaupd routine
>ido = 0
>info = 0
>! (/ ISHIFT, -, MXITER, NB, NCONV, -, MODE, NP, NUMOP, NUMOPB, 
>NUMREO /)
>iparam = (/ 1 , 0, 1000*eprms%neigs, 1 , 0 , 0, 1 , 0 , 0 , 0 , 0 /)
>! Workspace
>lworkl = eprms%ncv*(eprms%ncv + 8)
>allocate(resid(eprms%n), workd(3*eprms%n), workl(lworkl))
>
>do
>call dsaupd(ido, B, eprms%n, which, eprms%neigs, tol, resid, &
>eprms%ncv, v, eprms%ldv, iparam, ipntr, workd, workl, lworkl, info)
>
>select case (ido)
>case (-1,1)
>! multiply y <- OP*x
>! where x = workd(ipntr(1))
>! y = workd(ipntr(2))
>call PeronaMalikResponse(workd(ipntr(1)), workd(ipntr(2)), img, &
>eprms, pprms)
>case default
>exit
>end select
>end do
>
>! Error !!!
>if (info /= 0) then
>EigenVecs = info
>goto 99999
>end if
>
>allocate(select(eprms%ncv))
>
>call dseupd(rvec, 'A', select, d, v, eprms%ldv, sigma, B , eprms%n, &
>which, eprms%neigs, tol, resid, eprms%ncv, v, eprms%ldv, iparam, &
>ipntr, workd, workl, lworkl, info)
>
>deallocate(select)
>99999 deallocate(resid, workd, workl)
>end function EigenVecs
>_______________________________________________
>Omp mailing list
>Omp at openmp.org
>http://openmp.org/mailman/listinfo/omp
>


More information about the Omp mailing list