また、やや満足できる解決を図った場合は、誰の心に思いを共有します。私もコメントを改善/インを微調整します。
基本的に、そしての良識ある方には(非常に)初歩的なモデルのスケジューラのための並列プ:
function c=est_cost_para(cost_blocks,cost_it,num_cores)
% Estimate cost of parallel computation
% Inputs:
% cost_blocks: Estimate of cost per block in arbitrary units. For
% consistency with the other code this must be in the reverse order
% that the scheduler is fed, i.e. cost should be ascending!
% cost_it: Base cost of iteration (regardless of number of entries)
% in the same units as cost_blocks.
% num_cores: Number of cores
%
% Output:
% c: Estimated cost of parallel computation
num_blocks=numel(cost_blocks);
c=zeros(num_cores,1);
i=min(num_blocks,num_cores);
c(1:i)=cost_blocks(end-i+1:end)+cost_it;
while i<num_blocks
i=i+1;
[~,i_min]=min(c); % which core finished first; is fed with next block
c(i_min)=c(i_min)+cost_blocks(end-i+1)+cost_it;
end
c=max(c);
end
パラメータ cost_it
のための空の繰り返しは、原油ブレンドの多くの異なる側面の影響が考えら分離すること:のコストは空の繰り返しに for
/parfor
ループ(きによって異なりブロック)の起動時間resp.送信データの parfor
ループだけるかどうか。私の主な理由捨てるものとはならないようにしたいて算/決をきめ細かいます。
私は、上記のルーチンを決めるcut-off次のようになっています:
% function i=cutoff_ser_para(cost_blocks,cost_it,num_cores)
% Determine cut-off between serial an parallel regime
% Inputs:
% cost_blocks: Estimate of cost per block in arbitrary units. For
% consistency with the other code this must be in the reverse order
% that the scheduler is fed, i.e. cost should be ascending!
% cost_it: Base cost of iteration (regardless of number of entries)
% in the same units as cost_blocks.
% num_cores: Number of cores
%
% Output:
% i: Number of blocks to be calculated serially
num_blocks=numel(cost_blocks);
cost=zeros(num_blocks+1,2);
for i=0:num_blocks
cost(i+1,1)=sum(cost_blocks(end-i+1:end))/num_cores + i*cost_it;
cost(i+1,2)=est_cost_para(cost_blocks(1:end-i),cost_it,num_cores);
end
[~,i]=min(sum(cost,2));
i=i-1;
end
特に、いを膨らませ/の値を変更する est_cost_para
る想定外 cost_it
最も楽観的なケジューリングが可能です。私として残すために、それは主としてどうなるかはわからないようです。保守的な(避け供給も大きなブロックの並列ループ)は、このコースの追加割合のバッファーとしても使用電源>1を膨らませる並行します。
ることにも注意 est_cost_para
呼続以下のブロックが使っている変数名 cost_blocks
両方のルーチンは、サブセットを生成するための開発ツールです。
と比較してアプローチに私の語に絶問いに見える二つのメリット:
- の比較的複雑な依存性のデータもブロックの数などのコスト)とのコア数が捕獲したり、スケジューラの模擬することはできずング式。
- 計算のコストの全ての可能な組み合わせのシリアル-パラレル分布とその最小はできません"こだわった"ものを読みながらのデータからは一面例によるジャンプは大型のデータですが、小さいとの比較をしています。
もちろん、漸近的計算量で呼び出し est_cost_para
その中にループすべての時間が、自分の場合(num_blocks<500
)これは絶対にできます。
最後に、場合にも価値の cost_it
なかには現在そのもの、のみによって算出してくださいによる測定の実際の実行時間に各ブロックについては、純粋に並列部分にアピールするとともに、そのようにこれらのデータのコスト予測した動きを習得することの値が更新され cost_it
は、次の通常の使用の違いをトータルコストと並列にコストを挿入することによりコストがゼロの装着式)。これも"に収束"が最も有用な価値 cost_it
の問題の質問です。