Memory Vs Code
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Daniel Shub
2012-4-9
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 个评论
Jan
2012-4-10
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!