Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test solid harmonic ordering runtime switchable #271

Merged
merged 12 commits into from
Nov 24, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Install prerequisite MacOS packages
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'macos-latest' }}
run: |
brew install ninja gcc@10 boost eigen bison ccache automake python3 numpy scipy
brew install ninja gcc@10 boost eigen bison ccache automake python@3.11 numpy scipy
echo "FC=/usr/local/bin/gfortran-10" >> $GITHUB_ENV
echo "EIGEN3_INCLUDE_DIR=/usr/local/include/eigen3" >> $GITHUB_ENV
Expand Down
11 changes: 9 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
Following is a brief summary of changes made in each release of Libint.

- 2022-xx-yy: 2.8.0-beta.1
- UNMERGED PR #270: For Windows, basis sets with a star have been renamed to "s" on the filesystem,
- UNMERGED PR #271: Add `libint2::configuration_accessor` and `libint2::supports` functions. If
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- UNMERGED PR #271: Add `libint2::configuration_accessor` and `libint2::supports` functions. If
- PR #271: Add `libint2::configuration_accessor` and `libint2::supports` functions. If

library source is patched, these provides codes for what integrals a library instance can supply.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
library source is patched, these provides codes for what integrals a library instance can supply.
library source is patched, these provide codes for what integrals a library instance can supply.

- UNMERGED PR #271: Small pkgconfig and cmake detection improvements. Enable unity build.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- UNMERGED PR #271: Small pkgconfig and cmake detection improvements. Enable unity build.
- PR #271: Small pkgconfig and cmake detection improvements. Enable unity build.

