 # filling the table

Hi,
How can I fill the square table with this rule: each cell in row has cell in row above value. first row is 0 to N-1. the table is one dimensional.
each row should be compute with parallelism and than synchronize thread and compute next row. for example for N=4 it should at the end looks like:
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3

thanks

Hi,

If I understand your problem you have to:

1. compute index= blockDim.x* blockIdx.x + blockIdx.y

2. assign each element of the vector as: outVector[index] = index % N (i.e. the modulus operator)

Hope this helps

no, it was an example. in the cell could be other value, for example a,b,c,d. and i can’t compute each cell i must copy from cell above
if W is width than tab[i]=tab[i-W] (for i>=W).

I’ve solved it. Solution:

[codebox]

dim3 block(10,1,1);

dim3 grid(image.size()/(block.x*H),1,1);

go<<<grid,block>>>(out,degree,thre,W,H);

//kernel

global void go(int * out, int degree, int thre, int W, int H){

``````	int x=blockIdx.x * blockDim.x + threadIdx.x;

for(int i=0;i<H;i++){

out[i*W+x]=i*W+x;

if(i>0)

out[i*W+x]=out[i*W-W+x];

}

}
``````

[/codebox]