Re: [eigen] Different computation time when using Eige |

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

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] Different computation time when using Eige*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Mon, 27 Jun 2016 13:34:00 +0200*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=l+AE0WzuTxMe+TLtwfJiBLzp7k7SC5qMF/Zvv6FvX6I=; b=0fAA65RwOnQZlT0FXWHksC7lJqYXM4+5HeYkluULQt6T3B6eG6Z3Pd0rWvZv+F6q85 rO9HPb2AoFhSAM8pAwu0YZf3/xAx47KUPlLEcYVli+WHBEKkamwaSxAV8e9LOFsJ1IZI mzMODA5pGPj+bO9zVhlewL9BTnvBWiHN6DyMLGnCahofr3jIjv9+nyrXJjaWGb0/xf/f svuHgnI5zMUOzzp9F7XdpWFPZI1EjXyzpELo3iPHvCczxhmgi2om5ygJomOg2CcSExnT 92MSDBJ0JIkxkhteKRRoUZqT4rOPGXeMXI5TFQqsXjjblsew3bfZhCAZuCH3Ji0zG/cI bY/Q==

Before investigating further, let me share the answer I gave on the forum:

Prior to Eigen 3.3, it's better if you split:

v3.noalias() += A*v1 + B*v2;

as:

v3.noalias() += A*v1;

v3.noalias() += B*v2;

otherwise one (or two) temporaries will be issued. (in theory, Eigen 3.3 does this splitting for you).

Then, performance of matrix-vector products highly depends on whether the matrices are already in cache. If they are too large, that's never possible, but if they are small enough to fit in L1 or L3, then the performance will be impacted by the evaluation context and the system load. For instance, is your application multi-threaded?

v3.noalias() += A*v1 + B*v2;

as:

v3.noalias() += A*v1;

v3.noalias() += B*v2;

otherwise one (or two) temporaries will be issued. (in theory, Eigen 3.3 does this splitting for you).

Then, performance of matrix-vector products highly depends on whether the matrices are already in cache. If they are too large, that's never possible, but if they are small enough to fit in L1 or L3, then the performance will be impacted by the evaluation context and the system load. For instance, is your application multi-threaded?

gael

On Mon, Jun 27, 2016 at 11:37 AM, tuch s <tuchfly@xxxxxxxxx> wrote:

I have used eigen to do the following computation in a deep learning programme，

- Code: Select all
`cur->i = this->bi;`

cur->i.noalias() += this->Wxi*xt + this->Whi*prev->h;

cur->f = this->bf;

cur->f.noalias() += this->Wxf*xt + this->Whf*prev->h;

cur->o = this->bo;

cur->o.noalias() += this->Wxo*xt + this->Who*prev->h;

cur->u = this->bu;

cur->u.noalias() += this->Wxu*xt + this->Whu*prev->h;

W* is a matrix, and h, f, i, o, u are all vectors.

But I tried several times with the same input data， the time consuming is much different.

Some times it costs 0.4 second to get the output, but some times it cost 2.1 second to get the output.

How can I solve this problem to get stable time cost ?

**Follow-Ups**:

**References**:**[eigen] Different computation time when using Eige***From:*tuch s

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Different computation time when using Eige** - Next by Date:
**Re: [eigen] Re: Complete orthogonal decomposition rank computation corner case** - Previous by thread:
**Re: [eigen] Different computation time when using Eige** - Next by thread:
**Re: [eigen] Different computation time when using Eige**

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