Project

General

Profile

Bug #1930

TabulatedNormalDistributionTest.OutputDouble14 and SimdScalarTest.andNotI tests fail on i686

Added by Dominik Mierzejewski over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Affected version - extra info:
bec9c8757e59cae58fc61ed841c0bb73c84079db
Affected version:
Difficulty:
uncategorized
Close

Description

When GROMACS (git commit bec9c8757e59cae58fc61ed841c0bb73c84079db) is built on i686 arch with -DGMX_SIMD=None or -DGMX_SIMD=SSE2, the following internal tests fail:

The following tests FAILED:
      9 - MathUnitTests (Failed)
     12 - SimdUnitTests (Failed)

Relevant log snippets:

[ RUN      ] TabulatedNormalDistributionTest.OutputDouble14
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[0]
    Actual: 6.2040742877964679
 Reference: 6.2040742877964199
Difference: 4.79616e-14 (54 double-prec. ULPs, rel. 1.2e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[1]
    Actual: -5.0443347697094563
 Reference: -5.0443347697093763
Difference: 7.99361e-14 (90 double-prec. ULPs, rel. 2e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[2]
    Actual: -3.848441018887919
 Reference: -3.8484410188878648
Difference: 5.41789e-14 (122 double-prec. ULPs, rel. 2.71e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[3]
    Actual: -3.5752202548964847
 Reference: -3.5752202548964327
Difference: 5.19584e-14 (117 double-prec. ULPs, rel. 2.6e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[4]
    Actual: 1.8067989684420849
 Reference: 1.806798968442128
Difference: 4.30767e-14 (194 double-prec. ULPs, rel. 4.31e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[5]
    Actual: 6.2412274164064083
 Reference: 6.2412274164063648
Difference: 4.35207e-14 (49 double-prec. ULPs, rel. 1.09e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[6]
    Actual: -1.5439517116690951
 Reference: -1.5439517116690484
Difference: 4.66294e-14 (210 double-prec. ULPs, rel. 4.66e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[7]
    Actual: -8.951438171789313
 Reference: -8.951438171789011
Difference: 3.01981e-13 (170 double-prec. ULPs, rel. 3.77e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[8]
    Actual: -2.3151355578004633
 Reference: -2.3151355578004198
Difference: 4.35207e-14 (98 double-prec. ULPs, rel. 2.18e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[9]
    Actual: 2.7598447450963288
 Reference: 2.7598447450963115
Difference: 1.73195e-14 (39 double-prec. ULPs, rel. 8.66e-15)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
[  FAILED  ] TabulatedNormalDistributionTest.OutputDouble14 (1 ms)

[ RUN      ] SimdScalarTest.andNotI
/builddir/build/BUILD/gromacs-bec9c8757e59cae58fc61ed841c0bb73c84079db/src/gromacs/simd/tests/scalar.cpp:285: Failure
Value of: andNot(std::int32_t(0xF0F0F0F0), std::int32_t(0xCCCCCCCC))
  Actual: 2.02116e+08
Expected: std::int32_t(0x0C0C0C0C)
Which is: 202116108
[  FAILED  ] SimdScalarTest.andNotI (1 ms)

Associated revisions

Revision 96912ad0 (diff)
Added by Erik Lindahl over 4 years ago

Fix incorrect return type for scalar version of simd andNot

The return type for the integer version was incorrectly set
to float. Fixed by properly adding separate integer, float
and double versions. This has never been used in any higher
level code yet, so it won't have caused any problems.

Refs #1930.

Change-Id: I84a4dfe51cf898664631ec2b0313ecf8e11a4a3a

Revision d44d7d6b (diff)
Added by Erik Lindahl over 4 years ago

Fix precision loss in tabulated normal distribution

The tabulated normal distribution was generated by
simply integrating a gaussian function, which led to
severe loss-of-precision for double precision tables.
Fixed by implementing proper inverse error functions
in the math module, and using this to fill the table
directly.

Fixes #1930.

Change-Id: I74b72b4a6d36f1eb382c6456501ce5644c92725e

History

#1 Updated by Berk Hess over 4 years ago

  • Assignee set to Erik Lindahl

#2 Updated by Erik Lindahl over 4 years ago

  • Status changed from New to Accepted

Hi Dominik,

I'll look into and fix it this weekend. In the mean time, what compiler did you use (just in case I can't reproduce it)

#3 Updated by Dominik Mierzejewski over 4 years ago

Hi, Erik.
Thanks for looking into this. This happens on Fedora development branch (rawhide). The compiler is:

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/6.0.0/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 6.0.0 20160311 (Red Hat 6.0.0-0.17) (GCC) 

#4 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '1' for Issue #1930.
Uploader: Erik Lindahl ()
Change-Id: I84a4dfe51cf898664631ec2b0313ecf8e11a4a3a
Gerrit URL: https://gerrit.gromacs.org/5771

#5 Updated by Erik Lindahl over 4 years ago

  • Status changed from Accepted to Blocked, need info

The SIMD issue I could identify without any tests, but after that I unfortunately cannot reproduce the other bug on rawhide. Starting from a new install of fedora23 into a virtual machine, I did a system-upgrade to rawhide and installed cmake, git, fftw3-devel, libxml2-devel and gcc-c++, followed by building Gromacs.

When using https://gerrit.gromacs.org/#/c/5774/ (which has the fixes for gmock), all regression tests pass (it won't even catch the SIMD issue, actually).

I still looked through the normaldistribution code in detail, and given how close the values are, your results indicate a very small loss in accuracy that likely originates either from std::exp or std::sqrt.

If you can provide exact instructions for how to reproduce this on a new install/VM I can look more into it, otherwise I suspect there might be something in your standard library!

#6 Updated by Dominik Mierzejewski over 4 years ago

With latest git master HEAD, only TabulatedNormalDistributionTest.OutputDouble14 is failing:

[ RUN      ] TabulatedNormalDistributionTest.OutputDouble14
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[0]
    Actual: 6.2040742877964679
 Reference: 6.2040742877964199
Difference: 4.79616e-14 (54 double-prec. ULPs, rel. 1.2e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[1]
    Actual: -5.0443347697094563
 Reference: -5.0443347697093763
Difference: 7.99361e-14 (90 double-prec. ULPs, rel. 2e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[2]
    Actual: -3.848441018887919
 Reference: -3.8484410188878648
Difference: 5.41789e-14 (122 double-prec. ULPs, rel. 2.71e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[3]
    Actual: -3.5752202548964847
 Reference: -3.5752202548964327
Difference: 5.19584e-14 (117 double-prec. ULPs, rel. 2.6e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[4]
    Actual: 1.8067989684420849
 Reference: 1.806798968442128
Difference: 4.30767e-14 (194 double-prec. ULPs, rel. 4.31e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[5]
    Actual: 6.2412274164064083
 Reference: 6.2412274164063648
Difference: 4.35207e-14 (49 double-prec. ULPs, rel. 1.09e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[6]
    Actual: -1.5439517116690951
 Reference: -1.5439517116690484
Difference: 4.66294e-14 (210 double-prec. ULPs, rel. 4.66e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[7]
    Actual: -8.951438171789313
 Reference: -8.951438171789011
Difference: 3.01981e-13 (170 double-prec. ULPs, rel. 3.77e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[8]
    Actual: -2.3151355578004633
 Reference: -2.3151355578004198
Difference: 4.35207e-14 (98 double-prec. ULPs, rel. 2.18e-14)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
/builddir/build/BUILD/gromacs-d6e35c96ceeb552afeeec4655567af2945994958/src/testutils/refdata.cpp:788: Failure
   In item: /TabulatedNormalDistributionDouble14/[9]
    Actual: 2.7598447450963288
 Reference: 2.7598447450963115
Difference: 1.73195e-14 (39 double-prec. ULPs, rel. 8.66e-15)
 Tolerance: abs. 8.88178e-16, 4 ULPs (rel. 8.88e-16)
[  FAILED  ] TabulatedNormalDistributionTest.OutputDouble14 (0 ms)

I'm building gromacs in mock (mock -r fedora-rawhide-i386). After you add yourself to the mock group, you can use mock to build packages for any supported Fedora (and CentOS) version, actually.

Please download the src.rpm from: http://koji.fedoraproject.org/koji/buildinfo?buildID=749934 and try building it under mock: mock -r fedora-rawhide-i386 gromacs-2016-0.1.20160318gitbec9c87.fc25.src.rpm. This will actually build, because the two failing tests are disabled by %patch4. You can comment it out in the spec file (/var/lib/mock/fedora-rawhide-i386/root/builddir/build/SPECS/gromacs.spec), and then:

$ mock -r fedora-rawhide-i386 shell
# su - mockbuild 
$ cd build/SPECS
$ rpmbuild -bi gromacs.spec

If you have a bit of time for an interactive session, I can walk you through it.

#7 Updated by Erik Lindahl over 4 years ago

  • Status changed from Blocked, need info to Accepted

We found this on icc targeting Xeon Phi too. It's caused by an FMA instruction (vs. separate multiply & add) when filling the table data. It's entirely harmless, but I'll see if we can fix it properly so all hosts provide the same numbers rather than accepting ~200 ULP differences.

#8 Updated by Gerrit Code Review Bot over 4 years ago

Gerrit received a related patchset '1' for Issue #1930.
Uploader: Erik Lindahl ()
Change-Id: I74b72b4a6d36f1eb382c6456501ce5644c92725e
Gerrit URL: https://gerrit.gromacs.org/5850

#9 Updated by Erik Lindahl over 4 years ago

  • Status changed from Accepted to Resolved

#10 Updated by Erik Lindahl over 4 years ago

  • Status changed from Resolved to Closed

#11 Updated by Erik Lindahl over 4 years ago

PS Dominik: With the new change you should be able to remove patch 4 in the rpm.

#12 Updated by Dominik Mierzejewski over 4 years ago

Unfortunately, I'm still getting this test failure:

[----------] 1 test from TabulatedNormalDistributionTableTest
[ RUN      ] TabulatedNormalDistributionTableTest.HasValidProperties
/builddir/build/BUILD/gromacs-d44d7d6bebdb7fa52090b744854d49f34099e044/src/gromacs/random/tests/tabulatednormaldistribution.cpp:173: Failure
  Value of: variance
    Actual: 0.99999999999999967
  Expected: 1.0
  Which is: 1
Difference: 3.33067e-16 (3 double-prec. ULPs, rel. 6.66e-16)
 Tolerance: 1 ULPs (rel. 2.22e-16)
Table should have unit variance
[  FAILED  ] TabulatedNormalDistributionTableTest.HasValidProperties (2 ms)
[----------] 1 test from TabulatedNormalDistributionTableTest (2 ms total)

#13 Updated by Nicholas Breen over 4 years ago

I can also reproduce the above on an x86 Debian build host with similar properties, but in double precision only. Additionally, new failures in SimdIntegerTest.cvtR2I and .cvttR2I.

Also available in: Atom PDF