parallel processing time problem
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Edric Ellis
le 13 Mai 2013
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 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!