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
56 changes: 44 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,43 @@ jobs:
fail-fast: false
matrix:
include:
- name: gcc / serial / Release
# ---- alpscore-free core (default build, no ALPSCore on the box) ----
- name: gcc / serial / Release / core
cxx: g++
mpi: OFF
build_type: Release
alps: OFF

- name: gcc / MPI / Release
- name: clang / serial / Release / core
cxx: clang++
mpi: OFF
build_type: Release
alps: OFF

- name: gcc / serial / Debug / core
cxx: g++
mpi: OFF
build_type: Debug
alps: OFF

- name: gcc / MPI / Release / core
cxx: g++
mpi: ON
build_type: Release
alps: OFF

- name: clang / serial / Release
cxx: clang++
# ---- legacy ALPSCore compat layer (EDLIB_WITH_ALPSCORE=ON) ----
- name: gcc / serial / Release / alpscore
cxx: g++
mpi: OFF
build_type: Release
alps: ON

- name: gcc / serial / Debug
- name: gcc / MPI / Release / alpscore
cxx: g++
mpi: OFF
build_type: Debug
mpi: ON
build_type: Release
alps: ON

steps:
- uses: actions/checkout@v4
Expand All @@ -53,17 +71,19 @@ jobs:
clang

# -----------------------------------------------------------------------
# ALPSCore (built from source, cached by commit hash)
# ALPSCore (only needed for the legacy compat layer; built from source,
# cached by commit hash)
# -----------------------------------------------------------------------
- name: Cache ALPSCore
if: matrix.alps == 'ON'
id: cache-alpscore
uses: actions/cache@v4
with:
path: /opt/alpscore
key: alpscore-v2.3.3-${{ matrix.cxx }}-MPI${{matrix.mpi}}-${{ runner.os }}

- name: Build and install ALPSCore
if: steps.cache-alpscore.outputs.cache-hit != 'true'
if: matrix.alps == 'ON' && steps.cache-alpscore.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch v2.3.3 \
https://github.com/ALPSCore/ALPSCore.git /tmp/alpscore-src
Expand All @@ -89,7 +109,8 @@ jobs:
-G Ninja \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DALPSCore_DIR=/opt/alpscore/share/ALPSCore \
-DEDLIB_WITH_ALPSCORE=${{ matrix.alps }} \
${{ matrix.alps == 'ON' && '-DALPSCore_DIR=/opt/alpscore/share/ALPSCore' || '' }} \
-DTesting=ON \
-DExamples=OFF \
-DUSE_MPI=${{ matrix.mpi }} \
Expand All @@ -98,17 +119,28 @@ jobs:
- name: Build EDLib
run: cmake --build build -j$(nproc)

# Serial jobs: ctest runs the core suite, plus the legacy alps suite
# when EDLIB_WITH_ALPSCORE=ON registered it.
- name: Run tests (serial)
if: matrix.mpi == 'OFF'
run: ctest --test-dir build -V --output-on-failure

# Core tests always exist; the legacy alps suite only when alps=ON.
# Symmetry tests run single-process; parallel-path tests on 2 ranks.
- name: Run tests (MPI, 2 ranks)
if: matrix.mpi == 'ON'
run: |
set -e
MPIRUN="mpirun --oversubscribe --mca osc pt2pt --mca btl ^sm -np 2"
./build/test/SzSymmetryTest
./build/test/NSymmetryTest
$MPIRUN ./build/test/HubbardModelTest
$MPIRUN ./build/test/HubbardTest
$MPIRUN ./build/test/LanczosTest
$MPIRUN ./build/test/StaticObservablesTest
$MPIRUN ./build/test/MpiTest
if [ "${{ matrix.alps }}" = "ON" ]; then
./build/test/alpscore/SzSymmetryAlpsCoreTest
./build/test/alpscore/NSymmetryAlpsCoreTest
$MPIRUN ./build/test/alpscore/HubbardModelAlpsCoreTest
$MPIRUN ./build/test/alpscore/LanczosAlpsCoreTest
$MPIRUN ./build/test/alpscore/StaticObservablesAlpsCoreTest
fi
142 changes: 89 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)
project(EDLib LANGUAGES C CXX
VERSION 2.0)
VERSION 3.0)

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
Expand All @@ -10,60 +10,77 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(CXXStandard)
use_cxx17()

find_package(ALPSCore COMPONENTS params hdf5 gf REQUIRED)
option(EDLIB_WITH_ALPSCORE
"Pull EDLib-alpscore (legacy ALPSCore-based API: alps::params / alps::hdf5 / alps::gf) via FetchContent. Off = header-only edlib:: core only."
OFF)

find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${ALPSCore_INCLUDES})

