|Re: [eigen] AutoDiffScalar|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] AutoDiffScalar
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 6 Nov 2009 11:11:41 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=De3ol0xznGN5Nz1kEShjU9Bz7exRdrWroN4sKp8zXCk=; b=MvyVkwxGQH3NMN9+TxeO3Iuc5e5DHFSUxVzejKlMMf7LvPkGxARy2ik2F/hx0GTN1e 3CkBGBAFgi74dUi14y+4f6fawup4LOHCBSKrB3HvXy8HFTB1nfd76kGUQDdjd06QaUHC uD9BjD+M3PcuJThK3uETl/hbx8KAeZsu/GrP0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ln7fMgDRghWnE79wmQu3qbfJn7d2pgn7ZPU/I+jG3VAdb3HRYrpf6UFXI0Tr28jDW3 G1awycGoTrIKwTBw6pjda8TGIYJ9vZ7swgZLqMQbwxn3bnZ1UTy8KqnylM0bGXWb+amd 93XTJ1PWybZw80X/D7x9gIHGMnZ/5t1IulT8w=
thanks for your help in improving the AD module. I'm currently looking at your changes and try to merge them with my local changes, but I have some remarks/questions:
* I think your "RealScalar prec => const RealScalar& prec" change is useless because, e.g., for a MatrixXd, or an AutoDiffScalar<VectorXd>, RealScalar==double. Basically, whatever the complexity of the coeffecient type, RealScalar type should always be equal to a primitive scalar type. Benoit, what do you think, shall I undo that change while doing the merge ? https://bitbucket.org/bjornpiltz/autodiff/changeset/d2bf8e746508/
* Why did you add ei_unused() ? What is its purpose ?
* The behavior of the reserve() function looks even more odd than before. Unless you have strong arguments, I will remove the optional reserveSizeFactor parameter and update resize/append accordingly.
* I don't understand the purpose of your changes in the ctor. E.g., it is fundamental that "CompressedStorage data(size);" is equivalent to "CompressedStorage data; data.resize(size);"
* Your change in realloacate kills performances if, e.g., Scalar==AutoDiffScalar<VectorXf> because here we really want shallow copies. I agree that using memcpy is unsafe if the Scalar object creates a child-object which itself reference the parent... but recall that here we are designing containers for numerical values, not general containers. So I think it is fine to use memcpy here. Also a memcpy is much faster than simple for loops, and it is very important to provide optimal performances here.
2009/10/28 Björn Piltz <bjornpiltz@xxxxxxxxxxxxxx>
Ok, I've pushed my changes to https://bitbucket.org/bjornpiltz/autodiff. It would be great if you could take a look!
I'm getting performance like:
Computing first order:
Fixed Dynamic Sparse
Eigen 72 ms 427 ms 718 ms
Sacado 194 ms 430 ms
Computing second order:
Fixed Dynamic Sparse
Eigen 553 ms 7813 ms 13983 ms
Sacado 1002 ms 3617 ms
The first goal performance-wise should be to make the second order dynamic case as fast as Sacado.
If you remember I suggested doing something like:
typedef double Real;
typedef float Real;
struct MyTraits<AutoDiffScalar<DerType> >
typedef MyTraits<AutoDiffScalar<DerType>::Real>::Real Real;
I think this should be put outside of the AutoDiff module, if you want Eigen to support matrices of matrices. I just don't know where exactly.