Borrar filtros
Borrar filtros

how MATLAB's parfeval function works?

2 visualizaciones (últimos 30 días)
Jack
Jack el 12 de Feb. de 2015
Comentada: Edric Ellis el 13 de Feb. de 2015
In MATLAB documentation we have a code example for parfeval function. I have some questions about it. This is the code:
p = gcp();
% To request multiple evaluations, use a loop.
for idx = 1:10
f(idx) = parfeval(p,@magic,1,idx); % Square size determined by idx
end
% Collect the results as they become available.
magicResults = cell(1,10);
for idx = 1:10
% fetchNext blocks until next results are available.
[completedIdx,value] = fetchNext(f);
magicResults{completedIdx} = value;
fprintf('Got result with index: %d.\n', completedIdx);
end
1. How parfeval works? This function send every (idx) evaluational of magicfunction to a specific worker?
2. If we have only one line code f = parfeval(p,@magic,1,10); . How this code works? It will send evaluation only to one worker and returns the output? So what is difference between parfeval and parfevalOnAll?
3. What is difference between fetchNext and fetchOutputs? Why after first for loop we need fetchNext and a second loop to get the results? We don't have all results after first loop? why? I think we are waiting for workers to complete the process in second loop. Is this true? We can't do it without any loop?
4. I think we can use magicResults{idx} = fetchOutputs(f(idx)); in second loop. We have same results. what is difference between these two structures?
  1 comentario
Edric Ellis
Edric Ellis el 13 de Feb. de 2015
This question was fairly comprehensively answered over on stack overflow. Is there any more detail you need?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Asynchronous Parallel Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by