|
Ublas : |
Subject: Re: [ublas] Performance woes affecting ublas
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2010-05-19 07:23:19
As Karli mentions, NDEBUG is very important in release builds, and indeed I don't see NDEBUG in the posted code. Also instead of defining it in header files, you may find it convinient to define it in your makefile, i.e. add an -DNDEBUG, in your compile options (the "D" is important).
The major speedup you get when you define NDEBUG, is that range assertions are disabled. This means that when you access, or change an element in a container, uBlas will not check if the index is within the size of the container. Otherwise every time you access an element, one or more (depending on the container you are using) if-throws will kick in to keep you safe from yourself. The documentation additionally states the the NDEBUG also enables expression templates, although I haven't been able to figure out how this is not done anyway.
Additionally turning on optimizations (O2 or O3) will certainly give a boost in performance. I usually use those flags to avoid O3 and still keep a good performance (of course those are just a personal taste):
gcc:
-DNDEBUG -O2 -msse3 -mfpmath = sse -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=1msvc:
-DNDEBUG -O2 -xSSE3 -fp-model fast -parallel -vec_report2
I think the NDEBUG issue should be more aggressively dealt with in the documentation, because it is paramount in uBlas performance and it makes newcomers (myself included back then) buffled at first.
Best
Nasos
> Date: Wed, 19 May 2010 11:04:58 +0200
> From: rupp_at_[hidden]
> To: ublas_at_[hidden]
> Subject: Re: [ublas] Performance woes affecting ublas
>
> Hi Rui,
>
> I'm currently working on an OpenCL based C++ library for linear algebra
> on GPUs, which is widely interface-compatible to ublas (more on this in
> a couple of days in a separate thread). While all the vector and
> dense-matrix benchmarks went fine, I discovered that sparse
> matrix-vector products performed VERY badly (about a factor of 20
> compared to plain C) in ublas.
>
> However, I found the reason after some search on port 80: You have to
> disable all debugging information by the preprocessor macro
> #define NDEBUG
> definded before any ublas-stuff is included. A quick 'grep NDEBUG *' in
> your source directories did not give any results, therefore I suppose
> that NDEBUG is not defined in your project.
>
> I tried to compile your code to give you the numbers, but unfortunately
> some upper/lowercase clashes in the Eigen/eigen folder prevented me from
> doing so. However, I'm pretty sure you can handle this for yourself :-)
>
> Best regards,
> Karli
>
>
>
> Rui Maciel wrote:
> > (...)
> > <run with solver>
> > rui_at_kubuntu:benchmark$ make test
> > ./test.sh
> > Testing eigen...
> > Building the FEM equation
> > Solving the FEM equation
> > Done.
> >
> > real 0m5.254s
> > user 0m5.170s
> > sys 0m0.060s
> > Testing ublas...
> > Building the FEM equation
> > Solving the FEM equation
> > Done.
> >
> > real 1m0.298s
> > user 1m0.150s
> > sys 0m0.140s
> > </run>
> >
> > <run without solver>
> > rui_at_kubuntu:benchmark$ make test
> > ./test.sh
> > Testing eigen...
> > Building the FEM equation
> > Solving the FEM equation
> > Done.
> >
> > real 0m3.489s
> > user 0m3.490s
> > sys 0m0.000s
> > Testing ublas...
> > Building the FEM equation
> > Solving the FEM equation
> > Done.
> >
> > real 0m11.006s
> > user 0m10.950s
> > sys 0m0.030s
> > </run>
> >
> > (...)
> > So feel free to show how it is done and please do try to improve on the
> > results, not through insults and absurd accusations.
> >
> >
> > Rui Maciel
> >
> > [1]
> > http://www.google.pt/search?q=site%3Ahttp%3A%2F%2Fwww.boost.org%2Fdoc%2Flibs%2F1_41_0%2Flibs%2Fnumeric%2Fublas%2Fdoc%2F+umfpack
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > ublas mailing list
> > ublas_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/ublas
> > Sent to: rupp_at_[hidden]
>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: nasos_i_at_[hidden]
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4