[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #pragma with Sun cc

From: Bruno Haible
Subject: Re: #pragma with Sun cc
Date: Wed, 29 Oct 2008 11:47:23 +0100
User-agent: KMail/1.5.4

Eric Blake wrote:
> > $ cc -xopenmp foo.c
> > cc: Warning: Optimizer level changed from 0 to 3 to support parallelized 
> > code.
> > "foo.c", line 3: invalid source character: '#'
> Does this bug affect all preprocessor directives when using -xopenmp, or
> only #pragma?

It affects only '# pragma omp', not '# include', '# line', '# if', '# elif',
'# else', '# endif', '# define', '# undef', '# pragma pack'. It looks like
the preprocessor is passing the entire directive to some openmp backend,
which reparses the entire directive.

> I fear that it may have some big ramifications to existing
> code bases if this bug plagues things like '# include' or '# define',
> which occur liberally in gnulib and other open source projects.

It doesn't.

> Has Sun been notified of their bug?

The bug is fixed in SunStudio 9, 10, and 11.

> I'm wondering how best to document this portability issue in the autoconf
> manual, and whether the AC_OPENMP macro should be taught to recognize this 
> bug.

I don't think it's worth to disable the AC_OPENMP support in this case.
I mean, once the program is compiled, it runs flawlessly. (But I don't know
why it used only 4 threads although I set OMP_NUM_THREADS to 16, on a
uniprocessor machine.)

But I agree that it should be documented. Probably it's more useful to mention
this in the AC_OPENMP documentation, than under "Portable C and C++ 
Here's a proposed wording:

2008-10-29  Bruno Haible  <address@hidden>

        * doc/autoconf.texi (AC_OPENMP): Document portability pitfall.

--- autoconf.texi.bak   2008-10-29 11:32:00.000000000 +0100
+++ autoconf.texi       2008-10-29 11:42:40.000000000 +0100
@@ -6577,6 +6577,11 @@
 respectively.  Similar remarks as for C hold, except that
 @code{CPPFLAGS} is not used for Fortran, and no preprocessor macro
 signals OpenMP support.
+Note: For portability, it is best to avoid spaces between @samp{#} and
address@hidden omp}.  That is, write @samp{#pragma omp}, not
address@hidden pragma omp}.  The Sun WorkShop 6.2 C compiler chokes on the
 @end defmac
 @node C Compiler

reply via email to

[Prev in Thread] Current Thread [Next in Thread]