3

I'm try to parallelize a big program in Fortran90 using OpenMP.

I get segmentation fault errors all the time. I am wondering if there is any easy way to fix them. What do you do if you have a segmentation fault error?

1
  • 2
    Unless you've really screwed something up, the most probable cause is insufficient stack space for private static arrays. Unlike in the serial case, whenever OpenMP is active, automatic heap arrays are disabled and all unsaved local arrays become stack arrays. See this answer for more information. Feb 4, 2013 at 20:43

2 Answers 2

7

First roll your code back to its original, unparallelised, version. You do have this under version control don't you ?

Check very carefully that your serial program does not cause any segmentation faults. Pay particular attention to the issues raised in this document from Intel. Read this even if you are not using the Intel Fortran compiler. Take the corrective actions it suggests.

Now, parallelise your first construct. Choose a simple, un-nested, loop if you can. Re-test your program. Think about what you have done and make sure that you understand what is going on. Choose another simple construct to parallelise. When you have finished the simple ones move on to the more complicated ones, all the while testing as you go and learning as you go.

So, to answer your question: the best way to fix such faults is to not make them in the first place. You report that you get segmentation faults all the time, this suggests to me that you have tried to run before you can walk.

And to answer another question: no, there is no easy way to fix them.

0
3

As HPM suggested, do you get the segmentation faults only when you compile with OpenMP, or also without OpenMP?

I suggest compiling using all debugging options provided by your compiler. Your compiler might be able to identify some of the problems and report them to you as Fortran problems rather than as memory access problems. For example, run-time subscript checking will identify illegal subscripts that can cause segmentation faults. Other compiler options can enforce good coding practices that will make bugs less likely. What compiler are you using?

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.