Memory Vs Code

1 view (last 30 days)
Shani Gal
Shani Gal on 9 Apr 2012
Hi
I have a program that manipulates a large matrix size A=[1e6,5]
And I was wondering if running the code twice on a small matrix lets say A1=[0.5e6,5] and A2=[0.5e6,5] will be faster than running the code on the original matrix?
How can I found out before making changes to the code?
Thanks
Shani

Answers (1)

Daniel Shub
Daniel Shub on 9 Apr 2012
Unfortunately, there is no way to know before making changes. It really depends on what your are doing. MATLAB has a number of optimizations that kick in for various size matrices. For example, if you are doing identical processing on each column, MATLAB very well could utilize multithreading. You can read up on what functions MATLAB multithreads, but my take is that the list is not complete and sometimes wrong.
  1 Comment
Jan
Jan on 10 Apr 2012
Even the best documentation cannot answer such questions, because there are a lot of dependencies to disk speed, cache size, memory size and speed, number of (virtual) processors, concurrent tasks, programming problems like false cache sharing, etc. The only reliable method to estimate the speed gain of multi-threading is implementing both versions and compare them. Most of all if the program should run on different machines, it is even useful to keep both versions, such that the user can make the decision. Unfortunately, this means that two version must be maintained and fixing bugs will be dangerous.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!