linux-il  

Re: With and Without gcc OMP

Shachar Shemesh
Mon, 24 Sep 2007 07:27:01 -0700

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,
yes. #if, however, do not. The following construct should work:
#ifdef HAVE_OMP
#pragma ....
#endif

Regarding the Haifux thing, it's my fault. Will try to handle it this
week, but I'm a bit ill at the moment.

Shachar

=================================================================
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]