You will find here all the code and data necessary to reproduce my tests.
The Python solver is contained in file hangman.py. To run it on the supplied large input set, the syntax is:
python hangman.py [-w [num_workers]] < B-large-1.in > B-large-1.out
With the -w option, the multi-worker solver is used. You can ask for a specific number of workers, or let Python decide, generally based on the number of available CPUs on your system. You can even run with one worker: it should take almost the same time as with the sequential solver. There is a small overhead for starting a new process and marshalling data between the main process and the worker, but it should stay small.
Without the -w option, the sequential solver is used: only the main program processes the input.
The Java solver source file is hangman.java. To compile it, you need at least JDK 1.5. Just run:
Then, the syntax to run it from the command line is:
java -cp . hangman [-w [num_workers]] < B-large-1.in > B-large-1.out
The meaning of the command-line options are the same as for Python (see above). If you run the program on Windows, the result file will contain CR-LF line endings, so you need to compare the results with diff -b.
- is what you should open to run the solver
- is the generic Pool/master implementation
- is the part that parses the input and posts tasks to the worker pool
- is the almost generic worker
To run the program in non-web worker mode, just click the "Run without workers" button. Be aware that the browser will probably tell you every few seconds that a script is making the page unresponsive. You need to allow it to continue if you want it to finish.
To run the program with web workers, you need to create a pool first. When you do that, a row of green squares will appear, to track the activity of allocated workers. Then, launch the computation with "Run". The "Queue size" will move briefly to 10, workers will turn red when busy. The result will appear once the queue is empty and all workers have finished.
The C++ source is hangman.cpp. To compile it with GCC (at least version 4.2 for OpenMP support), do:
g++ -O3 -std=c++0x hangman.cpp -o hangman -fopenmp
Then run with:
./hangman [-w [num_workers]] < B-large-1.in > B-large-1.out
The meaning of the command-line options are the same as for Python (see above).
- is the large input set.
is the expected result. If you produce your result in B-large-1.out, you can check that the result is correct with:
diff -b B-large-1.out B-large-1.check
The -b option is necessary to account for possible differences in whitespace and line endings.