Skip to content

Update benchmarks #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ef81d97
Distribute visibilities to get strong scaling benchmarks
tkoskela Oct 24, 2024
4a2984d
Add warmup time to benchmarks
tkoskela Oct 24, 2024
ccddb82
Enable debug logging
tkoskela Oct 24, 2024
10614a6
Scatter visibilities. Define parameters.
tkoskela Oct 28, 2024
aa05250
Clean up padmm benchmarks
tkoskela Oct 30, 2024
b59fa42
Use factories in padmm benchmarks
tkoskela Nov 1, 2024
60e1afd
Merge branch 'tk/mpi_operator_benchmark_strong_scaling' of github.com…
tkoskela Nov 1, 2024
86b9c19
Don't use hard coded paths
tkoskela Nov 7, 2024
01e2128
Fix variable names
tkoskela Nov 7, 2024
f36b91b
Add some logging to report where vis data is coming from
tkoskela Nov 8, 2024
645d7f0
Update measurements the same way as mpi version
tkoskela Nov 8, 2024
06f4732
Clarify names, call the right padmm object
tkoskela Nov 8, 2024
4e9f982
Add placeholders to logging command
tkoskela Nov 8, 2024
73fd8d8
Reduce sopt verbosity
tkoskela Nov 8, 2024
e5333f1
Fix bugs and lint. Add smaller test for comparison with serial version
tkoskela Nov 8, 2024
f8ba8c0
Add info to factory functions
tkoskela Nov 8, 2024
54ae8dd
Add FB algorithms, rename to be more descriptive
tkoskela Nov 8, 2024
6c539de
Help purify look up the ONNX runtime
tkoskela Nov 13, 2024
9cab4f0
Install data files for TF models
tkoskela Nov 13, 2024
45d7bb4
Add FB benchmark that uses onnx rt
tkoskela Nov 13, 2024
206342a
Merge branch 'development' into tk/mpi_operator_benchmark_strong_scaling
tkoskela Nov 14, 2024
1aa8861
Linting
tkoskela Nov 14, 2024
21ff63f
More linting
tkoskela Nov 14, 2024
7677b1f
Linting++
tkoskela Nov 14, 2024
ec1febd
One more for the linter
tkoskela Nov 14, 2024
e3385e4
Merge branch 'development' into tk/mpi_operator_benchmark_strong_scaling
tkoskela Nov 28, 2024
16b0fac
Remove obsolete reference to notinstalled namespace
tkoskela Dec 12, 2024
2810d43
Use correct models directory
tkoskela Dec 12, 2024
ad473fc
remove onnxrt lookup, should be provided by sopt
tkoskela Dec 12, 2024
ed0bfd8
Remove duplicate
tkoskela Dec 12, 2024
430a155
Add bigger problems and more runtime
tkoskela Dec 12, 2024
f5daf32
Linting
tkoskela Dec 13, 2024
152b518
refactor + add serial fb algorithms
tkoskela Dec 13, 2024
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,5 @@ endif()

add_subdirectory(cpp)


# Exports Purify so other packages can access it
include(export_purify)
4 changes: 0 additions & 4 deletions cmake_files/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ if(tests) # Adds ctest
include(AddCatchTest)
endif()

if(examples)
find_package(TIFF REQUIRED)
endif()

if(tests OR examples)
file(COPY data DESTINATION .)
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake_files/export_purify.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ install(FILES
)

install(EXPORT PurifyTargets DESTINATION share/cmake/purify COMPONENT dev)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/data" DESTINATION "${CMAKE_INSTALL_PREFIX}")
4 changes: 2 additions & 2 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ if(dompi)
add_executable(mpi_benchmark_MO_wproj main.cc utilities.cc measurement_operator_wproj.cc)
target_link_libraries(mpi_benchmark_MO_wproj ${MPI_LIBRARIES} benchmark libpurify)
#target_include_directories(mpi_benchmark_MO_wproj PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
add_executable(mpi_benchmark_PADMM main.cc utilities.cc padmm_mpi.cc)
target_link_libraries(mpi_benchmark_PADMM ${MPI_LIBRARIES} benchmark libpurify)
add_executable(mpi_benchmark_algorithms main.cc utilities.cc algorithms_mpi.cc)
target_link_libraries(mpi_benchmark_algorithms ${MPI_LIBRARIES} benchmark libpurify)
#target_include_directories(mpi_benchmark_PADMM PUBLIC "${PROJECT_SOURCE_DIR}/cpp" "${CMAKE_CURRENT_BINARY_DIR}/include")
add_executable(mpi_benchmark_WLO main.cc utilities.cc wavelet_operator_mpi.cc)
target_link_libraries(mpi_benchmark_WLO ${MPI_LIBRARIES} benchmark libpurify)
Expand Down
156 changes: 156 additions & 0 deletions cpp/benchmarks/algorithms.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#include "purify/config.h"
#include "purify/types.h"
#include <array>
#include <benchmark/benchmark.h>
#include "benchmarks/utilities.h"
#include "purify/algorithm_factory.h"
#include "purify/directories.h"
#include "purify/measurement_operator_factory.h"
#include "purify/operators.h"
#include "purify/utilities.h"
#include "purify/wavelet_operator_factory.h"
#include <sopt/imaging_padmm.h>
#include <sopt/relative_variation.h>
#include <sopt/utilities.h>
#include <sopt/wavelets.h>
#include <sopt/wavelets/sara.h>

using namespace purify;

