Example #1
0
    int Update(const std::vector<Cell>& lat, int i, int L, int N) const {
        int newCurr = current & (BARRIER|STATIONARY);
        newCurr |= lat[RightNeigh(i,L,N)].current & LEFT;
        newCurr |= lat[RightDownNeigh(i,L,N)].current & LEFT_UP;
        newCurr |= lat[LeftDownNeigh(i,L,N)].current & RIGHT_UP;

        newCurr |= lat[LeftNeigh(i,L,N)].current & RIGHT;
        newCurr |= lat[LeftUpNeigh(i,L,N)].current & RIGHT_DOWN;
        newCurr |= lat[RightUpNeigh(i,L,N)].current & LEFT_DOWN;
        return rules[newCurr];
    }
__global__ void UpdateCells(int* inCells, int* outCells, int* rules, int L, int N) {
	const int i=blockIdx.x*blockDim.x+threadIdx.x;
	if (i >= N) {
		return;
	}
	int newCurr = inCells[i] & (BARRIER|STATIONARY);
	newCurr |= inCells[RightNeigh(i,L,N)]     & RIGHT;
	newCurr |= inCells[RightDownNeigh(i,L,N)] & RIGHT_DOWN;
	newCurr |= inCells[LeftDownNeigh(i,L,N)]  & LEFT_DOWN;
	newCurr |= inCells[LeftNeigh(i,L,N)]      & LEFT;
	newCurr |= inCells[LeftUpNeigh(i,L,N)]    & LEFT_UP;
	newCurr |= inCells[RightUpNeigh(i,L,N)]   & RIGHT_UP;
	//if (i%L ==0 ) newCurr=0;
	//if (i<L) newCurr=0;
	
	outCells[i] = rules[newCurr];
	
}