Re: [eigen] RFC: making a deterministic and reproducable product codepath with Eigen

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


On 2016-09-06 16:09, Peter wrote:
It's beyond my knowledge, whether scalar products will always be
scheduled in the same way on the FPUs by the hardware,
especially if the scalar product appears after an if-statement.
I'm just sceptical, but maybe I just got surprised too often.

I would be very surprised, if a CPU would give different results for the very same machine instructions (given the same inputs and FPU-configuration, of course), solely based on internal scheduling.

Overall, I'm not sure if your overall goal is really feasible to achieve. If you don't care (too much) about performance, then maybe by providing a "always use simple 3-loop-matrix-products"-path, and always evaluate as if we followed C++ operator precedence (which takes away many optimization opportunities, e.g. for (Scalar * A * B + C) ). Certainly, many element-wise operations (R= A+B+C) could still be lazily evaluated (and even vectorized), but allowing vectorization even for simple reductions will depend on the packet-size. Things like blocking, expression-tree-reordering, vectorization will likely change for different Eigen-versions (and depending on the CPU). Making all of that user-configurable, will likely become a maintenance nightmare over time.

For the given use-case, I guess the simplest solution would be to hand-craft a simple library with naive but stable implementations.

Alternatively, if you mostly care about hardware independence (but not Eigen-version independence), it might be possible to compile to some intermediate code which is then translated to equivalent code for each architecture (which is one of the main ideas of LLVM, I guess). Of course, you'd also need to get rid of any run-time dependent decisions (like determining block-sizes from CPU cache sizes).



Christoph






--
 Dipl. Inf., Dipl. Math. Christoph Hertzberg

 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Zentrale: +49 421 178 45-6611

 Besuchsadresse der Nebengeschäftsstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx

 Weitere Informationen: http://www.informatik.uni-bremen.de/robotik



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