problems with openMP and ifc

problems with openMP and ifc

Hi there ,
I'm just beginner in the openMP world !
I'm wondering with a little test program in f90:

!----------------------------------------------------
! test
!
!
Program test

integer, PARAMETER :: N =450
real :: b(N,N,N),c(N,N,N)

write (*,*) ' Memory=',2.*4.*N**3/1024**2,'Mb'
aN = Float(N**2)

!$OMP PARALLEL DO DEFAULT(SHARED)
! $OMP PRIVATE (i,j,k)

Do i=1,N
Do j=1,N
Do k=1,N

b(i,j,k) = sin((i**2+j**2+k**2)/aN)
c(j,k,i) = log(b(i,j,k))

EndDo
EndDo
EndDo

write(*,*) ' done N=',N

End program test

I use ifc 7.1 compiler on a 4 processors PIII machine with Linux 2.4.20-27.7.

ifc -openmp -o test test.f90

It compiles right, but when I execute it, instantaneously
appears: "segmentation fault"

What's Happening ??

Thanks a Lot !!!
Santiago

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

Try making it small enough to fit under 1MB until you get some of the issues resolved. I take it that the segfault means you are actually running your compilation, rather than linux system commands of the same name.

Yes, the segmentation fault comes when I run the compilation (the test output). The strange with all this is if I re-write the code in f77 style, all works fine.
What do you think is happening ?
Thaks
Santigo

THANKS !, I was trying and I founded with N up to 120 it works fine. For bigger Ns it returns "segmentation fault". In other hand, in f77 style, it works fine for N up to 450 like the example.
Which could be the problem ?? because I need to use large amount of memory and my code is large too, and in f90 !!!!.
Thank you again

Santiago

If "f90 style" means using an array constructor in each thread to make the argument of sin(), it looks like you want to restrict your array constructor to individual 2-d arrays involving only the value of i in each thread. That doesn't appeal to me as any more stylish than keeping it in the style you quote, will be inefficient because of unnecessary memory use, and the extra memory consumption would grow considerably with the number of threads. You have potential false aliasing problems, if you use enough threads that more than 1 thread is hitting the same cache line. Writing into the same 128-byte cache line which another thread is reading will destroy any advantage of threading.

If you want to use partial array assignment for the 2nd statement,
c(:,:,i) = log(b(i,:,:)) might work, but it looks like you need to keep the i index in there to keep the arrays conformable, with the operations properly allocated by thread. You leave it up to the compiler which loop is inner, and you might want to investigate whether it makes a good or bad choice of blocking of operations, and whether it makes temporary copies of the array sections.
The OpenMP issues might attract more expert attention in the threading forum.

Since smaller arrays work, you a probably blowing your
stack. In tcsh, try "ulimit stacksize unlimited".

Craig

Thank you Craig !! All is working fine now !
the stacksize was the problem.
Thanks again

Santiago

Leave a Comment

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