Looks like Richard and I came up with exactly the same patch.<div><br></div><div>--Sean Silva<br><br><div class="gmail_quote">On Wed, Jun 13, 2012 at 7:33 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure if Clang has codegen support for C++11 constructs for CUDA.<div><br></div><div>However, if it does, the attached one-liner patch will probably make it work.</div>
<span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">--Sean Silva<br><br></font></span><div class="gmail_quote"><div class="im">
On Wed, Jun 13, 2012 at 6:57 PM, Peter Colberg <span dir="ltr"><<a href="mailto:peter@colberg.org" target="_blank">peter@colberg.org</a>></span> wrote:<br></div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi,<br>
<br>
I am experimenting with CUDA language support in Clang, and so far<br>
the kernel-call test in Clang trunk (r158426) compiles and runs, on<br>
a Tesla C2050.<br>
<br>
Now I would like to enable C++11 support in Clang to use compile-time<br>
C++11 features in GPU code, primarily variadic templates and lambda<br>
functions.<br>
<br>
The following code compiles fine:<br>
<br>
    // <a href="http://kernel-call.cu" target="_blank">kernel-call.cu</a><br>
<br>
    #include <cuda_runtime.h><br>
<br>
    __attribute__((global)) void g1(int x) {}<br>
<br>
    int main(void) {<br>
      // CHECK: call{{.*}}cudaConfigureCall<br>
      // CHECK: icmp<br>
      // CHECK: br<br>
      // CHECK: call{{.*}}g1<br>
      g1<<<1, 1>>>(42);<br>
    }<br>
<br>
    clang++ -std=cuda -I/usr/local/cuda-4.2/cuda/include -L/usr/local/cuda-4.2/cuda/lib64 -lcudart -o kernel-call <a href="http://kernel-call.cu" target="_blank">kernel-call.cu</a><br>
<br>
After adding a lambda function (in the host code), compilation fails:<br>
<br>
    #include <cuda_runtime.h><br>
<br>
    __attribute__((global)) void g1(int x) {}<br>
<br>
    int main(void) {<br>
      // CHECK: call{{.*}}cudaConfigureCall<br>
      // CHECK: icmp<br>
      // CHECK: br<br>
      // CHECK: call{{.*}}g1<br>
      g1<<<1, 1>>>(42);<br>
<br>
      auto lambda = [](){};<br>
    }<br>
<br>
    clang++ -std=cuda -I/usr/local/cuda-4.2/cuda/include -L/usr/local/cuda-4.2/cuda/lib64 -lcudart -o kernel-call <a href="http://kernel-call.cu" target="_blank">kernel-call.cu</a><br>
    kernel-call.cu:14:3: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]<br>
      auto lambda = [](){};<br>
      ^<br>
    kernel-call.cu:14:17: error: expected expression<br>
      auto lambda = [](){};<br>
                    ^<br>
    1 warning and 1 error generated.<br>
<br>
As expected, -std=c++11 does not work, since it disables CUDA support:<br>
<br>
    clang++ -std=c++11 -I/usr/local/cuda-4.2/cuda/include -L/usr/local/cuda-4.2/cuda/lib64 -lcudart -o kernel-call <a href="http://kernel-call.cu" target="_blank">kernel-call.cu</a><br>
    kernel-call.cu:5:16: warning: global attribute ignored<br>
    __attribute__((global)) void g1(int x) {}<br>
                   ^<br>
    kernel-call.cu:12:7: error: expected expression<br>
      g1<<<1, 1>>>(42);<br>
          ^<br>
    kernel-call.cu:12:14: error: expected expression<br>
      g1<<<1, 1>>>(42);<br>
                 ^<br>
    1 warning and 2 errors generated.<br>
<br>
<br>
Is there a way to tell Clang to enable C++11 extensions?<br>
<br>
Thanks,<br>
Peter<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div>