I make this topic because I’m having a problem trying to implement a 2D array so that I can use it on the device.
The problem goes like this:
I need to use this structure: struct neighbor{
float3 neighbor1; → coordinates of the vertex corresponding to the row index;
float3 neighbor2; → the coordinates of the vertex2 and vertex3 wich makes a triangle;
float3 neighbor3;
};
so that in each member of the matrix has a structure like that.
I think that implementing it on the host it’s not that difficult, but the problem is how to get it to the device after…
the main problem, that I’m not figuring out is how to fill the 2D array with data, since i’m declaring it as 1D array “cudaMalloc(d_neighbours, sizeof(neighbour) * NUM_NEIGHBOURS);” the array will have 2903 rows and 16 columns, and I don’t know hot put this on the memory.
Obrigado pelo post na mesma! Or thank you for the post (if you don’t know portuguese)
I’ve already saw this, and I think it will be part of the solution, the main problem, and of course it is very simple (only I can’t figure it out) is how to access it like a matrix. How can I access it using the indexes so I can store in the matrix like this:
for(int i=0;i<numvertex;i++){
for(int j=0;j<16;j++){
matrix[i+j].neighbor1=make_float3(x,y,z);
^^^
the problem is here
}
}