Hi!
I’ve got a 2D array with 2903 rows and 16 columns and I would like to know how to calculate the optimal grid size and block size so i can map a function to all of its members.
Thanks in advance.
Hi!
I’ve got a 2D array with 2903 rows and 16 columns and I would like to know how to calculate the optimal grid size and block size so i can map a function to all of its members.
Thanks in advance.
That really depends on what to do with the members…
16x16 blocksize and a grid with size ceil(2903/16)x1x1 could be an option.
hi E.D. Riedijk!
thanks for the reply.
I’m thinking using you’re grid and block sizes, I just need help how to define the index so i can travel through the 2D array:
This is how I’m thinking this for the index:
int i=blockIdx.x*blockDim.x+threadIdx.x;
int j=blockIdx.y*blockDim.y+threadIdx.y;
int index =i*numvertex+j;
But I’m not sure if its right…
Please advice.
When computing the function, do you consider each element in your 2D array separately? (Like squaring every element, or adding 1 to each, or something similar?) If that’s the case, you can also treat the 2D array as a big 1D array with 2903 * 16 elements, and map each element in the array to a thread in the order they are stored in memory.
that’s exactly what I’m doing, thank you for bring me down to the earth, I was going to treat this as a matrix but there is no need to, has you can see above I wanted two indexes but using has 1D array i will only need one.
Thank you again for opening my eyes.