evaleev / libint

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

status of compiled c++11 interface #239

Open loriab opened 2 years ago

loriab commented 2 years ago

I haven't investigated much (nor, clearly, worked out the defines), but there may be some header inclusions not quite working for the compiled c++11 interface. Is this in use downstream in its current form? (Note: this refers to #233; feature not present in master.)

cmake_minimum_required(VERSION 3.16)
project(mine)
find_package(Libint2 2.7.0 REQUIRED COMPONENTS CXX_ho)
find_package(Threads)  # clang does not autolink threads even though we are using std::thread
add_executable(mineexe ../src/lib/libint/tests/hartree-fock/hartree-fock++.cc)

target_compile_definitions(mineexe PUBLIC LIBINT2_DOES_NOT_INLINE_ENGINE=1)
target_link_libraries(mineexe Libint2::int2-cxx Threads::Threads)  # sbuild-33c
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /psi/toolchainconda/envs/basenol2/bin/x86_64-conda-linux-gnu-cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /psi/toolchainconda/envs/basenol2/bin/x86_64-conda-linux-gnu-c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Eigen3: /psi/toolchainconda/envs/singleeigen/include/eigen3 (Required is at least version "3") 
-- Found Boost: /psi/toolchainconda/envs/singleboost/lib/cmake/Boost-1.73.0/BoostConfig.cmake (found suitable version "1.73.0", minimum required is "1.57")  
-- Libint2Config components requested: CXX_ho
-- Libint2Config components found: CXX;CXX_ho;C;Fortran;eri_c3_d0_l2;eri_c3_d0_l3;eri_c3_d1_l2;eri_c4_d0_l2;eri_c4_d1_l2;impure_sh;onebody_d0_l2;onebody_d0_l3;onebody_d1_l2;shared;sss;static
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /psi/gits/libint2-efv/sbuild-33c
[1/2] Building CXX object CMakeFiles/mineexe.dir/psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc.o
FAILED: CMakeFiles/mineexe.dir/psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc.o 
/psi/toolchainconda/envs/basenol2/bin/x86_64-conda-linux-gnu-c++ -DBOOST_ALL_NO_LIB -DDATADIR=\"/psi/gits/libint2-efv/install-33/share/libint/2.7.1\" -DLIBINT2_DOES_NOT_INLINE_ENGINE=1 -isystem /psi/gits/libint2-efv/install-33/include -isystem /psi/toolchainconda/envs/singleeigen/include/eigen3 -isystem /psi/toolchainconda/envs/singleboost/include -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 /psi/toolchainconda/envs/basenol2/include -MD -MT CMakeFiles/mineexe.dir/psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc.o -MF CMakeFiles/mineexe.dir/psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc.o.d -o CMakeFiles/mineexe.dir/psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc.o -c /psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc
In file included from /psi/gits/libint2-efv/install-33/include/libint2/boys_cheb7.h:24,
                 from /psi/gits/libint2-efv/install-33/include/libint2/statics_definition.h:26,
                 from /psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc:53:
/psi/gits/libint2-efv/install-33/include/libint2/boys_cheb7_v2.h:34:66: error: 'cheb_table_nintervals' was not declared in this scope
   34 | template<> double libint2::FmEval_Chebyshev7<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+1)*(interpolation_order+1)]=
      |                                                                  ^~~~~~~~~~~~~~~~~~~~~
/psi/gits/libint2-efv/install-33/include/libint2/boys_cheb7_v2.h:34:90: error: 'cheb_table_mmax' was not declared in this scope
   34 | template<> double libint2::FmEval_Chebyshev7<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+1)*(interpolation_order+1)]=
      |                                                                                          ^~~~~~~~~~~~~~~
/psi/gits/libint2-efv/install-33/include/libint2/boys_cheb7_v2.h:34:110: error: 'interpolation_order' was not declared in this scope
   34 | template<> double libint2::FmEval_Chebyshev7<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+1)*(interpolation_order+1)]=
      |                                                                                                              ^~~~~~~~~~~~~~~~~~~
In file included from /psi/gits/libint2-efv/install-33/include/libint2/tenno_cheb.h:24,
                 from /psi/gits/libint2-efv/install-33/include/libint2/statics_definition.h:27,
                 from /psi/gits/libint2-efv/src/lib/libint/tests/hartree-fock/hartree-fock++.cc:53:
/psi/gits/libint2-efv/install-33/include/libint2/tenno_cheb15.h:15:60: error: 'cheb_table_nintervals' was not declared in this scope
   15 | template<> double libint2::TennoGmEval<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+2)*(interpolation_order+1)*(interpolation_order+1)]=
      |                                                            ^~~~~~~~~~~~~~~~~~~~~
/psi/gits/libint2-efv/install-33/include/libint2/tenno_cheb15.h:15:84: error: 'cheb_table_mmax' was not declared in this scope
   15 | template<> double libint2::TennoGmEval<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+2)*(interpolation_order+1)*(interpolation_order+1)]=
      |                                                                                    ^~~~~~~~~~~~~~~
/psi/gits/libint2-efv/install-33/include/libint2/tenno_cheb15.h:15:104: error: 'interpolation_order' was not declared in this scope
   15 | template<> double libint2::TennoGmEval<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+2)*(interpolation_order+1)*(interpolation_order+1)]=
      |                                                                                                        ^~~~~~~~~~~~~~~~~~~
/psi/gits/libint2-efv/install-33/include/libint2/tenno_cheb15.h:15:128: error: 'interpolation_order' was not declared in this scope
   15 | template<> double libint2::TennoGmEval<double>::cheb_table[cheb_table_nintervals][(cheb_table_mmax+2)*(interpolation_order+1)*(interpolation_order+1)]=
      |                                                                                                                                ^~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
