Parallel processing 在ArrayFire中将seq与double2数组一起使用时降级为float2

Parallel processing 在ArrayFire中将seq与double2数组一起使用时降级为float2,parallel-processing,arrayfire,Parallel Processing,Arrayfire,我正在利用ArrayFire库使用以下测试代码 void test_seq(const array& input, array& output, const int N) { array test = seq(0,N-1); output = input; } (for the moment `array test` has no role) doub

我正在利用ArrayFire库使用以下测试代码

void test_seq(const array& input, array& output, const int N)
{
    array test      = seq(0,N-1);                                         
    output          = input;
}

(for the moment `array test` has no role)

double2* test_CPU; test_CPU=(double2*)malloc(10*sizeof(double2));       
for (int k=0; k<10; k++) { test_CPU[k].x=2.; test_CPU[k].y=1.; }
array test_GPU(10, test_CPU);
array test_GPU_output = constant(0.,10, c64);
test_seq(test_GPU,test_GPU_output,10);
print(test_GPU_output);
try {
    double2 *CPU_test = test_GPU_output.host<double2>();
    printf("%f %f\n",CPU_test[0].x,CPU_test[0].y);
} catch (af::exception& e) {
fprintf(stderr, "%s\n", e.what()); 
}
我收到以下运行时错误消息

src/gena/gtypes.cpp:112:错误:从cuComplex类型的数组请求了cuDoubleComplex

如果,在另一边,我改变路线

double2 *CPU_test = test_GPU_output.host<double2>();
double2*CPU\u test=test\u GPU\u output.host();

float2*CPU\u test=test\u GPU\u output.host();
一切又恢复正常了。由于使用
seq
,似乎有降级到float2的情况。如果我使用类似于
seq(0,N-1,f64)
(我甚至不知道ArrayFire是否允许这样做),上述问题不会消失


如何保持
double2
处理并避免降级到
float2

将seq转换为数组时,它存储为单精度(float)

目前在arrayfire中,涉及两个精度不同的阵列的操作的规则是选择较低的精度。这就是
input*test
从双精度转换为单精度的原因(因此
float2

现在的解决方案是在测试生成下面添加一行

test = test.as(f64);

这只会增加很少的开销,因为数组在必要时才会生成。

感谢您的及时回答。我会试试你的解决办法。不幸的是,现在我的代码和ArrayFire示例都不起作用。我想我暂时有许可证问题(尽管我的互联网连接正常)。我会让你知道的。再次感谢。@Jackolanten如果您仍有问题,请给我发电子邮件(我的个人资料中有此电子邮件)。我解决了许可证问题。我的网络连接失败了。此外,您的解决方案工作正常。非常感谢。我已经接受了你的回答。
float2 *CPU_test = test_GPU_output.host<float2>();
test = test.as(f64);