Changes

Jump to: navigation, search

TriForce

27 bytes added, 15:26, 20 March 2019
Assignment 2
__global__ void superSolve(int * d_a) {
//Used to remember which row | col | box ( section ) have which values
__shared__ bool rowHas[N][N];
__shared__ bool colHas[N][N];
__shared__ bool boxHas[N][N];
//Used to ensure that the table has changed
__shared__ int added, past;
//Number of spaces which can place the number
__shared__ int rowCount[N][N];
__shared__ int colCount[N][N];
__shared__ int boxCount[N][N];
//Where the square is located in the Sudoku
int row = threadIdx.x;
int col = threadIdx.y;
int box = row / BOXWIDTH + (col / BOXWIDTH) * BOXWIDTH;
//Unique identifier for each square in row, col, box
//Corresponds to the generic Sudoku Solve
//Using a Sudoku to solve a Sudoku !!!
int offset = col + (row % BOXWIDTH) * BOXWIDTH + (box % BOXWIDTH);
//Squares location in the Sudoku
int gridIdx = col * N + row;
int at = d_a[gridIdx];
if (!gridIdx) { //Thread at 0,0 sets values
added = -1;
past = -2;
}
rowHas[col][row] = false;
colHas[col][row] = false;
boxHas[col][row] = false;
__syncthreads();
if (at != UNASSIGNED) {
rowHas[row][at - 1] = true;
boxHas[box][at - 1] = true;
}
//Previous loop has not changed any values
while (added != past) {
boxCount[col][row] = 0;
__syncthreads();
if (!gridIdx) //forget old change index
past = added;
int count = 0; //number of values which can fit in this square
int guess = at; //last value found which can fit in this square
 
for (int idx = 0; idx < N; ++idx) {
//Ensures that every square in each section is working on a different number in the section
__syncthreads();
}
//Only ONE value can fit in this spot
if (count == 1) {
}
__syncthreads();
if (at == UNASSIGNED) {
//Find values which can go in only one spot in the section

Navigation menu