class AlgoFixture : public ::benchmark::Fixture {
public:
void SetUp(const ::benchmark::State &state) {
// Reading image from file and update related quantities
bool newImage = b_utilities::updateImage(state.range(0), m_image, m_imsizex, m_imsizey);

// Generating random uv(w) coverage
bool newMeasurements =
b_utilities::updateMeasurements(state.range(1), m_uv_data, m_epsilon, newImage, m_image);

bool newKernel = m_kernel != state.range(2);

m_kernel = state.range(2);
// creating the measurement operator
const t_real FoV = 1; // deg
const t_real cellsize = FoV / m_imsizex * 60. * 60.;
const bool w_term = false;
m_measurements_transform = factory::measurement_operator_factory<Vector<t_complex>>(
factory::distributed_measurement_operator::serial, m_uv_data, m_imsizey, m_imsizex,
cellsize, cellsize, 2, kernels::kernel::kb, m_kernel, m_kernel, w_term);

t_real const m_sigma = 0.016820222945913496 * std::sqrt(2); // see test_parameters file
}

void TearDown(const ::benchmark::State &state) {}

t_real m_epsilon;
t_uint m_counter;
t_real m_sigma;
std::vector<std::tuple<std::string, t_uint>> const m_sara{
std::make_tuple("Dirac", 3u), std::make_tuple("DB1", 3u), std::make_tuple("DB2", 3u),
std::make_tuple("DB3", 3u), std::make_tuple("DB4", 3u), std::make_tuple("DB5", 3u),
std::make_tuple("DB6", 3u), std::make_tuple("DB7", 3u), std::make_tuple("DB8", 3u)};

Image<t_complex> m_image;
t_uint m_imsizex;
t_uint m_imsizey;

utilities::vis_params m_uv_data;

t_uint m_kernel;
std::shared_ptr<sopt::LinearTransform<Vector<t_complex>> const> m_measurements_transform;
std::shared_ptr<sopt::algorithm::ImagingProximalADMM<t_complex>> m_padmm;
std::shared_ptr<sopt::algorithm::ImagingForwardBackward<t_complex>> m_fb;
};

BENCHMARK_DEFINE_F(AlgoFixture, Padmm)(benchmark::State &state) {
// Benchmark the application of the algorithm
auto const wavelets = factory::wavelet_operator_factory<Vector<t_complex>>(
factory::distributed_wavelet_operator::serial, m_sara, m_imsizey, m_imsizex);

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

while (state.KeepRunning()) {
auto start = std::chrono::high_resolution_clock::now();
(*m_padmm)();
auto end = std::chrono::high_resolution_clock::now();
state.SetIterationTime(b_utilities::duration(start, end));
}
}

BENCHMARK_DEFINE_F(AlgoFixture, ForwardBackward)(benchmark::State &state) {
// Benchmark the application of the algorithm
auto const wavelets = factory::wavelet_operator_factory<Vector<t_complex>>(
factory::distributed_wavelet_operator::serial, m_sara, m_imsizey, m_imsizex);

t_real const beta = m_sigma * m_sigma;
t_real const gamma = 0.0001;

m_fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
factory::algo_distribution::serial, m_measurements_transform, wavelets, m_uv_data, m_sigma,
beta, gamma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true, false, 1e-3,
1e-2, 50, 1.0);

while (state.KeepRunning()) {
auto start = std::chrono::high_resolution_clock::now();
(*m_fb)();
auto end = std::chrono::high_resolution_clock::now();
state.SetIterationTime(b_utilities::duration(start, end));
}
}

#ifdef PURIFY_ONNXRT
BENCHMARK_DEFINE_F(AlgoFixture, ForwardBackwardOnnx)(benchmark::State &state) {
// Benchmark the application of the algorithm
auto const wavelets = factory::wavelet_operator_factory<Vector<t_complex>>(
factory::distributed_wavelet_operator::serial, m_sara, m_imsizey, m_imsizex);

t_real const beta = m_sigma * m_sigma;
t_real const gamma = 0.0001;
std::string tf_model_path = purify::models_directory() + "/snr_15_model_dynamic.onnx";

m_fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
factory::algo_distribution::serial, m_measurements_transform, wavelets, m_uv_data, m_sigma,
beta, gamma, m_imsizey, m_imsizex, m_sara.size(), state.range(3) + 1, true, true, false, 1e-3,
1e-2, 50, 1.0, tf_model_path, factory::g_proximal_type::TFGProximal);

while (state.KeepRunning()) {
auto start = std::chrono::high_resolution_clock::now();
(*m_fb)();
auto end = std::chrono::high_resolution_clock::now();
state.SetIterationTime(b_utilities::duration(start, end));
}
}

BENCHMARK_REGISTER_F(AlgoFixture, ForwardBackwardOnnx)
//->Apply(b_utilities::Arguments)
->Args({128, 10000, 4, 10})
->UseManualTime()
->MinTime(10.0)
->MinWarmUpTime(5.0)
->Repetitions(3) //->ReportAggregatesOnly(true)
->Unit(benchmark::kMillisecond);
#endif

BENCHMARK_REGISTER_F(AlgoFixture, Padmm)
//->Apply(b_utilities::Arguments)
->Args({128, 10000, 4, 10})
->UseManualTime()
->MinTime(10.0)
->MinWarmUpTime(5.0)
->Repetitions(3) //->ReportAggregatesOnly(true)
->Unit(benchmark::kMillisecond);

BENCHMARK_REGISTER_F(AlgoFixture, ForwardBackward)
//->Apply(b_utilities::Arguments)
->Args({128, 10000, 4, 10})
->UseManualTime()
->MinTime(10.0)
->MinWarmUpTime(5.0)
->Repetitions(3) //->ReportAggregatesOnly(true)
->Unit(benchmark::kMillisecond);

BENCHMARK_MAIN();
Loading