Hi, people!
I need fast Sudoku solver for my exhaustive search projects. For 3 last years I used JCZSolver 1.0 and I was quite satisfacted by that solver. Two weeks ago I had a possibility to test
fsss2 solver by Mladen Dobrichev.
Mathimagics help me to plug in
fsss2 solver and explain the way to call this solver from traditional C programs.I am very grateful to him for his help!
Some words about by computer. It's rather old notebook with 64-bit CPU Intel Core2 Duo CPU T8300 @ 2.40GHz. (CPU supports SSE4.1 instruction set.) OS - MS Windows 7 32-bit, MinGW32 with gcc.
In fact I need 2 functions only to perform exhaustive search.
is_puzzle_valid(puzzle) - it returns "yes", if the puzzle is valid (has unique solution), otherwise - "no". No solutions at the output are required.
fill_solution_grid(puzzle,solution_grid) - it returns "yes" and solution_grid (1st available solution), if the puzzle has at least one solution, "no" - if the puzzle has no solutions.
Speed of the
fill_solution_grid(puzzle,solution_grid) function isn't important, because it is called less frequently, than the
is_puzzle_valid(puzzle) function. But speed of the
is_puzzle_valid(puzzle) function is crucial for my exhaistive search procedure. So,
is_puzzle_valid(puzzle) function only was tested in benchmark tests. This function was modelled by
dSolve(puzzle,NULL,NULL) call for
fsss2 solver and by
JCZSolver(puzzle,NULL,2) call for
JCZSolver.
I prepared benchmark file with 10000 puzzles from my real exhaustive search project. All puzzles have multiple solutions. Each puzzle is solved 1000 times to remove time to read this puzzle from the benchmark file. So, 10000 puzzles are solved 1000 times each, totally 10 millions puzzles are solved during benchmark run. Here are results.
- Code: Select all
JCZSolver - 113000 puzzles/sec (8.8 us per puzzle)
fsss2 - 254000 puzzles/sec (3.9 us per puzzle)
So, you can see that on my benchmark
fsss2 is 2.25 times faster than
JCZSolver. I suspect, that cause is that
fsss2 uses SSE4.1 (128-bit registers), but perhaps
JCZSolver doesn't exploit 128-bit registers feature.
One can find my benchmark puzzles by the link
http://sites.google.com/site/sergsudoku/benchmark.zip,
JCZSolver benchmark program - by the link
http://sites.google.com/site/sergsudoku/JCZSolver_benchmark.c,
fsss2 benchmark program - by the link
http://sites.google.com/site/sergsudoku/fsss2-32_benchmark.c.
Serg