# cpp-arnoldi: header-only C++ Arnoldi/Lanczos eigensolver (replaces ARPACK).
include(FetchContent)
FetchContent_Declare(cpp_arnoldi
GIT_REPOSITORY https://github.com/Q-solvers/cpp-arnoldi.git
GIT_TAG 444304d88d6029f717031ea5b45294a4bd2a3517)
GIT_REPOSITORY https://github.com/Q-solvers/cpp-arnoldi.git
GIT_TAG 444304d88d6029f717031ea5b45294a4bd2a3517)
FetchContent_MakeAvailable(cpp_arnoldi)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message("setting build type to default, i.e. optimized build")
set(CMAKE_BUILD_TYPE Release)
message("setting build type to default, i.e. optimized build")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_DISABLE_ASSERTS -DNDEBUG -g")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")


set(extlibs
${Boost_LIBRARIES}
${HDF5_LIBRARIES}
${ALPSCore_LIBRARIES}
arnoldi::arnoldi
)
arnoldi::arnoldi)

if(USE_MPI)
if(!ALPS_HAVE_MPI)
MESSAGE(FATAL_ERROR "Enable MPI support in ALPSCore.")
endif(!ALPS_HAVE_MPI)
find_package(MPI REQUIRED)
if(MPI_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI")
set(parlibs MPI::MPI_CXX)
endif(MPI_FOUND)
endif()
message(INFO " Using parallel libraries: ${parlibs}")
endif(USE_MPI)
endif()

add_subdirectory(include/edlib)
add_subdirectory(include/ext)

include(GNUInstallDirs)

add_library(${PROJECT_NAME} INTERFACE)
add_library(EDLib::EDLib ALIAS ${PROJECT_NAME}) # Define namespaced alias target
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
add_library(EDLib::EDLib ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME} INTERFACE Eigen3::Eigen arnoldi::arnoldi)

# Legacy ALPSCore-based shim layer lives in the separate EDLib-alpscore
# project, fetched here on demand. It defines the EDLib::Alpscore INTERFACE
# target and the EDLIB_WITH_ALPSCORE compile definition.
if(EDLIB_WITH_ALPSCORE)
FetchContent_Declare(edlib_alpscore
GIT_REPOSITORY https://github.com/Q-solvers/EDLib-alpscore.git
GIT_TAG master)
FetchContent_MakeAvailable(edlib_alpscore)
list(APPEND extlibs EDLib::Alpscore)

# Fold EDLib-alpscore into the parent install: a single
# `find_package(EDLib)` provides both the core and the alpscore shim.
set_target_properties(EDLib-alpscore PROPERTIES EXPORT_NAME Alpscore)
endif()

