Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by k ( 15 years ago )
__global__ void kernel(bool *a1_d, bool *a2_d,int N){
int th_x=threadIdx.x+blockDim.x*blockIdx.x,
th_y=threadIdx.y+blockDim.y*blockIdx.y,
idx=th_y*N+th_x;
int nboors=0, x_temp, y_temp;
for(int x=th_x-1; x<=th_x+1; ++x){
for(int y=th_y-1; y<=th_y+1; ++y){
if(x==th_x && y==th_y) continue;
if(x==-1) x_temp=N-1;
else if(x==N) x_temp=0;
else x_temp=x;
if(y==-1) y_temp=N-1;
else if(y==N) y_temp=0;
else y_temp=y;
if(a1_d[y_temp*N+x_temp]) ++nboors;
}
}
if(a1_d[idx]){
if(nboors==2 || nboors==3) a2_d[idx]=1;
else a2_d[idx]=0;
}else{
if(nboors==3) a2_d[idx]=1;
}
}
Revise this Paste
Children: 40554