0
thrust:complex<float>
のベクトルを操作するのにthrust::transform
を使用しようとしています。次の例では、コンパイル時に数ページのエラーが発生します。thrust :: complex型で操作する:thrust :: transform
#include <cuda.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/transform.h>
#include <thrust/complex.h>
int main(int argc, char *argv[]) {
thrust::device_vector< thrust::complex<float> > d_vec1(4);
thrust::device_vector<float> d_vec2(4);
thrust::fill(d_vec1.begin(), d_vec1.end(), thrust::complex<float>(1,1));
thrust::transform(d_vec1.begin(), d_vec1.end(), d_vec2.begin(), thrust::abs< thrust::complex<float> >());
}
私はUbuntuのXenialにCUDA 8.0を使用してnvcc --std=c++11 main.cpp -o main
を使って打ち鳴らす3.8.0-2ubuntu4してコンパイルしています。
主なエラーがあるように見える:
main.cpp: In function ‘int main(int, char**)’:
main.cpp:17:105: error: no matching function for call to ‘abs()’
gin(), d_vec1.end(), d_vec2.begin(), thrust::abs< thrust::complex<float> >());
と
/usr/local/cuda-8.0/bin/../targets/x86_64-linux/include/thrust/detail/complex/arithmetic.h:143:20: note: template argument deduction/substitution failed:
main.cpp:17:105: note: candidate expects 1 argument, 0 provided
gin(), d_vec1.end(), d_vec2.begin(), thrust::abs< thrust::complex<float> >());
^
本当の山車に取り組んで問題ありません
が、複雑なものでありませんように。私は欠けているタイプのエラーがあると思っていますが、私はまだ推力&テンプレートで学習曲線の急な部分にいます。
これは、トリックを行いますが、なぜ '推力::否定<推力::複雑なは>()' '推力::変換()'の呼び出しに落ちません'thrust :: abs()'はファンクタでラップする必要がありますか?そして、1つのパラメータを期待することに対する苦情は、入力ベクトルに対して供給された単項演算のパラレル実行を設定し、出力ベクトルに結果を書き込む 'thrust :: transform()'ではありませんか? –
@AndreasYankopolus negate **は既に**ファンクタなので、ラッピングは不要です。あなたがしたのは、 'thrust :: transform()'と呼ばれ、 'thrust :: transform'の中にパラメータを入れていないということですが、関数を提供する必要があります(= function ** object **、 'operator()'を提供します)。 –
thrust/functional.hとthrust/complex.hの定義を見てみましょう。 –