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

Mahesha HS mahesha.llvm at gmail.com
Thu Nov 8 22:21:32 PST 2012


Hi,

I spent some time going through the code base related to *attributes*
support in Clang. As per the definition of the class "class
AttributeList" in clang/include/clang/Sema/AttributeList.h, the
implementation aims at supporting following four kinds of attributes
syntax as of today.

1. Classis GNU syntax
2. C++11X syntax
3. Microsoft declspec syntax
4. Microsoft typespec syntax

If OpenMP standards body accept the new C++11X based OpenMP syntax
like "for [[omp::for(clause, clause), … ]] (loop-head) loop-body",
then its implementation belongs to above syntax category 2 (C++11X
syntax).

However, as you are suggesting to treat OpenMP classic *pragma*
syntax too as *attribute* syntax, one way of doing it is by including
pragma syntax as another attribute syntax item to above list as 5th
one. But, I do not know - at this point - how well we can fit the
OpenMP pragma syntax as attribute syntax. I would ask other community
members to comment on this approach.

On the other hand, internal mapping of OpenMP pragma syntax to new
C++11X based OpenMP syntax will become *messy* in many ways starting
from preserving source location information till error reporting.  So,
I am personally *against* this approach unless somebody proves that
this approach will be neat and it will not be error prone, and it will
not be maintenance head ache.  That said, door is open for others to
discuss about this approach.


--
mahesha




On Thu, Nov 8, 2012 at 7:28 PM, Mahesha HS <mahesha.llvm at gmail.com> wrote:
> On Thu, Nov 8, 2012 at 6:18 PM, Olaf Krzikalla
> <Olaf.Krzikalla at tu-dresden.de> wrote:
>> Am 08.11.2012 04:20, schrieb Mahesha HS:
>>
>>> GCC ( g++ ) happily reports *un-declared* error for the variable VarA
>>> when I do not pass -fopenmp option, and abort the compilation. Yes,
>>> OpenMP spirit is clearly broken here.  Though, I did not test the
>>> other compilers, I guess that they follow GCC for whatever the
>>> reasons.
>>
>> MSVC rejects the code.
>>
>>
>>
>>(I believe it is even a non-intentionally
>> extension of gcc introduced by an unified handling of
>> condition-expressions).
>
> Possible.
>
>> Regarding side effects in expressions, while these might be considered evil,
>> they are actually allowed by the OpenMP standard. But they don't impose any
>> problems to the implementation.
>>
>> A program shall compile and run with and without -fopenmp. It is not
>> required that both variants yield the same output.
>
> Yes. I agree.  We can probably re-discuss about it when we encounter
> the implementation in a near future, if required.
>
> Now, I am going through the Clang code base which is related to
> *attributes* implementation.  Once, I get hold of this code base, I
> guess, some discussion is required around how to implement OpenMP
> *pragmas* as *attributes*. Meanwhile, it would be great if your share
> your thoughts too in this line, I mean from the perspective of
> implementation strategy. I do think that common code base should serve
> the need of both the syntax - classic pragma syntax and new C++11
> attribute based syntax.
>
> --
> mahesha



-- 
mahesha




More information about the cfe-dev mailing list