Parallel toolbox using parfor loop

hello all i have the following part of my code: parpool(8);
tm00=tic;
parfor i=1:1:size(sss0,2)
maxflows((sss0{1,i}(1,:)),(sss0{1,i}(2,:)),(sss0{1,i}(3,:)),source,sink);
end
tm01=toc(tm00)
the variable sss0 is a cell array represents a graph in each cell, i am using parallel to speed up the computation, i want to compute the maximum flow for each graph from source to sink. maxflows is a function that i was create it to adjust parameter then use maxflow built in function to calculate it. when i use 8 workers i get longer time from using 1 worker
any suggestions

Risposte (1)

Matt J
Matt J il 2 Apr 2018
Modificato: Matt J il 4 Apr 2018

0 voti

Typically, this is because the processing task is too simple to make the costs of parallelizing the execution worthwhile. If maxflows is doing very little work, for example, the cost of broadcasting the data to the parallel workers could dominate whatever maxflows is doing.

5 Commenti

thanks Matt i tried to minimize number of clusters to make each cluster contains more data i have cell array contains 4 elements (arrays) 1- 3*99681 2- 3*258840 3- 3*29646 4- 3*4465 when i run it on single worker it takes 6.8319 when i run it on 4 workers it takes 5.9299 ????
abdullah alzaqebah
abdullah alzaqebah il 4 Apr 2018
Modificato: abdullah alzaqebah il 4 Apr 2018
yes sure i am using it for research issues and am increasing the data in each time to show the gained speed up. when i increase the data the single worker takes 304.5714 on 4 workers it takes 287.7831 which means 1.06 speed up
Matt J
Matt J il 4 Apr 2018
Modificato: Matt J il 4 Apr 2018
How many loop iterations are you doing in the 304 sec. case? To get a benefit from parfor, you need to keep the amount of data you send to each worker small, but do a large amount of computation with it once it is there.
i use the built in function maxflow in the matlab
this is the maxflow code
https://www.mathworks.com/matlabcentral/fileexchange/65167-ford-fulkerson-algorithm-for-max-flow-problem

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by