cuda - using std::bind2nd with thrust -
i'm trying use std::bind2nd thrust. have code compiles host pointer, not device pointer. think identical , should work in both cases.
// 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)); // compilation fails 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)); when try call second copy_if bind2nd error below:
/opt/cuda/include/thrust/detail/internal_functional.h(99): warning: calling __host__ function __host__ __device__ function not allowed is there way using adapters binary functions in thrust? have seen people using "thrust::bind2nd" in examples on web can't find in of our header files.
it possible use adaptors in thrust. if want use them on gpu, adaptor must __device__ function. why first copy_if compiles , second doesn't - predicate host function, not device function , use of device_vector implies device compilation trajectory.
in short, if want adaptor function use on gpu, need write 1 yourself, standard library ones (bind1st, bind2nd, bind) can't used.
Comments
Post a Comment