Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures on some architectures (CPU types) #18

Open
olebole opened this issue Dec 7, 2016 · 3 comments
Open

Test failures on some architectures (CPU types) #18

olebole opened this issue Dec 7, 2016 · 3 comments

Comments

@olebole
Copy link
Contributor

olebole commented Dec 7, 2016

By disabling pandas I was able to try the build of sopt on different CPU types under Debian. On most platforms, it builds fine, however a few show test failures:

The test results are all similar:

The following tests FAILED:
	  7 - test_sdmm (Failed)
	  9 - test_proximal (Failed)
	 10 - seeded_proximal (Failed)
	 13 - test_reweighted (Failed)

and it happens always in the same line as an abort():

 5/14 Test  #7: test_sdmm ........................***Failed    0.02 sec
test_sdmm: /usr/include/eigen3/Eigen/src/Core/MapBase.h:191: 
  void Eigen::MapBase<Derived, 0>::checkSanity(typename Eigen::internal::enable_if<(Eigen::internal::traits<OtherDerived>::Alignment > 0), void*>::type)
  const [with T = Eigen::Ref<const Eigen::Matrix<double, -1, 1, 0, 4096, 1>, 16, Eigen::InnerStride<1> >;
 Derived = Eigen::Ref<const Eigen::Matrix<double, -1, 1, 0, 4096, 1>, 16, Eigen::InnerStride<1> >; 
 typename Eigen::internal::enable_if<(Eigen::internal::traits<OtherDerived>::Alignment > 0), void*>::type = void*]:
 Assertion `( ((internal::UIntPtr(m_data) % internal::traits<Derived>::Alignment) == 0) || (cols() * rows() * innerStride() * sizeof(Scalar)) < internal::traits<Derived>::Alignment ) && "data is not aligned"' failed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_sdmm is a Catch v1.2.0 host application.
Run with -? for options

Randomness seeded to: 1481110860

-------------------------------------------------------------------------------
Proximal translation
-------------------------------------------------------------------------------
/«PKGBUILDDIR»/cpp/tests/sdmm.cc:32
...............................................................................

/«PKGBUILDDIR»/cpp/tests/sdmm.cc:32: FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

===============================================================================
test cases: 1 | 1 failed
assertions: 4 | 3 passed | 1 failed

I have no glue how to debug this. Any hints?

@rbirdic
Copy link

rbirdic commented Mar 21, 2017

Hi,

I have investigated further this issue on mips/mipsel.

Here is backtrace for test 'test_proximal':

#0  Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> >, 0>::checkSanity<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> > >(Eigen::internal::enable_if<(Eigen::internal::traits<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> > >::Alignment>(0)), void*>::type) const (this=0x7ffed518)
    at /usr/include/eigen3/Eigen/src/Core/MapBase.h:193
#1  0x557f9f00 in Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> >, 0>::MapBase (this=0x7ffed518, dataPtr=0x7ffed528, rows=5, cols=1)
    at /usr/include/eigen3/Eigen/src/Core/MapBase.h:176
#2  0x557fe30c in Eigen::RefBase<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> > >::construct<Eigen::Matrix<double, -1, 1, 0, 4096, 1> > (this=0x7ffed518, expr=...)
    at /usr/include/eigen3/Eigen/src/Core/Ref.h:106
#3  0x5584b8fc in Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> >::construct<Eigen::Block<Eigen::MatrixWrapper<Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::ArrayWrapper<Eigen::Matrix<double, -1, 1, 0, -1, 1> const> const, Eigen::ArrayWrapper<Eigen::Matrix<double, -1, 1, 0, -1, 1> const> const> const> const, -1, 1, false> > (
    this=0x7ffed518, expr=...) at /usr/include/eigen3/Eigen/src/Core/Ref.h:272
...
#19 0x55891d94 in main (argc=1, argv=0x7fff6624) at ./cpp/tests/common_catch_main.cc:21

In frame 3, we can see that address of m_data(0x7ffed508) is aligned on 8 bytes, but because of the value of EIGEN_MAX_ALIGN_BYTES in test it is expected to be aligned on 16.


(gdb) f 3
#3  0x5584b840 in Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> >::construct<Eigen::Block<Eigen::MatrixWrapper<Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::ArrayWrapper<Eigen::Matrix<double, -1, 1, 0, -1, 1> const> const, Eigen::ArrayWrapper<Eigen::Matrix<double, -1, 1, 0, -1, 1> const> const> const> const, -1, 1, false> > (
    this=0x7ffed4f8, expr=...) at /usr/include/eigen3/Eigen/src/Core/Ref.h:272
272	      Base::construct(m_object);


(gdb) p m_data
$24 = (Eigen::MapBase<Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> >, 0>::PointerType) 0x7ffed508

Problem is in eigen package:
Eigen/src/Core/util/Macros.h

For 32-bit mips architecture it has been assumed that it is not necessary to take care of alignment (flag EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT is set to 1).
In that case m_data will be aligned on 8 bytes and it will cause test failure.

Adding MIPS in the list of architectures that support alignment solves this issue,
build and all tests successfully pass.

--- /usr/include/eigen3/Eigen/src/Core/util/Macros_orig.h       2017-03-21 14:37:30.301239469 +0000
+++ /usr/include/eigen3/Eigen/src/Core/util/Macros.h    2017-03-21 14:38:00.171490940 +0000
@@ -715,7 +715,7 @@
   // certain common platform (compiler+architecture combinations) to avoid these problems.
   // Only static alignment is really problematic (relies on nonstandard compiler extensions),
   // try to keep heap alignment even when we have to disable static alignment.
-  #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)
+  #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_MIPS || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64)
   #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
   #elif EIGEN_ARCH_ARM_OR_ARM64 && EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(4, 6)
   // Old versions of GCC on ARM, at least 4.4, were once seen to have buggy static alignment support

I will create an issue and recommend mentioned solution for eigen3 package on Debian.

Until this is resolved, workaround for this can be passing flag -DEIGEN_MAX_STATIC_ALIGN_BYTES=16 through CXXFLAGS:

--- sopt-2.0.0_orig/debian/rules        2016-11-09 11:24:48.000000000 +0000
+++ sopt-2.0.0/debian/rules     2017-03-21 13:33:19.828943062 +0000
@@ -6,6 +6,11 @@

 CMAKE_FLAGS += -DDEB_BUILD_MULTIARCH=`dpkg-architecture -qDEB_BUILD_MULTIARCH` 
  
+DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) 
+ifneq (,$(filter $(DEB_BUILD_ARCH),mips mipsel)) 
+       export DEB_CXXFLAGS_MAINT_APPEND = -DEIGEN_MAX_STATIC_ALIGN_BYTES=16 
+endif 
+ 
 %: 
        dh $@ --parallel --buildsystem=cmake

Regards,
Radovan

@ggael
Copy link

ggael commented Jun 6, 2017

Hi,

I'm Eigen's maintainers, I don't think adding MIPS in the list of architecture supporting static alignment is the proper fix. To truly fix this issue upstream I would need to know how the Eigen::Ref<Eigen::Matrix<double, -1, 1, 0, 4096, 1> const, 16, Eigen::InnerStride<1> > in frame #3 of the above backtrace have been instantiated, or in other word, what is the last line of SOPT's code in the backtrace. Thanks.

@ggael
Copy link

ggael commented Jun 6, 2017

ah, nevermind, I know remember that this intriguing "4096" max static size comes from Eigen's stableNorm, and that I fixed this issue a few months ago: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1400, have to release 3.3.4 asap ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants