linux-il  

Re: With and Without gcc OMP

Omer Zak
Mon, 24 Sep 2007 05:56:50 -0700

Think out of the box!

Assumptions:
1. You use a Makefile to build the stuff.
2. There is a different target for each compiler/option combination.

Then, in the non-gomp compilations, pass the source code files through
your own pre-processor, before compiling them.
You'll probably want to set the output file name using the -o option,
because you'll be mangling your input file name.
Your pre-processor could be egrep -v or m4 or awk, but it will comment
out (or remove) exactly the unwanted #pragma lines.

If, due to some reason, the above way to break out of the box does not
meet your requirements, then find another way to break out of the box.

                                       --- Omer


On Mon, 2007-09-24 at 14:11 +0200, Orna Agmon Ben-Yehuda wrote:
> Hi All,
> 
> I am trying to compile the same code using gcc 4.2, which has gomp (gnu open 
> mp 
> - a library for automatic thread paralelization) already in it. I want the 
> code 
> to still compile cleanly (using -Werror) without openMP at all, because it is 
> said that there is a performance penalty to compiling with openMP, even if 
> not 
> using it (that is, defining the number of threads at runtime to be 1).
> 
> I would also like to be able to still compile the code cleanly on prior 
> versions of gcc, specifically on 3.4.* which I currently use.
> 
> The problem is that in order to use OMP I need to insert pragmas such as
> 
> #pragma omp for
> 
> And both gcc 3.4.4 and gcc 4.2 without the -fopenmp flag complain about 
> ignoring a pragma for each such line.
> 
> I tried hiding the pragma using a construct such as
> 
> #ifdef HAVE_OMP
> #define MYOMP(C) C
> #else
> #define MYOMP(C)
> #endif
> 
> But it seems that pragmas are parsed before defines are parsed, so this 
> construct creates multiple errors when used:
> 
> MYOMP(#pragma omp for)
> 
> In gcc 4.2 there are two -W switches to control pragma warnings:
> -Wno-pragmas - controls errors in known pragmas
> and
> -Wunknown-pragmas
> To create extra warnings for pragmas in system headers.
> 
> Those do not exist in gcc 3.4, and anyway do not help me even in gcc 4.2 
> without -fopenmp, because the warnings I get are included in -Wall, which I 
> wish to use when I compile (I already have a compilation line of several 
> lines 
> length, imagine what would happen if I did NOT use -Wall).
> 
> Any ideas?
-- 
In civilized societies, captions are as important in movies as
soundtracks, professional photography and expert editing.
My own blog is at http://www.zak.co.il/tddpirate/

My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]