Hi,
How to allocate memory for device and copy it from host to device for the following structure?
typedef struct {
long int *data;
int length;
long int total;
} entity;
I just do it in the following way:
entity *gpuEntitys;
int entitySize = sizeof(entity);
int totalEntitySize = N*entitySize;
cudaMalloc((void**)&gpuEntitys, totalEntitySize);
cudaMemcpy(gpuEntitys, entityHost, totalEntitySize, cudaMemcpyHostToDevice);
When I try to write to the property data, I get an error:
CUDA error at code=77(cudaErrorIllegalAddress)
__global__ void kernel(entity *entitys) {
entity ent = entitys[index];
ent.data[1] = 1;
}
Could anyone give a tip?
thanks!