multithreading - How to parallelize Sudoku solver using Grand Central Dispatch? -
As a programming drill, I have just finished writing a sudoku solver that uses back-tracking algorithms (see for a simple example written in C)
To make this one step further, I would like to parallel it using the Snow Leopard GCD so that it runs on the core of all my machines. Can someone point me out how should I go about doing this and what code should I change? Thanks!
Matte
For one, back tracking is a deep search before Not directly parallel, because any new calculation result can not be used directly by other threads. Instead, you have to break the problem early, i.e. the thread # 1 starts with the first combination for the node in the back tracking graph, and makes the subfifty do the rest to find the rest. Thread # 2 starts with the second and possibly the second possible combination In short, possible combinations of n at the top level of the search space (possibly not "forward-track") N , then assign these to n n the starting point for threads.
Although I think the idea is fundamentally flawed: many Sudoku changes are resolved in a few thousands further cases + move towards the back, and a thread is solved within milliseconds . It is really so fast that the small coordinates required for some threads (suppose that the n threads calculation time is less than the original timing of 1 / n ) core / multi - The CPU is not negligible compared to the total running time, thus it is not a more efficient solution than any other occasion.
Comments
Post a Comment