1

Ok, I am desperate. I am relatively new to OMP and am having a lot of problems with a seemingly simple parallelization in fortran. The code below is the smallest portion of a much larger code producing this kind of error. All this snippet is meant to do, is read the rows of a shared two dimensional complex array (which here I have filled with arbitrary numbers) into parallel instances of a private one dimensional array (for further parallel processing in the finished code).

Using ifort, once the loop has been executed for roughly 3000 values of the iterator j, the program crashes with the error:

* glibc detected * ./run.sh: munmap_chunk(): invalid pointer: 0x00002ac9b47ffde0 ***

gfortran on the other hand does not produce any errors, but yields all together nonsensical output in the completed program, which leads me to believe there is a mistake that gfortran isn´t picking up. Everything works as it should in serial.

PROGRAM partest
    implicit none

    INTERFACE
            INTEGER FUNCTION OMP_GET_THREAD_NUM()
            END FUNCTION
    END INTERFACE

    INTEGER :: i,j,npot,N,nproc
    COMPLEX *16, ALLOCATABLE :: temp_wv(:,:),tv(:)

    N=4096
    npot=140

    ALLOCATE(temp_wv(N,npot),tv(npot))
    print *, "assign random values to array"
    DO i=1,N
            DO j=1,npot
                    temp_wv(i,j)=exp(dcmplx(0,i+j))
            ENDDO
    ENDDO

    print *,"parallel region"

!$OMP PARALLEL DO &
!$OMP DEFAULT(NONE) &
!$OMP PRIVATE(tv,nproc) &
!$OMP SHARED(temp_wv,N,npot)
    DO j=1,N
            nproc=OMP_GET_THREAD_NUM()
            print*, "THREAD", nproc, "ITERATOR", j,N
            tv=temp_wv(j,:)
    ENDDO
!$OMP END PARALLEL DO
    print *, "DONE"
END PROGRAM partest
3
  • Apologies, I did compile the code but then edited the i out of this post for reasons of foolishness Commented Feb 26, 2014 at 14:38
  • My test didn't indicate any problem in any of the two compilers (very recent versions) with the version after the edit. Commented Feb 26, 2014 at 14:48
  • Could you tell me the version of the compiler you are using? I am using ifort 12.1.4 and gfortran 4.4.7 Commented Feb 26, 2014 at 14:56

1 Answer 1

1

Okay, so for anyone who is interested: the problem appears to have been that with my version of ifort you cannont allocate the size of a private variable outside the parallel region. Splitting the

$OMP PARALLEL DO 

into

$OMP PARALLEL 

and

$OMP DO 

and allocating the private array inbetween these statements did the trick.

Sign up to request clarification or add additional context in comments.

1 Comment

Allocatable private arrays are feature of OpenMP 3.0, that may be the reason. pic.dhe.ibm.com/infocenter/lnxpcomp/v121v141/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.