Hey, this is getting more and more off the topic of Sudoku, which is the purpose of this forum. Please stick to Sudoku related topic
Thanks
Jason
System Admin
champagne wrote:In most cases, the user does not care about the results, only by the count of solutions (cancelling the task if the count is >1).
In some cases (UA collector on my side for example) the solution is needed, but in a specific context and a tailor made extraction can be done.
if (((AR>>3) & 7) != S) {
AR &= 0777777707 | (S<<3);
UPWCL(1, 1, 4, 7, 13, 16, 19, 22, 25);
}
emerentius_ wrote:I think I've found a sizeable performance improvement. I'm not sure if it's valid under all circumstances.
In the places that look like the following code snippet in the Update routine, just before calling UPWCL, deleting the if-branch has improved the speed for most sudoku sets by 5-12% (in my Rust code).
- Code: Select all
if (((AR>>3) & 7) != S) {
AR &= 0777777707 | (S<<3);
UPWCL(1, 1, 4, 7, 13, 16, 19, 22, 25);
}
....
champagne wrote:What you are doing is not clear, but in the original code, this says
champagne wrote:If you have new assignments in the band for the current digit,
update the new "unassigned status"
update the current digit status in other bands
update the other digits status.
emerentius_ wrote:champagne wrote:If you have new assignments in the band for the current digit,
update the new "unassigned status"
update the current digit status in other bands
update the other digits status.
Where exactly are you quoting this from?
emerentius_ wrote:Sorry, I meant: Skip the check and execute the contained code unconditionally.
champagne wrote:This looks like a code written by me, so I hope that it is doing what I expected
champagne wrote: This was my understanding, but if I identified the code, I confirm that I see no reason to speed up the process
emerentius_ wrote:champagne wrote:This looks like a code written by me, so I hope that it is doing what I expected
Did you post the code in this thread already? If so, where? I'd be happy for anything that'd help me understand the intricacies of the solver.
emerentius_ wrote:champagne wrote: This was my understanding, but if I identified the code, I confirm that I see no reason to speed up the process
Do you mean, you don't see why that would speed it up? There is not much code inside and branch misprediction can be costly.
champagne wrote:I don't understand "branch misprediction". This code has been studied by many guys (and is directly derived from the original code) The inside code is activated if and only if an assignment took place in the update sequence just above. Even using the pre processor, it contains about 10 instructions.
jczsolve mine mine with change
sudoku17
time [s] 0.202 0.204 0.182
instructions 683,716,125 744,529,659 825,465,246
instr/cycle 1.16 1,25 1.5
branches 110,258,289 94,151,698 95,898,610
misses 10,447,095 10,346,431 7,355,023
top50k
time [s] 0.34 0.335 0.294
instructions 1,060,183,483 1,137,223,944 1,221,260,048
instr/cycle 1.08 1,13 1.41
branches 170,937,968 143,608,199 145,150,639
misses 19,495,500 19,436,784 13,925,122
hard20x500
time [s] 1.646 1.665 1.536
instructions 6,226,479,344 6,650,678,851 6,905,523,959
instr/cycle 1,28 1,35 1,53
branches 1,015,336,637 923,752,040 913,476,946
misses 82,979,035 83,671,900 61,916,728
10x_hard375.txt 500x_hard20.txt 10x_top1465.txt sudoku17.txt top50k.txt
jczsolve 0.834 1.625 0.286 0.201 0.341
rusty jczsolve 0.684 1.350 0.252 0.177 0.286
ratio 1.22 1.2 1.13 1.14 1.19
emerentius_ wrote:I've changed the heuristic in GuessFirstCell to always check the first cell for each of the 3 bands and to choose the cell with the minimum number of possibilities (rather than stop at the first existing unsolved cell). This has no effect on easy sudokus where GuessFirstCell is never called but speeds up very hard sudokus on average by over 10%. I've checked it with your collection of potential hardest from 2017-12. The guess function is also sometimes called in sudoku17 but has no meaningful effect on speed there.
I'm hosting my code here, in case someone is interested. This is the solver's source file and this is the command line program I'm using for benchmarks.
emerentius_ wrote:I never figured out what UPDN or UPWCL was supposed to stand for.
...
Code still available at the Github repo