How to make Matlab faster

17 visualizzazioni (ultimi 30 giorni)
Leon
Leon il 17 Set 2018
Commentato: Walter Roberson il 18 Set 2018
I'm running a program that takes several days to finish, but it only consumes 30% of my computer CPU and less than 30% of my RAM.
Is there a way we can configure Matlab so that it will use the computer's full capacity?
Thanks.
  1 Commento
James Tursa
James Tursa il 17 Set 2018
How can we possibly answer this? We would need to see your code, what the profiler says about where the time is being spent, whether the functions you are using are multi-threaded, whether you have a lot of disk access, etc.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 17 Set 2018
We can deduce that you probably have four cores (1 core = 25% usage), that your algorithm is mostly iterative and does not involve large arrays (automatic vectorization would use more cores), and that if you are reading files then you are not reading large volumes of data (operating system would automatically cache files using more memory.)
Depending what your algorithm does, it might be possible to vectorize it, which provides more opportunities for MATLAB to automatically invoke high-performance multithreaded libraries.
If you are applying to same iterative algorithm to a number of different starting points with the calculations being independent of each other, then it might be possible to improve by running several copies of the algorithm at the same time using the Parallel Computing toolbox.
But we do not have enough information to give more than generalities.
  2 Commenti
Leon
Leon il 18 Set 2018
Many thanks! Good to learn of parallel computing toolbox.
Walter Roberson
Walter Roberson il 18 Set 2018
Note that the Parallel Computing Toolbox often does not help. Each worker runs as a separate process, and it is necessary to send commands to the process and to send the data to be processed, and afterwards it is necessary to pull back results. It is common for the overhead of these things to be more costly than just executing the code in serial.
Parallel Computing Toolbox works best for transferring comparatively little data, and for doing a lot of iterative computation on it. I say iterative because vectorized computation on large vectors is often handed over to high performance libraries to run in multiple cores automatically, so that kind of computation is hampered by not just running without the toolbox but using all available cores.
The Parallel Computing Toolbox cannot handle all access patterns. It is common to need to tune code to get it to work with parfor.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by