need simple example using pmode

2 ビュー (過去 30 日間)
huda nawaf
huda nawaf 2013 年 3 月 12 日
hi,
*i need simple example using pmode . for example : if I have this array
x=[2 90 2 17 80; 5 3 2 90 8; 60 74 1 2 3;55 6 4 11 0];
how i can use my two workers to sum this array, where each worker will work on part of array, the collect the result.
I don't know how i partition the array on two workers , the how to collect the results.
please , i need simple example about that.
thanks in advance*

回答 (1 件)

Konrad Malkowski
Konrad Malkowski 2013 年 3 月 13 日
Here's an example how to use
distributed
arrays and how to use SPMD:
matlabpool open 2
x = 1:1:100;
y = 100:-1:1;
dx = distributed(x);
dy = distributed(y);
dz = dx + dy
spmd
dz
end
Note that dz is distributed across two workers :-).
Hope this helps
  3 件のコメント
Konrad Malkowski
Konrad Malkowski 2013 年 3 月 15 日
Yes you could use this functionality in the way that you describe. You will need to check documentation for distributed/codistributed arrays to see which options are supported.
You can also do MPI like programming in MATLAB using labSend, labReceive commands, etc.
huda nawaf
huda nawaf 2013 年 3 月 16 日
編集済み: huda nawaf 2013 年 5 月 12 日
I have a matrix , say x(10*10); and I have two workers what I need is running the code for each part of matrix. I want to ask , must I write the code two times as follows, then coolect the result? what if I have 5 workers, must write the code 5 times?
matlabpool open 2
x=dlmread()with size 10*10
for i=1:5
for j=1:10
process....
end
end
result=z
for i=6:10
for j=1:10
process....
end
end
result=z1;
dx = distributed(z);
dy = distributed(z1);
dz = dx + dy
spmd
dz
end
thanks in advance

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by