Why is c++ taking longer than MATLAB?
Comparing my run times with other people coding the same method is revealing that my c++ code is taking about 30% longer than their MATLAB codes when it should be much, much faster. I cannot seem to figure out why is this.
I use Visual studio 2015 community as my compiler. I use of Ox (full optimization). My hardware is comparable to my peers. Anyone have any ideas? |
You wrote poorly optimized code.
|
parrallel solution
Well from what i know, is that i compared once codes : Python & Matlab & Fortran , the Fortran is the most faster.
To answer your question : you can install ( openmpi ) than try some tutorials to make your code parallel and if your machine has 4 processors your code will be 4Xtimes faster :) |
If he managed to get slower execution in c++ than in matlab I don't think parallelization is the next logical step.
He should really investigate what slows down his code, for example by using a profiling tool. |
For many built-in functions, Matlab accelerates the routine by running them in parallel. I.e. max, min, etc. Is your c++ purely serial? Are you even comparing the same code?
|
Since you are using Visual Studio, if you forgive me for being so obvious, are you sure you are "running" the code? Perhaps you are debugging the code using built in F5 (at least this was the way it was in an older Visual Express) so the IDE is actually losing time debugging your time. You might want to try reaching the directory where your .exe file is and run it from there perhaps?
|
I don't know how your code is or what it does. Are they using sparse matrices in Matlab? They reduce the calculation allot.
|
All times are GMT -4. The time now is 04:50. |