Search code examples
cudathrust

CUDA-9.2 Thrust compilation failure when trying to resize a device_vector of thrust::complex<float>?


Simple example, in a file titled test.cu:

#include <thrust/complex.h>
#include <thrust/device_vector.h>
#include <iostream>
int main(void) {
    thrust::device_vector<thrust::complex<float> > V1(10);
    V1.resize(20);
    printf("%d\n", V1.size());
}

Attempting to build the above with nvcc fails, with a buttload of thrust errors, starting from complex.inl(187): error: no instance of overloaded function "thrust::complex::real [with T=float]" matches the argument list. However, I can confirm that the thrust/complex.h header file includes a templated real() method, which is prefaced with __host__ as well as __device__.

Using a host_vector instead of a device_vector, the code compiles and runs with the expected result. Is this simply an unsupported feature as of CUDA-9.2?


Solution

  • It sounds like this problem is reproducible in CUDA-9 but is solved in CUDA-10. I'll just upgrade