Compile with march=native by default
As discussed here, we can probably enable -march=native
by default, and give the user the option to disable.
- We still need to check whether this works on Windows (check for test failures!)
- Need to document that this requires dependent projects to build with same flag.
Comments (7)
-
-
reporter Good question. With
dependent projects
I mean projects which you build against gtsam. The more detailed explanation: Any project which calls gtsam functions which have Eigen types as parameters must be compiled with '-march=native`. Unfortunately, this requirement is transitive, so if you have two projects A and B, which form a dependency chain A --> B --> gtsam, and they all use Eigen, then you must use the same flags in all three projects.The reason for this has to do with alignment. Compiling with
-march=native
enables FMA, AVX, AVX2 instructions, and these change alignment of Eigen types. Incompatible mixing of flags then results in undefined behavior, numerical errors, or - if you're lucky - crashes. Eigen has some tickets on this: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1349 -
A quick note: If
-march=native
is appended to thePUBLIC
interface of gtsam, it will be automatically propagated to "dependent"/user's projects... that's why that cmake mechanism is great! Users shouldn't be even aware of this important detail. -
reporter @jlblancoc That sounds great. We'll have to try that.
-
@cbeall3 will you do a PR, or put this issue as wontfix or “on hold”
-
reporter Will try to get around to it this weekend.
-
- changed status to resolved
GTSAM moved to Github! Resolved by Chris there by https://github.com/borglab/gtsam/pull/4
- Log in to comment
I have a question about the recently added performance section of the README (sorry if this is the wrong place to ask this). You said that
by
dependent projects
are you referring to the dependencies of GTSAM such as boost, tbb etc, or are you referring to the user's projects which use GTSAM? I think it would be worth clarifying in the README. And what sort of problems occur? are they noticeable failures likeinvalid opcode
or do things go wrong in a subtle way?