Reusing OpenMP front end infrastructure for OpenACC -- how?

Jakub Jelinek jakub@redhat.com
Thu Sep 5 15:02:00 GMT 2013


On Thu, Sep 05, 2013 at 04:51:14PM +0200, Thomas Schwinge wrote:
> Implementing OpenACC support in GCC's frontends, there are things that I
> trivially have to reimplement, that are already present for OpenMP.  For
> example, the infrastructure for parsing clauses (as attached to OpenACC
> and OpenMP directives), and their representation in the GCC internal data
> structures.  Given the syntactical similarity of OpenACC and OpenMP, this
> infrastructure is similar, too, if not even identical.  Thus, my inner
> engineer tells me we ought to share this infrastructure instead of having
> a copy of it only different for s%omp%oacc.
> 
> For a specific example, I'd like to reuse everything known by omp_clause*
> and similar, and extend it with the things OpenACC does
> additionally/differently (adding safe-guards, if not already present, to
> the OpenMP code so that no clauses specific to OpenACC end up there).

Most of the omp-low.c code has asserts to verify no unknown clauses are
passed to it, and during parsing it has bitmasks of allowable clauses.

> Is this generally an accepted approach?  If yes, should I rename omp* to,
> say, oacc_omp* (putting the OpenACC tag first for the simple reason that
> it sorts first alphabetically), or can we think of a better tag than
> oacc_omp, or should I leave the names as omp* and add comments that these
> things are used for OpenACC, too?

I think there is no point in renaming the existing stuff, we use it for some
Cilk+ stuff too these days, renaming could only complicate maintainance,
making it harder to backport OpenMP bugfixes to older release branches etc.
IMHO just use from the OpenMP parsing, trees and gimple stuff whatever is
usable for OpenACC too, and just for stuff that doesn't have counterparts
add oacc/OACC stuff.
Say, for clauses IMHO it is just fine if you use OMP_CLAUSE tree code, and
just add additional OACC_CLAUSE_SOMETHING, OACC_CLAUSE_SOMETHINGELSE etc.
to the list of omp clauses and descriptors, just put it likely at the end
of the list with a comment that it is OpenACC specific stuff.  If some clause
is used with the same meaning in both standards, you can either just always use
OMP_CLAUSE_WHATEVER, or #define OACC_CLAUSE_WHATEVER OMP_CLAUSE_WHATEVER.

	Jakub



More information about the Gcc mailing list