Why does the parallel mode slow down the speed of each core/task
Show older comments
I did not know the fact until see my log data.
I am running some time consuming optimization. Within each trial run(simulation), it's a large computation that takes about 140s if only one simulation is running(non-parallel mode). However, if the independent tasks are running simultaneously on different cores (I have a i7 processor) is applied. I discovered that the more cores I used, the slower each task runs. Below I pasted the recorded time consumption data of EACH TASK in different situations. The consumption of all the steps are in seconds.
Init IO Runoff WaterBudget StateUpdate Routing
case 1: 1-worker/task(non-parallel)
2.1372 25.5530 53.4303 7.6752 8.0341 65.8012
case 2: 2-worker/task parallel
2.2464 18.3457 50.7939 5.6472 9.0481 67.5952
case 3: 4-worker/task parallel
3.7284 25.9586 67.5640 8.6893 13.7437 88.2966
case 4: 7-worker/task parallel
6.4896 47.8143 123.9428 20.7949 25.6622 150.5722
Can anyone give me an explanation on what happened? I expected the parallel computation gave me the times of improvement, which equals to the number of cores. The results let me down obviously.
By the way, I performed those computation in my personal computer of an intel i-7 3770 CPU(with 8 logical cores) and sufficient RAM. 1-job/multi-task mode is employed in my codes. The tasks are created by createTask function rather than batch. I have already excluded the time of submitting/waiting a job and collecting the results from each worker.
Matrix(Vectorized) computation is extensively used throughout the process.(I use no loops except the computation is order dependent). Can this be a reason? Thank you!
1 Comment
Xinyi Shen
on 26 Jun 2014
Accepted Answer
More Answers (1)
Edric Ellis
on 30 Jun 2014
1 vote
Parallel workers run in 'single computational thread' mode, and this can mean that using multiple workers is no faster than using a single multi-threaded desktop MATLAB. This is especially the case when your code is already well vectorised - as vectorised calls in MATLAB are often intrinsically multi-threaded. You can check this by launching your desktop MATLAB with the '-singleCompThread' argument and checking the performance of that.
1 Comment
Xinyi Shen
on 30 Jun 2014
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!