c++和cuda混合编程记录二

来源:互联网 发布:excel粘贴数据和公式 编辑:程序博客网 时间:2024/06/05 23:03
  /////带有继承关系的内存分配遇到了问题,父类,子类    sphere *world_device;    cudaMalloc( (void**)&world_device,sizeof(sphere) * SPHERENUM );    sphere world_host[ SPHERENUM ] =    {        sphere(0,0,-1,      0.5,   new lambertian(0.8, 0.1, 0.2 )),        sphere(0,-100.5,-1, 100,   new lambertian( 0.8, 0.8, 0.0 )),        sphere( 1,0,0.3,   1,     new metal( 0.8, 0.6, 0.2, 0.0 )),        sphere( -1,1,-1,    1,     new dielectric(0.9)),        sphere( 1,0,-2  ,   -0.45, new dielectric(1.5))    };    cudaMemcpy( world_device, world_host,                                sizeof(sphere) * SPHERENUM,                                cudaMemcpyHostToDevice );//
这样是可以的。记录一下
原创粉丝点击