Changes

Jump to: navigation, search

TriForce

361 bytes added, 16:10, 20 March 2019
Assignment 2
__global__ void superSolve(int * d_a) {
//Used to remember which sections 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;
__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 offset = col + (row % BOXWIDTH) * BOXWIDTH + (box % BOXWIDTH);
//Squares location in the gridSudoku
int gridIdx = col * N + row;
past = -2;
}
 
rowHas[col][row] = false;
colHas[col][row] = false;
boxHas[box][at - 1] = true;
}
 
//Previous loop has not changed any values
while (added != past) {
colCount[col][row] = 0;
boxCount[col][row] = 0;
__syncthreads();  if (!gridIdx) //need to forget old change a new value 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
int num = (idx + offset) % N;
if (at == UNASSIGNED && !(rowHas[row][num] || colHas[col][num] || boxHas[box][num])) {
boxCount[box][num] ++;
}
__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 row | grid | box
for (int idx = 0; idx < N; ++idx) {
if (!(rowHas[row][idx] || colHas[col][idx] || boxHas[box][idx]) &&

Navigation menu