ICC should not generate warning about "#pragma omp ..." when OMP is disabled

ICC should not generate warning about "#pragma omp ..." when OMP is disabled

Greetings,

ICC 13.0, MSVC 2010

When I disable OpenMP support of ICC, it is displaying bunch of warnings in build log like:

c:path/to/file.h(439): warning #161: unrecognized #pragma

    #pragma omp sections

            ^
this warning is abusing me.

I have many OMP pragma's in the code, and when I do benchmarks without OpenMP support versus with OpenMP support, I might miss some IMPORTANT warning hidden somewhere in thousands of these warnings.

I don't want to pass to compiler "/Qwd161" do disable warning about invalid pragma's, since I am afraid of typo in other pragma's, so I would expect warning in this case as non-false positive.

Any objections? This is just a suggestion. TIA!

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.
16 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Why don't you just compile with openmp serial code? That way all omp pragmas will still be valid, just the code will be executed sequentially.

If you don't like that idea for some reason you can try doing something like this:

#ifdef _OPENMP

#define OMP(x)	omp x

#else

#define OMP(x)	message("")

#endif

Regards,
Igor Levicki

Quoting Igor Levicki
Why don't you just compile with openmp serial code? That way all omp pragmas will still be valid, just the code will be executed sequentially.

If you don't like that idea for some reason you can try doing something like this:
- collapse sourceview plaincopy to clipboardprint?

  1. #ifdef_OPENMP
  2. #defineOMP(x)ompx
  3. #else
  4. #defineOMP(x)message("")
  5. #endif

#ifdef _OPENMP

#define OMP(x)	omp x

#else

#define OMP(x)	message("")

#endif

Ugly hack with preprocessor is rather a workaround then a serious solution, and it has adverse side effect of printing many empty lines into build log.

I don't want to switch it to serial code, because I'm afraid run-time linking OMP .dll might cause overhead, compared to completely turned off the OMP.

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Not knowing whether by "switch it to serial" you mean setting OMP_NUM_THREADS=1, here's another option: link against libompstubs library. I doubt you could measure the associated startup time, and the stubs calls almost certainly are faster than the normal ones.

Quoting Tim Prince

Not knowing whether by "switch it to serial" you mean setting OMP_NUM_THREADS=1, here's another option: link against libompstubs library. I doubt you could measure the associated startup time, and the stubs calls almost certainly are faster than the normal ones.

By sequential I meant in MSVS "Generate Sequential Code (/Qopenmp_stubs)", is this what you meant by "stubs" ? I don't care much about start-up time, but I am afraid of (possibly) creating unused thread by OpenMP library by using this option, which could affect running performance (I don't mind about start-up performance).

But some switch would be really sexy. Just like "ignore '#pragma omp' at all when OMP is not understood/turned on", w/o a warning, so I will need not to use switch to ignore warning, nor use preprocessor hacks, nor using "sequential OMP".

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Yes, /QOpenmp_stubs will avoid creating threads for OpenMP.

Unfortunately there isn't currently a clean way to do this, but I like the idea, so I've submitted a feature request to our front end team to create a different warning to explicitly diagnose unrecognized OpenMP pragmas separately.

Brandon Hewitt
Technical Consulting Engineer

For 1:1 technical support: http://premier.intel.com

Software Product Support info: http://www.intel.com/software/support

Quoting Brandon Hewitt (Intel)
Unfortunately there isn't currently a clean way to do this, but I like the idea, so I've submitted a feature request to our front end team to create a different warning to explicitly diagnose unrecognized OpenMP pragmas separately.

You mean when OpenMP support is disabled, it should generate for "#pragma omp ..." special warning (not one like in current implementation "unrecognised pragma"), but special warning like "OMP is disabled, ignoring #pragma omp" with its separate warning number? So one could easily disable only OMP warnings, but not ALL #pragma warnings? If so, I like the idea to have separate warning number for this.

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

As I said (and Tim confirmed), switching to serial OpenMP code will solve your problem.

