フィルターのクリア

How can I choose which lines of a for loop to send to each worker?

3 ビュー (過去 30 日間)
Marta
Marta 2017 年 4 月 26 日
コメント済み: Marta 2017 年 4 月 26 日
Hi!
I am running a for loop where I compute 3 variables separately and then add them all up in the end, i.e.
for time=0:endtime
calculate_a(a,u);
calculate_b(b,u);
calculate_c(c,u);
u=a+b+c;
end
I would like to parallelise this loop so that each calculation of a, b and c is done by an individual worker and they are all put together for the u calculation, i.e.:
for time=0:endtime
calculate_a(a,u); % performed by worker 1
calculate_b(b,u); % performed by worker 2
calculate_c(c,u); % performed by worker 3
% all workers share their outcome and perform
u=a+b+c;
end
I am new to parallel computing in Matlab. Can you help me figure out how to go about this? Also, are there any problems in creating a stand-alone program (.exe) from Matlab when using parallel computing?
Many thanks! Marta
  2 件のコメント
Adam
Adam 2017 年 4 月 26 日
If you have a for loop like that I would assume it is more usual to parallelise the for loop with a simple parfor than to parallelise the contents of the loop which I guess would have to be done with batch or spmd commands
Marta
Marta 2017 年 4 月 26 日
Hi Adam. Thanks for the tip. I can't parallelise the for loop. It is a sequential loop: u evolves with time and I plot it every so often.
I will look into batch and spmd, thank you for the tip, Marta

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Parallel Server についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by