Can matlab automatically make my code parallel

2 vues (au cours des 30 derniers jours)
Xinyi Shen
Xinyi Shen le 15 Fév 2015
My department in UCONN has purchased a MDCS license that will be delivered soon to run our hydrologic model parallel. Before it is delivered, I have a question regarding the parallelism of matlab. Our model runs in a time series form. In time domain, each iteration depends on its previous one. Therefore, the for loop with regard to time cannot be parallelized. However, since it is also spatially distributed, we are looking for parallelize it spatially between grid-cells.
With in each iteration, the code has been already fully vectorized, which means we do not loop over grid-cells. All computational steps include only basic arithmetic, logical operation and the accumarray functions on all cells as input and output.
I heard rumors that matlab could automatically make your code parallel (i.e., utilize all cores a single computer and utilize all processors/cores of a cluster) if only the code is fully vectorized . For a single multi-core computer, you need to do nothing while for a cluster, you only need to set your variables as distributed array.
I doubt the authenticity of this rumor because when I run the code without parfor or spmd, matlab does not use all my cores and the CPU occupation is 1/n of 100% where n is the number of cores.
Please let me know if this rumor is true. Thanks.

Réponses (1)

John D'Errico
John D'Errico le 15 Fév 2015
Even without tools like parfor, many tools in MATLAB will automatically start using multiple processors, but only when the problem is big enough to warrant it. Because of overhead, using two processors is not fully twice as fast as the use of one. In fact, it may be slower.
I do often see MATLAB using multiple cores on some problems. But it needs to be something sufficiently big.
This for example, is sufficient to utilize 5 of 8 cores on my CPU:
n = 9000;A = randn(n)*randn(n);
With some effort, at times I've seen almost all 8 cores running nearly flat out.

Catégories

En savoir plus sur Parallel Computing 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!

Translated by