-
Notifications
You must be signed in to change notification settings - Fork 98
308 lines (276 loc) · 11.7 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: Linux/MacOS Build
on: [push, pull_request]
#env:
jobs:
build_repo:
strategy:
fail-fast: false
matrix:
build_type : [ Release ]
os : [ ubuntu-20.04 ]
include:
- os: ubuntu-20.04
cxx: g++-10
name: "${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
runs-on: ${{ matrix.os }}
env:
CXX : ${{ matrix.cxx }}
CCACHE_DIR : ${{github.workspace}}/build/.ccache
CCACHE_COMPRESS : true
CCACHE_COMPRESSLEVEL : 6
BUILD_CONFIG : >
-G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_PREFIX_PATH=/usr/local/Cellar/eigen/3.3.9;/usr/local/opt/bison
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DMPIEXEC_PREFLAGS='--bind-to;none;--allow-run-as-root'
-DENABLE_FORTRAN=ON
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/library/install
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- uses: actions/checkout@v2
- id: skip_check
name: Check if can skip
uses: fkirc/[email protected]
with:
cancel_others: 'true'
- name: Create Build Environment
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: |
cmake -E make_directory ${{github.workspace}}/build/compiler
cmake -E make_directory ${{github.workspace}}/build/library
cmake -E make_directory ${{github.workspace}}/build/library_test
- name: Install prerequisite MacOS packages
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'macos-latest' }}
run: |
brew install ninja gcc@10 boost eigen bison ccache automake python3 numpy scipy
echo "FC=/usr/local/bin/gfortran-10" >> $GITHUB_ENV
echo "EIGEN3_INCLUDE_DIR=/usr/local/include/eigen3" >> $GITHUB_ENV
- name: Install prerequisites Ubuntu packages
if: ${{ steps.skip_check.outputs.should_skip != 'true' && matrix.os == 'ubuntu-20.04' }}
run: |
sudo apt-get update
sudo apt-get install ninja-build g++-10 gfortran-10 liblapack-dev libboost-dev libeigen3-dev ccache python3-numpy python3-scipy
echo "FC=/usr/bin/gfortran-10" >> $GITHUB_ENV
echo "EIGEN3_INCLUDE_DIR=/usr/include/eigen3" >> $GITHUB_ENV
- name: Prepare ccache timestamp
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Setup ccache cache files
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
uses: actions/[email protected]
with:
path: ${{github.workspace}}/build/.ccache
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.name }}-ccache-
- name: Generate configure script
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
shell: bash
working-directory: ${{github.workspace}}
run: ./autogen.sh && ls -l ${{github.workspace}}/configure
- name: Generate Libint library
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build/compiler
run: |
CPPFLAGS="-I$EIGEN3_INCLUDE_DIR" CXXFLAGS="-std=c++11 -Wno-enum-compare" ${{github.workspace}}/configure --with-max-am=2 --with-eri-max-am=2 --with-eri3-max-am=3 --enable-eri=0 --enable-eri3=0 --enable-1body=1 --disable-1body-property-derivs --with-multipole-max-order=2
make -j3
#make check
#cd src/bin/test_eri && ./stdtests.pl && cd ../../..
make export
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/${{ env.ARTIFACT }}
retention-days: 1
- name: Build+test+install Libint library
#if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
if: false
shell: bash
working-directory: ${{github.workspace}}/build/library
run: |
tar -xzf ../compiler/libint-2*.tgz
cd libint-2*
echo "LIBINT_EXPORTED_DIR=`pwd`" >> $GITHUB_ENV
cmake -S . -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPython_EXECUTABLE=`which python3` $BUILD_CONFIG
cmake --build build --target check
cmake --build build --target install
- name: Test installed Libint library
#if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
if: false
shell: bash
working-directory: ${{github.workspace}}/build/library_test
run: |
cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.8)
project(hf++)
find_package(Libint2 2.8.0 REQUIRED)
find_package(Threads) # clang does not autolink threads even though we are using std::thread
add_executable(hf++ EXCLUDE_FROM_ALL $LIBINT_EXPORTED_DIR/tests/hartree-fock/hartree-fock++.cc)
target_link_libraries(hf++ Libint2::cxx Threads::Threads)
EOF
cmake . -DCMAKE_PREFIX_PATH=${{github.workspace}}/build/library/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE
cmake --build . --target hf++
./hf++ $LIBINT_EXPORTED_DIR/tests/hartree-fock/h2o_rotated.xyz | python $LIBINT_EXPORTED_DIR/tests/hartree-fock/hartree-fock++-validate.py $LIBINT_EXPORTED_DIR/MakeVars.features
- name: Build Python bindings
#if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
if: false
shell: bash
working-directory: ${{github.workspace}}/build/library
run: |
cd libint-2*
cd build
cmake . -DLIBINT2_PYTHON=ON
cmake --build . --target libint2-python
cmake --build . --target libint2-python-test
build_export:
needs: build_repo
strategy:
fail-fast: false
matrix:
cfg:
- runs-on: ubuntu-latest
lane: ubuntu-gnu
libargs: >
-DBUILD_SHARED_LIBS=ON
testargs: ""
-DLIBINT2_LOCAL_Eigen3_FIND=ON
# note full paths depend on setup-miniconda:
# * Miniforge is miniconda3 vs. Miniconda is miniconda
- runs-on: macos-latest
lane: macos-clang
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: ubuntu-latest
lane: ubuntu-intel
libargs: >
-DCMAKE_CXX_COMPILER=icpx
-DCMAKE_CXX_FLAGS="--gcc-toolchain=/usr/share/miniconda3/envs/test --sysroot=/usr/share/miniconda3/envs/test/x86_64-conda-linux-gnu/sysroot -target x86_64-conda-linux-gnu"
# flags are long-form of below (envvars not available at spinup)
# -DCMAKE_CXX_FLAGS="--gcc-toolchain=${CONDA_PREFIX} --sysroot=${CONDA_PREFIX}/${HOST}/sysroot -target ${HOST}"
testargs: >
-DCMAKE_CXX_COMPILER=icpx
-DCMAKE_CXX_FLAGS="--gcc-toolchain=/usr/share/miniconda3/envs/test --sysroot=/usr/share/miniconda3/envs/test/x86_64-conda-linux-gnu/sysroot -target x86_64-conda-linux-gnu"
name: "Export • ${{ matrix.cfg.lane }} • ${{ matrix.cfg.libargs }}"
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 \
-DCMAKE_INSTALL_PREFIX="${{github.workspace}}/installed" \
-DCMAKE_CXX_COMPILER=${CXX} \
-DLIBINT2_PYTHON=ON \
-DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
-DPython_EXECUTABLE="${CONDA_PREFIX}/bin/python" \
${{ matrix.cfg.libargs }}
cmake --build build --target install libint2-python-test
- name: Test Installed Libint library
shell: bash -l {0}
run: |
mkdir test_installed_library && cd test_installed_library
cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 3.16)
project(hf++)
find_package(Libint2 2.7.2 REQUIRED COMPONENTS eri_c4_d0_l2 CXX_ho)
get_target_property(_l2_maxam Libint2::int2 Libint2_MAX_AM_ERI)
message("Libint2_MAX_AM_ERI \${_l2_maxam}")
find_package(Threads) # clang does not autolink threads even though we are using std::thread
add_executable(hf++ EXCLUDE_FROM_ALL "../libint/tests/hartree-fock/hartree-fock++.cc")
target_link_libraries(hf++ Libint2::cxx Threads::Threads)
EOF
cmake -S . -B build -DCMAKE_PREFIX_PATH="${{github.workspace}}/installed" ${{ matrix.cfg.testargs }}
cmake --build build --target hf++
./build/hf++ ../libint/tests/hartree-fock/h2o_rotated.xyz
# missing "features" which can't be populated b/c config unknown to CMake
#./build/hf++ ../libint/tests/hartree-fock/h2o_rotated.xyz | python ../libint/tests/hartree-fock/hartree-fock++-validate.py ../libint/features
- name: Build (again) & Test Python bindings
shell: bash -l {0}
working-directory: ${{github.workspace}}/libint/python
run: |
cmake . -D LIBINT2_PYTHON=ON -D CMAKE_PREFIX_PATH="${{github.workspace}}/installed" ${{ matrix.cfg.testargs }}
cmake --build . --target libint2-python
cmake --build . --target libint2-python-test