loriab commented 8 months ago

Ok, the error above can be fixed for the tests with LIBINT2_CONSTEXPR_STATICS=1. But then specifically for the hartree-fock++ test, the compiled cxx lib only suceeds for Linux with conda gcc (which by default adds in extra flags -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /psi/toolchainconda/envs/nol2bare/include). It fails for Linux with ubuntu gcc10, for Linux with Intel compilers, for Mac always (Apple clang and conda clang), and for Windows always (clang-cl), with the error below. I suspect some visibility attribute needs to be set on the engine header fns or in engine.cpp. A case where it worked, the enforce_params_type showed up in the int2-cxx lib as a W (weak) symbol, whereas a case that it didn't, it was present as a T (text) symbol.

13: [2/2] Linking CXX executable tests/hf++-libint2
13: FAILED: tests/hf++-libint2 
13: : && /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -O3 -DNDEBUG -isysroot /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.7 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  tests/CMakeFiles/hf++-libint2.dir/hartree-fock/hartree-fock++.cc.o -o tests/hf++-libint2  -Wl,-rpath,/Users/runner/work/libint/libint/build/compiler/build/src/lib/libint/library-prefix/src/library-build  libint2-cxx.dylib  libint2.dylib && :
13: Undefined symbols for architecture x86_64:
13:   "libint2::any libint2::Engine::enforce_params_type<std::__1::vector<std::__1::pair<double, double>, std::__1::allocator<std::__1::pair<double, double> > > >(libint2::Operator, std::__1::vector<std::__1::pair<double, double>, std::__1::allocator<std::__1::pair<double, double> > > const&, bool)", referenced from:
13:       libint2::Engine::Engine<std::__1::vector<std::__1::pair<double, double>, std::__1::allocator<std::__1::pair<double, double> > > >(libint2::Operator, unsigned long, int, int, double, std::__1::vector<std::__1::pair<double, double>, std::__1::allocator<std::__1::pair<double, double> > >, libint2::BraKet, libint2::ScreeningMethod) in hartree-fock++.cc.o
13:   "libint2::any libint2::Engine::enforce_params_type<double>(libint2::Operator, double const&, bool)", referenced from:
13:       libint2::Engine::Engine<double>(libint2::Operator, unsigned long, int, int, double, double, libint2::BraKet, libint2::ScreeningMethod) in hartree-fock++.cc.o
13: ld: symbol(s) not found for architecture x86_64
13: clang: error: linker command failed with exit code 1 (use -v to see invocation)
13: ninja: build stopped: subcommand failed.
12/13 Test #13: libint2/hf++/build ...............***Failed   24.23 sec
test 14
      Start 14: libint2/hf++/run
Failed test dependencies: libint2/hf++/build
13/13 Test #14: libint2/hf++/run .................***Not Run   0.00 sec

The following tests passed:
    libint2/eritest/build
    libint2/hf/build
    libint2/unit/build
    libint2/eritest/run0
    libint2/eritest/run1
    libint2/eritest/run2
    libint2/eritest/run3
    libint2/eritest/run4
    libint2/unit/run
    libint2/unit/sho=gaussian/run
    libint2/hf/run

85% tests passed, 2 tests failed out of 13

Total Test time (real) =  47.78 sec

The following tests FAILED:
     13 - libint2/hf++/build (Failed)
     14 - libint2/hf++/run (Not Run)
13: [2/2] Linking CXX executable tests/hf++-libint2
13: FAILED: tests/hf++-libint2 
13: : && /usr/bin/g++-10 -g  tests/CMakeFiles/hf++-libint2.dir/hartree-fock/hartree-fock++.cc.o -o tests/hf++-libint2  libint2-cxx.a  libint2.a  -lpthread && :
13: /usr/bin/ld: tests/CMakeFiles/hf++-libint2.dir/hartree-fock/hartree-fock++.cc.o: in function `libint2::Engine::Engine<std::vector<std::pair<double, double>, std::allocator<std::pair<double, double> > > >(libint2::Operator, unsigned long, int, int, double, std::vector<std::pair<double, double>, std::allocator<std::pair<double, double> > >, libint2::BraKet, libint2::ScreeningMethod)':
13: /home/runner/work/libint/libint/build/compiler/build/src/lib/libint/library-prefix/src/library/include/libint2/engine.h:518: undefined reference to `libint2::any libint2::Engine::enforce_params_type<std::vector<std::pair<double, double>, std::allocator<std::pair<double, double> > > >(libint2::Operator, std::vector<std::pair<double, double>, std::allocator<std::pair<double, double> > > const&, bool)'
13: /usr/bin/ld: tests/CMakeFiles/hf++-libint2.dir/hartree-fock/hartree-fock++.cc.o: in function `libint2::Engine::Engine<double>(libint2::Operator, unsigned long, int, int, double, double, libint2::BraKet, libint2::ScreeningMethod)':
13: /home/runner/work/libint/libint/build/compiler/build/src/lib/libint/library-prefix/src/library/include/libint2/engine.h:518: undefined reference to `libint2::any libint2::Engine::enforce_params_type<double>(libint2::Operator, double const&, bool)'
13: collect2: error: ld returned 1 exit status
13: ninja: build stopped: subcommand failed.
 6/17 Test #13: libint2/hf++/build ...............***Failed   18.07 sec
...
The following tests FAILED:
     13 - libint2/hf++/build (Failed)
     14 - libint2/hf++/run (Not Run)