Re: [eigen] How do you link multiple versions (e.g. AVX vs SSE) of the same Eigen code?

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


There may be other compile flags that break the ABI (I don't see any out of hand, which one do you have in mind?), but this (the flags to control SIMD) is a special case because it is very common for people to want to compile the same code with different values for these flags and choose at runtime between these code paths, which becomes very tricky and sub-optimal if the ABI is not the same.

Regardless, to the extent that it's true that *static* 32byte alignment is important for performance, I'm OK to treat this as a documentation issue and default to breaking the ABI, with sufficient warnings/documentation.

I was just wonder to what extent that was the case: static 32byte alignment is irrelevant to 1) dynamic-size matrices, and 2) the most important cases of fixed-size vectorizability (Vector4f, Matrix4f). But, sure, the compromise you're describing sounds fine with enough warnings/documentation, and at least it's more symmetric as we don't hardcode one magic universal alignment (16byte) anymore.

Benoit


2015-01-28 3:17 GMT-05:00 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:

Support for AVX is not completely finalized. In particular we still have to re-enable vectorization for 128bits width vectors. So finally Vector4f will still be 16 bytes aligned and vectorized.

Then regarding alignment/ABI issues, I would keep the current behavior by default: if someone enable AVX, the best option is really to enable 32 bytes alignement, otherwise AVX gains would be strongly reduced. There are many other compiler options breaking the ABI anyway, so this only has to be clearly documented. For use cases as yours, we could offer compile-time options to choose the default maximal alignement requirement: 0, 16, 32, etc. instead of the current options that only allow you to disable alignement. Then it is up to the user to choose whether he prefers to enforce ABI compatibility by enabling 32B alignment on SSE or limit to 16B alignment for AVX.

gael


On Wed, Jan 28, 2015 at 12:30 AM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
Benoit, Gael, could you confirm that this change is intentional?

Pro:
  improves perf of certain 4d ops
Con:
 - regresses perf of 4f ops, as now Vector4f isn't aligned anymore!!!!
 - breaks long-standing invariant that Eigen ABI is independent of compile flags

Benoit