Testing of solid harmonics runtime switchable from #269.
- PR #270: For Windows, basis sets with a star have been renamed to "s" on the filesystem,
so 6-31g**.g94 -> 6-31gss.g94. In code, the basis can be accessed through "6-31g**" (longstanding)
or "6-31gss" (new) for all operating systems.
- UNMERGED PR #270: Adapt build system and header imports so that library and Python bindings can build on
- PR #270: Adapt build system and header imports so that library and Python bindings can build on
Windows (at least with clang-cl compiler atop MSVC). Note that a Linux- or Mac-generated export
builds on Windows; one cannot generate an export on Windows. Note also that only a static library
build, not a shared one, works on Windows (see #237).
- PR #269: minimum CMake bumped to 3.16
- PR #269: Solid harmonics ordering is runtime switchable in the library. Issue
`libint2::set_solid_harmonics_ordering(libint2::SHGShellOrdering_Gaussian)` or `_Standard` after
initialization. Similarly, prefer new `INT_SOLIDHARMINDEX(sho, l, m)` to usual `(l, m)` version.
- PR #269: The ordering for spherical multipole integrals has been fixed at Standard, rather than
Gaussian or Standard as previously. Note that between this and the next item above, the
`--with-shgauss-ordering=standard|gaussian` has been rendered pointless for the C++ interface.
- PR #268: Python detection (relevant to Python bindings, Fortran, and some tests) now uses modern
`find_package(Python)`. Specify with `Python_EXECUTABLE` (note change in case) or
https://cmake.org/cmake/help/latest/module/FindPython.html for details .
Expand Down
130 changes: 130 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
### Run-Time Compatibility

Functions are provided to check the library configuration and solid harmonics orderings at runtime:

Note: As of v2.8.0 (libtool-based), the configuration_accessor() function will return `(nyi)` by default.
Packagers are encouraged to patch a generated configuration string into file `configuration.cc.cmake.in` to
imitate future cmake-based behavior. See sample patch below. The string can be generated by editing
and running `export/cmake/configuration-gen.py`.
Also patch MAX_AM_ERI in `CMakeLists.txt` (of export tarball; `export/cmake/CMakeLists.txt.export` in repo src).

```
libint2::initialize();
printf("SHGShell: %d\n", libint2::solid_harmonics_ordering());
libint2::set_solid_harmonics_ordering(libint2::SHGShellOrdering_Gaussian);
printf("SHGShell: %d\n", libint2::solid_harmonics_ordering());
// if patched as described above
printf("Configuration: %s\n", libint2::configuration_accessor().c_str());
printf("Supports: dddd=%d mmmm=%d\n", libint2::supports("eri_dddd_d0"), libint2::supports("eri_mmmm_d0"));
libint2::finalize();
```
```
SHGShell: 1
SHGShell: 2
Configuration: eri_dddd_d0_l2;eri_ffff_d0;ss;...
Supports: dddd=1 mmmm=0
```

For the C library, a similar function is available:

```
printf("CMake Configuration (C) : %s\n", configuration_accessor());
```
```
CMake Configuration (C) : eri_dddd_d0;eri_ffff_d0;ss;...
```

If you have a built libint2 library whose history you don't know, a command like this on Linux can provide the same information:

```
strings -n80 /a/random/L2/lying/around/libint2.so
```
```
ss;onebody_ii_d0;onebody_hh_d0;eri_iiI_d0;eri_iii_d0;eri_II_d0;eri_ii_d0;eri_hhhh_d0;eri_hhH_d0;eri_hhh_d0;eri_HH_d0;eri_hh_d0;eri_gggg_d1;eri_dddd_d1
```

A patch like the following is suitable for an export tarball generated from the next following.
[See guide](#configuration-codes) for decoding the configuration components.

```
--- src/configuration.cc.cmake.in 2023-09-05 09:13:50.000000000 -0400
+++ src/configuration.cc.cmake.in_basic 2023-09-05 23:41:00.444396591 -0400
@@ -24,6 +24,6 @@
@return the semicolon-separated strings from CMake components */
const char * configuration_accessor() {
//return "@Libint2_CONFIG_COMPONENTS@";
- return "(nyi)";
+ return "ss;multipole_nn_d0;multipole_mm_d0;multipole_ll_d0;multipole_kk_d0;multipole_ii_d0;multipole_hh_d0;multipole_gg_d0;multipole_ff_d0;multipole_dd_d0;onebody_ii_d0;onebody_hh_d0;onebody_gg_d0;onebody_ff_d0;onebody_dd_d0;onebody_hh_d1;onebody_gg_d1;onebody_ff_d1;onebody_dd_d1;onebody_gg_d2;onebody_ff_d2;onebody_dd_d2;eri_hhhh_d0;eri_gggg_d0;eri_ffff_d0;eri_dddd_d0;eri_gggg_d1;eri_ffff_d1;eri_dddd_d1;eri_iiI_d0;eri_hhI_d0;eri_hhH_d0;eri_ggI_d0;eri_ggH_d0;eri_ggG_d0;eri_ffI_d0;eri_ffH_d0;eri_ffG_d0;eri_ffF_d0;eri_ddI_d0;eri_ddH_d0;eri_ddG_d0;eri_ddF_d0;eri_ddD_d0;eri_hhH_d1;eri_ggH_d1;eri_ggG_d1;eri_ffH_d1;eri_ffG_d1;eri_ffF_d1;eri_ddH_d1;eri_ddG_d1;eri_ddF_d1;eri_ddD_d1;eri_iii_d0;eri_hhi_d0;eri_hhh_d0;eri_ggi_d0;eri_ggh_d0;eri_ggg_d0;eri_ffi_d0;eri_ffh_d0;eri_ffg_d0;eri_fff_d0;eri_ddi_d0;eri_ddh_d0;eri_ddg_d0;eri_ddf_d0;eri_ddd_d0;eri_hhh_d1;eri_ggh_d1;eri_ggg_d1;eri_ffh_d1;eri_ffg_d1;eri_fff_d1;eri_ddh_d1;eri_ddg_d1;eri_ddf_d1;eri_ddd_d1;eri_II_d0;eri_HH_d0;eri_GG_d0;eri_FF_d0;eri_DD_d0;eri_HH_d1;eri_GG_d1;eri_FF_d1;eri_DD_d1;eri_ii_d0;eri_hh_d0;eri_gg_d0;eri_ff_d0;eri_dd_d0;eri_hh_d1;eri_gg_d1;eri_ff_d1;eri_dd_d1;g12_gggg_d0;g12_ffff_d0;g12_dddd_d0;g12_gggg_d1;g12_ffff_d1;g12_dddd_d1";
}
```
```
./configure \
--enable-eri=1 \
--enable-eri3=1 \
--enable-eri2=1 \
--enable-1body=2 \
--enable-g12=1 \
--disable-1body-property-derivs \
--with-multipole-max-order=10 \
--with-g12-max-am=4 \
--with-eri-max-am=5,4 \
--with-eri3-max-am=6,5 \
--with-eri2-max-am=6,5 \
--with-max-am=6,5
```


#### Configuration Codes

Evenually, these will be CMake Components, too.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Evenually, these will be CMake Components, too.
Eventually, these will be CMake Components, too.


```
multipole_hh_dD - library includes spherical multipole integrals with max angular momentum up to
"h" (h=spdfghikl...; s,p not enumerated) and derivative order "D" (D=0,1,2,...).
For example, the presence of "multipole_ii_d0" means mpole ints are available for L=6.
onebody_hh_dD - library includes 1-body integrals with max angular momentum up to "h"
(h=spdfghikl...; s,p not enumerated) and derivative order "D" (D=0,1,2,...).
For example, the presence of "onebody_ii_d1" means onebody gradient ints are
available for L=6.
eri_hhhh_dD - library includes 2-body integrals with 4 centers and max angular momentum up to
"h" (h=spdfghikl...; s,p not enumerated) and derivative order "D" (D=0,1,2,...).
For example, the presence of "eri_ffff_d1" means 4-center gradient ints are
available for L=3. That is, the library was configured with at least
"--enable-eri=1 --with-eri-max-am=?,>=3".
eri_hhL_dD - library includes 2-body integrals with 3 centers and max angular momentum up to
eri_hhl_dD Cartesian "h" for the two paired centers and Cartesian "l" or solid harmonics "L"
for the unpaired/fitting center, (h/l=spdfghikl..., L=SPDFGHIKL...; l>=h
enumerated; s,p,S,P not enumerated) and derivative order "D" (D=0,1,2,...). The
"eri_hhL_dD" component is always available when 3-center ints are present. When pure
solid harmonics are assumed for 3-center ints, "eri_hhl_dD" will *not be available*.
For example, the presence of "eri_ffG_d0" means 3-center energy ints are
available for L=3 (paired centers) and L=4 (fitting center). That is, the library
was configured with at least "--enable-eri3=0 --with-max-am=3 --with-eri3-max-am=4".
The presence of "eri_ffg_d0" means the library configuration did not additionally
include "--enable-eri3-pure-sh[=yes]".
eri_HH_dD - library includes 2-body integrals with 2 centers and max angular momentum up to
eri_hh_dD Cartesian "h" or solid harmonics "H", (h=spdfghikl..., H=SPDFGHIKL...; s,p,S,P not
enumerated) and derivative order "D" (D=0,1,2,...). The "eri_HH_dD" component is
always available when 2-center ints are present. When pure solid harmonics are
assumed for 2-center ints, "eri_hh_dD" will *not be available*.
For example, the presence of "eri_FF_d2" means 2-center Hessian ints are
available for L=3. That is, the library was configured with at least
"--enable-eri2=2 --with-eri2-max-am=?,?,>=3". The presence of "eri_ff_d2" means the
library configuration did not additionally include "--enable-eri2-pure-sh[=yes]".
g12_hhhh_dD - library includes F12 integrals with Gaussian factors and max angular momentum up to
"h" (h=spdfghikl...; s,p not enumerated) and derivative order "D" (D=0,1,2,...).
For example, the presence of "g12_iiii_d2" means g12 Hessian ints are available for L=6.

cart shell_set used_by
-------- --------- -------
ss - library integrals use ordering standard + standard = mpqc4, cp2k, psi4 (psi4 requires runtime-setting of solid harmonic ordering to Gaussian)
so - library integrals use ordering + orca
is - library integrals use ordering intv3 + standard = mpqc3
io - library integrals use ordering + orca
gs - library integrals use ordering gamess + standard = gamess
go - library integrals use ordering + orca
os - library integrals use ordering orca + standard
oo - library integrals use ordering + orca = orca
bs - library integrals use ordering bagel + standard = bagel
bo - library integrals use ordering + orca
```
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ esac
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING,$libint_shgshell_ordering)
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING_STANDARD,$LIBINT_SHGSHELL_ORDERING_STANDARD)
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING_GAUSSIAN,$LIBINT_SHGSHELL_ORDERING_GAUSSIAN)
AC_SUBST(LIBINT_SHGSHELL_ORDERING_STANDARD)
AC_SUBST(LIBINT_SHGSHELL_ORDERING_GAUSSIAN)
AC_SUBST(LIBINT_SHGSHELL_ORDERING,$libint_shgshell_ordering)

