|Re: [eigen] Performance tuning|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Performance tuning
- From: Adolfo Rodríguez Tsouroukdissian <adolfo.rodriguez@xxxxxxxxxxxxxxxx>
- Date: Mon, 2 Jan 2012 13:49:28 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=Y4zzIpcOHZylEVz5psevMmvniHhC1RbyjEmmOkTuJEQ=; b=MxfSSwtjztlbjh0xoO5hOmjVJEubf7IijbyXm5hbNmQL16m367IzG3qwClivgAJzsa nXNQvYuNk123RtM1WvylwICL7emkZri0zrLU+rEqQb6+G8lUquvk4XS9ehVaruK7q/ZI xVeDAClZWiAcYomvkDwcjBjsy0sWj0UnxZ0i8=
On Wed, Dec 28, 2011 at 6:50 PM, Tim Holy <holy@xxxxxxxxx>
I'm writing to ask about people's favorite techniques for tuning the
performance of their code, and in particular whether there exists a HOWTO (or
a desire to write one).
Here's one example: for the kinds of problems I'm studying, I've found that
one of the most helpful steps is to avoid the creation of temporaries. Because
temporaries are usually created "silently," I am sometimes surprised by which
lines are triggering temporaries. Once I discovered that this was an issue,
here's how I went about solving the problem at first:
1. Compile the program with debugging symbols and optimization
2. Profile my code in valgrind
3. See how many times posix_memalign gets called.
4. If it's too many, comment out a suspicious-looking block of code.
5. Go back to step 1 until the problem is localized, then fix it.
But after growing tired of this process, I finally realizing that a better way
to discover the problematic line(s) is to set a breakpoint in
Core/Util/Memory.h::aligned_realloc. And, of course, maybe there's even a
better way I haven't yet stumbled across, like setting some compiler flag to
throw an exception upon the creation of a temporary?
The EIGEN_RUNTIME_NO_MALLOC macro might help here. It is especially useful for unit tests. Minimal usage example:
#define EIGEN_RUNTIME_NO_MALLOC // Define this symbol to enable runtime tests for allocations
int main(int argc, char** argv)
// It's OK to allocate here
Eigen::MatrixXd A = Eigen::MatrixXd::Random(20, 20);
// It's NOT OK to allocate here
// An assertion will be triggered if an Eigen-related heap allocation takes place
// It's OK to allocate again
But there are other issues I don't know how to solve. For example, in
valgrind, I frequently wish that the cost of inlined code could be "folded in"
to the cost computed for the individual lines of my source code. Does anyone
know of a way of doing that? Or is there a different tool that can do this?
A natural gathering place for useful tips might be
but currently that section is fairly short.
Adolfo Rodríguez Tsouroukdissian
PAL ROBOTICS S.L
c/ Pujades 77-79, 4º4ª
08005 Barcelona, Spain.
AVISO DE CONFIDENCIALIDAD: Este mensaje y sus documentos adjuntos, pueden contener información privilegiada y/o confidencial que está dirigida exclusivamente a su destinatario. Si usted recibe este mensaje y no es el destinatario indicado, o el empleado encargado de su entrega a dicha persona, por favor, notifíquelo inmediatamente y remita el mensaje original a la dirección de correo electrónico indicada. Cualquier copia, uso o distribución no autorizados de esta comunicación queda estrictamente prohibida.
CONFIDENTIALITY NOTICE: This e-mail and the accompanying document(s) may contain confidential information which is privileged and intended only for the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of this e-mail and/or accompanying document(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender at the above e-mail address.