I am currently trying to run experiments in parallel using MATLAB 2013b that are very time-consuming.
One strategy to speed things up is to use the results from one experiment to "warm start" the next experiment. In my case, this is a little complicated because each experiment has one of n_types
types, and I can only use an experiment of type k
to speed up another experiment of type k
.
Unfortunately, I cannot implement this strategy with the parfor
function because it would require each job to update a common variable (which stores the warm start information). That said, I have heard that it might be possible to do this using the spmd
framework.
I am wondering if someone could help me 'translate' the following block of generic (non-working) parfor
code into something that will work in the spmd
code.
n_cores = %provided by user (# of workers that are available)
inputs = %provided by user (n_jobs x 1 cell array of structs)
types = %provided by user (n_types x 1 array of integer values)
n_jobs = length(inputs)
n_types = length(unique(types))
outputs = cell(n_jobs,1) %cell array to store job output
warm_starts = cell(0,n_types) %empty 0 x n_type cell array to store warm start data
matlabpool('open',n_cores)
parfor i = 1:length(jobs)
%run myfun in parallel
outputs{i} = myfun(inputs{i},warm_starts(types(i)));
%update warm start data for experiments of this type with data from current experiment
warm_starts{end+1,types(i)) = get_warm_start(job_outputs{i});
end
It's not quite clear to me how many different
warm_starts
you might want to store for eachtype
. I'm going to assume you want to store just 1. Here's how you might do that:The main things I've done there are to manually split the work up so that each worker operates on a chunk of the 'jobs', and then use GCAT to broadcast warm start information after each round.