How to make Matlab faster

19 次查看(过去 30 天)
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 个评论
James Tursa
James Tursa 2018-9-17
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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-9-17
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 个评论
Leon
Leon 2018-9-18
Many thanks! Good to learn of parallel computing toolbox.
Walter Roberson
Walter Roberson 2018-9-18
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by