fortran 90, segmentation fault

General OpenMP discussion

fortran 90, segmentation fault

Postby gsal » Sun Jul 14, 2013 2:56 pm

Hello, everybody...totally new at OpenMP, here...started yesterday morning.

So, surfed various threads, on-line tutorials and very official documentation...can't remember where, but even in some very official-looking PDF document on OpenMP, the author mentioned the certainty of getting a segmentation fault error at the end of the program if something, something, something...something about the arrays being move to the stack...

Now, I am no computer scientist and don't know about programs innerworkings at the system, OS, or whatever level...does somebody know what I am talking about? and can somebody explain in plain English what the problem could be? and for as long as the certainty of the seg fault is known, I would hope that the solution to that problem is also well known?

As it is, I have medium size Fortran 90 program with several modules and a bunch of allocatable arrays...decided to parallelize the program and get "segmentation fault" on exit.

thanks in advance for any hints and great thanks for the actually solution :D

Oh, I forgot to mentioned that I did try "ulimit -s unlimited" and setting "OMP_STACKSIZE" and "GOMP_STACKSIZE" to various quantities (as much as 1G), but the seg fault continued to appear.
gsal
 
Posts: 3
Joined: Sun Jul 14, 2013 2:32 pm

Re: fortran 90, segmentation fault

Postby MarkB » Mon Jul 15, 2013 2:16 am

Hi there,

Have you actually added OpenMP directives to your code, or are you just trying to compile the original code with OpenMP enabled?

In the latter case, compiling with OpenMP forces all local variables to be stack allocated. If there are large local arrays, this may indeed cause stack overflows, but it looks like you have eliminated that possibility. Another effect of this is to expose bugs in the code which assume that local variables without the SAVE attribute preserve their values between subroutine calls.

Hope that helps,
Mark.
MarkB
 
Posts: 434
Joined: Thu Jan 08, 2009 10:12 am

Re: fortran 90, segmentation fault

Postby gsal » Mon Jul 15, 2013 2:44 am

Thanks for replying.

Yes, I do have a couple of busy DO loops enclosed in "parallel do" OpenMP directives...program execution time went from 160 seconds down to 40 seconds.

In regards to the SAVE attribute...I didn't even know about it and hope it does not show up anywhere (I am co-writing the program). The way I am 'saving' values between calls and across subroutines is via the use of modules.

Other than that, the program gives the same results with or without OpenMP, so, the seg fault happens on exit without affecting results. Oh, and there is no seg fault when running without OpenMP.

But, I guess I will look into array allocation and de-allocation, to start with, and see if I find something odd.

Thanks, again.
Germán
gsal
 
Posts: 3
Joined: Sun Jul 14, 2013 2:32 pm

Re: fortran 90, segmentation fault

Postby MarkB » Mon Jul 15, 2013 3:27 am

Does the seg fault occur if you run with OpenMP but with only one thread?
What compiler(s) are you using?
MarkB
 
Posts: 434
Joined: Thu Jan 08, 2009 10:12 am

Re: fortran 90, segmentation fault

Postby gsal » Mon Jul 15, 2013 6:51 am

Hhhhmmm...you are going to have to forgive me...the problem may not be related to OpenMP at all.

You see...I have writing and testing this program with g95, all along and never had seg fault.

Then, somebody pointed me to OpenMP.

So, the sole purpose of switching to gfortran was to take advantage of OpenMP (g95 does not support it).

From the moment I started to compile with gfortran, I have been using -fopenmp and getting seg fault...but, prompted by the question above in regards to 1 thread, I also went ahead and compiled the program without -fopenmp and I continue to get seg fault...

...so, it looks like I get seg fault with gfortran whether I use OpenMP or not...

Sorry about that and thanks for your replies...at least, we found out that it is not OpenMP related, that is useful information.

Germán
gsal
 
Posts: 3
Joined: Sun Jul 14, 2013 2:32 pm

Re: fortran 90, segmentation fault

Postby MarkB » Mon Jul 15, 2013 11:33 am

No problem! I often find it useful when debugging OpenMP code to try and figure out first whether it is a parallel bug or just a regular sequential one....
MarkB
 
Posts: 434
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 10 guests