segmentation fault openmp legacy code

General OpenMP discussion

segmentation fault openmp legacy code

Postby freephys » Sat Dec 14, 2013 10:35 pm

Hi, I am trying to applying openmp to legacy fortran77 code and I tried to do as following but I encounter a runtime error while running the code.
Line 89 of expect.f is the line: rv_avg(m) = rv_avg(m) + psi(k,m)*psi(k,m)*rosc(k)

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
main 0000000000411CE9 expect_ 89 expect.f
libiomp5.so 00002B13E9690FE3 Unknown Unknown Unknown
Command exited with non-zero status 174

I have make stack large enough with ulimit and export KMP_STACKSIZE. I am wondering what went wrong and any suggestions about how to optimizing the legacy code. Thanks a lot!
login1$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 514847
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 150
virtual memory (kbytes, -v) 8388608
file locks (-x) unlimited


Code: Select all
!$OMP PARALLEL shared(ng,nstates,natoms,psi,rosc,grt,frt)
!$OMP DO private(k,m)&
!$OMP& reduction(+:rv_avg,b_avg)
      do k = 1, ng
         do m = 0, nstates - 1
            rv_avg(m) = rv_avg(m) + psi(k,m)*psi(k,m)*rosc(k)
            b_avg(m) = b_avg(m) + psi(k,m)*psi(k,m)/(mu*rosc(k)**2)
         enddo
      enddo
!$OMP ENDDO
       
!$OMP DO private(k,m,j)&
!$OMP& reduction(+:grt_avg)     
      do k = 1,ng
         do m = 0, nstates -1
            do j = 1, 3
               grt_avg(m,j) = grt_avg(m,j) + psi(k,m)*psi(k,m)*grt(k,j)
            enddo
         enddo
      enddo   
!$OMP ENDDO

!$OMP DO private(k,m,j,l)&
!$OMP reduction(+:frt_avg)
      do k = 1,ng 
         do m = 0, nstates -1
            do j = 1,3
               do l = 1, natoms
                  frt_avg(m,l,j) = frt_avg(m,l,j)   &
                       + psi(k,m)*psi(k,m)*frt(k,l,j)
                enddo
             enddo
         enddo
      enddo
!$OMP DO private(k,m,j,l,mp)&
!$OMP reduction(+:d_coup)     
      do k = 1,ng
         do m =0 , nstates - 1
            do j = 1,natoms
               do l = 1, natoms
                  do mp = 0, nstates - 1
                     d_coup(m,mp,l,j) = d_coup(m,mp,l,j)   &
                          + psi(k,m)*psi(k,mp)*frt(k,l,j)
                  enddo
               enddo
            enddo
         enddo
      enddo
!$OMP END DO
!$OMP END PARALLEL

freephys
 
Posts: 2
Joined: Tue Oct 15, 2013 2:42 pm

Re: segmentation fault openmp legacy code

Postby MarkB » Mon Dec 16, 2013 5:35 am

Hi there,

Does the code run correctly if you compile without OpenMP, and does it run correctly with OpenMP enabled on one thread?
The array reductions look like they might require a significant amount of worker thread stack space: are you sure you set KMP_STACKSIZE large enough?

Do the m loops have sufficient iterations to move them outermost and parallelise them instead, and avoid the array reductions?

By the way, the loop and array index ordering in the code looks to be quite poorly optimised for sequential performance: there are lots on non-unit-stride
memory access patterns, and this will likely be bad for parallel scaling too.
MarkB
 
Posts: 422
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 8 guests