112
edits
Changes
TriForce
,→Kernel Optimization Attempts
Result : Not faster, HOWEVER there is a slight error, by setting notSeen = 0, the section counters will rarely reach one
{| class="wikitable mw-collapsible mw-collapsed"
! CountDown - using Int as Boolean Array(EDITED now 4.28 seconds)
|-
|
int notSeen = 0; //Boolean Array as an Integer
if (gridIdx == 0)
changed = true;
rowHas[col][row] = false;
colHas[col][row] = false;
}
// Previous loop has not changed any values
while (changed) {
__syncthreads();
if (gridIdx == 0) // forget previous change
changed = false;
int b_shuttle = 1;
for (int idx = 0; idx < N; ++idx) {
int num = (idx + offset) % N;
if (b_shuttle & notSeen) {&& if (at != UNASSIGNED || rowHas[row][num] || boxHas[box][num] || colHas[col][num])) { notSeen ^= b_shuttle; --count;
rowCount[row][num]--;
colCount[col][num]--;
boxCount[box][num]--;
}
__syncthreads();
if ((b_shuttle & notSeen) && (count == 1 || rowCount[row][num] == 1 || boxCount[box][num] == 1 || colCount[col][num] == 1)){ rowHas[row][num] = true; inSection colHas[col][num] = falsetrue; boxHas[box][num] = true; changed = true; notSeen ^= b_shuttle; at = num + 1; count = 0; }
b_shuttle <<= 1;
}
__syncthreads();
__syncthreads();
if (changed && gridIdx == 0)
d_a[gridIdx] = at;
}
int count = 0; //Number of values which can fit in this square
if (gridIdx == 0)
changed = true;
__syncthreads();
int guess;
for (int idx = 0; idx < N; ++idx) {
int num = (idx + offset) % N;
if (at == UNASSIGNED && !(rowHas[row][num] || boxHas[box][num] || colHas[col][num])) {
notSeen |[num] = b_shuttletrue; //this value can go here
++count; //how many values this square can have
guess = num;
}
__syncthreads();
}
if (gridIdx == 0) // forget previous change
changed = false;
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 (b_shuttle & notSeen [num] &&
(at != UNASSIGNED || rowHas[row][num] || boxHas[box][num] || colHas[col][num])) {
rowCount[row][num]--;
colCount[col][num]--;
boxCount[box][num]--;
notSeen ^[num] = b_shuttlefalse;
--count;
}
boxHas[box][num] = true;
changed = true;
notSeen ^[num] = b_shuttlefalse;
at = num + 1;
count = 0;
}
}
__syncthreads();