Reputation: 3052
Say I have the following code:
a = 5;
x = function1(a);
y = function2(a);
What I want to do is to assign the computation of function1 to one worker and the computation of function2 to another worker such that I can compute them in parallel. Each of the functions have to be computed in serial, so I cannot use spmd around the statement. Are there any other possibilities?
Upvotes: 1
Views: 36
Reputation: 25140
You could use parfeval
for this, like so:
a = 5;
xfut = parfeval(@function1, 1, a); % second arg is number of outputs from function1
yfut = parfeval(@function2, 1, a);
You can get the outputs of the functions using the method fetchOutputs
on xfut
and yfut
. You can use the wait
method to wait until one or both complete.
Upvotes: 1