Boost logo

Ublas :

Subject: Re: [ublas] Element-wise operations are really slow
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2010-04-28 17:06:17

Hello xiss,

I still cannot agree with you numbers.

Am Wednesday 28 April 2010 schrieb xiss burg:
> Gunter,
> Actually I got confused because you said both push_back and
> append_element. Anyway, I tried both. append_element is 100 times
> slower than an ublas::matrix with +=s. I don't know what I'm doing
> wrong (sorry if there's something really stupid there). Please take a
> look at the source attached.

I slightly modified your example an get the following timings on my
machine (AMD Athlon(tm) 64 X2 Dual Core Processor 4800+)

$ g++ -DNDEBUG -O2 -I /home/gw/include/ -o fetest assemble_femat.cpp
$ ./fetest
numNodes : 200
numTetrahedrons: 800
GVOV with COO-vector
time elapsed: 0.03
time elapsed: 0.09
time elapsed: 5
time elapsed: 0.01
gvov - coo: 3.57628e-06
gvov - crs: 3.09944e-06
crs - coo: 2.68221e-06


numNodes : 400
numTetrahedrons: 1600
GVOV with COO-vector
time elapsed: 0.12
time elapsed: 0.19
time elapsed: 33.78
time elapsed: 0.01
gvov - coo: 4.47035e-06
gvov - crs: 3.8743e-06
crs - coo: 3.63588e-06

and finally

numNodes : 4000
numTetrahedrons: 16000
GVOV with COO-vector
time elapsed: 0.6
time elapsed: 2.18
skipped due to size
time elapsed: 0.83
gvov - coo: 3.8594e-06

So I still believe that the sparse types have a comparable performance.
Of course you have to take some special care when you are dealing with
very large matrices. So you should try to fill the matrix from top to
bottom (or only fill half of the matrix when it is symmetric).
Additionally the asymptotic costs of the different sparse matrices
The filling of a sparse matrix is by design always slower than for a
dense matrix (and it is quite possible to have a factor of 10 for
single operations). However this must be compared to the better
complexity because sparse operations should be O(nnz) or maybe
O(log(n)*nnz). Operations on dense types usually have the complexity
O(n) or worse. Thus it makes only little sense to compare sparse and
dense algorithm for small matrices.

numNodes : 32000
numTetrahedrons: 128000
GVOV with COO-vector
time elapsed: 4.96
time elapsed: 19.74

BTW: If you really want to solve big FE problems, then you should think
about using a specialized package, e.g.,
(more links on )