This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [Gomp-discuss] Re: Implementing OpenMP pragmas for the C front end


Steven Bosscher and Neil Booth have written:

SB> ----------
SB> /* ERROR - The flush directive cannot be the immediate
SB>  * substatement of an if statement. */
SB> if (x!=0)
SB>   #pragma omp flush (x)

NB> Surely not.  I think this is a *really really* bad idea; I
NB> wouldn't support it going into GCC.  It's simply not the way
NB> C and C++ work.

Well, this *is* the way OpenMP works. From the OpenMP standard for C and
C++:

[quote]
The directives, library functions, and environment variables defined in this
document will allow users to create and manage parallel programs while
permitting portability. The directives extend the C and C++ sequential
programming model with single program multiple data (SPMD) constructs,
work-sharing constructs, and synchronization constructs, and they provide
support for the sharing and privatization of data. Compilers that support
the OpenMP C and C++ API will include a command-line option to the compiler
that activates and allows interpretation of all OpenMP compiler directives.
[end quote]

I've always considered the OpenMP directives to be language extensions that
can be ignored by a compiler. Nothing in the C or C++ Standards prevents
pragmas from acting as do the ones defined by OpenMP. In Fortran, the OMP
directives exist as comments with a specific format.

SB> if (x!=0)
SB>   {
SB>     #pragma omp flush (x)
SB>   }

NB> Ugh.  Which @#$&*( thought of this?

A concept of OpenMP is that a program maintains its logic whether its is
compiled for serial or parallel execution. Thus the use of pragmas, which
can be ignored (or warned about) by any non-OpenMP compiler.

OpenMP is an outgrowth of an unfinished ANSI draft, X3H5. The OpenMP
Architecture Review Board is comprised of members from IBM, Sun, HP, Intel,
SGI, Fujitsu, and ASCI. No Microsoft, just as an interesting note. The
OpenMP Standard is implemented in C, C++, and Fortran compilers from these
companies.

..Scott



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]