From 81c7c498bc4299e411a7f433e02c39d5b6e1e307 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Fri, 22 Dec 2023 16:56:26 -0500 Subject: [PATCH 1/3] most rest of config --- CMakeLists.txt | 53 ++++++++++++++++++++++++++- INSTALL.md | 23 ++++++++++++ include/libint2/config.h.cmake.in | 55 ++++++++++++++++++++++++++++ include/libint2/config2.h.cmake.in | 7 ++++ src/lib/libint/CMakeLists.txt | 2 + src/lib/libint/CMakeLists.txt.export | 11 ++++++ src/lib/libint/features.cmake.in | 1 + 7 files changed, 151 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a0142cd9..ed43b7168 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,7 +186,7 @@ option_with_default(WITH_ERI_OPT_AM option_with_default(WITH_ERI3_MAX_AM "Support 3-center ERIs for Gaussians of angular momentum up to N. Can specify values for each derivative level as a semicolon-separated string. (default: max_am) - This option controls only the single fitting center; the paired centers use WITH_MAX_AM." -1) + This option controls only the single fitting center. The paired centers use WITH_MAX_AM." -1) option_with_default(WITH_ERI3_OPT_AM "Optimize 3-center ERIs maximally for up to angular momentum N (N <= max-am). Can specify values for each derivative level as a semicolon-separated string. (default: (max_am/2)+1)" -1) @@ -212,15 +212,66 @@ option_with_default(WITH_G12DKH_MAX_AM option_with_default(WITH_G12DKH_OPT_AM "Optimize G12DKH integrals for up to angular momentum N (N <= max-am). (default: (max_am/2)+1)" -1) +# <<< Miscellaneous >>> + +option_with_print(LIBINT_CONTRACTED_INTS + "Turn on support for contracted integrals." ON) +option_with_default(LIBINT_ERI_STRATEGY + "(EXPERT) Compute ERIs using the following strategy. (0 for OS, 1 for HGP, 2 for HL)" 1) +option_with_print(LIBINT_USE_COMPOSITE_EVALUATORS + "Libint will use composite evaluators (i.e. every evaluator will compute one integral type only)" ON) +option_with_print(LIBINT_SINGLE_EVALTYPE + "Generate single evaluator type (i.e. all tasks use the same evaluator). OFF is NYI" ON) +option_with_default(LIBINT_ENABLE_UNROLLING + "Unroll shell sets into integrals (will unroll shell sets larger than N) (0 for never, N for N, 1000000000 for always)" 100) +option_with_default(LIBINT_ALIGN_SIZE + "(EXPERT) if posix_memalign is available, this will specify alignment of Libint data, in units of + sizeof(LIBINT2_REALTYPE). Default is to use built-in heuristics: system-determined for vectorization off (default) or veclen * sizeof(LIBINT2_REALTYPE) for vectorization on." 0) +mark_as_advanced(LIBINT_ALIGN_SIZE) +option_with_print(LIBINT_GENERATE_FMA + "Generate FMA (fused multiply-add) instructions (to benefit must have FMA-capable hardware and compiler)" OFF) +option_with_print(LIBINT_ENABLE_GENERIC_CODE + "Use manually-written generic code" OFF) +option_with_print(LIBINT_API_PREFIX + "Prepend this string to every name in the library API (except for the types)." OFF) +option_with_print(LIBINT_VECTOR_LENGTH + "Compute integrals in vectors of length N." OFF) +option_with_default(LIBINT_VECTOR_METHOD + "Specifies how to vectorize integrals. Irrelevant when `LIBINT_VECTOR_LENGTH=OFF. Allowed values are 'block' (default), and 'line'." block) +option_with_print(LIBINT_ACCUM_INTS + "Accumulate integrals to the buffer, rather than copy (OFF for copy, ON for accum)." OFF) +option_with_print(LIBINT_FLOP_COUNT + "Support (approximate) FLOP counting by the library. (Generated code will require C++11!)" OFF) +option_with_print(LIBINT_PROFILE + "Turn on profiling instrumentation of the library. (Generated code will require C++11!)" OFF) + + + ######################## Process & Validate Options ########################### +include(CheckFunctionExists) +include(CheckIncludeFileCXX) include(FeatureSummary) include(int_orderings) include(int_am) +check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN) +if (NOT HAVE_POSIX_MEMALIGN) + message(FATAL_ERROR "did not find posix_memalign ... this SHOULD NOT happen. Cannot proceed.") +endif() + +check_include_file_cxx(stdint.h HAVE_STDINT_H) # limits.h? + booleanize01(ERI3_PURE_SH) booleanize01(ERI2_PURE_SH) +booleanize01(LIBINT_SINGLE_EVALTYPE) +booleanize01(LIBINT_CONTRACTED_INTS) booleanize01(DISABLE_ONEBODY_PROPERTY_DERIVS) +booleanize01(LIBINT_GENERATE_FMA) +booleanize01(LIBINT_ENABLE_GENERIC_CODE) booleanize01(SUPPORT_T1G12) +booleanize01(LIBINT_ACCUM_INTS) +booleanize01(LIBINT_FLOP_COUNT) +booleanize01(LIBINT_PROFILE) ################################## Main Project ################################# diff --git a/INSTALL.md b/INSTALL.md index d47c60a16..5c38e6213 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -165,6 +165,29 @@ Note that options, docs, and CMake components are focused on the C++ interface, * `--disable-1body-property-derivs` --> `-D DISABLE_ONEBODY_PROPERTY_DERIVS=ON` +* Defunct as non-CMake-like: `--build`, `--host`, `--target`, + +* `--with-api-prefix=pfx` --> `-D LIBINT_API_PREFIX=pfx` +* `--enable-unrolling=yes` --> `-D LIBINT_ENABLE_UNROLLING=1000000000` +* `--enable-unrolling=no` --> `-D LIBINT_ENABLE_UNROLLING=0` +* `--enable-unrolling=S` --> `-D LIBINT_ENABLE_UNROLLING=S` +* `--enable-generic-code` --> `-D LIBINT_ENABLE_GENERIC_CODE=ON` +* `--with-vector-length=N` --> `-D LIBINT_VECTOR_LENGTH=N` +* `--with-vector-method=choice` --> `-D LIBINT_VECTOR_METHOD=choice` +* `--with-align-size=N` --> `-D LIBINT_ALIGN_SIZE=N` (G) (`-D LIBINT2_ALIGN_SIZE=N` for L) +* `--enable-fma` --> `-D LIBINT_GENERATE_FMA=ON` +* `--enable-accum-ints` --> `-D LIBINT_ACCUM_INTS=ON` +* `--enable-flop-counter` -> `-D LIBINT_FLOP_COUNT=ON` +* `--enable-profile` --> `-D LIBINT_PROFILE=ON` +* `--disable-contracted-ints` --> `-D LIBINT_CONTRACTED_INTS=OFF` +* `--disable-single-evaltype` --> `-D LIBINT_SINGLE_EVALTYPE=OFF` (NYI) +* `--enable-composite-evaluators` --> `-D LIBINT_USE_COMPOSITE_EVALUATORS=ON` +* `--disable-composite-evaluators` --> `-D LIBINT_USE_COMPOSITE_EVALUATORS=OFF` +* `--with-eri-strategy=OS` --> `-D LIBINT_ERI_STRATEGY=0` +* `--with-eri-strategy=HL` --> `-D LIBINT_ERI_STRATEGY=2` + + + ### Run-Time Compatibility diff --git a/include/libint2/config.h.cmake.in b/include/libint2/config.h.cmake.in index 08e7d9d26..d13fe2871 100644 --- a/include/libint2/config.h.cmake.in +++ b/include/libint2/config.h.cmake.in @@ -38,6 +38,9 @@ /* The micro version number. */ #define LIBINT_MICRO_VERSION @LIBINT_MICRO_VERSION@ +/* Prefix for all names in API */ +#cmakedefine LIBINT_API_PREFIX "@LIBINT_API_PREFIX@" + /* Max AM (same for all derivatives; if not defined see LIBINT_MAX_AM_LIST) */ #cmakedefine LIBINT_MAX_AM @LIBINT_MAX_AM@ @@ -164,6 +167,24 @@ /* Max optimized AM for G12DKH method integrals */ #cmakedefine G12DKH_OPT_AM @G12DKH_OPT_AM@ +/* Whether integral sets can be unrolled */ +#cmakedefine LIBINT_ENABLE_UNROLLING @LIBINT_ENABLE_UNROLLING@ + +/* Whether generic code can be used */ +#cmakedefine LIBINT_ENABLE_GENERIC_CODE @LIBINT_ENABLE_GENERIC_CODE@ + +/* maximum length of vectors */ +#cmakedefine LIBINT_VECTOR_LENGTH @LIBINT_VECTOR_LENGTH@ + +/* how to vectorize */ +#cmakedefine LIBINT_VECTOR_METHOD "@LIBINT_VECTOR_METHOD@" +#ifndef LIBINT_VECTOR_LENGTH +#undef LIBINT_VECTOR_METHOD +#endif + +/* if can be controlled with posix_memalign, alignment size */ +#define LIBINT_ALIGN_SIZE @LIBINT_ALIGN_SIZE@ + /* Specifies the ordering of cartesian Gaussians in a shell. Allowed values are defined at the bottom of this file -- also see CMakeLists.txt */ #cmakedefine LIBINT_CGSHELL_ORDERING @LIBINT_CGSHELL_ORDERING@ @@ -173,6 +194,30 @@ /* Specifies the class of shell sets generated. Allowed values are defined at the bottom of this file -- also see CMakeLists.txt */ #cmakedefine LIBINT_SHELL_SET @LIBINT_SHELL_SET@ +/* Generate FMA instructions? */ +#cmakedefine LIBINT_GENERATE_FMA @LIBINT_GENERATE_FMA@ + +/* Accumulate integrals to the buffer? */ +#cmakedefine LIBINT_ACCUM_INTS @LIBINT_ACCUM_INTS@ + +/* Whether FLOP counting is supported */ +#cmakedefine LIBINT_FLOP_COUNT @LIBINT_FLOP_COUNT@ + +/* Whether profile instrumentation will be enabled */ +#cmakedefine LIBINT_PROFILE @LIBINT_PROFILE@ + +/* Support contracted integrals? */ +#cmakedefine LIBINT_CONTRACTED_INTS @LIBINT_CONTRACTED_INTS@ + +/* Generate single evaluator type? */ +#cmakedefine LIBINT_SINGLE_EVALTYPE @LIBINT_SINGLE_EVALTYPE@ + +/* Generate composite evaluators? */ +#cmakedefine01 LIBINT_USE_COMPOSITE_EVALUATORS + +/* Strategy for ERI evaluation */ +#define LIBINT_ERI_STRATEGY @LIBINT_ERI_STRATEGY@ + /* Known orderings of cartesian Gaussians */ @@ -194,6 +239,16 @@ #cmakedefine LIBINT_SHELL_SET_STANDARD @LIBINT_SHELL_SET_STANDARD@ #cmakedefine LIBINT_SHELL_SET_ORCA @LIBINT_SHELL_SET_ORCA@ +/* + Libint-independent features + */ + +/* have stdint.h ? */ +#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@ + +/* have posix_memalign ? */ +#cmakedefine HAVE_POSIX_MEMALIGN @HAVE_POSIX_MEMALIGN@ + /* compiler type detection */ #define LIBINT_COMPILER_ID_GNU 0 #define LIBINT_COMPILER_ID_Clang 1 diff --git a/include/libint2/config2.h.cmake.in b/include/libint2/config2.h.cmake.in index bf9d976f9..49d704492 100644 --- a/include/libint2/config2.h.cmake.in +++ b/include/libint2/config2.h.cmake.in @@ -28,9 +28,16 @@ #ifndef _libint2_include_libint2_config_h_1 #define _libint2_include_libint2_config_h_1 +#undef LIBINT_ALIGN_SIZE +#undef HAVE_POSIX_MEMALIGN /* retired Jan 2023 #undef LIBINT_SHGSHELL_ORDERING */ +/* if can be controlled with posix_memalign, alignment size */ +#define LIBINT2_ALIGN_SIZE @LIBINT2_ALIGN_SIZE@ /* Specifies the ordering of solid harmonics Gaussians in a shell. Retired Jan 2023 in favor of becoming a generator-time-only option */ /* #cmakedefine LIBINT_SHGSHELL_ORDERING @LIBINT_SHGSHELL_ORDERING@ */ +/* have posix_memalign ? */ +#cmakedefine HAVE_POSIX_MEMALIGN @HAVE_POSIX_MEMALIGN@ + #endif /* header guard */ diff --git a/src/lib/libint/CMakeLists.txt b/src/lib/libint/CMakeLists.txt index f07b88711..345544bb6 100644 --- a/src/lib/libint/CMakeLists.txt +++ b/src/lib/libint/CMakeLists.txt @@ -54,6 +54,8 @@ add_custom_target(libint-library-export DEPENDS "${EXPORT_STAGE_DIR}.tgz") # * DOWNLOAD_DIR is tidier but fails on Windows URL "${EXPORT_STAGE_DIR}.tgz" LOG_DOWNLOAD 1 + CMAKE_ARGS #"${library_CMAKE_ARGS}" + -DLIBINT2_ALIGN_SIZE=${LIBINT_ALIGN_SIZE} CMAKE_CACHE_ARGS -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} diff --git a/src/lib/libint/CMakeLists.txt.export b/src/lib/libint/CMakeLists.txt.export index 762bb3042..3404d71de 100644 --- a/src/lib/libint/CMakeLists.txt.export +++ b/src/lib/libint/CMakeLists.txt.export @@ -2,6 +2,7 @@ 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 CMP0074 NEW) +cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0079 NEW) ############################# Version and Metadata ############################# @@ -29,6 +30,16 @@ set(pnv libint2) # projectnameversion ################################### Options #################################### include(options) +include(CheckFunctionExists) + + +check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN) +if (HAVE_POSIX_MEMALIGN) + option_with_default(LIBINT2_ALIGN_SIZE + "(EXPERT) if posix_memalign is available, this will specify alignment of Libint data, in units of sizeof(LIBINT2_REALTYPE). Default is to use built-in heuristics." 0) + mark_as_advanced(LIBINT2_ALIGN_SIZE) +endif() + # <<< Ordering Conventions >>> diff --git a/src/lib/libint/features.cmake.in b/src/lib/libint/features.cmake.in index 1c2ca9344..2d310e873 100644 --- a/src/lib/libint/features.cmake.in +++ b/src/lib/libint/features.cmake.in @@ -3,6 +3,7 @@ LIBINT_ONEBODY_DERIV = @LIBINT_ONEBODY_DERIV@ LIBINT_SUPPORTS_ERI = @LIBINT_SUPPORTS_ERI@ LIBINT_ERI_MAX_AM = @Libint2_MAX_AM_ERI@ LIBINT_ERI_DERIV = @LIBINT_ERI_DERIV@ +LIBINT_CONTRACTED_INTS = @LIBINT_CONTRACTED_INTS@ LIBINT_SHELL_SET = @LIBINT_SHELL_SET@ LIBINT_SHGSHELL_ORDERING = @LIBINT_SHGSHELL_ORDERING@ LIBINT_SHGSHELL_ORDERING_STANDARD = @LIBINT_SHGSHELL_ORDERING_STANDARD@ From 7a4d6b32fb940f53d7cb70112346ee44991914e5 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Fri, 22 Dec 2023 23:55:58 -0500 Subject: [PATCH 2/3] realtype --- CMakeLists.txt | 9 +++++++ INSTALL.md | 34 ++++++++++++++++++++++++++ cmake/modules/int_userreal.cmake | 40 +++++++++++++++++++++++++++++++ include/libint2/config.h.cmake.in | 16 +++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 cmake/modules/int_userreal.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ed43b7168..52a02be7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,11 @@ option_with_default(LIBINT_ALIGN_SIZE "(EXPERT) if posix_memalign is available, this will specify alignment of Libint data, in units of sizeof(LIBINT2_REALTYPE). Default is to use built-in heuristics: system-determined for vectorization off (default) or veclen * sizeof(LIBINT2_REALTYPE) for vectorization on." 0) mark_as_advanced(LIBINT_ALIGN_SIZE) +option_with_default(LIBINT2_REALTYPE + "Specifies the floating-point data type used by the library. Consumed at library build-time." double) +option_with_print(LIBINT_USER_DEFINED_REAL_INCLUDES + "Additional #includes necessary to use the real type." OFF) +include(int_userreal) option_with_print(LIBINT_GENERATE_FMA "Generate FMA (fused multiply-add) instructions (to benefit must have FMA-capable hardware and compiler)" OFF) option_with_print(LIBINT_ENABLE_GENERIC_CODE @@ -261,6 +266,10 @@ endif() check_include_file_cxx(stdint.h HAVE_STDINT_H) # limits.h? +if(cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + set(LIBINT_HAS_CXX11 1) +endif() + booleanize01(ERI3_PURE_SH) booleanize01(ERI2_PURE_SH) booleanize01(LIBINT_SINGLE_EVALTYPE) diff --git a/INSTALL.md b/INSTALL.md index 5c38e6213..eae6ca64b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -109,6 +109,38 @@ Note that options, docs, and CMake components are focused on the C++ interface, ### Compilers and Flags (G L) (TARBALL) +### Miscellaneous (G L) + +* `LIBINT2_REALTYPE` — L — Specifies the floating-point data type used by the library. [Default=double] + By overriding the default it is possible to customize the library to use a lower-precision representation (which typically results in a performance boost) and/or to generate [SIMD](http://en.wikipedia.org/wiki/SIMD) vectorized code. *N.B. C++11 interface cannot be currently used with SIMD vectorized libraries!* The following values are valid: + * `double` -- double-precision floating-point representation of a real number; + * `float` -- single-precision floating-point number; + * `libint2::simd::VectorAVXDouble` -- vector of 4 packed doubles that can be used with [AVX](http://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions available on reasonably-modern x86 hardware (starting with Intel Sandy Bridge and AMD Bulldozer microarchitectures, available in processors since 2011); + * `libint2::simd::VectorSSEDouble` -- vector of 2 packed doubles that can be used with [SSE2](http://en.wikipedia.org/wiki/SSE2) instructions available on all x86 platforms, including those released before 2011; + * `libint2::simd::VectorSSEFloat` -- vector of 4 packed floats that can be used with [SSE](http://en.wikipedia.org/wiki/Streaming_SIMD_Extensions) instructions available on all x86 platforms, including those released before 2011; + * `libint2::simd::VectorQPXDouble` -- vector of 4 packed doubles that can be used with QPX instructions available on recent PowerPC hardware (IBM Blue Gene/Q); + * `libint2::simd::VectorFP2Double` -- vector of 2 packed doubles that can be used with FP2 (Double Hummer) instructions available on older PowerPC hardware (IBM Blue Gene/P). + + With the exception of `float`, these are vector types implemented in Libint using compiler _intrinsics_, functions that translate directly into vector instructions. To use these vector types you may need to provide additional compiler flags that will enable support for vector instructions. For example, to enable support for AVX in Clang use the `-mavx` compiler flag. With Intel compiler use flag `-xHOST` to enable all vector instruction sets supported by the processor on which you are compiling. + + **N.B.** It is also possible to use real vector types of [Agner Fog's vectorclass library](http://www.agner.org/optimize/#vectorclass), e.g. `Vec4d` and `Vec8f` for AVX. To use this library you need to add this to CPPFLAGS or CXXFLAGS: `-Ipath_to_vectorclass -DLIBINT2_HAVE_AGNER_VECTORCLASS` . On macOS, we only succeeded in using this library with a recent GNU C++ compiler, not with Clang. Not tested after CMake rework. + +* `LIBINT_USER_DEFINED_REAL_INCLUDES` — L — Additional #includes necessary to use the real type. [Defaults=none] +* `LIBINT_CONTRACTED_INTS` — G — Turn on support for contracted integrals. [Default=ON] +* `LIBINT_ERI_STRATEGY` — G — Compute ERIs using the following strategy (experts only). (0 for OS, 1 for HGP, 2 for HL). [Default=1] +* `LIBINT_USE_COMPOSITE_EVALUATORS` — G — Libint will use composite evaluators (i.e. every evaluator will compute one integral type only). [Default=ON] +* `LIBINT_SINGLE_EVALTYPE` — G — Generate single evaluator type (i.e. all tasks use the same evaluator). OFF is NYI [Default=ON] +* `LIBINT_ENABLE_UNROLLING` — G — Unroll shell sets into integrals (will unroll shell sets larger than N) (0 for never, N for N, 1000000000 for always). [Default=100] +* `LIBINT_ALIGN_SIZE` — G — If posix_memalign is available, this will specify alignment of Libint data, in units of sizeof(LIBINT2_REALTYPE). Default is to use built-in heuristics: system-determined for vectorization off (default) or veclen * sizeof(LIBINT2_REALTYPE) for vectorization on. (experts only). [Default=0] +* `LIBINT_GENERATE_FMA` — G — Generate FMA (fused multiply-add) instructions (to benefit must have FMA-capable hardware and compiler). [Default=OFF] +* `LIBINT_ENABLE_GENERIC_CODE` — G — Use manually-written generic code. [Default=OFF] +* `LIBINT_API_PREFIX` — G — Prepend this string to every name in the library API (except for the types). [Default=OFF] +* `LIBINT_VECTOR_LENGTH` — G — Compute integrals in vectors of length N. [Default=OFF] +* `LIBINT_VECTOR_METHOD` — G — Specifies how to vectorize integrals. Irrelevant when `LIBINT_VECTOR_LENGTH=OFF. Allowed values are 'block' and 'line'. [Default=block] +* `LIBINT_ACCUM_INTS` — G — Accumulate integrals to the buffer, rather than copy (OFF for copy, ON for accum). [Default=OFF] +* `LIBINT_FLOP_COUNT` — G — Support (approximate) FLOP counting by the library. (Generated code will require C++11!). [Default=OFF] +* `LIBINT_PROFILE` — G — Turn on profiling instrumentation of the library. (Generated code will require C++11!). [Default=OFF] + # GNU Autotools Update Guide @@ -185,6 +217,8 @@ Note that options, docs, and CMake components are focused on the C++ interface, * `--disable-composite-evaluators` --> `-D LIBINT_USE_COMPOSITE_EVALUATORS=OFF` * `--with-eri-strategy=OS` --> `-D LIBINT_ERI_STRATEGY=0` * `--with-eri-strategy=HL` --> `-D LIBINT_ERI_STRATEGY=2` +* `--with-real-type=type` --> `-D LIBINT2_REALTYPE=type` +* `--with-real-type-inclues=inc` --> `-D LIBINT_USER_DEFINED_REAL_INCLUDES="#include "` diff --git a/cmake/modules/int_userreal.cmake b/cmake/modules/int_userreal.cmake new file mode 100644 index 000000000..871065963 --- /dev/null +++ b/cmake/modules/int_userreal.cmake @@ -0,0 +1,40 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0075 NEW) # support CMAKE_REQUIRED_LIBRARIES + +include(CMakePushCheckState) + +cmake_push_check_state() +list(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/src/lib/libint") + +if(NOT(LIBINT2_REALTYPE STREQUAL "double")) + set(LIBINT_USER_DEFINED_REAL "${LIBINT2_REALTYPE}") + if(NOT(LIBINT_USER_DEFINED_REAL_INCLUDES)) + set(LIBINT_USER_DEFINED_REAL_INCLUDES "") + endif() + + check_cxx_source_compiles(" +#include +${LIBINT_USER_DEFINED_REAL_INCLUDES} + +int main(void) { + ${LIBINT_USER_DEFINED_REAL} x1; + ${LIBINT_USER_DEFINED_REAL} x2 = 2.0; + ${LIBINT_USER_DEFINED_REAL} x3 = x2; + ${LIBINT_USER_DEFINED_REAL} x4 = x2 + x3; + ${LIBINT_USER_DEFINED_REAL} x5 = x2 - x3; + ${LIBINT_USER_DEFINED_REAL} x6 = x2 * x3; + ${LIBINT_USER_DEFINED_REAL} x7 = 2 * x2; + ${LIBINT_USER_DEFINED_REAL} x8 = x2 * 3; + x6 += x2 * x3; + x7 -= 3 * x3; +} +" + _user_defined_real_compiles) + + if (NOT _user_defined_real_compiles) + message(FATAL_ERROR "LIBINT2_REALTYPE ${LIBINT_USER_DEFINED_REAL} is not usable, perhaps extra -I directories or extra #include's are needed?") + endif() +endif() + +cmake_pop_check_state() +cmake_policy(POP) diff --git a/include/libint2/config.h.cmake.in b/include/libint2/config.h.cmake.in index d13fe2871..b4e05d623 100644 --- a/include/libint2/config.h.cmake.in +++ b/include/libint2/config.h.cmake.in @@ -194,6 +194,12 @@ /* Specifies the class of shell sets generated. Allowed values are defined at the bottom of this file -- also see CMakeLists.txt */ #cmakedefine LIBINT_SHELL_SET @LIBINT_SHELL_SET@ +/* User-defined real type */ +#cmakedefine LIBINT_USER_DEFINED_REAL "@LIBINT_USER_DEFINED_REAL@" + +/* Include statements needed to use LIBINT_USER_DEFINED_REAL */ +#cmakedefine LIBINT_USER_DEFINED_REAL_INCLUDES "@LIBINT_USER_DEFINED_REAL_INCLUDES@" + /* Generate FMA instructions? */ #cmakedefine LIBINT_GENERATE_FMA @LIBINT_GENERATE_FMA@ @@ -218,6 +224,16 @@ /* Strategy for ERI evaluation */ #define LIBINT_ERI_STRATEGY @LIBINT_ERI_STRATEGY@ +/* -------------------------- + have C++ features? + -------------------------- */ + +/* define if CXX compiler can compile C++11 */ +#cmakedefine LIBINT_HAS_CXX11 @LIBINT_HAS_CXX11@ + +/* C++ compiler allows template with default params as template template parameter (check is NYI) */ +#undef CXX_ALLOWS_DEFPARAMTEMPLATE_AS_TEMPTEMPPARAM + /* Known orderings of cartesian Gaussians */ From 808ada6967e380b7894532a9da57dfb3049b5094 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Sat, 23 Dec 2023 02:36:11 -0500 Subject: [PATCH 3/3] finish up config2 --- INSTALL.md | 60 ++++++++++++++++++++++++++++ cmake/modules/int_userreal.cmake | 5 ++- include/libint2/config2.h.cmake.in | 4 ++ src/lib/libint/CMakeLists.txt | 9 ++++- src/lib/libint/CMakeLists.txt.export | 7 +++- src/lib/libint/populate.cmake | 1 + 6 files changed, 81 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index eae6ca64b..74e3152be 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,3 +1,63 @@ +#### Note: If you received this file from a `libint-2.*.tgz` source archive, `(TARBALL)` marks portions of this document relevant to you. + + +# Libint Compiler vs Library + +Before you read on: + +* If you want a pre-built Libint library, packages may be available: + * conda-forge: `conda install libint -c conda-forge` for Linux, Apple (Intel), Apple Silicon, and Windows. See https://github.com/conda-forge/libint-feedstock/tree/main/recipe for configuration, tarball, and build conditions. + * Debian (TBD) + * Fedora (TBD) +* If you want to know how to _use_ a libint library in your code: + * if you use C++11 or later (strongly recommended): read the [Libint Wiki](https://github.com/evaleev/libint/wiki/using-modern-CPlusPlus-API) + * if you use pre-2011 C++, C, Fortran, or any other language, refer to the [Libint Programmer's Manual](https://sourceforge.net/projects/libint/files/libint-for-beginners/progman-2.0.3-stable.pdf/download) +* If you want to _build and use_ a libint _library_: + * if all you want is a basic library that computes integrals necessary to compute energies, use the pre-generated library labeled "lmax=6 library (standard ints only)" from the [latest release](https://github.com/evaleev/libint/releases/latest) of Libint + * many codes using libint, e.g. orca and mpqc, already include an appropriately configured libint library, and you do not need to generate it yourself + * if you need compilation directions, _read on_, skipping the compiler/generation parts. (TARBALL) +* If you want to know how to _generate_ a libint _library_ using the libint _compiler_, these are some compelling circumstances: + * if you need a custom libint library with choice of integral types, AM, orderings, language interfaces, etc. + * if you want to develop libint with new integral types, recurrence relations, and computation + strategies, you'll need to edit the compiler. If you are interested in working on the compiler + code please consider consulting with one of the Libint authors to avoid duplication of effort. + * if you do need to generate a custom library, _read on_. + + +----------------------------------------------------------------------------- + +# Overview + +The Libint build is structured into three parts: + +* generator/compiler + - (1) build src/bin/libint/ into compiler executable `build_libint` + - pretty quick, runs in parallel + - consumes all the enable/max/opt/orderings integral options + - (2) optionally testable +* export + - (3) run `build_libint` to generate library source (C++) files (that upon + compilation can become a Libint2 library) and combine them with other + static source files in src/lib/libint/ and general static files (e.g., + include/ and docs/) into an independent tarball ready for distribution + (with its own CMake configuration, tests, etc.). + - really slow for non-trivial angular momenta; runs in serial + - consumes no options + - build target `export` to stop after this step and collect source tarball +* library (TARBALL) + - from the repo, can be built as a subproject (FetchContent) or completely insulated (bare ExternalProject; default). + For FetchContent, must build libint-library-export target before library build targets appear. + Alternately, can start from independent TARBALL generated by (3) and build as standalone project + or dependency (FetchContent or ExternalProject) + - (4) unpack the export tarball and build the library and install into \/library-install-stage/ + - duration depends on number of integrals requested; runs in parallel + - consumes language-interface and the CMAKE_INSTALL_[DATA|INCLUDE|LIB]DIR paths options + - the default build target includes this final library build + - (5) optionally testable + - (6) install into CMAKE_INSTALL_PREFIX + - (7) optional Python build alongside library or afterwards. optional testing requires library install + + # Configuring Libint * Notes diff --git a/cmake/modules/int_userreal.cmake b/cmake/modules/int_userreal.cmake index 871065963..cbd6d9a03 100644 --- a/cmake/modules/int_userreal.cmake +++ b/cmake/modules/int_userreal.cmake @@ -4,7 +4,8 @@ cmake_policy(SET CMP0075 NEW) # support CMAKE_REQUIRED_LIBRARIES include(CMakePushCheckState) cmake_push_check_state() -list(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/src/lib/libint") +# needed for #include . works for top-level but not for EP; check again after more installs +list(APPEND CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/include;${PROJECT_SOURCE_DIR}/src/lib/libint") if(NOT(LIBINT2_REALTYPE STREQUAL "double")) set(LIBINT_USER_DEFINED_REAL "${LIBINT2_REALTYPE}") @@ -13,7 +14,7 @@ if(NOT(LIBINT2_REALTYPE STREQUAL "double")) endif() check_cxx_source_compiles(" -#include +//#include ${LIBINT_USER_DEFINED_REAL_INCLUDES} int main(void) { diff --git a/include/libint2/config2.h.cmake.in b/include/libint2/config2.h.cmake.in index 49d704492..20058ffb7 100644 --- a/include/libint2/config2.h.cmake.in +++ b/include/libint2/config2.h.cmake.in @@ -30,10 +30,14 @@ #undef LIBINT_ALIGN_SIZE #undef HAVE_POSIX_MEMALIGN +#undef LIBINT_USER_DEFINED_REAL /* retired Jan 2023 #undef LIBINT_SHGSHELL_ORDERING */ /* if can be controlled with posix_memalign, alignment size */ #define LIBINT2_ALIGN_SIZE @LIBINT2_ALIGN_SIZE@ +/* User-defined real type */ +#cmakedefine LIBINT2_REALTYPE "@LIBINT2_REALTYPE@" + /* Specifies the ordering of solid harmonics Gaussians in a shell. Retired Jan 2023 in favor of becoming a generator-time-only option */ /* #cmakedefine LIBINT_SHGSHELL_ORDERING @LIBINT_SHGSHELL_ORDERING@ */ diff --git a/src/lib/libint/CMakeLists.txt b/src/lib/libint/CMakeLists.txt index 345544bb6..6be004c93 100644 --- a/src/lib/libint/CMakeLists.txt +++ b/src/lib/libint/CMakeLists.txt @@ -45,6 +45,12 @@ add_custom_target(libint-library-export DEPENDS "${EXPORT_STAGE_DIR}.tgz") # <<< Build Library >>> include(ExternalProject) + + list(APPEND library_CMAKE_ARGS + -DLIBINT2_ALIGN_SIZE=${LIBINT_ALIGN_SIZE} + -DLIBINT2_REALTYPE=${LIBINT2_REALTYPE} + ) + ExternalProject_Add( library DEPENDS @@ -54,8 +60,7 @@ add_custom_target(libint-library-export DEPENDS "${EXPORT_STAGE_DIR}.tgz") # * DOWNLOAD_DIR is tidier but fails on Windows URL "${EXPORT_STAGE_DIR}.tgz" LOG_DOWNLOAD 1 - CMAKE_ARGS #"${library_CMAKE_ARGS}" - -DLIBINT2_ALIGN_SIZE=${LIBINT_ALIGN_SIZE} + CMAKE_ARGS "${library_CMAKE_ARGS}" CMAKE_CACHE_ARGS -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} diff --git a/src/lib/libint/CMakeLists.txt.export b/src/lib/libint/CMakeLists.txt.export index 3404d71de..3b09da11e 100644 --- a/src/lib/libint/CMakeLists.txt.export +++ b/src/lib/libint/CMakeLists.txt.export @@ -40,10 +40,15 @@ if (HAVE_POSIX_MEMALIGN) mark_as_advanced(LIBINT2_ALIGN_SIZE) endif() +option_with_default(LIBINT2_REALTYPE + "Specifies the floating-point data type used by the library." double) +include(int_userreal) + # <<< Ordering Conventions >>> -# retired Jan 2023 # option_with_default(LIBINT2_SHGAUSS_ORDERING "Ordering for shells of solid harmonic Gaussians: standard or gaussian" standard) +# Jan 2023, retired # option_with_default(LIBINT2_SHGAUSS_ORDERING ... +# August 2023: the following variable has an effect on `INT_SOLIDHARMINDEX(l, m)` but otherwise the choice can be deferred to runtime. set(LIBINT2_SHGAUSS_ORDERING ${LIBINT2_SHGAUSS_ORDERING}) message(STATUS "Setting option LIBINT2_SHGAUSS_ORDERING: ${LIBINT2_SHGAUSS_ORDERING} (read-only from generation-time)") diff --git a/src/lib/libint/populate.cmake b/src/lib/libint/populate.cmake index 333d6f479..00166960e 100644 --- a/src/lib/libint/populate.cmake +++ b/src/lib/libint/populate.cmake @@ -5,6 +5,7 @@ file( "${PROJECT_SOURCE_DIR}/cmake/modules/int_orderings.cmake" "${PROJECT_SOURCE_DIR}/cmake/modules/options.cmake" "${PROJECT_BINARY_DIR}/cmake/modules/int_computed.cmake" + "${PROJECT_SOURCE_DIR}/cmake/modules/int_userreal.cmake" DESTINATION "${EXPORT_STAGE_DIR}/cmake/modules" )