Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-06-01 16:00:07

On Wednesday 01 June 2005 22:24, Max Weinberg wrote:
> Hi,
> using Stefan's [corrected] code, I also see that valarray is up to two
> times faster than ublas vector. It is hard to say where the inefficiency
> comes from. I think it has to do with indirect adressing. ublas uses
> indexed access when doing the vector addition. On each element access,
> first the base address data () of the vector is fetched, then the index[]
> is added.
> When using the code variant below, you can get faster than valarray. [if
> the code is correct, not thoroughly checked]. It uses sequential access to
> vector elements. For unknown reasons, valarray also seems to use indexed
> access (at least in the VC implementation).

Oddly, and something I still find hard to believe, most modern processor
compiler combinations execute indexed array access faster then using
sequential pointers. uBLAS can use both. It defaults to indexing as this
seems to work best. Not sure why VC should have problems in this case it
certainly used to prefer indexing.

You can influence uBLAS default by defining
when you compile.

Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering