Tag: deep copy

如何使用CUDA执行struct的深度复制?

使用CUDA编程我在尝试将一些数据从主机复制到gpu时遇到了问题。 我有3个这样的嵌套结构: typedef struct { char data[128]; short length; } Cell; typedef struct { Cell* elements; int height; int width; } Matrix; typedef struct { Matrix* tables; int count; } Container; 所以Container “包含”一些Matrix元素,而这些元素又包含一些Cell元素。 假设我以这种方式动态分配主机内存: Container c; c.tables = malloc(20 * sizeof(Matrix)); for(int i = 0;i<20;i++){ Matrix m; m.elements = malloc(100 * sizeof(Cell)); c.tables[i] = m; […]