Hi Tuukka, On Mon, Apr 16, 2012 at 9:59 AM, Tuukka Verho <[email protected]> wrote: > I tidied it up a bit more and changed some of the variable names to better > ones. I think this version is also more efficient if you count the function > calls. I managed to compile this time, thanks...
The original code was more efficient. Pretty much all of the Eigen code (MatrixBase::col(), operator*/+, etc) end up getting inlined by the compiler, so there is no extra overhead from traversing the stack. I haven't checked the assembly, but I believe it ends up being equivalent to just working with straight arrays. By default, Eigen also stores matrices as column-major, so operations on MatrixBase.col() should be able to be vectorized, as well. The cellMatrixT * q takes 9 multiplications and is performed for each of the 27 image vectors, so this costs 243 FLOPs per bond. Contrasted with caching the vectors for each loop, the cost is reduced to 3 * 3 (a) + 9 * 3 (b) + 27 * 3 (c) = 117 FLOPs per bond, less than half of the required operations for the matrix approach. The number of cheaper additions should be roughly the same. I'm ignoring the squared norm calculation (3 FLOPs), but these are unavoidable. That said, my experience in performance analysis is limited, and I'm not sure how the caching overhead may affect things. I assume the cached vectors can be stored in registers, or L1 cache at worst, so it's probably rather trivial. > Drawing the bonds in several pieces may lead to funny effects in some cases, > there's an example in the attachments. I don't know how big a problem that is > but some such cases might end up being reported as bugs... Those are nasty looking indeed! We should try to think of a way to clean those up before anything gets submitted. The main problem here is that the clippedCylinder only clips along one plane, so if a bond segment is near two planes part of the cylinder will jut out. A potential solution would be to have the clippedCylinder take a set of planes as arguments, but this would be a pain to code. Maybe Avogadro 2.0 painters could have a set of clipping planes so that we could more easily draw these structures? Then we could just use native GL clipping and emulate it somehow for the other paintdevices... Dave ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ Avogadro-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/avogadro-devel
