xtb icon indicating copy to clipboard operation
xtb copied to clipboard

Integrate tblite library for evaluating xTB Hamiltonians

Open awvwgk opened this issue 2 years ago • 1 comments

  • [x] enable optional build with tblite
    • [x] support as feature in meson (default: auto-detect)
    • [x] support as option CMake (default: off?)
  • [x] provide calculator implementation
    • [x] basic single point calculator
    • [x] allow selection of method or parameter file
    • ~~allow creation of solvation models~~ (separate PR)
    • ~~provide info printout from parametrization~~ (separate PR)
  • [ ] regression tests
  • [x] documentation about new option

Closes #514

awvwgk avatar May 15 '22 13:05 awvwgk

This is mostly complete, in case anyone is interested in helping to get it merged let me know.

awvwgk avatar Oct 01 '22 07:10 awvwgk

Ready for review.

awvwgk avatar Oct 23 '22 10:10 awvwgk

I cannot compile a static version of this anymore with the latest intel compiler (using -static -OpenMP linking flags). However, some trial and error let me narrow this down to the ifcore library, which is probably used by one of the subprojects (json_fortran?). Adding an explicit -lifcoremt to the linker flags fixes this for me.

A way to fix this via the meson build system would be to add an ifcoremt library dependency to tblite.

lib_deps += fc.find_library('ifcoremt')

somewhere here https://github.com/tblite/tblite/blob/fa115545f7a6ba8e3f0e62df5cdace8781f4d309/config/meson.build#L143-L145

But this probably needs to be customized for the various compilers we use.

MtoLStoN avatar Nov 10 '22 17:11 MtoLStoN

Yes, that is due to libraries without direct OpenMP dependency in the tree, but will only pop up for static linking with Intel. For dist I recommend to use

Linux

meson setup _build \
    -Dprefix=/ \
    -Dlibdir=lib \
    -Dbuildtype=release \
    -Dfortran_link_args="-lifcoremt -static" \
    -Ddefault_library=static \
    -Dlapack=mkl
meson compile -C _build
meson install -C _build --destdir $PWD/xtb-dist

Windows (powershell)

meson setup _build `
    -Dfortran_args="/fpp" `
    -Ddefault_library=static `
    -Db_vscrt=mt `
    -Dbuildtype=release `
    -lapack=custom `
    -Dfortran_link_args="mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib ifcoremt.lib /STACK:16777216"
meson compile -C _build
meson install -C _build --destdir $pwd\xtb-dist
cp $env:MKLROOT\..\..\compiler\latest\windows\redist\intel64_win\compiler\libiomp5md.dll xtb-dist\bin

Might work to just drop-in -Dfortran_args=-qopenmp / -Dfortran_args=/qopenmp instead of messing with the link arguments.

awvwgk avatar Nov 10 '22 19:11 awvwgk

Agree. As stated, adding an explicit -lifcoremt linker flag works for me for static linking. However, the dynamic build needs an additional "-qopenmp" linker flag to compile, which is nothing terrible, but we should probably include that in the README to prevent future questions.

Otherwise, this looks good to me.

MtoLStoN avatar Nov 11 '22 13:11 MtoLStoN

Thanks for sharing.

MtoLStoN avatar Nov 29 '22 11:11 MtoLStoN