LIBINT_SHELL_SET_STANDARD=1 AC_SUBST(LIBINT_SHELL_SET_STANDARD)
LIBINT_SHELL_SET_ORCA=2 AC_SUBST(LIBINT_SHELL_SET_ORCA)
Expand Down
3 changes: 2 additions & 1 deletion export/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ strip_some_preproc_symb:: exportdir
-rm $(TOPDIR)/$(EXPORTDIR)/include/libint2/config.h.cmake.tmp

exportdir::
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/libint2.pc.in $(TOPDIR)/$(EXPORTDIR)
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/INSTALL.export $(TOPDIR)/$(EXPORTDIR)/INSTALL
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/LICENSE.export $(TOPDIR)/$(EXPORTDIR)/LICENSE
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/README.md $(TOPDIR)/$(EXPORTDIR)/README.md
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/INSTALL.md $(TOPDIR)/$(EXPORTDIR)/INSTALL.md
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/COPYING $(TOPDIR)/$(EXPORTDIR)/COPYING
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/COPYING.LESSER $(TOPDIR)/$(EXPORTDIR)/COPYING.LESSER
-$(INSTALL) $(INSTALLLIBOPT) $(SRCTOPDIR)/CITATION $(TOPDIR)/$(EXPORTDIR)/CITATION
Expand Down Expand Up @@ -98,6 +98,7 @@ exportdir::
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/cmake/CMakeLists.txt.include.export $(TOPDIR)/$(EXPORTDIR)/include/CMakeLists.txt
$(INSTALL) $(INSTALLDIROPT) $(TOPDIR)/$(EXPORTDIR)/cmake
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/cmake/libint2-config.cmake.in $(TOPDIR)/$(EXPORTDIR)/cmake/libint2-config.cmake.in
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/cmake/libint2.pc.cmake.in $(TOPDIR)/$(EXPORTDIR)/cmake/libint2.pc.cmake.in
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/cmake/hftest.cmake $(TOPDIR)/$(EXPORTDIR)/cmake/hftest.cmake
$(INSTALL) $(INSTALLDIROPT) $(TOPDIR)/$(EXPORTDIR)/cmake/modules
-$(INSTALL) $(INSTALLLIBOPT) $(SRCDIR)/cmake/modules/*.cmake $(TOPDIR)/$(EXPORTDIR)/cmake/modules
Expand Down
59 changes: 42 additions & 17 deletions export/cmake/CMakeLists.txt.export
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.16) # 3.15: new Python detection; 3.16 to make the final leap
cmake_minimum_required(VERSION 3.16) # 3.16: unity build
# 3.15: new Python detection
# 3.8: introduced C++ standards as features
cmake_policy(SET CMP0079 NEW)

Expand All @@ -15,6 +16,7 @@ if (LIBINT_BUILDID)
else(LIBINT_BUILDID)
set(LIBINT_EXT_VERSION ${LIBINT_VERSION})
endif(LIBINT_BUILDID)
set(MAX_AM_ERI "") # patch here in export tarball w/highest 4-center, 0-deriv ERI AM in numbers

# Add module directory and modules =====================================================================================

Expand All @@ -28,6 +30,10 @@ include(RedefaultableOption)
include(CMakePushCheckState)
include(AddCustomTargetSubproject)

include(GNUInstallDirs)
set(L2 Libint2) # Namespace
set(pnv libint2) # projectnameversion

# Options ==============================================================================================================

redefaultable_option(REQUIRE_CXX_API "C++11 Libint interface" ON)
Expand Down Expand Up @@ -188,12 +194,17 @@ foreach(FN IN LISTS LIBINT2_LIBRARY_CXX_SRC)
list(APPEND LIB_CXX_SRC "src/${FN}")
endforeach()
# Create object files to use for static and shared libraries
add_library(libint2_obj OBJECT ${LIB_CXX_SRC})
add_library(libint2_obj OBJECT ${LIB_CXX_SRC} "src/configuration.cc")
target_include_directories(libint2_obj PRIVATE include ${PROJECT_BINARY_DIR}/include)
# Compile static library with position independent code

target_compile_definitions(libint2_obj PRIVATE __COMPILING_LIBINT2)
target_compile_features(libint2_obj PUBLIC "cxx_std_11")
set_target_properties(
libint2_obj
PROPERTIES
UNITY_BUILD TRUE
)
if (TARGET MPFR::GMPXX)
target_link_libraries(libint2_obj PUBLIC MPFR::GMPXX)
endif()
Expand Down Expand Up @@ -404,14 +415,23 @@ if (LIBINT_HAS_CXX_API)
tests/unit/test-shell-order.cc
tests/unit/test-util.cc
)
add_executable(unit_tests-libint2 EXCLUDE_FROM_ALL tests/unit/test.cc ${utests_src})
target_compile_definitions(unit_tests-libint2 PRIVATE -DNO_LIBINT_COMPILER_CODE)
target_link_libraries(unit_tests-libint2 libint2_cxx)
add_test(libint2/unit/build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target unit_tests-libint2)
set_tests_properties(libint2/unit/build PROPERTIES FIXTURES_SETUP LIBINT2_UNIT_TESTS_EXEC)
add_test(NAME libint2/unit/run
COMMAND $<TARGET_FILE:unit_tests-libint2>)
set_tests_properties(libint2/unit/run
add_executable(unit_tests_s-libint2 EXCLUDE_FROM_ALL tests/unit/test.cc ${utests_src})
target_compile_definitions(unit_tests_s-libint2 PRIVATE -DNO_LIBINT_COMPILER_CODE)
target_link_libraries(unit_tests_s-libint2 libint2_cxx)
add_test(libint2/unit_s/build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target unit_tests_s-libint2)
set_tests_properties(libint2/unit_s/build PROPERTIES FIXTURES_SETUP LIBINT2_UNIT_TESTS_EXEC)
add_test(NAME libint2/unit_s/run
COMMAND $<TARGET_FILE:unit_tests_s-libint2>)
set_tests_properties(libint2/unit_s/run
PROPERTIES FIXTURES_REQUIRED LIBINT2_UNIT_TESTS_EXEC)
add_executable(unit_tests_g-libint2 EXCLUDE_FROM_ALL tests/unit/test_g.cc ${utests_src})
target_compile_definitions(unit_tests_g-libint2 PRIVATE -DNO_LIBINT_COMPILER_CODE)
target_link_libraries(unit_tests_g-libint2 libint2_cxx)
add_test(libint2/unit_g/build "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target unit_tests_g-libint2)
set_tests_properties(libint2/unit_g/build PROPERTIES FIXTURES_SETUP LIBINT2_UNIT_TESTS_EXEC)
add_test(NAME libint2/unit_g/run
COMMAND $<TARGET_FILE:unit_tests_g-libint2>)
set_tests_properties(libint2/unit_g/run
PROPERTIES FIXTURES_REQUIRED LIBINT2_UNIT_TESTS_EXEC)

add_executable(hf-libint2 EXCLUDE_FROM_ALL tests/hartree-fock/hartree-fock.cc)
Expand Down Expand Up @@ -545,6 +565,8 @@ configure_file(

# In the future CMake switchover, configuration.h/cc define a string summary of capabilities. @ONLY is maximally deferred in case config2 changes the
# summary (as it used to when LIBINT_SHGSHELL_ORDERING was library-config-time selected).
# Note that in the future CMake switchover, configuration.cc should be a .cmake.in in the repo. It is not, for the moment, so the libtool build
# of the library works and because there's nothing to substitute until CMake knows the build configuration.
#configure_file(${PROJECT_SOURCE_DIR}/include/libint2/util/configuration.h.cmake.in ${PROJECT_BINARY_DIR}/include/libint2/util/configuration.h @ONLY)
configure_file(src/configuration.cc.cmake.in ${PROJECT_BINARY_DIR}/src/configuration.cc @ONLY)

Expand All @@ -554,15 +576,18 @@ configure_file(
@ONLY
)

configure_file(
libint2.pc.in
${PROJECT_BINARY_DIR}/libint2.pc
@ONLY
)
include(JoinPaths)
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(cmake/libint2.pc.cmake.in libint2.pc @ONLY)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libint2.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/
COMPONENT ${L2}_Development
)

# install cmake-processed files
install(FILES ${PROJECT_BINARY_DIR}/libint2.pc
DESTINATION lib/pkgconfig)
install(FILES ${PROJECT_BINARY_DIR}/include/libint2/config.h
DESTINATION "${LIBINT2_INSTALL_INCLUDEDIR}/libint2")
install(FILES ${PROJECT_BINARY_DIR}/include/libint2/basis.h
Expand Down
Loading
Loading