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

OpenMP: Missing Privatization Warnings

mriedman
Novice
724 Views

Mymost frequent error with OpenMP is forgetting to privatize variables. It's because I got used to the good old HP-UX f90 which would warn me in such cases.
Is anybody aware of a way to haveifort issue a warning if a scalar is modified inside a parallel section and if it was not privatized ? Found no hints in official documentation. This would be very valuable and should be trivial toimplement (if it's not already there and unknown).

0 Kudos
4 Replies
TimP
Honored Contributor III
724 Views
The official way is by setting default(none) so as to require everything to be designated private or shared. This helps catch more mistakes than simply writing to shared variable.
The long way is to run with Intel Thread Checker, which should flag races caused by multiple threads modifying shared variables. A new replacement for it is under development.
Sun Studio compilers also performed some analysis, and would simply decline to observe omp parallel for various reasons, including such mistakes. It was quite a hassle to determine when and why parallelization was dropped, although some optional diagnostics were available. ifort takes more of the attitude "programmer knows best."
0 Kudos
Steven_L_Intel1
Employee
724 Views
You might also try the Source Checker feature of the compiler - I know it will detect many kinds of OpenMP coding errors, but am not certain about this one.
0 Kudos
Izaak_Beekman
New Contributor II
724 Views
What do you mean Source Checker? Is this a sort of lint-ing functionality?

it looks like something like

ifort -diag-enable warn ...

might invoke this functionality. Is this correct? Can this run without building object files (i.e. as linting combined with -syntax-only)?
0 Kudos
Steven_L_Intel1
Employee
724 Views
I recommend that you read the documentation for use of Source checker. Yes, it's sort of a cross-program-unit lint and it does not generate objects when used, so you would typically have an alternate build configuration to use it.

I find that it often puts out a lot of noise for Fortran programs, so don't pay attention to everything it complains about, but it can be very useful.
0 Kudos
Reply