std::bind2ndを推力で使用しようとしています。ホストポインターでコンパイルするコードがありますが、デバイスポインターではコンパイルしません。それらは同一であり、どちらの場合でも機能するはずだと思います。
// this compiles fine
thrust::host_vector<unsigned int> h_vec(nwords);
thrust::host_vector<unsigned int> h_map(nwords);
thrust::host_vector<unsigned int> h_out1(nwords);
thrust::copy_if(h_vec.begin(), h_vec.end(), h_map.begin(), h_out1.begin(),
std::bind2nd(thrust::equal_to<int>(),1));
// this compilation fails with the error below
thrust::device_vector<unsigned int> d_map(nwords);
thrust::device_vector<unsigned int> d_vec(nwords);
thrust::device_vector<unsigned int> d_out1(nwords);
thrust::copy_if(d_vec.begin(), d_vec.end(), d_map.begin(), d_out1.begin(),
std::bind2nd(thrust::equal_to<int>(),1));
bind2ndを使用して2番目のcopy_ifを呼び出そうとすると、次のエラーが発生します。
/opt/cuda/include/thrust/detail/internal_functional.h(99): warning: calling a
__host__ function from a __host__ __device__ function is not allowed
推力でバイナリ関数にアダプタを使用する別の方法はありますか?Webの例で「thrust::bind2nd」を使用している人を見たことがありますが、どのヘッダーファイルでもそれを見つけることができません。