Compiling with march=native results in crashes due to alignment

Issue #414 closed
Chris Beall created an issue

Compiling with march=native or -mavx2 etc. causes alignment-related crashes in several tests. Many routines in Eigen now make use of vectorization with these flags enabled, so we should consider adding them to Release mode once the errors are fixed. (For example, I observed an almost 2x speedup in Cholesky for large matrices.)

To reproduce in Debug mode, C++ compilation flags: -std=c++11 -Wall -g -fno-inline -DEIGEN_INITIALIZE_MATRICES_BY_NAN -march=native -O1

Mac:

97% tests passed, 6 tests failed out of 232
Total Test time (real) = 126.90 sec
The following tests FAILED:
    105 - testBearingRangeFactor (Child aborted)
    149 - testGaussianISAM2 (Child aborted)
    157 - testMarginals (Child aborted)
    161 - testNonlinearISAM (Child aborted)
    205 - testNonlinearClusterTree (Child aborted)
    227 - testTOAFactor (Child aborted) 

Ubuntu 16.04 with gcc 5.4:

     41 - testUnit3 (OTHER_FAULT)
    102 - testAdaptAutoDiff (SEGFAULT)
    105 - testRangeFactor (OTHER_FAULT)  
    106 - testBearingRangeFactor (OTHER_FAULT)
    119 - testSlamExpressions (OTHER_FAULT)
    145 - testGaussianISAM2 (OTHER_FAULT)
    149 - testExpressionFactor (OTHER_FAULT)
    170 - testNonlinearISAM (OTHER_FAULT)
    172 - testMarginals (OTHER_FAULT)
    202 - testNonlinearClusterTree (OTHER_FAULT)

I identified two issues:

  1. Alignment error in boost::bind in numericalDerivative (easy fix, I'll make a PR)
  2. Alignment error in ExecutionTrace for expressions. This one is less obvious - might need help.

Comments (4)

  1. Chris Beall reporter

    Another failure on Mac that I didn't see before. Just making a note so I don't forget about it. Think it's unrelated to the two other issues. Mac, Release with -O3 and 'march=native`

     42/232 Test  #42: testPose2 ..............................***Failed    0.01 sec
    Not equal:
    expected:
    [
        4.43711e-18        -0.3    0.557664;
                    0.3 8.35916e-18   -0.596998;
                      0           0           0
      ]
    actual:
    [
               0     -0.3        0;
                 0.3        0 0.557664;
                   0        0        0
      ]
    /Users/cbeall3/git/gtsam2/gtsam/geometry/tests/testPose2.cpp:196: Failure: "assert_equal(expected, xiprime, 1e-6)" 
    Not equal:
    expected:
    [
        -6.79325e-17           -6      7.33443;
                       6 -1.37573e-16     -10.3855;
                       0            0            0
      ]
    actual:
    [
              0      -6       0;
                  6       0 7.33443;
                  0       0       0
      ]
    /Users/cbeall3/git/gtsam2/gtsam/geometry/tests/testPose2.cpp:201: Failure: "assert_equal(expected2, xiprime2, 1e-6)" 
    

    Edit: Can't reproduce this one on Ubuntu 16.04

  2. Log in to comment