Good morning,
I’m starting in cuda. I have a struct “Point” on my problem:
struct Point {
double x, y, z, radius;
- Point neighbors [NUM_VIZINHOS];
- Point possiveisVizinhos [NUM_POSSIVEISVIZINHOS];
}
I can copy / access / change / return A “point” when sending to a kernel.
But I can not do the same with an array of “points” with the following code.
const int size = nPoints * sizeof (Point);
cudaMalloc ((void **) & arrayPoints_d, size);
cudaMalloc ((void **) & arrayAux_d, nPoints * nPoints * sizeof (int));
cudaMemcpy (arrayPoints_d, arrayPoint, size, cudaMemcpyHostToDevice);
kernel <<< blocks, threads >>> (arrayPoints_d, nPoints, arrayAux_d);
cudaMemcpy (arrayAux, arrayAux_d, nPoints * nPoints * sizeof (int), cudaMemcpyDeviceToHost);
global void kernel (Point * arrayPoints, nPoints int, int * arrayAux) {
x = int + threadIdx.x blockIdx.x blockDim.x *;
double value = 0;
if (x <nPoints) {
for (int j = 0 j <nPoints nPoints *, + + j) {
arrayPoints value = [x​​]. radius;
arrayAux [j + x * nPoints] = value;
}
}
}
I can not access the data structure in this case above.
Do not repair simple errors in code because I translated the code. I wonder if you can send arryas a struct to a device, and if possible an example of how to allocate / copy / modify / return this array. Thank you!