Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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)
Expand All @@ -216,15 +216,75 @@ 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_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
"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?

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)
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 #################################
Expand Down
117 changes: 117 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -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 \<build\>/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
Expand Down Expand Up @@ -109,6 +169,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

Expand Down Expand Up @@ -165,6 +257,31 @@ 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`
* `--with-real-type=type` --> `-D LIBINT2_REALTYPE=type`
* `--with-real-type-inclues=inc` --> `-D LIBINT_USER_DEFINED_REAL_INCLUDES="#include <stdio.h>"`





### Run-Time Compatibility
Expand Down
41 changes: 41 additions & 0 deletions cmake/modules/int_userreal.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0075 NEW) # support CMAKE_REQUIRED_LIBRARIES

include(CMakePushCheckState)

cmake_push_check_state()
# needed for #include <libint2/util/vector.h>. 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}")
if(NOT(LIBINT_USER_DEFINED_REAL_INCLUDES))
set(LIBINT_USER_DEFINED_REAL_INCLUDES "")
endif()

check_cxx_source_compiles("
//#include <libint2/util/vector.h>
${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)
71 changes: 71 additions & 0 deletions include/libint2/config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@

Expand Down Expand Up @@ -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@

Expand All @@ -173,6 +194,46 @@
/* 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@

/* 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@

/* --------------------------
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
*/
Expand All @@ -194,6 +255,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
Expand Down
Loading
Loading