GalSim-developers/GalSim — pull request #212 by rmjarvis (2012-07-03 17:58:46+00:00)
Title: #67 A first foray into multiprocessing with GalSim

The nominal issue here was to write unit tests to check that the random number generator works correctly in multi-processing mode. So I did that, and they do.

I also decided to write another demo script that uses multiple processes for making a big Great08-style image. I chose to do bulge + disk profiles with parameters chosen as random variates. It also uses photon shooting for even more usage of the random number generators.

To do this, I needed to enable pickling for the Image classes, which I figured out how to do. We'll probably want to do something similar for our other wrapped C++ classes, but I only needed Image for this script, so I didn't do any other classes here. Now that there is an example to follow, it should be pretty straightforward to pickle the others. Here is a [reference page](http://www.boost.org/doc/libs/1_49_0/libs/python/doc/v2/pickle.html) that explains several options for how to do this. I chose their option 4 "Light-weight alternative", which was pretty easy to implement.

Anyway, the script makes two images. Once using just a single process. Then again making the same image using multiple processes. It ends with an assert that the two images are (exactly) equal. This works on the two machines I tested it on.