Modify the topographica script so that it runs with mpiexec
Make a new subclass of CFProjection, e.g. MultiProcessorCFProjection , that will be a plug-in replacement for CFProjection but with parallel capabilities. At first, MultiProcessorCFProjection does exactly the same thing as CFProjection. Make your test .ty file(s) use this class instead of CFProjection.
To make the rest of the steps easier, turn off optimization (remove _opt from the various components in your copy of tiny.ty or other testing file), so that you don't have to worry about the C code's implicit assumptions. Also turn off learning, for now. Also turn off randomness in the initial weights -- use Gaussian patterns for now.
Find out how to instantiate CFProjection
Once that works, change the constructor or other initialization routines, if any, for MultiProcessorCFProjection to divide the work between compute nodes from the start, so that each node only has a copy of the weights relevant to the processing that it has to do. At first, it's probably easiest if the master node (rank 0) has a copy of all the weights, while the others have only a subset. While in this stage, we can debug everything using the usual plotting and analysis mechanisms that use the data from the master node, without having to reimplement all of that just yet. Implementation plan:
[Chris] Refactor CFProjection to replace the list of lists of cfs (self._cfs) with a flattened list (self.flatcfs?), to remove the assumption that all CFs are stored in 2D arrays. This will require changing all of the C code, which is a pain, but it should actually significantly simplify it.
[Chris] Make the MaskedCFiter use self.flatcfs instead of the self.cfs numpy object array. Again, this should simplify the implementation of MaskedCFIter , while making it simpler to keep everything coherent. Actually, we should probably just make the mask update the flatcfs list whenever it changes, so that only unmasked cfs are in the list; otherwise we'll have a problem relating the 2D mask to the 1D list. Up to this point, none of the changes should involve multiprocessing at all.
When multiprocessing (or on a single processor just for testing), split up the list and distribute it to multiple Python processes, so that any operation invoked on MultiprocessorCFProjection is actually distributed across all processors and run on MultiprocessorCFProjection running on that processor, using its local list of cfs. It's probably best just to assert numpy.alltrue(mask) (or whatever is syntactically correct), and not worry about masks at all.
Find out what exactly CFSheet consists of, and how to distribute it
Figure out what topo.sim['V1'].activity is
Read through the rest of the class
Read through the ProjectionSheet class
Figure out how simulation.connect and simulation.run work
Find out how exactly CFProjection is dotproducting cfs
Figure out what input_sheet_slice.submatrix() is
Figure out how CFIter works and how to iterate from and to a certain point in matrix
Create the s/r mechanism
Using the s/r mechanism, send cfs to slave nodes and store. Check if sending and receiving work
Create new activate() method in MPI_CFProjection
At each call broadcast the input_activity matrix
Create according method in MPI_io
Create according method in MPI_client
Add broadcasting to MPI_CFProjection.activate()
Send an appropriate portion of CF's to each node
Create according method in MPI_io
Create according method in MPI_client
Add broadcasting to MPI_CFProjection.activate()
Gather resulting activities into one matrix
Compute activity on all nodes
Create methods (io,client?) for sending back resulting activities
Gather activities into new matrix at MPI_CFProjection
Transform the non-zero part into a list
Send
Gather at master node and put into the activity array, calculating appropriate position for gathered activity values
Commit to GIT
Debug
Commit again
Test, test, test...
Talk to Jim and Chris
No comments:
Post a Comment