evaleev / libint

Libint: high-performance library for computing Gaussian integrals in quantum mechanics
Other
225 stars 95 forks source link

hartree-fock++ and gcc7 #160

Closed loriab closed 2 years ago

loriab commented 4 years ago

FYI, the hartree-fock++ test gives a problem with some gcc compilers (confirmed conda gcc 7.3; intel atop those same is clean). It looks to be a problem with gcc itself, since patched. This is not a problem with libint, just a notice to others who may hit it. Can be patched with below that de-parenthesizes the (n2).

test 9
      Start  9: hf++test_build

9: Test command: /home/psilocaluser/toolchainconda/envs/py38/bin/cmake "--build" "/home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library-build" "--target" "hartree-fock++"
9: Test timeout computed to be: 10000000
9: [1/2] Building CXX object tests/CMakeFiles/hartree-fock++.dir/hartree-fock/hartree-fock++.cc.o
9: FAILED: tests/CMakeFiles/hartree-fock++.dir/hartree-fock/hartree-fock++.cc.o 
9: /home/psilocaluser/toolchainconda/envs/py38/bin/x86_64-conda_cos6-linux-gnu-c++  -D__COMPILING_LIBINT2=1 -Itests/../include -I/home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/../src -I/home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/../include -I/home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/../include/libint2 -isystem /home/psilocaluser/toolchainconda/envs/py38/include/eigen3 -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/psilocaluser/toolchainconda/envs/py38/include -march=native -march=native -O3 -DNDEBUG -MD -MT tests/CMakeFiles/hartree-fock++.dir/hartree-fock/hartree-fock++.cc.o -MF tests/CMakeFiles/hartree-fock++.dir/hartree-fock/hartree-fock++.cc.o.d -o tests/CMakeFiles/hartree-fock++.dir/hartree-fock/hartree-fock++.cc.o -c /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc: In instantiation of 'compute_2body_fock_deriv(const libint2::BasisSet&, const std::vector<libint2::Atom>&, const Matrix&, double, const Matrix&)::<lambda(int)> [with unsigned int deriv_order = 1]':
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc:1885:13:   required from 'struct compute_2body_fock_deriv(const libint2::BasisSet&, const std::vector<libint2::Atom>&, const Matrix&, double, const Matrix&) [with unsigned int deriv_order = 1; Matrix = Eigen::Matrix<double, -1, -1, 1>]::<lambda(int)>'
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc:1774:8:   required from 'std::vector<Eigen::Matrix<double, -1, -1, 1> > compute_2body_fock_deriv(const libint2::BasisSet&, const std::vector<libint2::Atom>&, const Matrix&, double, const Matrix&) [with unsigned int deriv_order = 1; Matrix = Eigen::Matrix<double, -1, -1, 1>]'
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc:618:58:   required from here
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc:1917:32: internal compiler error: in maybe_undo_parenthesized_ref, at cp/semantics.c:1705
9:    (std::min((i), (j))) * ((n2) - (std::min((i), (j))) - 1) / 2 + \
9:                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~
9: /home/psilocaluser/gits/libint2/build31/src/library-prefix/src/library/tests/hartree-fock/hartree-fock++.cc:1934:46: note: in expansion of macro 'upper_triangle_index'
9:                          const auto coord12 = upper_triangle_index(
9:                                               ^
9: Please submit a full bug report,
9: with preprocessed source if appropriate.
9: See <https://gcc.gnu.org/bugs/> for instructions.
diff --git a/tests/hartree-fock/hartree-fock++.cc b/tests/hartree-fock/hartree-fock++.cc
index c2a552a..ffed427 100644
--- a/tests/hartree-fock/hartree-fock++.cc
+++ b/tests/hartree-fock/hartree-fock++.cc
@@ -1914,7 +1914,7 @@ std::vector<Matrix> compute_2body_fock_deriv(const BasisSet& obs,
 // n2 = matrix size times 2
 // i,j = (unordered) indices
 #define upper_triangle_index(n2, i, j)                             \
-  (std::min((i), (j))) * ((n2) - (std::min((i), (j))) - 1) / 2 + \
+  (std::min((i), (j))) * (n2 - (std::min((i), (j))) - 1) / 2 + \
       (std::max((i), (j)))
                 // look over shellsets in the order in which they appear
                 std::size_t shellset_idx = 0;