[cfe-commits] [PATCH] First OpenMP patch

Dmitri Gribenko gribozavr at gmail.com
Wed Nov 21 09:06:50 PST 2012


On Wed, Nov 21, 2012 at 6:02 PM, Mahesha HS <mahesha.llvm at gmail.com> wrote:
> Though -fopenmp and -fno-openmp are mutually exclusive options,
> underlying functionality, that we intended to implement differ a
> little. In a nutshell, we, sometime back discussed in CFE DEV list to
> implement OpenMP as follows. We thought that passing neither -fopenmp
> nor -fno-openmp  is not same as passing only -fno-openmp.  Following
> is the intended implementation. This forced me to add two lang options
> as I could not handle it using only one lang option. If this was not
> there, I guess, all your comments would not have araised.
>
> if (source contains OpenMP statements) {
>      if (neither -fopenmp nor -fno-openmp present) {
>          Throw warning.
>      }
>      else if (only -fopenmp present) {
>          Process OpenMP
>      }
>      else if (only -fno-openmp) {
>         Silently ignore OpenMP. Do not throw warning.
>      }
>     else if (both -fopenmp and -fno-openmp are present) {
>         Decide based on which one appears later in the command line.
>     }
> }

I think the implementation should use the general diagnostics
infrastructure.  For example, by default add something like
-Wsource-uses-openmp and disable it in case of -fno-openmp.

$ g++ -W -Wall /tmp/zzz.cc
/tmp/zzz.cc:3:0: warning: ignoring #pragma omp barrier [-Wunknown-pragmas]

By the way, the algorithm above is not consistent with gcc, which
ignores the pragma when no -f flag is passed.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list