0
我有一个问题,从设备/全局内核访问和分配变量与cusp array1d类型。附带的代码给出错误从设备内核访问cusp变量元素
alay.cu(8): warning: address of a host variable "p1" cannot be directly taken in a device function
alay.cu(8): error: calling a __host__ function("thrust::detail::vector_base<float, thrust::device_malloc_allocator<float> > ::operator []") from a __global__ function("func") is not allowed
代码下面
#include <cusp/blas.h>
cusp::array1d<float, cusp::device_memory> p1(10,3);
__global__ void func()
{
p1[blockIdx.x]=p1[blockIdx.x]+blockIdx.x*5;
}
int main()
{
func<<<10,1>>>();
return 0;
}
是的,我想通过设备线程操纵装置array1d,你能不能详细说明或给出示例代码,因为我仍然不明白? – user3040447
只是一个疑问,你的意思是'cusp :: array1d p2(10)= p1;'是cusp :: array1d p2(10)= p1; “是吗? –
不,我编辑了这个问题和代码,使我的问题更易于理解 – user3040447