<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Kernel launch failure with lambdas in CUDA on Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=48866">48866</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Kernel launch failure with lambdas in CUDA on Windows
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>CUDA
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>joachim@joameyer.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given multiple (nested) lambdas as CUDA kernel parameters, the mangling/naming
seems to be inconsistent between host and device and thus `cudaLaunchKernel`
fails with error code 98. Might be related to the lambda numbering issues,
solved in Clang 10 (<a href="https://reviews.llvm.org/D68818">https://reviews.llvm.org/D68818</a>)?

A rather minimal reproducer is:
```
#include <exception>
#include <iostream>

template <class T>
__global__ void kernel(int *t, int n, T lambda)
{
    if(threadIdx.x < n)
        t[threadIdx.x] = lambda(t[threadIdx.x]);
}

int main(){
    int* t=nullptr;
    cudaMalloc(&t,12);
    auto lambda = [](int t){
        return t++;
    };
    kernel<<<1, 32>>>(t, 3, lambda);

    [&]()
    {
        auto lambda2 = [](int t){
            return t++;
        };
        kernel<<<1, 32>>>(t, 3, lambda2);
    }();
    if(cudaGetLastError())
    {
        std::cout << "err";
        cudaFree(t);
        std::terminate();
    }
    cudaFree(t);
    return 0;
}
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>