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: unassignedclangb...@nondot.org Reporter: crtr...@sandia.gov CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs