1

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()); 
}

そして、すべてが正しくコンパイルされ、実行されます。

ただし、上記の関数を次のように変更します

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

次のランタイムエラーメッセージが表示されます

src / gena / gtypes.cpp:112:エラー:タイプcuComplexの配列からcuDoubleComplexを要求しました

反対側で、私が行を変更した場合

double2 *CPU_test = test_GPU_output.host<double2>();

float2 *CPU_test = test_GPU_output.host<float2>();

すべてが再び正常に実行されます。の使用に関連してfloat2への降格があるようですseq。上記の問題は、次のようなものを使用しても解消seq(0,N-1,f64)されません(ArrayFireで許可されているかどうかさえわかりません)。

double2処理を継続し、降格を回避するにはどうすればよいfloat2ですか?

4

1 に答える 1

0

seqを配列に変換する場合、単精度(float)として格納されます。

現在arrayfireでは、精度の異なる2つの配列を含む操作のルールは、より低い精度を選択することです。input * testこれが、倍精度から単精度に変換される理由です(したがってfloat2)。

今のところ解決策は、テストの生成の下に行を追加することです。

test = test.as(f64);

配列は必要になるまで生成されないため、オーバーヘッドはほとんど追加されません。

于 2013-02-28T16:40:20.833 に答える