Pragma parsing

Jakub Jelinek jakub@redhat.com
Thu Dec 18 18:16:00 GMT 2014


On Thu, Dec 18, 2014 at 07:00:09PM +0100, Thomas Schwinge wrote:
> OK, so there is this limit.  But, I fail to understand how merely moving
> the OpenACC-only PRAGMA_*_CLAUSE_* to the end of enum pragma_omp_clause
> will help overcome that?  Or have I now completely confused myself, and
> I'm not even understanding the problem anymore?  :-|
> 
> The only way this would make sense (in my confused mind) is, if we then
> did PRAGMA_OACC_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION for the
> clauses whose names exist in both standards, and
> PRAGMA_OACC_CLAUSE_PRESENT = [some PRAGMA_OMP_CLAUSE_* whose name does
> not exist in OpenACC], taking care that no two PRAGMA_OACC_CLAUSE_* are
> assigned the same enum value.  Wouldn't this become very cumbersome for
> future maintenance, however?

Well, if you e.g. put PRAGMA_OMP_CLAUSE_* that isn't relevant to OpenACC
first, then pragmas shared by both, then OpenACC pragmas, then perhaps you
could use biased bitmasks for the OpenACC constructs.  Anyway, guess keep
the ordering as is.

> > > I still don't like this very much, because we'll then get a "mess" of
> > > PRAGMA_OMP_CLAUSE_* intermixed with PRAGMA_OACC_CLAUSE_*.  I understand,
> > > for example, PRAGMA_OMP_CLAUSE_REDUCTION to just be a "numeric
> > > representation" of the "reduction" string -- and then, it doesn't make
> > > too much sense to me to express this both as PRAGMA_OMP_CLAUSE_REDUCTION
> > > and PRAGMA_OACC_CLAUSE_REDUCTION, or, similarly, to switch back and forth
> > > between PRAGMA_OMP_CLAUSE_* and PRAGMA_OACC_CLAUSE_*.  Yet, that's just
> > > the point that I'm making, so I'll defer if there's no consensus to be
> > > found here.
> > 
> > The point is that we now have lots of clauses, and making it clear what from
> > those clauses are Cilk+, what are OpenACC, what are OpenMP will help with
> > code readability.
> 
> The idea then is, I guess, to split parsing of OpenACC's
> PRAGMA_OACC_CLAUSE_* out of gcc/c/c-parser.c:c_parser_omp_clause_name
> into a new c_parser_oacc_clause_name, just like we already have a
> separate c_parser_oacc_all_clauses and c_parser_omp_all_clauses?  (The
> motivation for the latter is that this is where the disambiguation
> between the (possibly) different semantics of OpenACC and OpenMP clauses
> happens, that is, where the "names" PRAGMA_OMP_CLAUSE_* are resolved to
> actual gcc/tree-core.h:enum omp_clause_code's OMP_CLAUSE_*.  For example,
> there a OpenACC copy clause is translated into a OMP_CLAUSE_MAP with
> tofrom kind.)

I don't think that is needed.  It is the same parsing, so it can be shared,
just use PRAGMA_OMP_* for OpenMP clauses or clauses shared between OpenMP
and OpenACC and PRAGMA_OACC_* for OpenACC specific pragmas in the code
that works with both, and in OpenACC specific FE code the PRAGMA_OACC_*
aliases to PRAGMA_OMP_* values for the shared clauses.
I just want to be able to clearly see what is OpenACC specific and what is
not, similarly how Cilk+ already does it.

	Jakub



More information about the Gcc-patches mailing list