|
[Sponsors] |
April 25, 2017, 04:36 |
Why is c++ taking longer than MATLAB?
|
#1 |
New Member
Rob
Join Date: Apr 2017
Posts: 1
Rep Power: 0 |
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? |
|
April 25, 2017, 15:14 |
parrallel solution
|
#3 |
New Member
A.MAROUF
Join Date: Dec 2016
Posts: 22
Rep Power: 9 |
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 |
|
April 25, 2017, 15:23 |
|
#4 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
April 25, 2017, 21:47 |
|
#5 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66 |
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?
|
|
April 30, 2017, 13:05 |
|
#6 |
New Member
Ali Berk Kahraman
Join Date: Dec 2015
Location: Braunschweig, Germany
Posts: 14
Rep Power: 10 |
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?
|
|
April 30, 2017, 14:34 |
|
#7 |
Member
William
Join Date: Aug 2016
Posts: 56
Rep Power: 10 |
I don't know how your code is or what it does. Are they using sparse matrices in Matlab? They reduce the calculation allot.
|
|
Tags |
c++, compiler, matlab, speed, visual studio |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to start Fluent with Matlab?? | Jay Hu | FLUENT | 8 | November 9, 2022 07:30 |
Export/Import data contour plots with Matlab | meangreen | FLUENT | 11 | October 28, 2020 11:06 |
Very small Matlab job: post-processing OpenFOAM (.CSV) results | RbBb | CFD Freelancers | 1 | July 11, 2016 10:00 |
Linking with Matlab?? | LostinSpace | Phoenics | 0 | March 25, 2013 06:39 |
Live connection Matlab VS OF | levka | OpenFOAM Running, Solving & CFD | 0 | July 10, 2012 05:15 |