If you disable warning you may forget to re-enable OpenMP later. I really don't see a need for special treatment here.

Finally, instead of using message("") like in my example you can use any other NOP construct that won't generate any code or add any empty lines.

Regards,
Igor Levicki

Quote:

Igor Levicki wrote:

As I said (and Tim confirmed), switching to serial OpenMP code will solve your problem.

If you disable warning you may forget to re-enable OpenMP later. I really don't see a need for special treatment here.

Finally, instead of using message("") like in my example you can use any other NOP construct that won't generate any code or add any empty lines.

Greetings, which NOP pragma construct you would suggest? Because even "#pragma ivdep" is causing warning/remark message (since it is not in the front of a loop). I have came thru ICC documentation and maybe I am blind, but I don't see NOP pragma generating ***NONE*** output in the build log. And yes, switching OMP to generate serial code is remedy... but I guess it is just another JMP instruction into OpenMP DLL exported procedures table (or maybe followed by CALL instruction @ Windows) which could waste performance due to instruction cache flush. CALL maybe don't flush cache in all cases, but I guess JMP (as it is implemented on Windows) does indeed in any case (at least L1 cache ; maybe not L2 one).

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Quote:

Brandon Hewitt (Intel) wrote:

Unfortunately there isn't currently a clean way to do this, but I like the idea, so I've submitted a feature request to our front end team to create a different warning to explicitly diagnose unrecognized OpenMP pragmas separately.

Greetings, this I would very appreciate. Thank you.

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Quote:

Marián "VooDooMan" Meravý wrote:

Quote:

Brandon Hewitt (Intel)wrote:

Unfortunately there isn't currently a clean way to do this, but I like the idea, so I've submitted a feature request to our front end team to create a different warning to explicitly diagnose unrecognized OpenMP pragmas separately.

 

Greetings,

this I would very appreciate.

Thank you.

Or maybe some specific pragmas, like: #pragma warning( push ) # pragma warning( disable: <specific_number_of_ICC_warning/remark> ) // code #pragma warning( pop ) that I can use in the front of all header files, i.e. in the main, first *.h file of includes (in this case without "push" like -> ) #ifdef DISABLE_OMP_THINGIE_ETC # pragma warning( disable: <specific_number_of_ICC_warning/remark> ) #endif

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Try a variation on Igor's suggestion

#ifndef _OPENMP
#define omp comment
#endif

Jim Dempsey

www.quickthreadprogramming.com

Hi Marián,

In version 14.0 of the compiler (available in Intel(R) C++ Composer XE 2013 SP1), we now have OpenMP* pragmas under their own warning number, like so:

$ icc -c test.cpp
test.cpp(2): warning #3180: unrecognized OpenMP #pragma
  #pragma omp parallel for
          ^

test.cpp(8): warning #161: unrecognized #pragma
  #pragma blh
          ^

So now you can use -diag-disable 3180 to disable these OpenMP*-specific pragmas. Let me know if that helps.

Brandon Hewitt
Technical Consulting Engineer

For 1:1 technical support: http://premier.intel.com

Software Product Support info: http://www.intel.com/software/support

@Brandon

it is impractical to always changes more than 1 option (enable/disable OMP) in MSVC IDE, when I am transitioning between various configuration profiles, when I am experimenting in regard of best CPU utilisation in the project.

My wish is to file a feature request.

Thank you.

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Quote:

Marián "VooDooMan" Meravý wrote:

Quote:

Brandon Hewitt (Intel)wrote:

Unfortunately there isn't currently a clean way to do this, but I like the idea, so I've submitted a feature request to our front end team to create a different warning to explicitly diagnose unrecognized OpenMP pragmas separately.

 

Greetings, this I would very appreciate. Thank you.

Ouch, this thread is so old that I forgot in my previous post about above quote. I am sorry for that. Thanks again!

--
With best regards,
VooDooMan
-
If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.

Leave a Comment

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