[llvm-bugs] [Bug 30567] New: Cuda Nested lambda (lambda inside a device function) requires __device__ annotation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 29 13:00:25 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30567

            Bug ID: 30567
           Summary: Cuda Nested lambda (lambda inside a device function)
                    requires __device__ annotation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: crtrott at sandia.gov
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17381
  --> https://llvm.org/bugs/attachment.cgi?id=17381&action=edit
Reproducer example

With NVCC lambdas which are declared inside a __device__ (or __host__
__device__ ) function automatically get promoted to __device__ or __host__
__device__. In fact one is not even allowed to mark the operator. In clang one
must mark it though. This situation makes me write a lot of ifdefs. 

Would it be possible to make lambda operators inherit the the attribute from
its scope if not explicitly specified? I am attaching a reproducer
demonstrating what I currently need to do to make it work. 

Here are the error messages from NVCC if I use "[=] (const int& i) __device__"

main.cpp(14): warning: a __host__ function("lambda []::operator()") redeclared
with __device__, hence treated as a __host__ __device__ function

main.cpp(16): error: The operator() function for a lambda cannot be explicitly
annotated with execution space annotations (__host__/__device__/__global__),
the annotations are derived from its closure class

1 error detected in the compilation of
"/tmp/tmpxft_0001e52a_00000000-9_main.cpp1.ii".

and if I use "[=] __device__ (const int& i)":
main.cpp(14): error: An explicit __device__ lambda must be defined inside a
__host__ or __host__ __device__ function

1 error detected in the compilation of
"/tmp/tmpxft_0001e53a_00000000-9_main.cpp1.ii".

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160929/23fe6a93/attachment.html>


More information about the llvm-bugs mailing list