我一直在尝试实现一些需要在 thrust::complexes 上调用 reduce 的代码,编译器向我发出错误消息:
cannot pass an argument with a user-provided copy-constructor to a device-side kernel launch
代码如下:
#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();
}
[带有 g++ 的 CUDA 9.2]
我做错了什么吗?
最佳答案
自 CUDA 10.0 起已修复。
资料来源:我是 Thrust 的维护者。
关于c++ - thrust::complex with thrust reduce 无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51963467/