lundi 25 mai 2015

Does cuda 7 fully support lambda on device code?

If I use thrust::transform on thrust::host, the lambda usage is fine

thrust::transform(thrust::host, a, a+arraySize,b,d,[](int a, int b)->int
{
    return a + b;
});

However, if I change the thrust::host to thrust::device, The code wouldn't pass the compiler. Here is the error on vs 2013

The closure type for a lambda ("lambda [](int, int)->int") cannot be used in the template argument type of a __global__ function template instantiation, unless the lambda is defined within a __device__ or __global__ function

So the problem is how to add the __device__ or __global__ to lambda?

Aucun commentaire:

Enregistrer un commentaire