无法在device_memory中创建Cusp :: COO_MATRIX的TOLLUST :: HOST_VECTOR
Impossible to create thrust::host_vector of cusp::coo_matrix within device_memory?
我正在尝试制作一个 cusp::coo_matrix
的向量,并且似乎不能以这种方式使用 thrust::host_vector
。考虑此代码:
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;
}
我从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
有趣的是,我会因cusp::host_memory
而获得完全相同的错误(嗯,几乎相同):
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
所以,我的问题是,这真的是一个缺点还是我做错了什么?任何帮助都非常感谢。
此外,我已经测试了std::vector
,而不是thrust::host_vector
,它可以正常工作。并不是说我是推力图书馆的忠实拥护者,但我很好奇。此外,如果thrust::host_vector
不合适,我将需要重写一些代码(使用thrust::find
和其他一些功能)。
另外,还有其他方法可以制作一系列尖端矩阵吗?我不认为原始指针和new/delete
比std::vector
更好,我是对的吗?
如注释中所述,编译器警告是良性的。在推力主机向量中不使用POD类型是安全的。使用推力设备向量做同样的事情是不安全的。
此答案是从评论中添加为一个社区Wiki,以将其从未解决的列表中获取
相关文章:
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- Eigen - matrix.transpose 会创建矩阵的副本吗?
- 将 OpenCV-Matrix 转换为矢量
- C++在函数中创建的对 Eigen::Matrix 的悬空引用
- 为什么我们必须在 C++ 中释放数组数组,而不仅仅是整个"matrix"
- 为什么我不能从 Eigen::Matrix 继承?
- 使用 'Eigen::Matrix' 创建 'alglib::integer_1d_array'
- MATLAB API用于使用MatgetDir的C例外:Matrix :: Serialize ::在内存位置内置
- 特征"Sparse matrix format"示例是否包含错误?
- 是否存在与 Eigen::Matrix<>constexpr 构造函数相关的信息?
- What wrong with `(A.array() == A.array()).matrix()`?
- 如何从eigen :: matrix获取内存所有权
- matrix.size() 和 matrix[0].size() 有什么区别?
- 从类型 'Matrix&' 的右值初始化 类型的非 const 引用无效 'Matrix'
- 如何将 Eigen Jacobi SVD 与 Eigen Affine Matrix一起使用
- Map Eigen replicate Matrix
- | 9 |错误:非静态数据成员'matrix :: row'| 9 |错误:数组绑定不是在']']'令牌|之前的整数常数
- 如何将 Eigen::Matrix 映射到 std::vector<Eigen::vector>?
- 过载时出错 << "Exception thrown: read access violation.m.matrix was 0xCDDDCDDE."
- 有一个具有映射到 std::vector 属性的 Eigen::matrix 属性的类