Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into general-tensor-in…
Browse files Browse the repository at this point in the history
…dices
  • Loading branch information
Krzmbrzl committed Jun 25, 2024
2 parents 1b591fa + 7f31851 commit 5d1d12b
Show file tree
Hide file tree
Showing 118 changed files with 7,595 additions and 7,369 deletions.
62 changes: 35 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
cmake_minimum_required(VERSION 3.15.0) # need list(PREPEND for toolchains

# Preload versions/tags of all dependencies ====================================
include(external/versions.cmake)

###############################################################################
# CMake defaults to address key pain points
###############################################################################

# safety net for dev workflow: accidental install will not affect FindOrFetch*
if (NOT DEFINED CACHE{CMAKE_FIND_NO_INSTALL_PREFIX})
set(CMAKE_FIND_NO_INSTALL_PREFIX ON CACHE BOOL "Whether find_* commands will search CMAKE_INSTALL_PREFIX and CMAKE_STAGING_PREFIX; see https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_NO_INSTALL_PREFIX.html#variable:CMAKE_FIND_NO_INSTALL_PREFIX")
endif()

###############################################################################
# Bring ValeevGroup cmake toolkit
###############################################################################
include(external/versions.cmake)
include(FetchContent)
if (DEFINED PROJECT_BINARY_DIR)
set(VG_CMAKE_KIT_PREFIX_DIR PROJECT_BINARY_DIR)
Expand Down Expand Up @@ -191,6 +202,8 @@ set(SeQuant_src
SeQuant/core/eval_expr.cpp
SeQuant/core/eval_expr.hpp
SeQuant/core/eval_node.hpp
SeQuant/core/export/itf.cpp
SeQuant/core/export/itf.hpp
SeQuant/core/expr.cpp
SeQuant/core/expr.hpp
SeQuant/core/expr_algorithm.hpp
Expand All @@ -199,6 +212,7 @@ set(SeQuant_src
SeQuant/core/hugenholtz.hpp
SeQuant/core/index.cpp
SeQuant/core/index.hpp
SeQuant/core/index_space_registry.hpp
SeQuant/core/interval.hpp
SeQuant/core/latex.cpp
SeQuant/core/latex.ipp
Expand All @@ -219,7 +233,6 @@ set(SeQuant_src
SeQuant/core/rational.hpp
SeQuant/core/runtime.cpp
SeQuant/core/runtime.hpp
SeQuant/core/space.cpp
SeQuant/core/space.hpp
SeQuant/core/tag.hpp
SeQuant/core/tensor.cpp
Expand All @@ -230,6 +243,7 @@ set(SeQuant_src
SeQuant/core/tensor_network.hpp
SeQuant/core/timer.hpp
SeQuant/core/utility/context.hpp
SeQuant/core/utility/indices.hpp
SeQuant/core/utility/macros.hpp
SeQuant/core/utility/nodiscard.hpp
SeQuant/core/utility/singleton.hpp
Expand All @@ -246,8 +260,6 @@ set(SeQuant_src
SeQuant/domain/mbpt/context.cpp
SeQuant/domain/mbpt/convention.cpp
SeQuant/domain/mbpt/convention.hpp
SeQuant/domain/mbpt/mr.cpp
SeQuant/domain/mbpt/mr.hpp
SeQuant/domain/mbpt/models/cc.cpp
SeQuant/domain/mbpt/models/cc.hpp
SeQuant/domain/mbpt/op.cpp
Expand All @@ -256,12 +268,7 @@ set(SeQuant_src
SeQuant/domain/mbpt/rdm.hpp
SeQuant/domain/mbpt/spin.cpp
SeQuant/domain/mbpt/spin.hpp
SeQuant/domain/mbpt/sr.cpp
SeQuant/domain/mbpt/sr.hpp
SeQuant/domain/mbpt/vac_av.ipp
)
set_source_files_properties(
SeQuant/domain/mbpt/op.cpp SeQuant/domain/mbpt/sr.cpp SeQuant/domain/mbpt/mr.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
SeQuant/domain/mbpt/vac_av.ipp)

### optional prereqs
if (SEQUANT_EVAL_TESTS)
Expand Down Expand Up @@ -381,16 +388,16 @@ if (Boost_BUILT_FROM_SOURCE AND TARGET build-boost-in-SeQuant)
endif()

if (SEQUANT_IWYU)
find_program(iwyu_path NAMES include-what-you-use iwyu)

if (iwyu_path)
set(iwyu_options_and_path
"${iwyu_path}"
-Xiwyu --cxx17ns
-Xiwyu --no_comments
)
set_property(TARGET SeQuant PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_options_and_path})
endif()
find_program(iwyu_path NAMES include-what-you-use iwyu)

if (iwyu_path)
set(iwyu_options_and_path
"${iwyu_path}"
-Xiwyu --cxx17ns
-Xiwyu --no_comments
)
set_property(TARGET SeQuant PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_options_and_path})
endif()
endif()

### unit tests
Expand Down Expand Up @@ -428,6 +435,7 @@ if (BUILD_TESTING)
tests/unit/test_string.cpp
tests/unit/test_latex.cpp
tests/unit/test_utilities.cpp
tests/unit/test_export.cpp
)

if (TARGET tiledarray)
Expand Down Expand Up @@ -474,7 +482,8 @@ if (BUILD_TESTING)
add_executable(${example0} EXCLUDE_FROM_ALL
examples/${example0}/${example0}.cpp)
target_link_libraries(${example0} SeQuant)
set(${example0}_cmdline_args ";3 t std so;3 t csv so;3 lambda std so;3 lambda csv so;2 t std sf;2 t csv sf;2 lambda std sf;2 lambda csv sf")
# N.B. empty space, to appease foreach
set(${example0}_cmdline_args " ;3 t std so;3 t csv so;3 lambda std so;3 lambda csv so;2 t std sf;2 t csv sf;2 lambda std sf;2 lambda csv sf")

if (TARGET Eigen3::Eigen) # these examples require Eigen for full functionality
# Single-Reference closed-shell Coupled-Cluster equation
Expand Down Expand Up @@ -539,9 +548,9 @@ if (BUILD_TESTING)
target_link_libraries(${example7} SeQuant)
endif (BTAS_SOURCE_DIR)


foreach (i RANGE 8 11)
math(EXPR s "${i} - 7") # map 8..11 -> 1..4
set(lastexample 13)
foreach (i RANGE 8 ${lastexample})
math(EXPR s "${i} - 7") # map 8..13 -> 1..6
set(example${i} synopsis${s})
add_executable(${example${i}} EXCLUDE_FROM_ALL
examples/synopsis/${example${i}}.cpp)
Expand All @@ -554,18 +563,17 @@ if (BUILD_TESTING)
target_link_libraries(${example12} SeQuant)

# add tests for running examples
set(lastexample 12)
foreach (i RANGE ${lastexample})
if (TARGET ${example${i}})
add_dependencies(examples-sequant ${example${i}})
add_test(sequant/example/${example${i}}/build "${CMAKE_COMMAND}"
--build ${CMAKE_BINARY_DIR} --target ${example${i}})
if (NOT DEFINED ${example${i}}_cmdline_args)
set(${example${i}}_cmdline_args "")
set(${example${i}}_cmdline_args " ") # N.B. empty space, to appease foreach
endif()
set(${example${i}}_run_counter 0)
foreach (args ${${example${i}}_cmdline_args})
string(REPLACE " " ";" args ${args})
string(REPLACE " " ";" args "${args}")
add_test(NAME sequant/example/${example${i}}/run/${${example${i}}_run_counter}
COMMAND ${example${i}} ${args}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples)
Expand Down
27 changes: 21 additions & 6 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
SeQuant: installation guide
===========================

prerequisites:
## TL;DR
While in the SeQuant source directory:
* `cmake -B build -S .`
* `cmake --build build --target check-sequant`

## Prerequisites
* mandatory:
* CMake 3.15 or later
* a C++17 compiler
* [Boost](https://www.boost.org/), version 1.81 or higher (N.B. older compilers _may_ work with older Boost releases). *SeQuant can download and build Boost if configured with `Boost_FETCH_IF_MISSING=ON`, but this is not recommended.* The following non-header-only Boost libraries are required, hence Boost must be configured/built:
* [Boost](https://www.boost.org/), version 1.81 or higher. *SeQuant can download and build Boost if configured with `Boost_FETCH_IF_MISSING=ON`, but this is not recommended.* The following non-header-only Boost libraries are required, hence Boost must be configured/built:
- [Boost.Regex](https://www.boost.org/doc/libs/master/libs/regex/doc/html/index.html)
- [Boost.Locale](https://www.boost.org/doc/libs/master/libs/locale/doc/html/index.html)
* [Range-V3](https://github.com/ericniebler/range-v3.git), tag 0.12.0, *if not found, SeQuant will download and build Range-V3*
Expand All @@ -15,14 +20,24 @@ prerequisites:
* for building `stcc*` example programs
* [Eigen](http://eigen.tuxfamily.org/), version 3

for the impatient (from the top of the SeQuant source directory):
* `cmake -B build -S .`
* `cmake --build build --target check-sequant`
## Configure

From the SeQuant source directory run the following command to configure the build harness:
* `cmake -B build -S .`

useful CMake variables:
### Useful CMake variables
* [`BUILD_TESTING`](https://cmake.org/cmake/help/latest/module/CTest.html) --- enables unit tests targets, e.g. `check-sequant` [default=ON]
* [`CMAKE_CXX_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html#variable:CMAKE_%3CLANG%3E_COMPILER) --- specifies the C++ compiler to use
* [`CMAKE_PREFIX_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html) --- this semicolon-separated list specifies search paths for dependencies (Boost, Range-V3, etc.)
* [`CMAKE_INSTALL_PREFIX`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) --- the installation path for SeQuant
* `SEQUANT_MIMALLOC` --- use [mimalloc](https://github.com/microsoft/mimalloc) for fast memory allocation
* `SEQUANT_EVAL_TRACE` --- enables tracing of expression interpretation; especially useful in combination with TiledArray's memory tracing mechanism (configure TiledArray with `TA_TENSOR_MEM_PROFILE=ON` to enable that)
* `SEQUANT_PYTHON` --- enables building of Pythin bindings
* `Boost_FETCH_IF_MISSING` --- if set to `ON`, SeQuant will download and build Boost if it is not found by `find_package(Boost ...)`; this is not recommended. [default=OFF]

## Build

To build, test, and install SeQuant, run the following commands:
* `cmake --build build`
* (optional) `cmake --build build --target check-sequant`
* `cmake --build build --target install`
Loading

0 comments on commit 5d1d12b

Please sign in to comment.