C and C++ performance comparison in numerical computation
Hi there!
I have been writing this library as a summer project and I thought on writing it on C++ and then write a C wrappers collection (interface) so that C user could use it. But then I thought... shouldn't I write the numerical cores in C and do the interfaces in C++? My question is: up to which point is C better than C++ for required-performance codes such as numerical PDEs? I asked that question to the guy who developed Overture and he told me that as long as I could keep my C++ code just as a C code, performance shouldn't be compromised. Nonetheless, Overture has every numerical core written in C and Fortran and the interface written in C++. Thanks in advanced! \m/ |
Quote:
Quote:
Quote:
If you are less skilled, there are many performance pitfalls in C++, ways in which a less skilled programmer might unknowingly kill performance in C++, where a similar performance mistake in C would be more obvious. Quote:
C++ does not inherently add any overhead. If you code the same thing in C++ as you would have in C, you get the same performance. I wouldn't write performance critical code that way. I would write it better in C++ than in C. But I'm unusual. Quote:
Lots of performance critical numerical code is written in Fortran, maybe because that is what the algorithm experts writing the code have learned to think in. It sure isn't from any real advantage of Fortran compared to C++ |
johnsfine: Thank you!
That was an amazing reply and I appreciated it! |
Quote:
|
SigTerm: Awesome!
Thank you and you are right! Performance should be measured and off course I will! Thanks! |
|
|
Quote:
Kevin Barry |
Quote:
Quote:
I don't want to get much more specific about what should or shouldn't be in numerical PDE code, because that could get too close to some of my closed source professional work. |
Quote:
Kevin Barry |
Sergei: Wow! Those are excellent links, particularly I learned a lot while reading about Armadillo for C++. Similarly, IML with SparseLib++ seem both very useful.
Thank you! H_TeXMeX_H: The website about benchmarks for programing languages is very cool! I could run a couple of them to back my desicion up about selecting the language. Thank you! |
ta0kira: Your comment was very useful! I will take care of the iterative parts! Thank you for tailoring your answer toward PDE solvers development!
I believe that performance in numerical simulation is important but correctitud also matters. In early stages of development, I will focus of correctitud rather than in performance; nonetheless, performance will not be disregarded in an point! johnsfine: Thank you for your remarks! YES, I like templates, specially in this kind of libraries where one generally keep different versions to account for different data types for the scalars involved in you algorithm. Thank you guys! |
Thanks to all of you! I'm calling this one SOLVED!
|
All times are GMT -5. The time now is 11:03 PM. |