Re: [eigen] Intermediate Packet Storage |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Intermediate Packet Storage
- From: Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 18 Dec 2019 14:08:08 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-bremen.de; s=2019; t=1576674488; i=@uni-bremen.de; bh=3Be27FNta1ys9MZWUcU0wjNX+ziRvyJrqRAPJ519z7w=; h=To:References:From:Date:In-Reply-To; b=DgMyn7NKd/VuFdA2/FVxPmGbccsol4wmAbnYCjlJxC44ziqeuTO436cSc9wm5Y9Yq cV9erttzTV5i0f4h22eGiAChSnYCqYtiEWGIJvdnJvg5WS+LHMPv5S1VjOadOnzV61 KB47tHD4EvCbbiQHev9HCT5uYa1zYKynERKf9VHgA+V6yb3vh5rJlrHekKhZ8O/Z/V o6WkKzG6yTaIjalpBEgYhi6vaCct/EuKUI28cTPJOq4qXQmfKDWXCdu8wQyzJ7pJOa GHE9geGWp8HtUAayYzZ3rorAflY/eDCMtR6mNG9z04tZ8oH3b/rPIiyZiuWMBJuvvT c7iWoSBah1jOg==
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.:
https://godbolt.org/z/WxEeNF
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:
https://gitlab.com/libeigen/eigen/issues/984
[...]
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:
https://gitlab.com/libeigen/eigen/issues/692
This includes a proof-of-concept implementation, but I never actually
continued working on that.
Cheers,
Christoph
--
Dr.-Ing. Christoph Hertzberg
Besuchsadresse der Nebengeschäftsstelle:
DFKI GmbH
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Postadresse der Hauptgeschäftsstelle Standort Bremen:
DFKI GmbH
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: http://www.dfki.de/robotik
-------------------------------------------------------------
Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
Trippstadter Straße 122, D-67663 Kaiserslautern, Germany
Geschäftsführung:
Prof. Dr. Antonio Krüger (Vorsitzender)
Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats:
Dr. Gabriël Clemens
Amtsgericht Kaiserslautern, HRB 2313
-------------------------------------------------------------