install(TARGETS ${PROJECT_NAME}
set(_edlib_install_targets ${PROJECT_NAME})
if(EDLIB_WITH_ALPSCORE)
list(APPEND _edlib_install_targets EDLib-alpscore)
endif()

install(TARGETS ${_edlib_install_targets}
EXPORT ${PROJECT_NAME}_targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand All @@ -75,10 +92,10 @@ write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)

install(EXPORT ${PROJECT_NAME}_targets
FILE ${PROJECT_NAME}Targets.cmake
Expand All @@ -89,41 +106,60 @@ install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)

file (GLOB_RECURSE TARGET_INSTALL_LIB_HEADERS "${PROJECT_SOURCE_DIR}/include/edlib/*.h")
file (GLOB_RECURSE TARGET_INSTALL_EXT_HEADERS "${PROJECT_SOURCE_DIR}/include/ext/*.h")
install(FILES include/edlib.h
DESTINATION include)
install(FILES ${TARGET_INSTALL_LIB_HEADERS}
DESTINATION include/edlib)
install(FILES ${TARGET_INSTALL_EXT_HEADERS}
DESTINATION include/ext)
install(FILES include/edlib.h DESTINATION include)

# Core API: always installed (header-only, no alpscore).
install(DIRECTORY include/edlib DESTINATION include
FILES_MATCHING PATTERN "*.h" PATTERN ".ipynb_checkpoints" EXCLUDE)
install(DIRECTORY include/ext DESTINATION include
FILES_MATCHING PATTERN "*.h" PATTERN ".ipynb_checkpoints" EXCLUDE)

# Legacy alpscore shim headers come from the FetchContent'd EDLib-alpscore.
if(EDLIB_WITH_ALPSCORE)
install(DIRECTORY ${edlib_alpscore_SOURCE_DIR}/include/edlib/alpscore
DESTINATION include/edlib
FILES_MATCHING PATTERN "*.h" PATTERN ".ipynb_checkpoints" EXCLUDE)
install(DIRECTORY ${edlib_alpscore_SOURCE_DIR}/include/ext/alpscore
DESTINATION include/ext
FILES_MATCHING PATTERN "*.h" PATTERN ".ipynb_checkpoints" EXCLUDE)
endif()

option(Testing "Enable testing" OFF)
if(Testing)
include(EnableGtests)
#UseGtest()
#include_directories(${Hubbard_SOURCE_DIR}/test)
add_subdirectory(test)
include_directories(${GTEST_INCLUDE_DIR})
enable_testing()

# Core-only tests: build and run regardless of EDLIB_WITH_ALPSCORE.
add_subdirectory(test)
add_test(HubbardTest test/HubbardTest)
add_test(LanczosTest test/LanczosTest)
add_test(SzSymmetryTest test/SzSymmetryTest)
add_test(NSymmetryTest test/NSymmetryTest)
add_test(HubbardModelTest test/HubbardModelTest)
add_test(LanczosTest test/LanczosTest)
add_test(StaticObservablesTest test/StaticObservablesTest)


endif (Testing)

add_test(NSymmetryTest test/NSymmetryTest)
if(USE_MPI)
add_test(MpiTest test/MpiTest)
endif()

# Legacy alps-using tests only when the option is enabled.
if(EDLIB_WITH_ALPSCORE)
add_subdirectory(test/alpscore)
add_test(SzSymmetryAlpsCoreTest test/alpscore/SzSymmetryAlpsCoreTest)
add_test(NSymmetryAlpsCoreTest test/alpscore/NSymmetryAlpsCoreTest)
add_test(HubbardModelAlpsCoreTest test/alpscore/HubbardModelAlpsCoreTest)
add_test(LanczosAlpsCoreTest test/alpscore/LanczosAlpsCoreTest)
add_test(StaticObservablesAlpsCoreTest test/alpscore/StaticObservablesAlpsCoreTest)
endif()
endif()

option(Examples "Enable examples" ON)
if(Examples)
add_subdirectory(examples)
set(SOURCE_FILES main.cpp)
add_executable(Hubbard ${SOURCE_FILES})
target_link_libraries(Hubbard ${PROJECT_NAME} ${extlibs})
if(USE_MPI)
target_link_libraries(Hubbard ${parlibs})
endif(USE_MPI)
endif(Examples)
if(EDLIB_WITH_ALPSCORE)
set(SOURCE_FILES main.cpp)
add_executable(Hubbard ${SOURCE_FILES})
target_link_libraries(Hubbard ${PROJECT_NAME} ${extlibs})
if(USE_MPI)
target_link_libraries(Hubbard ${parlibs})
endif()
endif()
endif()
16 changes: 16 additions & 0 deletions cmake/EDLibConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(Eigen3 NO_MODULE)
find_dependency(BLAS)
find_dependency(LAPACK)

# cpp-arnoldi installs only a *Targets.cmake (no Config.cmake), so include
# it directly out of either lib/cmake or lib64/cmake.
include("${PACKAGE_PREFIX_DIR}/lib/cmake/arnoldi/arnoldiTargets.cmake" OPTIONAL)
include("${PACKAGE_PREFIX_DIR}/lib64/cmake/arnoldi/arnoldiTargets.cmake" OPTIONAL)

set(EDLIB_WITH_ALPSCORE @EDLIB_WITH_ALPSCORE@)
if(EDLIB_WITH_ALPSCORE)
find_dependency(ALPSCore COMPONENTS params hdf5 gf)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")
24 changes: 12 additions & 12 deletions examples/Anderson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
//
#include <iostream>

#include <edlib/EDParams.h>
#include <edlib/alpscore/EDParams.h>
#include <cstdlib>
#include "edlib/Hamiltonian.h"
#include "edlib/SzSymmetry.h"
#include "edlib/SOCRSStorage.h"
#include "edlib/CRSStorage.h"
#include "edlib/HubbardModel.h"
#include "edlib/GreensFunction.h"
#include "edlib/ChiLoc.h"
#include "edlib/HDF5Utils.h"
#include "edlib/SpinResolvedStorage.h"
#include "edlib/StaticObservables.h"
#include "edlib/MeshFactory.h"
#include "edlib/alpscore/Hamiltonian.h"
#include "edlib/alpscore/SzSymmetry.h"
#include "edlib/alpscore/SOCRSStorage.h"
#include "edlib/alpscore/CRSStorage.h"
#include "edlib/alpscore/HubbardModel.h"
#include "edlib/alpscore/GreensFunction.h"
#include "edlib/alpscore/ChiLoc.h"
#include "edlib/alpscore/HDF5Utils.h"
#include "edlib/alpscore/SpinResolvedStorage.h"
#include "edlib/alpscore/StaticObservables.h"
#include "edlib/alpscore/MeshFactory.h"

int main(int argc, const char ** argv) {
// Init MPI if enabled
Expand Down
Loading
Loading