parallel processing time problem
조회 수: 2 (최근 30일)
이전 댓글 표시
hello i have a question about the time when i use single core and when i use 4 cores at the first time i had time equal 15 second also this is the code
-----------------------
a=imread('something.jpg');
b(1:size(a,1),1:size(a,2))=0;
c(1:size(a,1),1:size(a,2))=0;
for i=1:size(a,1)
for j=1:size(a,2)
for k=1:size(a,3)
b(i,j)=b(i,j)+a(i,j,k);
c(i,j)=b(i,j)/3;
end
end
end
---------------------
when i try to use matlabpool i had time larger than i had it with single core so what is the problem ?? by the way i used this code with multi core
----------------------
a=imread('something.jpg');
b(1:size(a,1),1:size(a,2))=0;
c(1:size(a,1),1:size(a,2))=0;
parfor i=1:size(a,1)
parfor j=1:size(a,2)
for k=1:size(a,3)
b(i,j)=b(i,j)+a(i,j,k);
c(i,j)=b(i,j)/3;
end
end
end
-------------------------- thank you
댓글 수: 0
답변 (1개)
Edric Ellis
2013년 5월 13일
Firstly, you should note that only the outermost PARFOR has any effect. All the available parallelism is used there, so the inner PARFOR makes no difference.
In this case, the amount of computation you're doing inside the loop compared to the amount of data you're accessing is much too low. In this case, I think vectorization should give you much better results. I think in this case can't you simply do:
a = imread('something.jpg');
b = sum(a, 3);
c = b ./ 3;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!