I am trying to make a vector of cusp::coo_matrix
and it seems one cannot use thrust::host_vector
in this manner. Consider this code:
int main(void)
{
typedef typename cusp::coo_matrix<int, float, cusp::device_memory> maintype;
maintype B;
thrust::host_vector<maintype> h_vec(2,B);
return 0;
}
I get this error message from nvcc
:
Warning: calling a __host__ function("thrust::detail::vector_base<int, thrust::device_malloc_allocator<int> > ::vector_base") from a __host__ __device__ function("thrust::detail::vector_base<int, thrust::device_malloc_allocator<int> > ::vector_base [subobject]") is not allowed
Warning: calling a __host__ function("thrust::detail::vector_base<float, thrust::device_malloc_allocator<float> > ::vector_base") from a __host__ __device__ function("thrust::detail::vector_base<float, thrust::device_malloc_allocator<float> > ::vector_base [subobject]") is not allowed
The interesting thing is I get the exact same errors with cusp::host_memory
instead (well, almost the same):
Warning: calling a __host__ function("thrust::detail::vector_base<int, std::allocator<int> > ::vector_base") from a __host__ __device__ function("thrust::detail::vector_base<int, std::allocator<int> > ::vector_base [subobject]") is not allowed
Warning: calling a __host__ function("thrust::detail::vector_base<float, std::allocator<float> > ::vector_base") from a __host__ __device__ function("thrust::detail::vector_base<float, std::allocator<float> > ::vector_base [subobject]") is not allowed
So, my question is, is it really a drawback or am I doing something wrong? Any help much appreciated.
In addition, I've tested std::vector
instead of thrust::host_vector
and it works fine. Not that I am such a big fan of Thrust library, but I'm just curious. Moreover, I will need to rewrite a bit of code in case thrust::host_vector
isn't suitable (thrust::find
and some other functions are used).
Also, are there any other ways of making an array of cusp matrices? I don't think raw pointers and new/delete
is anyhow better than std::vector
, am I right?