Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28991 Discussions

How to debug programs with OpenMP parallelization?

jirina
New Contributor I
869 Views
I have a program which uses OpenMP. All parallel parts of the code look like this:
[cpp]!dec$ if defined (_PARALLELIZATION_)
!$omp parallel if ( enableOpenMP ) num_threads ( threads ) default ( shared )
...
!dec$ end if[/cpp]
_PARALLELIZATION_ is a preprocessor directive; enableOpenMP is a logical variable which can be influenced by users.

My problems with debugging occur when I use _PARALLELIZATION_ in the Debug configuration. Even though enableOpenMP is set to .false., the debugger does not work properly - conditional breakpoints are not hit and stepping (F10) through the region which could be made parallel (by setting enableOpenMP to .true.) skips some lines in the region.

The behavior is correct after removing _PARALLELIZATION_ from the preprocessor directives.

Compiler options used are:
/nologo /debug:full /Od /gen-interfaces /fixed /extend_source:132 /Qopenmp /fpscomp:general /debug-parameters:used /warn:declarations /warn:truncated_source /warn:interfaces /assume:byterecl /traceback /check:pointer /check:bounds /check:uninit /check:format /check:arg_temp_created /libs:static /threads /dbglibs /c /align:all /heap-arrays

I am using MS Visual Studio 2008 and IVF 11.0.072.

Are there any recommendations how to debug (possibly) parallel programs?
0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
869 Views


jirina,

In the above source code!dec$ if defined (_PARALLELIZATION_) is .NOT. a preprocessor directive. It is a conditional compilation directive. The preprocessor, FPP, is enabled with -fpp and look very similar to the C preprocessor

#ifdef _PARALLIZATION_
...
#endif

where _PARALLIZATION_ is defined using #define _PARALLIZATION_ or as an option -D_PARALLIZATION_=asdf

You have two ways of conditional compilation, one using the Fortran !DEC$ and the other using the FPP #if.

You might try using the FPP preprocessor to work around the problem you are experiencing.

Also, the !$OMP... become comments when OpenMP disabled. Therefore many of your conditional compilation directives might be removed. (and thus many of the sources to your line number problems).

And, you cannot (usually) F10 across a parallel region boundry. (place a break point after boundry and use F5)

The !dec$ if defined (_PARALLELIZATION_) problem should be reported to premier support along with a simple program exhibiting the problem.


Jim Dempsey

0 Kudos
jirina
New Contributor I
869 Views
I know _PARALLELIZATION_ is used for the conditional compilation. I used a wrong word - I should have used 'Preprocessor Definition' which is the term from the project properties dialog in MS Visual Studio 2008 and which is where I specify _PARALLELIZATION_.

I tried /fpp and #ifdef / #endif, but it did not help to resolve the problem. Anyway, thank you for your suggestion.

I use _PARALLELIZATION_ not only for !$OMP, but also for other stuff in my program (related to parallelization), so I would like to keep the conditional compilation. I hope it does not matter.

I have just submitted the issue with conditional breakpoints, including a small program exhibiting the problem; the issue number is 544550.
0 Kudos
Reply