Re: [eigen] Intermediate Packet Storage

[ Thread Index | Date Index | More Archives ]

On 18/12/2019 12.20, Joel Holdsworth wrote:
const Packet<uint32_t> E = a * b; // Some expensive calculation
const Packet<uint32_t> x = E + c;
const Packet<uint32_t> y = E + c;

This results in the value of E being stored onto the stack, and then reloaded twice to calculate x and y.

But of course, I just want E to stay in register.

I'm pretty sure that as long as `E` fits into a (set of) register(s) no reasonable compiler will store this on the stack, unless it actually runs out of register space, see e.g.:

Even if the small intermediate was stored on the stack, I assume the overhead should be negligible.

The problem is different, if you would want to apply your expressions at once on a set of large arrays. Something like the following will very likely require `E` getting stored or evaluated twice (unless the compiler is really smart detecting duplicated code or load after store).

    ArrayXi a,b,c,d; // input from somewhere

    ArrayXi E = a*b; // some expensive operations
    ArrayXi x = E+c, y=E+d;

For solving that problem you may be interested in:


I was wonder if there needs to be a new intermediate-friendly variant of Eigen::Array where the data is stored in arrays of SIMD types instead of plain-old-C arrays.

A while ago I started thinking about implementing Meta-Packets, but mostly to clean-up the current SIMD code base:
This includes a proof-of-concept implementation, but I never actually continued working on that.


 Dr.-Ing. Christoph Hertzberg

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

 Postadresse der Hauptgeschäftsstelle Standort Bremen:
 Robotics Innovation Center
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Tel.:     +49 421 178 45-4021
 Zentrale: +49 421 178 45-0
 E-Mail:   christoph.hertzberg@xxxxxxx

 Weitere Informationen:
  Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
  Trippstadter Straße 122, D-67663 Kaiserslautern, Germany

  Prof. Dr. Antonio Krüger (Vorsitzender)
  Dr. Walter Olthoff

  Vorsitzender des Aufsichtsrats:
  Dr. Gabriël Clemens
  Amtsgericht Kaiserslautern, HRB 2313

Mail converted by MHonArc 2.6.19+