i have a question on speed up application built by MATLAB software, i need to know the affect of using vectorization and parallel computation on speed up the application ? and if there is better method than both previous way in such case ? thanks
Asked
Active
Viewed 125 times
0
-
it depends on the particular case. Do you have any code you want to speed up? – Robert Seifert Oct 11 '13 at 13:26
-
Have a look to http://www.mathworks.com/discovery/matlab-gpu.html – Vuwox Oct 11 '13 at 14:43
1 Answers
3
The first thing you need to do when your MATLAB code runs too slow is to run it in the profiler. In recent versions of MATLAB, this can by done by pressing the "Run and Time" button on the main toolbar. This way, you will now which functions and which lines in these function take up the most time. Once you know this, you may do one of the following, depending on your circumstances and the nature of the particular piece of code:
- Think if your algorithm is the most optimal one in terms of O() complexity.
- Try turning loops into vector operations. The efficacy of this has declined in recent versions of MATLAB because of improvements in how loops are executed.
- If you have a multi-core CPU try using the parallel computing toolbox. If your code parallelizes well, you will get a sped up nearly equal to the number of cores.
- If you have an nVidia GPU try using the GPU support. You can get a speed-up by a factor of 10 or more with some problems, but not all problems are amicable to this sort of optimization.
- If everything else fails, you may outsource the slowest piece of your code to a low level language like C. See here for how to do this. You could then use low-level profiling tools like Intel vTune to get the absolute maximum speed from the low-level code.
- If it is still too slow, you may need to buy an FPGA. See here for a brief tutorial.

ziutek
- 585
- 1
- 4
- 12