Re: [eigen] Block CG(p=1) vs CG Classic

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Thanks Christoph for your quick response.

I have attached now the two snapshot (jpg). Sorry. Below my answers/questions.


2013/7/22 Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
On 22.07.2013 21:40, Pedro Torres wrote:
I'm new here and I have a newbie question. I have implemented a version of
Block Conjugate Gradient, to resolve AX=B where A(nxn), X(nxp) and B(nxp)..
Then, I compare the walltime of this block version (using p=1) agains
Classics CG using just VectorXd. Result: the block version took more time.

How much slower is it?

For example as you can see in the snapshop, block version took 4.8s  and classic version 3.8s, for a sparse matrix with n=14200. The number of iterations for both was 2400.
 


Specifically I see that the operation A*V, with V defined as MatrixXd
V(n,1) took more time than the operations A*v, with  v defined as VectorXd
v(n). Is this an expected result?. Can I do something to get approximately
more closer results?.

In general, products of MatrixXd(n,n) with VectorXd(n) are faster than with MatrixXd(n,1). Basically, the problem is that for Matrix*Matrix Eigen can make the same assumptions on alignment of each column.
If you know your p at compile time you can make X and B
Matrix<double, Dynamic, p> which for p==1 is equivalent to VectorXd.

In general, I would like to set p at runtime.
 

If your matrix A is generic dense, I would generally doubt that CG is the optimal method. If A is sparse, there might be some potential on Eigen's side to optimize Sparse*MatrixXd(n,p).


Definitely, my matrix is always sparse. Well, as a first test to optimize this I can replace Sparse*MatrixXd(n,p) with Sparse*Vector[i] with i=1...p. but I dont sure if this will perform better.

Could you recommend some tips or reference where I can read about this optimization Sparse*MatrixXd(n,p) on Eigen's side?.

Thanks you very much.

Best Regards



I attached some snapshot from VTune comparing this runs.

Sorry, can't see any attachment.

Christoph


--
----------------------------------------------
Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252
----------------------------------------------





--
Pedro Torres

Attachment: BCG.jpg
Description: JPEG image

Attachment: cgclassic.jpg
Description: JPEG image



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/