evaleev / libint

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

all-stage CMake #148

Closed loriab closed 3 years ago

loriab commented 4 years ago

WIP

This is the start to CMake as a replacement for libtool builds. So far it builds the generator, runs it, and builds the library. That may sound like good progress, but only one set of input options examined.

closes #147

loriab commented 4 years ago
loriab commented 4 years ago

As an update,

loriab commented 4 years ago

While Psi4 is still in the testing and tuning phases of Libint2 integration (https://github.com/psi4/psi4/pull/1721), and this PR isn't complete (Windows not fully working), most major features are in, and it's ready for consideration. @evaleev, please let me know if you have any questions, especially about the strategy.

Major features

Not fixed

Won't fix in this PR

loriab commented 3 years ago

This is rebased and passing.

loriab commented 3 years ago

Update from above. @evaleev, what's your hoped/needed timeframe for this PR? Things that must be done, imo, is eigen/mpfr dep detection. Thing that ought to be done is some manner of CI testing the pure cmake build. Otherwise, this is working as well as Psi4 needs it to.

Major features

Not fixed

Won't fix in this PR

evaleev commented 3 years ago

@loriab I am starting on this now. Looks like the biggest missing piece is docs update ... what are you thinking re: Eigen + MPFR? FetchContent, if missing?

loriab commented 3 years ago

Great, thank you!

On docs, I was supposing the in-file descriptions https://github.com/evaleev/libint/pull/148/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR16-R195 would do and be most likely to be kept up-to-date. Were you thinking about an alternate to https://github.com/evaleev/libint/wiki#compiling-libint-compiler? For the per-qc-program options section, some psi4 guidance is here (https://github.com/psi4/psi4/blob/master/external/upstream/libint2/CMakeLists.txt). And an example of the production build and absolute smallest possible build (for static analysis) are:

cmake -H. -Bbuild50 \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/home/psilocaluser/gits/libint2/install-50 \
    -DCMAKE_CXX_COMPILER=$CXX \
    -DCMAKE_C_COMPILER=$CC \
    -DEigen3_DIR=$CONDA_PREFIX/share/eigen3/cmake/ \
    -DMPFR_ROOT=$CONDA_PREFIX \
    -DBOOST_ROOT=$CONDA_PREFIX \
    -DLIBINT2_SHGAUSS_ORDERING=gaussian \
    -DERI3_PURE_SH=OFF \
    -DERI2_PURE_SH=OFF \
    -DBUILD_SHARED=ON \
    -DBUILD_STATIC=OFF \
    -DBUILD_TESTING=ON \
    -DENABLE_ERI=2 \
    -DENABLE_ERI3=2 \
    -DENABLE_ERI2=2 \
    -DENABLE_ONEBODY=1 \
    -DDISABLE_ONEBODY_PROPERTY_DERIVS=ON \
    -DMULTIPOLE_MAX_ORDER=4 \
    -DWITH_ERI_MAX_AM="7;7;4" \
    -DWITH_ERI3_MAX_AM="7;7;5" \
    -DWITH_ERI2_MAX_AM="7;7;5" \
    -DWITH_MAX_AM="7;7;5"
   -DENABLE_ERI=0 \
    -DENABLE_ONEBODY=-1 \
    -DDISABLE_ONEBODY_PROPERTY_DERIVS=ON \
    -DMULTIPOLE_MAX_ORDER=0 \
    -DWITH_ERI_MAX_AM="1" \
    -DWITH_MAX_AM="1"

Were there some docs sections you'd like me to draft?

loriab commented 3 years ago

I haven't usually built or offered to fetch-and-build software that's non-QC (pb11 excepted). So I was going to expect mpfr and eigen to be present and fail if not. With eigen being header-only, I can see treating it like boost and unpacking and installing and exporting a tarball. gmp/mpfr is trickiest, with an actual library. I've written a fancier FindMPFR.cmake, but its integration is WIP since I haven't gotten it to link libint2 with a system mpfr. What do you think of handling eigen like boost?

evaleev commented 3 years ago

@loriab

-- The C compiler identification is unknown
CMake Error at tests/CMakeLists.txt:33 (enable_language):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!

Anyway, I'll keep poking and pushing as I see fit.

evaleev commented 3 years ago

@loriab FYI: I made a sister branch (#205), instead of overwriting your work, where I eliminated almost all (1 remains) ExternalProject calls. This should make it easier to make sure the cmake state is the same (incl imported targets) throughout the project. Currently library is generated successfully but I messed something up ... config2.h.cmake.in is not found when I am configuring the generated library.

loriab commented 3 years ago

dox: at the minimum we need to update INSTALL (while at it might as well rename to INSTALL.md). End users do not seem to be OK with reading source, not sure why ;) Long-term I'd like to convert the wiki into markdown embedded into Doxygen, along the lines of what I did for TiledArray: https://valeevgroup.github.io/tiledarray/dox-master/

I'll work on a draft of INSTALL modifications

probably want to eliminate the autotools harness.

Do you mean the pkgconfig files? I've considered them harmless to generate for libxc, for example, just in case downstream wants to use autotools detection. Or do you mean configure.ac entirely? Fine by me, but this has had zero configuration and testing for C and Fortran interfaces.

some options seem to duplicate standard CMake vars ... ? should we use CMAKE_POSITION_INDEPENDENT_CODE (https://cmake.org/cmake/help/latest/variable/CMAKE_POSITION_INDEPENDENT_CODE.html) instead of BUILD_FPIC

Fine by me. BUILD_FPIC was an option I distributed widely in my early cmake days. It may have been useful then when building both shared (w/fpic) and static (w/o) before I trusted the cmake property.

Anyway, I'll keep poking and pushing as I see fit.

Sounds great, thank you! Let me know when you'd like a psi4 integration test performed. I can do Linux and Mac by hand, but right now the only way to check Windows (without imposing on @andysim) is to have psi4's Azure generate/export/build or build.

evaleev commented 3 years ago

I'll work on a draft of INSTALL modifications

OK, thanks! Can use the wiki installation guide augmented with a list of requirements CMake variables

Do you mean the pkgconfig files? I've considered them harmless to generate for libxc, for example, just in case downstream wants to use autotools detection. Or do you mean configure.ac entirely? Fine by me, but this has had zero configuration and testing for C and Fortran interfaces.

The latter: remove configure.ac entirely. There are too many issues, e.g. #204 , and I have not tries building exported libs using autotools in years.

Fine by me. BUILD_FPIC was an option I distributed widely in my early cmake days. It may have been useful then when building both shared (w/fpic) and static (w/o) before I trusted the cmake property.

I think we best replace

Sounds great, thank you! Let me know when you'd like a psi4 integration test performed. I can do Linux and Mac by hand, but right now the only way to check Windows (without imposing on @andysim) is to have psi4's Azure generate/export/build or build.

I'm almost done with the first round of revision ... lots of work remains still (Fortran, etc.) but getting there. Thanks for getting this started!

evaleev commented 3 years ago

lives on as #205