Skip to content

Commit a639d10

Browse files
authored
Merge pull request #387 from astro-informatics/tk/ci-build-examples-benchmarks
Add a CI job to build dependencies and benchmarks
2 parents 6c0fd2d + e0f1cf6 commit a639d10

File tree

5 files changed

+98
-22
lines changed

5 files changed

+98
-22
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ env:
1919
OMP_NUM_THREADS: 2
2020

2121
jobs:
22-
build:
22+
dependencies:
2323
# Skip CI if PR is a draft
2424
if: github.event.pull_request.draft == false
25-
name: build (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
25+
name: dependencies (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
2626
# The CMake configure and build commands are platform agnostic and should work equally
2727
# well on Windows or Mac. You can convert this to a matrix build if you need
2828
# cross-platform coverage.
@@ -161,7 +161,7 @@ jobs:
161161

162162
test:
163163
needs:
164-
build
164+
dependencies
165165
name: test (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
166166
runs-on: ${{matrix.os}}
167167
env:
@@ -239,9 +239,83 @@ jobs:
239239
export DYLD_LIBRARY_PATH=$(brew --prefix)/lib:${DYLD_LIBRARY_PATH}
240240
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
241241
242+
examples_benchmarks:
243+
needs:
244+
dependencies
245+
name: examples_benchmarks (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
246+
runs-on: ${{matrix.os}}
247+
env:
248+
CC: ${{ matrix.cc }}
249+
CXX: ${{ matrix.cxx }}
250+
strategy:
251+
fail-fast: false
252+
matrix:
253+
os:
254+
- ubuntu-22.04
255+
- macos-14
256+
cc:
257+
- gcc-12
258+
- clang
259+
cxx:
260+
- g++-12
261+
- clang++
262+
mpi:
263+
- "ON"
264+
- "OFF"
265+
omp:
266+
- "ON"
267+
exclude:
268+
- os: ubuntu-22.04
269+
cc: clang
270+
- os: ubuntu-22.04
271+
cxx: clang++
272+
- os: macos-14
273+
cc: gcc-12
274+
- os: macos-14
275+
cxx: g++-12
276+
- os: macos-14
277+
mpi: "ON"
278+
- os: ubuntu-22.04
279+
mpi: "OFF"
280+
steps:
281+
- uses: actions/checkout@v4
282+
283+
- uses: actions/download-artifact@v4
284+
with:
285+
name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }}
286+
287+
- name: Unpack dependencies
288+
run: tar xfv dependencies.tar
289+
- name: Install Dependencies on Ubunutu
290+
if: ${{ contains(matrix.os, 'ubuntu') }}
291+
run: |
292+
sudo apt update
293+
sudo apt install openmpi-bin libopenmpi-dev ccache graphviz libeigen3-dev libtiff-dev libcfitsio-dev libboost-all-dev libyaml-cpp-dev
294+
wget https://github.com/google/benchmark/archive/refs/tags/v1.8.5.tar.gz -O- | tar --no-same-owner -xz;
295+
cd benchmark-1.8.5
296+
cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -S . -B "build"
297+
cmake --build "build" --config Release --target install
298+
299+
- name: Install Dependencies on MacOS
300+
if: ${{ contains(matrix.os, 'macos') }}
301+
run: |
302+
brew install open-mpi libomp eigen ccache cfitsio boost yaml-cpp onnxruntime google-benchmark
303+
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV
304+
echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH
305+
306+
- name: Build examples
307+
# Build your program with the given configuration
308+
run: |
309+
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
310+
mkdir -p ${{github.workspace}}/build
311+
cd ${{github.workspace}}/build
312+
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Donnxrt=ON -Dhdf5=ON -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=OFF -Dexamples=ON -Dbenchmarks=ON
313+
make -j$(nproc --ignore 1) install
314+
315+
242316
doc:
243317
needs:
244-
build
318+
dependencies
245319
name: doc (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
246320
runs-on: ${{matrix.os}}
247321
env:

cmake_files/dependencies.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ if(tests OR examples)
7070
endif()
7171

7272
if(benchmarks)
73-
find_package(benchmark REQUIRED)
74-
#include(AddBenchmark)
73+
find_package(benchmark REQUIRED CONFIG)
7574
endif()
7675

7776
# Always find open-mp, since it may be used by sopt

cpp/benchmarks/CMakeLists.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
include_directories("${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
1+
include_directories("${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include" "${benchmark_DIR}/include")
22

33
add_executable(measurement_operator utilities.cc measurement_operator.cc)
4-
target_link_libraries(measurement_operator benchmark libpurify)
4+
target_link_libraries(measurement_operator benchmark::benchmark libpurify)
5+
56
add_executable(algorithms utilities.cc algorithms.cc)
6-
target_link_libraries(algorithms benchmark libpurify)
7+
target_link_libraries(algorithms benchmark::benchmark libpurify)
8+
79
add_executable(wavelet_operator utilities.cc wavelet_operator.cc)
8-
target_link_libraries(wavelet_operator benchmark libpurify)
10+
target_link_libraries(wavelet_operator benchmark::benchmark libpurify)
11+
912
add_executable(fft utilities.cc fft.cc)
10-
target_link_libraries(fft benchmark libpurify)
13+
target_link_libraries(fft benchmark::benchmark libpurify)
14+
1115
add_executable(degridding utilities.cc degridding.cc)
12-
target_link_libraries(degridding benchmark libpurify)
16+
target_link_libraries(degridding benchmark::benchmark libpurify)
1317

1418
# Skip ArrayFire benchmarks for now, add back later if needed
1519
# if(doaf)
@@ -20,15 +24,15 @@ target_link_libraries(degridding benchmark libpurify)
2024

2125
if(dompi)
2226
add_executable(mpi_benchmark_MO main.cc utilities.cc measurement_operator_mpi.cc)
23-
target_link_libraries(mpi_benchmark_MO ${MPI_LIBRARIES} benchmark libpurify)
27+
target_link_libraries(mpi_benchmark_MO ${MPI_LIBRARIES} benchmark::benchmark libpurify)
2428
#target_include_directories(mpi_benchmark_MO PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
2529
add_executable(mpi_benchmark_MO_wproj main.cc utilities.cc measurement_operator_wproj.cc)
26-
target_link_libraries(mpi_benchmark_MO_wproj ${MPI_LIBRARIES} benchmark libpurify)
30+
target_link_libraries(mpi_benchmark_MO_wproj ${MPI_LIBRARIES} benchmark::benchmark libpurify)
2731
#target_include_directories(mpi_benchmark_MO_wproj PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
2832
add_executable(mpi_benchmark_algorithms main.cc utilities.cc algorithms_mpi.cc)
29-
target_link_libraries(mpi_benchmark_algorithms ${MPI_LIBRARIES} benchmark libpurify)
33+
target_link_libraries(mpi_benchmark_algorithms ${MPI_LIBRARIES} benchmark::benchmark libpurify)
3034
#target_include_directories(mpi_benchmark_PADMM PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
3135
add_executable(mpi_benchmark_WLO main.cc utilities.cc wavelet_operator_mpi.cc)
32-
target_link_libraries(mpi_benchmark_WLO ${MPI_LIBRARIES} benchmark libpurify)
36+
target_link_libraries(mpi_benchmark_WLO ${MPI_LIBRARIES} benchmark::benchmark libpurify)
3337
#target_include_directories(mpi_benchmark_WLO PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
3438
endif()

cpp/benchmarks/algorithms.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ BENCHMARK_DEFINE_F(AlgoFixture, Padmm)(benchmark::State &state) {
7070

7171
m_padmm = factory::padmm_factory<sopt::algorithm::ImagingProximalADMM<t_complex>>(
7272
factory::algo_distribution::serial, m_measurements_transform, wavelets, m_uv_data, m_sigma,
73-
m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true, false, 1e-3, 1e-2, 50,
74-
1.0);
73+
m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true, false, 1e-3, 1e-2, 50);
7574

7675
while (state.KeepRunning()) {
7776
auto start = std::chrono::high_resolution_clock::now();
@@ -115,7 +114,7 @@ BENCHMARK_DEFINE_F(AlgoFixture, ForwardBackwardOnnx)(benchmark::State &state) {
115114
m_fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
116115
factory::algo_distribution::serial, m_measurements_transform, wavelets, m_uv_data, m_sigma,
117116
beta, gamma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true, false, 1e-3,
118-
1e-2, 50, 1.0, tf_model_path, nondiff_func_type::Denoiser);
117+
1e-2, 50, tf_model_path, nondiff_func_type::Denoiser);
119118

120119
while (state.KeepRunning()) {
121120
auto start = std::chrono::high_resolution_clock::now();

cpp/benchmarks/algorithms_mpi.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ BENCHMARK_DEFINE_F(AlgoFixtureMPI, PadmmDistributeImage)(benchmark::State &state
9090
m_padmm = factory::padmm_factory<sopt::algorithm::ImagingProximalADMM<t_complex>>(
9191
factory::algo_distribution::mpi_distributed, m_measurements_distribute_image, wavelets,
9292
m_uv_data, m_sigma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true,
93-
false, 1e-3, 1e-2, 50, 1.0);
93+
false, 1e-3, 1e-2, 50);
9494

9595
// Benchmark the application of the algorithm
9696
while (state.KeepRunning()) {
@@ -111,7 +111,7 @@ BENCHMARK_DEFINE_F(AlgoFixtureMPI, PadmmDistributeGrid)(benchmark::State &state)
111111
m_padmm = factory::padmm_factory<sopt::algorithm::ImagingProximalADMM<t_complex>>(
112112
factory::algo_distribution::mpi_distributed, m_measurements_distribute_grid, wavelets,
113113
m_uv_data, m_sigma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true,
114-
false, 1e-3, 1e-2, 50, 1.0);
114+
false, 1e-3, 1e-2, 50);
115115

116116
// Benchmark the application of the algorithm
117117
while (state.KeepRunning()) {
@@ -188,7 +188,7 @@ BENCHMARK_DEFINE_F(AlgoFixtureMPI, FbOnnxDistributeImage)(benchmark::State &stat
188188
m_fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
189189
factory::algo_distribution::mpi_serial, m_measurements_distribute_image, wavelets, m_uv_data,
190190
m_sigma, beta, gamma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true,
191-
false, 1e-3, 1e-2, 50, 1.0, tf_model_path, nondiff_func_type::Denoiser);
191+
false, 1e-3, 1e-2, 50, tf_model_path, nondiff_func_type::Denoiser);
192192

193193
// Benchmark the application of the algorithm
194194
while (state.KeepRunning()) {

0 commit comments

Comments
 (0)