Re: [Boost-users] [boost] C++ Performance
Forwarded to boost-users... Am Dienstag 20 November 2007 16:24:42 schrieb nisha kannookadan:
Hi everybody
Im a quite new boost user and I wonder, why C++ Program is so slow.
I wrote a program, and I have the same program in Matlab, I expected that my C++ version is much faster, but its not.
I use matrices, vectors, matrix- and vector proxies. Do some solving and compute calculations with prod, element_div, etc..
Is boost in general slower than matlab, should I use something else?
Id be real happy about any help.
Regards Nisha K _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Im a quite new boost user and I wonder, why C++ Program is so slow.
Check out some of the literature on your platform- if it is ia-32, see the links I posted earlier or go to Intel site. Don't assume that because you have a math program that you are limited by some "math thing." On larger data sets it is almost impossible to get a cache ignorant implementation of anything to run fast. And, don't rule out file IO or some other limitations. I'm probably paranoid about this because on cygwin it has been a big problem but time the suspect code before assuming it to be the time sink. Things like exceptions can be a big problem- if you have an ill conditioned or pathological problem and let the FPU throw 10 billion exceptions, it will be slow- it could be your other program checks for stuff like this. Mike Marchywka 586 Saint James Walk Marietta GA 30067-7165 404-788-1216 (C)<- leave message 989-348-4796 (P)<- emergency only marchywka@hotmail.com Note: Hotmail is blocking my mom's entire ISP claiming it is to reduce spam but probably to force users to use hotmail. Please DON'T assume I am ignoring you and try me on marchywka@yahoo.com if no reply here. Thanks.
From: maikbeckmann@gmx.de To: boost-users@lists.boost.org Date: Tue, 20 Nov 2007 20:07:42 +0100 Subject: Re: [Boost-users] [boost] C++ Performance
Forwarded to boost-users...
Am Dienstag 20 November 2007 16:24:42 schrieb nisha kannookadan:
Hi everybody
Im a quite new boost user and I wonder, why C++ Program is so slow.
I wrote a program, and I have the same program in Matlab, I expected that my C++ version is much faster, but its not.
I use matrices, vectors, matrix- and vector proxies. Do some solving and compute calculations with prod, element_div, etc..
Is boost in general slower than matlab, should I use something else?
Id be real happy about any help.
Regards Nisha K _________________________________________________________________ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_________________________________________________________________ Your smile counts. The more smiles you share, the more we donate. Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline
Am Dienstag 20 November 2007 16:24:42 schrieb nisha kannookadan:
I use matrices, vectors, matrix- and vector proxies. Do some solving and compute calculations with prod, element_div, etc..
So you implemented the solver yourself. Aside from other kind of optimizations the algorithm is the effective one!
Is boost in general slower than matlab,
One of my mayor tasks at work is using Matlab. The Matlab language itself is about magnitudes slower thank C/C++/Fortran. Try this example to see how slow a Matlab loop is <Matlab example> N=30000; tic; for idx=1:N vec(idx) = idx; end toc tic vec = [1:N]; toc If you want fast Matlab code you have to replace a generally slow Matlab loop with some fast vector syntax expression. The similar is valid for all script languages, AFAIK.
should I use something else?
If you want speed you have to ;)
Id be real happy about any help.
First try use full optimization (-O3 for gcc) and define NDEBUG. If NDEBUG is defined many performance consuming checks, which help you while developing your code, are disabled. Another thing that Matlab does to provide good performance is using highly optimized numeric libraries (blas, lapack or even faster: ATLAS). uBlas is able to use them as backend too. See "Bindings" at http://tinyurl.com/r1ee . Like all interpreted languages (i.e. python), Matlab can always be outperformed by C++, by the cost of the much more time consuming C++ coding. If you want to write an application you have to use a standalone language like C++ anyway. If you want to use some environment for solving numerical problems (Matlab or i.e. scipy for python) you can code otherwise slow script language loops in C++ and use this compiled modules from inside your script language: - for Matlab search for "mex", mexfiles and mexFuntion at their help browser - for python see http://docs.python.org/ext/ext.html Best Regards, --Maik Beckmann
participants (2)
-
Maik Beckmann
-
Mike Marchywka