Search code examples
c++cudathrust

thrust::complex with thrust reduce does not compile


I have been trying to implement some code requiring to call reduce on thrust::complexes, and the compiler fires me an error saying:

cannot pass an argument with a user-provided copy-constructor to a device-side kernel launch

Here is the code:

#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/complex.h>
#include <thrust/transform.h>
#include <vector>

using namespace thrust;

void exec() {
    auto v = std::vector<complex<double>>({1.0,1.0,1.0,1.0});
    auto complexZero = complex<double>();
    device_vector<complex<double>> devA(v);
    thrust::reduce(devA.begin(), devA.end(), complexZero, plus<complex<double>>());    
}
int main() {
    exec();
}

[CUDA 9.2 with g++]

Am I doing something wrong ?


Solution

  • This is fixed as of CUDA 10.0.

    Source: I'm the Thrust maintainer.