フィルターのクリア

how MATLAB's parfeval function works?

2 ビュー (過去 30 日間)
Jack
Jack 2015 年 2 月 12 日
コメント済み: Edric Ellis 2015 年 2 月 13 日
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 件のコメント
Edric Ellis
Edric Ellis 2015 年 2 月 13 日
This question was fairly comprehensively answered over on stack overflow. Is there any more detail you need?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeAsynchronous Parallel Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by