[cfe-dev] OpenMP support in CLANG: A proposal

Mahesha HS mahesha.llvm at gmail.com
Wed Nov 7 07:00:08 PST 2012


Ok, give me some time to understand your proposal. Regarding your
question about *scope*,  I meant following example. In OpenMP
annotated C++ source,  following code snippet is valid. In this
particular example, I meant about handling the scope of variable
"VarA" .

=======================================
#pragma omp parallel if (int VarA = 2)
{
   // parallel region
}

VarA = 3;

#pragma omp parallel if (VarA = 2)
{
   // parallel region
}
========================================

--
mahesha


On Wed, Nov 7, 2012 at 7:58 PM, Olaf Krzikalla
<Olaf.Krzikalla at tu-dresden.de> wrote:
> Hi,
>
> a general note at first: I noticed the line
>
> PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true,
>                         /*OwnsTokens=*/false);
>
> in your code. IMHO DisableMacroExpansion should be false, since all text
> after a #pragma omp is subject to macro expansion (OpenMP 3.1, sec.2.1).
> Also I dont understand what you mean with scope in the case of "if" clauses.
>
> I see, what you want to accomplish by integrating OpenMP directly in the
> parser. If you encounter a omp parallel directive you instruct the parser to
> parse a structured block. And if that fails it is an error.
>
> I would go another route. I would stll see OpenMP directives as attributes
> to statements. And by the moment these attributes are attached to a
> statement the appropriate checks can be made.
> Try to attach an "omp parallel" directive to a class declaration -> error
> Try to attach an "omp parallel for" directive to a non-conforming
> for-Statement -> error.
>
> You see by the second example, that with this approach you aren't longer
> limited by the means of the parser.
>
> Of course you are right by writing:
>
>> So, we have to piggy back Global parser
>> to handle scopes, parse expressions and compound statement (structured
>> block).
> Thats what I meant in point 4 of my previous writing. We have to shout it
> out as often as possible to the right people (I don't belong to them) that
> the Parser needs a serious refactoring in order to support expressions
> inside pragmas and (later) C++0x-attributes.
> To say it with Douglas Gregors words from a another posting: while OpenMP is
> just a standard, using it is an industry trend. (actually I have wondered
> that the clang people could ignore it successfully for such a long time).
>
> So my suggestion remains: try to handle OpenMP directives as attributes.
> Extend the attribute framework in a way, that made it possible to user-check
> attributes at the time they are attached to the appropriate AST entity. And
> refactor the parser framework so that it is possible to parse code snippets.
>
> Best Olaf
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



-- 
mahesha



More information about the cfe-dev mailing list