Behavior of parfeval when its input arguments get updated?
Mostrar comentarios más antiguos
Hi all,
I'd like to make sure the new function parfeval (<http://www.mathworks.com/help/distcomp/parfeval.html>) meets my need before subscribing to Matlab 2013b. My question is as follows (see the example code below).
Suppose I have a variable x which is an argument to the function used in parfeval (in my example, it is @magic). As I am collecting results and updating x, will I (a) get the same results (the update of x doesn't affect parfeval), and (b) potentially get different results due to the update of x ? I'd really like to have (b) instead of (a).
p = gcp();
% To request multiple evaluations, use a loop.
x = 0
for idx = 1:10
f(idx) = parfeval(p,@magic,1,x); % Square size determined by idx
end
% Collect the results as they become available.
for idx = 1:10
% fetchNext blocks until next results are available.
[completedIdx,value] = fetchNext(f);
fprintf('Got result with index: %d.\n', completedIdx);
x = x + completedIdx;
end
Thanks,
Regards, Thang
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Background and Parallel Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!