フィルターのクリア

parallel processing time is bigger,

1 回表示 (過去 30 日間)
Julio
Julio 2014 年 2 月 21 日
コメント済み: Julio 2014 年 2 月 23 日
I have a code comparing a to process using parfor and for, but the time of the parfor is bigger thans using "for". here below the program:
Count=12000000;
MSB=A(2:2:Count);
LSB=A(1:2:Count);
DiffB=zeros(Count/2,1);
B=DiffB;
tic
for i=2:2:Count
B(i/2)=A(i)*256 + A(i-1);
end
for j=1:size(B,2)-1
if((B(j+1)==0) && (B(j)==4095))
DiffB(j)=1;
else
DiffB(j)=B(j+1)-B(j);
end
end
t1=toc
tic
parfor i = 1:Count/2
B(i)=MSB(i)*256 + LSB(i);
end
C=B;
parfor j=1:size(B,2)-1
if((B(j+1)==0) && (C(j)==4095))
DiffB(j)=1
else
DiffB(j)=B(j+1)-C(j);
end
end
t2=toc
matlabpool close
disp('Tiempo differencia')
t2-t1
time for "FOR" is 0.6016 sec and the time for "PARFOR" 5.5039 sec can someone can tell me what did I make wrong?
  1 件のコメント
Julio
Julio 2014 年 2 月 21 日
NOte: before execute the code, I execute matlabpool('open',2); and it works

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

回答 (1 件)

Matt J
Matt J 2014 年 2 月 21 日
Are you running inside a script or in an mfile function? Try both.
  2 件のコメント
Matt J
Matt J 2014 年 2 月 21 日
編集済み: Matt J 2014 年 2 月 21 日
But aside from that, your compute-to-memory-access ratio looks very small. You are doing very little computation inside the loops for every element of data (LSB(i), MSB(i), etc...) that you are sending to the workers. PARFOR is intended for a situations where you are doing a lot more computational work inside the loops.
Julio
Julio 2014 年 2 月 23 日
Thanks for your answer, so the fact my process is very simple ,"PARFOR" is not usefull. thanks

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

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by