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?
You could use
parfeval
for this, like so:You can get the outputs of the functions using the method
fetchOutputs
onxfut
andyfut
. You can use thewait
method to wait until one or both complete.