[cfe-dev] Clang and CUDA with C++11 features

Sean Silva silvas at purdue.edu
Thu Jun 14 09:40:05 PDT 2012


Oh, yeah. idk why but I got the impression that you were trying to get it
to work while keeping the cuda call syntax (I haven't done any cuda
programming, but the alternative to the cuda call syntax in the example you
gave seemed painful to write), even though you explicitly said "Is there a
way to disable parsing of the CUDA call syntax <<< >>>?"

D'oh.

--Sean Silva

On Thu, Jun 14, 2012 at 7:53 AM, Peter Colberg <peter at colberg.org> wrote:

> On Wed, Jun 13, 2012 at 09:35:10PM -0700, Sean Silva wrote:
> > On Wed, Jun 13, 2012 at 8:28 PM, Peter Colberg <peter at colberg.org>
> wrote:
> > > The parser interprets the compressed C++11 template parameter syntax
> > > as a call to a CUDA kernel function. Is there a way to disable parsing
> > > of the CUDA call syntax <<< >>>? I would be using a C++ wrapper around
> > > cudaConfigureCall, cudaSetupArgument and cudaLaunch anyway.
> >
> > Try:
> >
> > find $HEADER_DIR | xargs sed --i.bak -e 's/>>>/> > >/'
> >
> > I don't think there are any syntactic dark corners where that will break
> > otherwise valid C++.
> >
> > No guarantees though (that's what the -i.bak is for ;).
>
> The other way around: CUDA violates the C++ standard with regard to
> template parameter syntax, so I would like to disable the CUDA
> execution syntax, and use cudaLaunch with a pointer instead.
>
> The lexer of Clang is straight-forward :-).
>
> --- lib/Lex/Lexer.cpp      2012-06-14 10:48:34.675569175 -0400
> +++ lib/Lex/Lexer.cpp   2012-06-14 10:48:51.246645348 -0400
> @@ -3054,10 +3054,6 @@
>         // If this is '<<<<' and we're in a Perforce-style conflict marker,
>         // ignore it.
>         goto LexNextToken;
> -      } else if (LangOpts.CUDA && After == '<') {
> -        Kind = tok::lesslessless;
> -        CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
> -                             SizeTmp2, Result);
>       } else {
>         CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
>         Kind = tok::lessless;
> @@ -3110,10 +3106,6 @@
>       } else if (After == '>' && HandleEndOfConflictMarker(CurPtr-1)) {
>         // If this is '>>>>>>>' and we're in a conflict marker, ignore it.
>         goto LexNextToken;
> -      } else if (LangOpts.CUDA && After == '>') {
> -        Kind = tok::greatergreatergreater;
> -        CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
> -                             SizeTmp2, Result);
>       } else {
>         CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
>         Kind = tok::greatergreater;
>
> Peter
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120614/60ec2517/attachment.html>


More information about the cfe-dev mailing list