Skip to content

Commit

Permalink
base lib
Browse files Browse the repository at this point in the history
take 2

take 3

take 4

take 5

take 6

take 7

take 8

take 9

take 10

take 11

take 12

take 13

take 14
  • Loading branch information
loriab committed Jan 7, 2024
1 parent 82c98d3 commit ee93781
Show file tree
Hide file tree
Showing 12 changed files with 556 additions and 51 deletions.
152 changes: 150 additions & 2 deletions .github/workflows/ci_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
- os: macos-latest
cxx: clang++
cc: clang
- build_type: Release
build_shared_libs: ON
- build_type: Debug
build_shared_libs: OFF

name: "Repo • ${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
runs-on: ${{ matrix.os }}
Expand All @@ -32,7 +36,7 @@ jobs:
BUILD_CONFIG : >
-G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_SHARED_LIBS=${{ matrix.build_shared_libs }}
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/library
-DWITH_MAX_AM=2;2
Expand Down Expand Up @@ -112,10 +116,154 @@ jobs:
cmake -S ../.. -B build $BUILD_CONFIG --log-level=DEBUG
cmake --build build --target check-libint2compiler
- name: Generate Libint export
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
shell: bash
working-directory: ${{github.workspace}}/build/compiler
run: |
cmake --build build --target export
cd build && echo "ARTIFACT=`ls -1 libint*tgz`" >> $GITHUB_ENV
- name: Archive Library Tarball
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.build_type == 'Release'}}
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ runner.os }}-${{ matrix.cxx }}
path: ${{github.workspace}}/build/compiler/build/${{ env.ARTIFACT }}
retention-days: 1

- name: Generate Libint library
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
shell: bash
working-directory: ${{github.workspace}}/build/compiler
run: |
cmake --build build --target libint-library-generate
cmake --build build --target library check-libint2
cd build && echo "ARTIFACT=`ls -1 libint*tgz`" >> $GITHUB_ENV
#rm -rf buildcm/ && cmake -S. -Bbuildcm -GNinja -DEXPORT_COMPRESSOR=bzip2 -DWITH_MAX_AM="2;2" -DWITH_ERI_MAX_AM="2;2" -DWITH_ERI3_MAX_AM="3;2" -DENABLE_ERI=1 -DENABLE_ERI3=1 -DMULTIPOLE_MAX_ORDER=2 -DBUILD_SHARED_LIBS=ON && time cmake --build buildcm --target check-libint2

build_export:
needs: build_repo
if: always() && (needs.build_repo.outputs.should_skip != 'true')
strategy:
fail-fast: false
matrix:
cfg:
- runs-on: ubuntu-latest
lane: ubuntu-gnu
libargs: >
-DBUILD_SHARED_LIBS=ON
testargs: ""

- runs-on: windows-latest
lane: windows-clang-cl
libargs: >
-GNinja
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_CXX_COMPILER=clang-cl
-DCMAKE_C_COMPILER=clang-cl
testargs: >
-GNinja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_COMPILER=clang-cl
-DCMAKE_C_COMPILER=clang-cl
- runs-on: macos-latest
lane: macos-clang
libargs: >
-DBUILD_SHARED_LIBS=ON
testargs: ""

- runs-on: ubuntu-latest
lane: ubuntu-intel
libargs: >
-DCMAKE_CXX_COMPILER=icpx
-DCMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
testargs: >
-DCMAKE_CXX_COMPILER=icpx
-DCMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
name: "Export • ${{ matrix.cfg.lane }}"
runs-on: ${{ matrix.cfg.runs-on }}

steps:
# Note we're not checking out the repo. All src from Linux tarball generated above.

- name: Write a Conda Env File
shell: bash -l {0}
run: |
cat > export.yaml <<EOF
name: test
channels:
- conda-forge
dependencies:
- cmake
- ninja
- cxx-compiler
- python
- boost
- eigen
- numpy
- scipy
- pybind11
#- dpcpp_linux-64
EOF
if [[ "${{ runner.os }}" == "Windows" ]]; then
sed -i "s/- cxx/#- cxx/g" export.yaml
fi
if [[ "${{ matrix.cfg.lane }}" == "ubuntu-intel" ]]; then
sed -i "s/#- dpcpp_linux-64/- dpcpp_linux-64/g" export.yaml
fi
cat export.yaml
- name: Create Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
use-mamba: true
python-version: "3.9"
activate-environment: test
channels: conda-forge
environment-file: export.yaml
show-channel-urls: true

- name: Environment Information
shell: bash -l {0}
run: |
conda info
conda list
- name: Prepare compiler environment for Windows
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- uses: actions/download-artifact@v3
with:
name: Linux-g++-10

