gomp-discuss
[Top][All Lists]
Advanced

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

Re: [Gomp-discuss] "#pragma omp" and GCC


From: Biagio Lucini
Subject: Re: [Gomp-discuss] "#pragma omp" and GCC
Date: Wed, 5 Feb 2003 12:25:28 +0000 (GMT)

On 5 Feb 2003, Steven Bosscher wrote:

> Yuck, it's really not easy...
> 
> I made a crude implementation of the most simple C OMP pragmas to play
> with, and I run in trouble all over when I need to interact with the
> parser. Two examples:
> 
> a. A "section" directive must appear in the block of an "sections"
> directive.
> In the specification, they define "section-scope" as a set of "section"
> directives followed by a "stuctured-blocks".  The set of sections is
> enclosed by brackets.  I don't know how we could make sure that when we
> see a "section" directive, we're inside a "section-scope".
> 
> b. All OpenMP pragmas put restrictions on syntax.
> So, "parallel", "section", "sections", "single", "master", "critical",
> and "atomic" all put restrictions on what can follow the directive.
> 
> 

[cut]

What about dealing with all the syntax problems directly in the parser?
For instance, you can set a flagt "parallel_region_flag = 1" whenever you
have
a 

#pragma openmp parallel

Then, when you find #pragna omp sections, you check the value of
parallel_region-flag; if it is different from 1, you return something like

"Error: the sections pragma can appear only inside a "#pragma omp
parallel""

Then, again, if the check is correct, you keep parsing and you set
parallel_sections_flag to 1. At the next "section" statement, you check
that paralell_sections_flag is 1, otherwise you return an error. And so
forth. This is very involved and full of sub-cases, I admit it, but
probably safe and will allow you to do things all in one place.

The same technique could be used for checking the validity of the clauses:
you build a table of directives vs. clauses, and when you find a directive
you also look if the following clause is legal. 

Last thing to do: look that clauses are compatible. E.g. if I say

#pragma omp paralell private(x) shared(x) 

this is obviously illegal. This is trivial, but what is less trivial is
that if you define

#pragma omp paralell private(x) reduction(+: x)

this is still illegal (at least according to the Intel compiler; some
other compiler will happily accept it).

Any thoughts?

Biagio





reply via email to

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