- name: Extract, Build, Install Libint Library
shell: bash -l {0}
run: |
tar -zxf libint*tgz
mkdir libint && mv libint-2*/* libint/ && cd libint/
cmake \
-S. \
-Bbuild \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/installed" \
-DCMAKE_CXX_COMPILER=${CXX} \
-DLIBINT2_PYTHON=OFF \
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
${{ matrix.cfg.libargs }}
cmake --build build --target install
- name: Test Libint library - unit tests
shell: bash -l {0}
working-directory: ${{github.workspace}}/libint/build
run: |
cmake --build . --target check
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
pull_request:
#pull_request:

jobs:
build_repo:
Expand Down
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
cmake_minimum_required(VERSION 3.19) # string(json
cmake_policy(SET CMP0074 NEW)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
if (POLICY CMP0135)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
cmake_policy(SET CMP0135 NEW)
endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0")
# needed by DynamicVersion
cmake_policy(SET CMP0140 NEW)
endif()
endif ()

############################# Version and Metadata #############################

Expand Down Expand Up @@ -111,6 +107,10 @@ option_with_default(LIBINT2_ENABLE_PYTHON
option_with_default(LIBINT2_PREFIX_PYTHON_INSTALL
"For LIBINT2_ENABLE_PYTHON=ON, whether to install the Python module in the Linux manner to CMAKE_INSTALL_PREFIX or to not install it. See target libint2-python-wheel for alternate installation in the Python manner to Python_EXECUTABLE's site-packages." OFF)

option_with_print(BUILD_SHARED_LIBS
"Build Libint library as shared, not static" OFF)
option_with_print(LIBINT2_BUILD_SHARED_AND_STATIC_LIBS
"Build both shared and static Libint libraries in one shot. Uses -fPIC." OFF)

# <<< Which Integrals Classes, Which Derivative Levels >>>

Expand Down Expand Up @@ -269,6 +269,8 @@ option_with_print(LIBINT_PROFILE
"Turn on profiling instrumentation of the library. (Generated code will require C++11!)" OFF)
option_with_print(LIBINT2_ENABLE_MPFR
"Use GNU MPFR library for high-precision testing (EXPERTS ONLY). Consumed at library build-time." OFF)
option_with_default(EXPORT_COMPRESSOR
"Export tarball with compression gzip or bzip2" gzip)
# next one defined by `include(CTest)`
message(STATUS "Showing option BUILD_TESTING: ${BUILD_TESTING}")

Expand Down Expand Up @@ -305,6 +307,16 @@ booleanize01(LIBINT_ACCUM_INTS)
booleanize01(LIBINT_FLOP_COUNT)
booleanize01(LIBINT_PROFILE)

if (EXPORT_COMPRESSOR STREQUAL "gzip")
set(EXPORT_COMPRESSOR_CMD "cfz")
set(EXPORT_COMPRESSOR_EXT "tgz")
elseif (EXPORT_COMPRESSOR STREQUAL "bzip2")
set(EXPORT_COMPRESSOR_CMD "jcf")
set(EXPORT_COMPRESSOR_EXT "tbz2")
else()
message(FATAL_ERROR "No valid compressor; invoke CMake with -DEXPORT_COMPRESSOR=gzip|bzip2")
endif()


################################## Dependencies #################################

Expand Down
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ Note that options, docs, and CMake components are focused on the C++ interface,
### Build Library How (G L) (TARBALL)
* `CMAKE_BUILD_TYPE` — G L — [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) [Default=Release]
* `BUILD_SHARED_LIBS` — L — Build Libint library as shared, not static. [Standard CMake variable](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html) [Default=OFF]
* `LIBINT2_BUILD_SHARED_AND_STATIC_LIBS` — L — Build both shared and static Libint libraries in one shot. Uses `-fPIC`. [Default=OFF]
### Detecting Dependencies (G L C) (TARBALL)
Expand Down
54 changes: 26 additions & 28 deletions cmake/modules/DynamicVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Helper module to get the project's version dynamically. Format is compatible wit

include_guard()
list(APPEND CMAKE_MESSAGE_CONTEXT DynamicVersion)
if (POLICY CMP0140)
# Enable using return(PROPAGATE)
# TODO: Remove when cmake 3.25 is commonly distributed
cmake_policy(SET CMP0140 NEW)
endif ()

#[==============================================================================================[
# Preparations #
Expand Down Expand Up @@ -118,9 +123,6 @@ function(dynamic_version)
`${OUTPUT_FOLDER}/.git_commit`
Current commit
`${OUTPUT_FOLDER}/.git_distance`
Current git distance from tag
## See also
- [pypa/setuptools_scm](https://github.com/pypa/setuptools_scm)
Expand Down Expand Up @@ -227,10 +229,14 @@ function(dynamic_version)
COMMAND_ERROR_IS_FATAL ANY)

# Copy all configured files
foreach (file IN ITEMS .DynamicVersion.json .version .git_describe .git_commit .git_distance)
if (EXISTS ${file})
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
endif ()
foreach (file IN ITEMS .DynamicVersion.json .version .git_describe .git_commit)
if (EXISTS ${ARGS_TMP_FOLDER}/${file})
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
file(COPY_FILE ${ARGS_TMP_FOLDER}/${file} ${ARGS_OUTPUT_FOLDER}/${file})
else ()
file(COPY ${ARGS_TMP_FOLDER}/${file} DESTINATION ${ARGS_OUTPUT_FOLDER}/)
endif ()
endif ()
endforeach ()

# Check configuration state
Expand Down Expand Up @@ -359,13 +365,13 @@ function(get_dynamic_version)
# Set fallback values
if (DEFINED ARGS_FALLBACK_VERSION)
string(JSON data SET
${data} version ${ARGS_FALLBACK_VERSION})
${data} version \"${ARGS_FALLBACK_VERSION}\")
file(WRITE ${ARGS_TMP_FOLDER}/.DynamicVersion.json ${data})
file(WRITE ${ARGS_TMP_FOLDER}/.version ${ARGS_FALLBACK_VERSION})
endif ()
if (DEFINED ARGS_FALLBACK_HASH)
string(JSON data SET
${data} commit ${ARGS_FALLBACK_HASH})
${data} commit \"${ARGS_FALLBACK_HASH}\")
file(WRITE ${ARGS_TMP_FOLDER}/.DynamicVersion.json ${data})
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${ARGS_FALLBACK_HASH})
endif ()
Expand Down Expand Up @@ -403,8 +409,11 @@ function(get_dynamic_version)
${data} version \"${CMAKE_MATCH_2}\")
file(WRITE ${ARGS_TMP_FOLDER}/.version ${CMAKE_MATCH_2})
# Get commit hash
# Cannot use Regex match from here, need to run string(REGEX MATCH) again
# https://gitlab.kitware.com/cmake/cmake/-/issues/23770
file(STRINGS ${ARGS_GIT_ARCHIVAL_FILE} node
REGEX "^node:[ ]?(.*)")
string(REGEX MATCH "^node:[ ]?(.*)" node "${node}")
string(JSON data SET
${data} commit \"${CMAKE_MATCH_1}\")
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${CMAKE_MATCH_1})
Expand Down Expand Up @@ -433,13 +442,13 @@ function(get_dynamic_version)
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
# Get version and describe-name
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match=?[0-9.]*
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --abbrev=8 --match=?[0-9.]*
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
OUTPUT_VARIABLE describe-name
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
# Match any part containing digits and periods (strips out rc and so on)
if (NOT describe-name MATCHES "^([v]?([0-9\\.]+).*)")
if (NOT describe-name MATCHES "^([v]?([0-9\\.]+)-([0-9]+)-g(.*))")
message(${error_message_type}
"Version tag is ill-formatted\n"
" Describe-name: ${describe-name}"
Expand All @@ -452,26 +461,13 @@ function(get_dynamic_version)
string(JSON data SET
${data} version \"${CMAKE_MATCH_2}\")
file(WRITE ${ARGS_TMP_FOLDER}/.version ${CMAKE_MATCH_2})
string(JSON data SET
${data} distance \"${CMAKE_MATCH_3}\")
string(JSON data SET
${data} short_sha \"${CMAKE_MATCH_4}\")
string(JSON data SET
${data} commit \"${git-hash}\")
file(WRITE ${ARGS_TMP_FOLDER}/.git_commit ${git-hash})
# Get full describe with distance
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --match=?[0-9.]*
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
OUTPUT_VARIABLE describe-name-long
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
# Match version (as above) and distance
if (NOT describe-name-long MATCHES "^([v]?([0-9\\.]+)-([0-9]+)-.*)")
message(${error_message_type}
"Version tag is ill-formatted\n"
" Describe-name-long: ${describe-name-long}"
)
return()
endif ()
string(JSON data SET
${data} distance \"${CMAKE_MATCH_3}\")
file(WRITE ${ARGS_TMP_FOLDER}/.git_distance ${CMAKE_MATCH_3})
message(DEBUG
"Found appropriate tag from git"
)
Expand Down Expand Up @@ -507,3 +503,5 @@ if (DynamicVersion_RUN)
endif ()
get_dynamic_version(${DynamicVersion_ARGS})
endif ()

list(POP_BACK CMAKE_MESSAGE_CONTEXT)
2 changes: 1 addition & 1 deletion include/libint2/config2.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define LIBINT2_ALIGN_SIZE @LIBINT2_ALIGN_SIZE@

/* User-defined real type */
#cmakedefine LIBINT2_REALTYPE "@LIBINT2_REALTYPE@"
#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@ */
Expand Down
3 changes: 1 addition & 2 deletions src/bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ add_subdirectory(libint)

include(AddCustomTargetSubproject)
add_custom_target_subproject(
libint2compiler
check
libint2compiler check # target check-libint2compiler
USES_TERMINAL
COMMAND ${CMAKE_CTEST_COMMAND} -V -R "libint2/compiler"
)
Expand Down
Loading

0 comments on commit ee93781

Please sign in to comment.