From cc428de54aefe5fefd19f0d777d3d7311f537d3f Mon Sep 17 00:00:00 2001 From: Tuomas Koskela Date: Thu, 14 Nov 2024 12:04:48 +0000 Subject: [PATCH 1/4] Remove the notinstalled namespace, data is now installed --- cmake_files/LookUpONNXRT.cmake | 54 ++++++++++++++++++++ cpp/benchmarks/measurement_operator_mpi.cc | 1 - cpp/benchmarks/measurement_operator_wproj.cc | 1 - cpp/benchmarks/utilities.cc | 1 - cpp/example/casa.cc | 2 +- cpp/example/compare_wprojection.cc | 1 - cpp/example/generate_vis_data.cc | 1 - cpp/example/histogram_equalisation.cc | 1 - cpp/example/image_wproj_chirp.cc | 1 - cpp/example/mem_w_algos.cc | 1 - cpp/example/padmm_mpi_random_coverage.cc | 1 - cpp/example/padmm_mpi_real_data.cc | 1 - cpp/example/padmm_random_coverage.cc | 9 ---- cpp/example/padmm_real_data.cc | 1 - cpp/example/padmm_reweighted_simulation.cc | 1 - cpp/example/padmm_simulation.cc | 1 - cpp/example/plot_wkernel.cc | 1 - cpp/example/sara_padmm_random_coverage.cc | 1 - cpp/example/sdmm_m31_simulation.cc | 1 - cpp/example/show_image.cc | 1 - cpp/example/time_w_algos.cc | 1 - cpp/example/wavelet_decomposition.cc | 1 - cpp/tests/algo_factory.cc | 49 +++++++++--------- cpp/tests/casacore.cc | 1 - cpp/tests/convolution.cc | 1 - cpp/tests/data.in.h | 2 - cpp/tests/directories.in.h | 27 +++------- cpp/tests/distribute.cc | 1 - cpp/tests/integration.cc | 1 - cpp/tests/measurement_operator.cc | 1 - cpp/tests/mpi_algo_factory.cc | 42 +++++++-------- cpp/tests/mpi_read_measurements.cc | 1 - cpp/tests/operators.cc | 25 +++++---- cpp/tests/operators_gpu.cc | 1 - cpp/tests/parser_test.cc | 6 +-- cpp/tests/purify_fitsio.cc | 1 - cpp/tests/read_measurements.cc | 1 - cpp/tests/sparse.cc | 1 - cpp/tests/utils.cc | 1 - cpp/tests/uvfits.cc | 1 - cpp/tests/wide_field_utilities.cc | 1 - cpp/tests/wkernel.cc | 1 - data/expected/padmm/test_parameters_mpi | 12 ++--- 43 files changed, 127 insertions(+), 134 deletions(-) create mode 100644 cmake_files/LookUpONNXRT.cmake diff --git a/cmake_files/LookUpONNXRT.cmake b/cmake_files/LookUpONNXRT.cmake new file mode 100644 index 000000000..a02721674 --- /dev/null +++ b/cmake_files/LookUpONNXRT.cmake @@ -0,0 +1,54 @@ + +find_package(onnxruntime QUIET) + +if(${onnxruntime_FOUND}) + find_path(onnxruntime_INCLUDE_DIR NAMES onnxruntime_cxx_api.h + HINTS + ENV onnxruntime_ROOT + ENV onnxruntime_ROOT_DIR + ${CMAKE_INSTALL_PREFIX}/include + ${KDE4_INCLUDE_DIR} + PATH_SUFFIXES onnxruntime + ) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_INCLUDE_DIR TRUE) + set(onnxruntime_LIBRARIES onnxruntime::onnxruntime) + get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE) + find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib") + set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}") + set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}") +endif() + +if(NOT ${onnxruntime_FOUND}) + message(STATUS "ONNXrt not found. Attempt to install...") + EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCH ) + message( STATUS "Detected architecture: ${ARCH}" ) + if ("${ARCH}" STREQUAL "x86_64") + set(ARCH "x64") + endif() + set(ORT_VERSION "1.16.3") + set(ORT_URL_BASE "https://github.com/microsoft/onnxruntime/releases/download") + set(ORT_TARNAME "onnxruntime-linux-${ARCH}-${ORT_VERSION}") + set(ORT_DEST "${CMAKE_CURRENT_BINARY_DIR}/external/${ORT_TARNAME}.tgz") + set(ORT_URL "${ORT_URL_BASE}/v${ORT_VERSION}/${ORT_TARNAME}.tgz") + # https://cmake.org/cmake/help/latest/policy/CMP0135.html + # + # CMP0135 is for solving re-building and re-downloading. + # The NEW policy suppresses warnings for some CMake versions. + if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) + endif() + set(onnxruntime_DIR "${CMAKE_INSTALL_PREFIX}/external") + file(DOWNLOAD ${ORT_URL} ${ORT_DEST} + EXPECTED_HASH SHA256=b072f989d6315ac0e22dcb4771b083c5156d974a3496ac3504c77f4062eb248e + ) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ORT_DEST}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${ORT_TARNAME} ${onnxruntime_DIR}) + set(onnxruntime_INCLUDE_DIR "${onnxruntime_DIR}/include") + set(onnxruntime_LIBRARY_DIR "${onnxruntime_DIR}/lib") + set(onnxruntime_LIBRARIES onnxruntime::onnxruntime) + add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL) + set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so) + set(onnxruntime_FOUND TRUE) +endif() + diff --git a/cpp/benchmarks/measurement_operator_mpi.cc b/cpp/benchmarks/measurement_operator_mpi.cc index c04c7992e..659e7c3a3 100644 --- a/cpp/benchmarks/measurement_operator_mpi.cc +++ b/cpp/benchmarks/measurement_operator_mpi.cc @@ -10,7 +10,6 @@ #include using namespace purify; -using namespace purify::notinstalled; // ----------------- Degrid operator constructor fixture -----------------------// diff --git a/cpp/benchmarks/measurement_operator_wproj.cc b/cpp/benchmarks/measurement_operator_wproj.cc index 70f932558..02c266c2e 100644 --- a/cpp/benchmarks/measurement_operator_wproj.cc +++ b/cpp/benchmarks/measurement_operator_wproj.cc @@ -12,7 +12,6 @@ #include using namespace purify; -using namespace purify::notinstalled; // ----------------- Degrid operator constructor fixture -----------------------// diff --git a/cpp/benchmarks/utilities.cc b/cpp/benchmarks/utilities.cc index cdb02fae9..2079a24aa 100644 --- a/cpp/benchmarks/utilities.cc +++ b/cpp/benchmarks/utilities.cc @@ -9,7 +9,6 @@ #include using namespace purify; -using namespace purify::notinstalled; namespace b_utilities { diff --git a/cpp/example/casa.cc b/cpp/example/casa.cc index 9d15d4d73..14a77396e 100644 --- a/cpp/example/casa.cc +++ b/cpp/example/casa.cc @@ -19,7 +19,7 @@ int main(int, char **) { purify::logging::set_level(purify::default_logging_level()); // Loads a measurement set - auto const ngc3256_filename = purify::notinstalled::ngc3256_ms(); + auto const ngc3256_filename = purify::ngc3256_ms(); auto const ngc3256 = purify::casa::MeasurementSet(ngc3256_filename); try { diff --git a/cpp/example/compare_wprojection.cc b/cpp/example/compare_wprojection.cc index 43d98bd3f..fc272115f 100644 --- a/cpp/example/compare_wprojection.cc +++ b/cpp/example/compare_wprojection.cc @@ -11,7 +11,6 @@ #include using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { #define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \ diff --git a/cpp/example/generate_vis_data.cc b/cpp/example/generate_vis_data.cc index 1c368e4c4..bffec2370 100644 --- a/cpp/example/generate_vis_data.cc +++ b/cpp/example/generate_vis_data.cc @@ -12,7 +12,6 @@ int main(int nargs, char const **args) { using namespace purify; - using namespace purify::notinstalled; purify::logging::set_level(purify::default_logging_level()); const std::string &pos_filename = mwa_filename("Phase1_config.txt"); diff --git a/cpp/example/histogram_equalisation.cc b/cpp/example/histogram_equalisation.cc index 744ce0157..61e0e35d7 100644 --- a/cpp/example/histogram_equalisation.cc +++ b/cpp/example/histogram_equalisation.cc @@ -4,7 +4,6 @@ #include "purify/directories.h" #include "purify/pfitsio.h" using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { // up samples M31 example diff --git a/cpp/example/image_wproj_chirp.cc b/cpp/example/image_wproj_chirp.cc index d8b8acf72..c954ca0d5 100644 --- a/cpp/example/image_wproj_chirp.cc +++ b/cpp/example/image_wproj_chirp.cc @@ -10,7 +10,6 @@ #include using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { #define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \ diff --git a/cpp/example/mem_w_algos.cc b/cpp/example/mem_w_algos.cc index d53e60d57..8d6b95f03 100644 --- a/cpp/example/mem_w_algos.cc +++ b/cpp/example/mem_w_algos.cc @@ -7,7 +7,6 @@ #include "purify/utilities.h" using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { auto const session = sopt::mpi::init(nargs, args); diff --git a/cpp/example/padmm_mpi_random_coverage.cc b/cpp/example/padmm_mpi_random_coverage.cc index 18994ec29..533eb8c50 100644 --- a/cpp/example/padmm_mpi_random_coverage.cc +++ b/cpp/example/padmm_mpi_random_coverage.cc @@ -30,7 +30,6 @@ #endif using namespace purify; -using namespace purify::notinstalled; std::tuple dirty_visibilities( Image const &ground_truth_image, t_uint number_of_vis, t_real snr, diff --git a/cpp/example/padmm_mpi_real_data.cc b/cpp/example/padmm_mpi_real_data.cc index 0eb766947..6dc717bd1 100644 --- a/cpp/example/padmm_mpi_real_data.cc +++ b/cpp/example/padmm_mpi_real_data.cc @@ -31,7 +31,6 @@ #endif using namespace purify; -using namespace purify::notinstalled; utilities::vis_params dirty_visibilities(const std::vector &names) { return utilities::read_visibility(names, true); diff --git a/cpp/example/padmm_random_coverage.cc b/cpp/example/padmm_random_coverage.cc index f22be4ed6..174f1fd83 100644 --- a/cpp/example/padmm_random_coverage.cc +++ b/cpp/example/padmm_random_coverage.cc @@ -21,7 +21,6 @@ #include "purify/pfitsio.h" #include "purify/utilities.h" using namespace purify; -using namespace purify::notinstalled; void padmm(const std::string &name, const Image &M31, const std::string &kernel, const t_int J, const utilities::vis_params &uv_data, const t_real sigma, @@ -182,13 +181,5 @@ int main(int, char **) { // adding noise to visibilities uv_data.vis = utilities::add_noise(y0, 0., sigma); padmm(name + "30", M31, kernel, 4, uv_data, sigma, std::make_tuple(w_term, cellsize)); - /* - const std::string &test_dir = "expected/padmm_serial/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); - auto uv_data = utilities::read_visibility(input_data_path, false); - uv_data.units = utilities::vis_units::radians; - t_real const sigma = 0.02378738741225; - padmm(name + "10", M31, kernel, 4, uv_data, sigma, std::make_tuple(w_term, cellsize)); - */ return 0; } diff --git a/cpp/example/padmm_real_data.cc b/cpp/example/padmm_real_data.cc index ded8a60af..290a6b00f 100644 --- a/cpp/example/padmm_real_data.cc +++ b/cpp/example/padmm_real_data.cc @@ -21,7 +21,6 @@ #include "purify/uvfits.h" #include "purify/wproj_utilities.h" using namespace purify; -using namespace purify::notinstalled; void padmm(const std::string &name, const t_uint &imsizex, const t_uint &imsizey, const std::string &kernel, const t_int J, const utilities::vis_params &uv_data, diff --git a/cpp/example/padmm_reweighted_simulation.cc b/cpp/example/padmm_reweighted_simulation.cc index 90eeec1cf..9fd5518b8 100644 --- a/cpp/example/padmm_reweighted_simulation.cc +++ b/cpp/example/padmm_reweighted_simulation.cc @@ -26,7 +26,6 @@ int main(int nargs, char const **args) { } using namespace purify; - using namespace purify::notinstalled; sopt::logging::set_level("debug"); std::string const kernel = args[1]; diff --git a/cpp/example/padmm_simulation.cc b/cpp/example/padmm_simulation.cc index 1200e7a7b..fd5cc71b6 100644 --- a/cpp/example/padmm_simulation.cc +++ b/cpp/example/padmm_simulation.cc @@ -24,7 +24,6 @@ int main(int nargs, char const **args) { } using namespace purify; - using namespace purify::notinstalled; sopt::logging::set_level("debug"); purify::logging::set_level("debug"); diff --git a/cpp/example/plot_wkernel.cc b/cpp/example/plot_wkernel.cc index dd5d297ba..7980a48cc 100644 --- a/cpp/example/plot_wkernel.cc +++ b/cpp/example/plot_wkernel.cc @@ -15,7 +15,6 @@ #include "purify/wkernel_integration.h" using namespace purify; -using namespace purify::notinstalled; using namespace purify; diff --git a/cpp/example/sara_padmm_random_coverage.cc b/cpp/example/sara_padmm_random_coverage.cc index 7094e8ab5..538f7b371 100644 --- a/cpp/example/sara_padmm_random_coverage.cc +++ b/cpp/example/sara_padmm_random_coverage.cc @@ -19,7 +19,6 @@ int main(int, char **) { using namespace purify; - using namespace purify::notinstalled; sopt::logging::set_level("info"); std::string const fitsfile = image_filename("M31.fits"); diff --git a/cpp/example/sdmm_m31_simulation.cc b/cpp/example/sdmm_m31_simulation.cc index c14644d42..9d764d13a 100644 --- a/cpp/example/sdmm_m31_simulation.cc +++ b/cpp/example/sdmm_m31_simulation.cc @@ -19,7 +19,6 @@ int main(int nargs, char const **args) { using namespace purify; - using namespace purify::notinstalled; if (nargs != 6) { PURIFY_CRITICAL(" Wrong number of arguments!"); diff --git a/cpp/example/show_image.cc b/cpp/example/show_image.cc index a26821ac7..471090083 100644 --- a/cpp/example/show_image.cc +++ b/cpp/example/show_image.cc @@ -4,7 +4,6 @@ #include "purify/directories.h" #include "purify/pfitsio.h" using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { // up samples M31 example diff --git a/cpp/example/time_w_algos.cc b/cpp/example/time_w_algos.cc index 4cf00c351..d96e5d62f 100644 --- a/cpp/example/time_w_algos.cc +++ b/cpp/example/time_w_algos.cc @@ -7,7 +7,6 @@ #include "purify/utilities.h" using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { auto const session = sopt::mpi::init(nargs, args); diff --git a/cpp/example/wavelet_decomposition.cc b/cpp/example/wavelet_decomposition.cc index 8dde64e84..f29e44c15 100644 --- a/cpp/example/wavelet_decomposition.cc +++ b/cpp/example/wavelet_decomposition.cc @@ -7,7 +7,6 @@ #include "purify/wavelet_operator_factory.h" using namespace purify; -using namespace purify::notinstalled; int main(int nargs, char const **args) { purify::logging::set_level("debug"); diff --git a/cpp/tests/algo_factory.cc b/cpp/tests/algo_factory.cc index 7a2032daf..9a51c68ae 100644 --- a/cpp/tests/algo_factory.cc +++ b/cpp/tests/algo_factory.cc @@ -22,15 +22,14 @@ #include "purify/test_data.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("padmm_factory") { const std::string &test_dir = "expected/padmm/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -81,11 +80,11 @@ TEST_CASE("padmm_factory") { // See https://github.com/astro-informatics/purify/issues/317 for details. TEST_CASE("primal_dual_factory", "[!shouldfail]") { const std::string &test_dir = "expected/primal_dual/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -136,12 +135,12 @@ TEST_CASE("primal_dual_factory", "[!shouldfail]") { TEST_CASE("fb_factory") { const std::string &test_dir = "expected/fb/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); - const std::string &result_path = notinstalled::data_filename(test_dir + "fb_result.fits"); + data_filename(test_dir + "residual.fits"); + const std::string &result_path = data_filename(test_dir + "fb_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -192,12 +191,12 @@ TEST_CASE("fb_factory") { #ifdef PURIFY_ONNXRT TEST_CASE("tf_fb_factory") { const std::string &test_dir = "expected/fb/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); - const std::string &result_path = notinstalled::data_filename(test_dir + "tf_result.fits"); + data_filename(test_dir + "residual.fits"); + const std::string &result_path = data_filename(test_dir + "tf_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -228,7 +227,7 @@ TEST_CASE("tf_fb_factory") { t_real const gamma = 0.0001; std::string tf_model_path = - purify::notinstalled::data_directory() + "/models/snr_15_model_dynamic.onnx"; + purify::models_directory() + "/snr_15_model_dynamic.onnx"; auto const fb = factory::fb_factory>( factory::algo_distribution::serial, measurements_transform, wavelets, uv_data, sigma, beta, @@ -252,12 +251,12 @@ TEST_CASE("tf_fb_factory") { TEST_CASE("onnx_fb_factory") { const std::string &test_dir = "expected/fb/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); - const std::string &result_path = notinstalled::data_filename(test_dir + "onnx_result.fits"); + data_filename(test_dir + "residual.fits"); + const std::string &result_path = data_filename(test_dir + "onnx_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -287,9 +286,9 @@ TEST_CASE("onnx_fb_factory") { t_real const gamma = 0.0001; std::string const prior_path = - purify::notinstalled::data_directory() + "/models/example_cost_dynamic_CRR_sigma_5_t_5.onnx"; + purify::models_directory() + "/example_cost_dynamic_CRR_sigma_5_t_5.onnx"; std::string const prior_gradient_path = - purify::notinstalled::data_directory() + "/models/example_grad_dynamic_CRR_sigma_5_t_5.onnx"; + purify::models_directory() + "/example_grad_dynamic_CRR_sigma_5_t_5.onnx"; std::shared_ptr> diff_function = std::make_shared>( prior_path, prior_gradient_path, sigma, 20, 5e4, *measurements_transform); @@ -317,11 +316,11 @@ TEST_CASE("onnx_fb_factory") { TEST_CASE("joint_map_factory") { const std::string &test_dir = "expected/joint_map/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); diff --git a/cpp/tests/casacore.cc b/cpp/tests/casacore.cc index daa62d6d7..6f262558c 100644 --- a/cpp/tests/casacore.cc +++ b/cpp/tests/casacore.cc @@ -17,7 +17,6 @@ #include "catch2/catch_all.hpp" namespace casa = casacore; -using namespace purify::notinstalled; TEST_CASE("Casacore") { // create the table descriptor casa::TableDesc simpleDesc = casa::MS::requiredTableDesc(); diff --git a/cpp/tests/convolution.cc b/cpp/tests/convolution.cc index 60a3b3b12..a14f82101 100644 --- a/cpp/tests/convolution.cc +++ b/cpp/tests/convolution.cc @@ -8,7 +8,6 @@ #include "purify/convolution.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("1d_zeropad") { const Vector signal = Vector::Random(3); diff --git a/cpp/tests/data.in.h b/cpp/tests/data.in.h index 05444604f..6aacbfc56 100644 --- a/cpp/tests/data.in.h +++ b/cpp/tests/data.in.h @@ -9,7 +9,6 @@ #include "purify/types.h" #include "purify/directories.h" namespace purify { -namespace notinstalled { //! read real values from data file template typename std::enable_if::value, std::vector>::type @@ -55,5 +54,4 @@ typename std::enable_if::value, std::vector>::type } } -} /* sopt::notinstalled */ #endif diff --git a/cpp/tests/directories.in.h b/cpp/tests/directories.in.h index e6026b0ec..259de5eec 100644 --- a/cpp/tests/directories.in.h +++ b/cpp/tests/directories.in.h @@ -4,37 +4,25 @@ #include #include namespace purify { -namespace notinstalled { //! Holds data and such inline std::string data_directory() { return "@CMAKE_INSTALL_PREFIX@/data"; } +//! Holds TF models +inline std::string models_directory() { return "@CMAKE_INSTALL_PREFIX@/models"; } +//! Where test outputs go +inline std::string output_directory() { return "@CMAKE_INSTALL_PREFIX@/outputs"; } + //! Holds data and such inline std::string data_filename(std::string const &filename) { return data_directory() + "/" + filename; } -//! Holds data and such in Scratch (useful for legion) -inline std::string scratch_directory() { - std::string dirName = "$ENV{HOME}/Scratch/purify/data"; - struct stat sb; - if ( stat("$ENV{HOME}/Scratch",&sb)!=0 || !S_ISDIR(sb.st_mode) ) - mkdir("$ENV{HOME}/Scratch",S_IRWXU); - if ( stat("$ENV{HOME}/Scratch/purify",&sb)!=0 || !S_ISDIR(sb.st_mode) ) - mkdir("$ENV{HOME}/Scratch/purify",S_IRWXU); - if ( stat("$ENV{HOME}/Scratch/purify/data",&sb)!=0 || !S_ISDIR(sb.st_mode) ) - mkdir("$ENV{HOME}/Scratch/purify/data",S_IRWXU); - return dirName; -} -//! Holds data and such in Scratch (useful for legion) -inline std::string scratch_filename(std::string const &filename) { - return scratch_directory() + "/" + filename; -} //! Image filename inline std::string image_filename(std::string const &filename) { return data_filename("images/" + filename); } //! Visibility filename inline std::string visibility_filename(std::string const &filename) { - return scratch_filename("vis_" + filename); + return data_filename("vis_" + filename); } //! Specific vla data inline std::string vla_filename(std::string const &filename) { @@ -57,8 +45,6 @@ inline std::string degridding_filename(std::string const &filename) { return data_filename("expected/degridding/" + filename); } -//! Where test outputs go -inline std::string output_directory() { return "@PROJECT_BINARY_DIR@/outputs"; } //! Test output file inline std::string output_filename(std::string const &filename) { return output_directory() + "/" + filename; @@ -66,5 +52,4 @@ inline std::string output_filename(std::string const &filename) { inline std::string ngc3256_ms() { return "@NGC3256_MS@"; } } -} /* sopt::notinstalled */ #endif diff --git a/cpp/tests/distribute.cc b/cpp/tests/distribute.cc index 033268769..6c25e2815 100644 --- a/cpp/tests/distribute.cc +++ b/cpp/tests/distribute.cc @@ -5,7 +5,6 @@ #include "purify/utilities.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("Distribute") { // Test splitting up of data for separate nodes auto const uv_data = utilities::read_visibility(vla_filename("at166B.3C129.c0.vis")); diff --git a/cpp/tests/integration.cc b/cpp/tests/integration.cc index 0cf51b76a..189f4da47 100644 --- a/cpp/tests/integration.cc +++ b/cpp/tests/integration.cc @@ -8,7 +8,6 @@ #include "purify/integration.h" #include "purify/kernels.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("integration") { const t_uint max_evaluations = 1000; diff --git a/cpp/tests/measurement_operator.cc b/cpp/tests/measurement_operator.cc index 80d750327..e9115e260 100644 --- a/cpp/tests/measurement_operator.cc +++ b/cpp/tests/measurement_operator.cc @@ -10,7 +10,6 @@ #include "purify/wproj_operators.h" #include -using namespace purify::notinstalled; using namespace purify; using Catch::Approx; diff --git a/cpp/tests/mpi_algo_factory.cc b/cpp/tests/mpi_algo_factory.cc index b26bebb9f..10a7773d1 100644 --- a/cpp/tests/mpi_algo_factory.cc +++ b/cpp/tests/mpi_algo_factory.cc @@ -41,7 +41,7 @@ TEST_CASE("Serial vs. Serial with MPI PADMM") { auto const world = sopt::mpi::Communicator::World(); const std::string &test_dir = "expected/padmm/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); auto uv_data = dirty_visibilities({input_data_path}, world); uv_data.units = utilities::vis_units::radians; @@ -77,9 +77,9 @@ TEST_CASE("Serial vs. Serial with MPI PADMM") { CHECK(diagnostic.niters == 10); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -113,11 +113,11 @@ TEST_CASE("Serial vs. Serial with MPI PADMM") { if (world.size() > 2 or world.size() == 0) return; // testing the case where there are two nodes exactly. const std::string &expected_solution_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_solution.fits") - : notinstalled::data_filename(test_dir + "solution.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_solution.fits") + : data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_residual.fits") - : notinstalled::data_filename(test_dir + "residual.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_residual.fits") + : data_filename(test_dir + "residual.fits"); if (world.size() == 1) CHECK(diagnostic.niters == 10); if (world.size() == 2) CHECK(diagnostic.niters == 11); @@ -145,7 +145,7 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { auto const world = sopt::mpi::Communicator::World(); const std::string &test_dir = "expected/primal_dual/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); auto uv_data = dirty_visibilities({input_data_path}, world); uv_data.units = utilities::vis_units::radians; @@ -182,9 +182,9 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { CHECK(diagnostic.niters == 16); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -219,11 +219,11 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { if (world.size() > 2 or world.size() == 0) return; // testing the case where there are two nodes exactly. const std::string &expected_solution_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_solution.fits") - : notinstalled::data_filename(test_dir + "solution.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_solution.fits") + : data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_residual.fits") - : notinstalled::data_filename(test_dir + "residual.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_residual.fits") + : data_filename(test_dir + "residual.fits"); if (world.size() == 1) CHECK(diagnostic.niters == 16); if (world.size() == 2) CHECK(diagnostic.niters == 18); const auto solution = pfitsio::read2d(expected_solution_path); @@ -277,11 +277,11 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { else if (world.size() == 2 or world.size() == 1) { // testing the case where there are two nodes exactly. const std::string &expected_solution_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_random_solution.fits") - : notinstalled::data_filename(test_dir + "solution.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_random_solution.fits") + : data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - (world.size() == 2) ? notinstalled::data_filename(test_dir + "mpi_random_residual.fits") - : notinstalled::data_filename(test_dir + "residual.fits"); + (world.size() == 2) ? data_filename(test_dir + "mpi_random_residual.fits") + : data_filename(test_dir + "residual.fits"); if (world.size() == 1) CHECK(diagnostic.niters == 16); if (world.size() == 2) CHECK(diagnostic.niters < 100); @@ -314,7 +314,7 @@ TEST_CASE("Serial vs. Serial with MPI Forward Backward") { auto const world = sopt::mpi::Communicator::World(); const std::string &test_dir = "expected/fb/"; - const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis"); + const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); auto uv_data = dirty_visibilities({input_data_path}, world); uv_data.units = utilities::vis_units::radians; @@ -350,9 +350,9 @@ TEST_CASE("Serial vs. Serial with MPI Forward Backward") { auto const diagnostic = (*fb)(); const std::string &expected_solution_path = - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); diff --git a/cpp/tests/mpi_read_measurements.cc b/cpp/tests/mpi_read_measurements.cc index 8c83d95b8..0b68f9376 100644 --- a/cpp/tests/mpi_read_measurements.cc +++ b/cpp/tests/mpi_read_measurements.cc @@ -8,7 +8,6 @@ #include "purify/read_measurements.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("uvfits") { auto const comm = sopt::mpi::Communicator::World(); diff --git a/cpp/tests/operators.cc b/cpp/tests/operators.cc index 2bf8c74fa..194fc7950 100644 --- a/cpp/tests/operators.cc +++ b/cpp/tests/operators.cc @@ -11,31 +11,30 @@ #include using namespace purify; -using namespace purify::notinstalled; namespace operators_test { const std::string test_dir = "expected/operators/"; //! data for u coordinate -const std::vector u = notinstalled::read_data( - notinstalled::data_filename(test_dir + "u_data")); //! data for v coordinate +const std::vector u = read_data( + data_filename(test_dir + "u_data")); //! data for v coordinate const std::vector v = - notinstalled::read_data(notinstalled::data_filename(test_dir + "v_data")); + read_data(data_filename(test_dir + "v_data")); //! data for degridding input const std::vector direct_input = - notinstalled::read_data(notinstalled::data_filename(test_dir + "direct_input_data")); + read_data(data_filename(test_dir + "direct_input_data")); //! data for degridding output -const std::vector expected_direct = notinstalled::read_data( - notinstalled::data_filename(test_dir + "expected_direct_data")); +const std::vector expected_direct = read_data( + data_filename(test_dir + "expected_direct_data")); //! data for gridding input -const std::vector indirect_input = notinstalled::read_data( - notinstalled::data_filename(test_dir + "indirect_input_data")); +const std::vector indirect_input = read_data( + data_filename(test_dir + "indirect_input_data")); //! data for gridding output -const std::vector expected_indirect = notinstalled::read_data( - notinstalled::data_filename(test_dir + "expected_indirect_data")); +const std::vector expected_indirect = read_data( + data_filename(test_dir + "expected_indirect_data")); //! data for gridding correction -const std::vector expected_S = notinstalled::read_data( - notinstalled::read_data(notinstalled::data_filename(test_dir + "expected_S_data"))); +const std::vector expected_S = read_data( + read_data(data_filename(test_dir + "expected_S_data"))); } // namespace operators_test TEST_CASE("Operators") { diff --git a/cpp/tests/operators_gpu.cc b/cpp/tests/operators_gpu.cc index 92436e4f1..7be63332d 100644 --- a/cpp/tests/operators_gpu.cc +++ b/cpp/tests/operators_gpu.cc @@ -11,7 +11,6 @@ #include "purify/wproj_operators_gpu.h" #include using namespace purify; -using namespace purify::notinstalled; TEST_CASE("GPU Operators") { af::setDevice(0); af::info(); diff --git a/cpp/tests/parser_test.cc b/cpp/tests/parser_test.cc index a9ea2e880..1fff8ce89 100644 --- a/cpp/tests/parser_test.cc +++ b/cpp/tests/parser_test.cc @@ -9,10 +9,10 @@ using namespace purify; TEST_CASE("Yaml parser and setting variables test") { - std::string file_path = purify::notinstalled::data_filename("config/config.yaml"); + std::string file_path = purify::data_filename("config/config.yaml"); YamlParser yaml_parser = YamlParser(file_path); std::string file_path_m = - purify::notinstalled::data_filename("config/test_measurements_config.yaml"); + purify::data_filename("config/test_measurements_config.yaml"); YamlParser yaml_parser_m = YamlParser(file_path_m); SECTION("Check the GeneralConfiguration measurement input variables") { REQUIRE(yaml_parser_m.source() == purify::utilities::vis_source::measurements); @@ -29,7 +29,7 @@ TEST_CASE("Yaml parser and setting variables test") { } SECTION("Check the GeneralConfiguration simulation input variables") { std::string file_path_s = - purify::notinstalled::data_filename("config/test_simulation_config.yaml"); + purify::data_filename("config/test_simulation_config.yaml"); YamlParser yaml_parser_s = YamlParser(file_path_s); REQUIRE(yaml_parser_s.source() == purify::utilities::vis_source::simulation); REQUIRE(yaml_parser_s.measurements() == diff --git a/cpp/tests/purify_fitsio.cc b/cpp/tests/purify_fitsio.cc index 68190ec26..57a099fae 100644 --- a/cpp/tests/purify_fitsio.cc +++ b/cpp/tests/purify_fitsio.cc @@ -8,7 +8,6 @@ #include "purify/pfitsio.h" using namespace purify; -using namespace purify::notinstalled; /*TEST_CASE("Purify fitsio", "[readwrite]") { Image input = pfitsio::read2d(image_filename("M31.fits")); diff --git a/cpp/tests/read_measurements.cc b/cpp/tests/read_measurements.cc index b8355a253..dc4a7a259 100644 --- a/cpp/tests/read_measurements.cc +++ b/cpp/tests/read_measurements.cc @@ -8,7 +8,6 @@ #include "purify/read_measurements.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("mkdir") { const std::string dirs = "test/mkdir/recursive"; diff --git a/cpp/tests/sparse.cc b/cpp/tests/sparse.cc index 670a79a1a..f29efaa5d 100644 --- a/cpp/tests/sparse.cc +++ b/cpp/tests/sparse.cc @@ -5,7 +5,6 @@ #include "purify/directories.h" #include "purify/logging.h" using namespace purify; -using namespace purify::notinstalled; TEST_CASE("sparse [iterator]", "[iterator]") { t_int NZnum = 40; diff --git a/cpp/tests/utils.cc b/cpp/tests/utils.cc index 1f8188848..915ca6355 100644 --- a/cpp/tests/utils.cc +++ b/cpp/tests/utils.cc @@ -5,7 +5,6 @@ #include "purify/uvw_utilities.h" using namespace purify; -using namespace purify::notinstalled; using Catch::Approx; TEST_CASE("utilities [mod]", "[mod]") { diff --git a/cpp/tests/uvfits.cc b/cpp/tests/uvfits.cc index dc490fe36..08fbdabf6 100644 --- a/cpp/tests/uvfits.cc +++ b/cpp/tests/uvfits.cc @@ -7,7 +7,6 @@ #include "purify/directories.h" #include "purify/uvfits.h" using namespace purify; -using namespace purify::notinstalled; using Catch::Approx; TEST_CASE("readfile") { diff --git a/cpp/tests/wide_field_utilities.cc b/cpp/tests/wide_field_utilities.cc index 3aa98d49f..477c194d0 100644 --- a/cpp/tests/wide_field_utilities.cc +++ b/cpp/tests/wide_field_utilities.cc @@ -12,7 +12,6 @@ #include "purify/wide_field_utilities.h" using namespace purify; -using namespace purify::notinstalled; using Catch::Approx; TEST_CASE("uvw units") { diff --git a/cpp/tests/wkernel.cc b/cpp/tests/wkernel.cc index 5c02dfa75..b5238021f 100644 --- a/cpp/tests/wkernel.cc +++ b/cpp/tests/wkernel.cc @@ -10,7 +10,6 @@ #include "purify/wkernel_integration.h" using namespace purify; -using namespace purify::notinstalled; using Catch::Approx; TEST_CASE("test transform kernels") { diff --git a/data/expected/padmm/test_parameters_mpi b/data/expected/padmm/test_parameters_mpi index c3f593969..f556d814c 100644 --- a/data/expected/padmm/test_parameters_mpi +++ b/data/expected/padmm/test_parameters_mpi @@ -54,8 +54,8 @@ dirty_visibilities(const std::vector &names, sopt::mpi::Communicato auto const diagnostic = (*padmm)(); CHECK(diagnostic.niters == 139); - const std::string &expected_solution_path = notinstalled::data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = notinstalled::data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -77,11 +77,11 @@ dirty_visibilities(const std::vector &names, sopt::mpi::Communicato //testing the case where there are two nodes exactly. const std::string &expected_solution_path = (world.size() == 2) ? - notinstalled::data_filename(test_dir + "mpi_solution.fits"): - notinstalled::data_filename(test_dir + "solution.fits"); + data_filename(test_dir + "mpi_solution.fits"): + data_filename(test_dir + "solution.fits"); const std::string &expected_residual_path = (world.size() == 2) ? - notinstalled::data_filename(test_dir + "mpi_residual.fits"): - notinstalled::data_filename(test_dir + "residual.fits"); + data_filename(test_dir + "mpi_residual.fits"): + data_filename(test_dir + "residual.fits"); if(world.size() == 1) CHECK(diagnostic.niters == 139); if(world.size() == 2) From 5ec5ad76c77a04be8f74d053dbe6a9a8f0bd083c Mon Sep 17 00:00:00 2001 From: Tuomas Koskela Date: Thu, 14 Nov 2024 12:12:10 +0000 Subject: [PATCH 2/4] Linting --- cpp/purify/config.in.h | 4 +- cpp/tests/CMakeLists.txt | 185 +++++++++++++++++++--------------- cpp/tests/algo_factory.cc | 39 +++---- cpp/tests/data.in.h | 56 +++++----- cpp/tests/directories.in.h | 2 +- cpp/tests/mpi_algo_factory.cc | 42 ++++---- cpp/tests/operators.cc | 23 ++--- cpp/tests/parser_test.cc | 6 +- 8 files changed, 176 insertions(+), 181 deletions(-) diff --git a/cpp/purify/config.in.h b/cpp/purify/config.in.h index 44e0b4713..c982f531f 100644 --- a/cpp/purify/config.in.h +++ b/cpp/purify/config.in.h @@ -28,9 +28,9 @@ //! Whether PURIFY is using (and SOPT was built with) onnxrt support #cmakedefine PURIFY_ONNXRT +#include #include #include -#include namespace purify { //! Returns library version @@ -46,6 +46,6 @@ inline std::tuple version_tuple() { inline std::string gitref() { return "@Purify_GITREF@"; } //! Default logging level inline std::string default_logging_level() { return "@PURIFY_TEST_LOG_LEVEL@"; } -} // namespace purify +} // namespace purify #endif diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 566e2368c..29ee57be7 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -1,90 +1,111 @@ -include_directories("${PROJECT_SOURCE_DIR}/cpp" "${PROJECT_BINARY_DIR}/include") -add_library(common_catch_main_object OBJECT "common_catch_main.cc") -if(Catch2_FOUND) - target_link_libraries(common_catch_main_object Catch2::Catch2) -endif() -if(EIGEN3_INCLUDE_DIR) -target_include_directories(common_catch_main_object SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR}) -endif() -if(sopt_FOUND) - target_include_directories(common_catch_main_object SYSTEM PUBLIC ${sopt_INCLUDE_DIR}) -endif() -target_include_directories(common_catch_main_object PUBLIC - "${EXTERNAL_ROOT}/include/" - "${PROJECT_BINARY_DIR}/include/" -) -file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/outputs") +include_directories( + "${PROJECT_SOURCE_DIR}/cpp" + "${PROJECT_BINARY_DIR}/include") add_library(common_catch_main_object OBJECT + "common_catch_main.cc") if (Catch2_FOUND) + target_link_libraries(common_catch_main_object Catch2::Catch2) endif() if ( + EIGEN3_INCLUDE_DIR) target_include_directories(common_catch_main_object SYSTEM PUBLIC ${ + EIGEN3_INCLUDE_DIR}) endif() if (sopt_FOUND) target_include_directories(common_catch_main_object SYSTEM PUBLIC ${ + sopt_INCLUDE_DIR}) endif() target_include_directories(common_catch_main_object PUBLIC + "${EXTERNAL_ROOT}/include/" + "${PROJECT_BINARY_DIR}/" + "include/") file(MAKE_DIRECTORY + "${PROJECT_" + "BINARY_DIR}" + "/outputs") + add_catch_test(algo_factory LIBRARIES libpurify) add_catch_test( + convolution + LIBRARIES libpurify) add_catch_test(distribute LIBRARIES libpurify) + add_catch_test(index_mapping LIBRARIES libpurify) add_catch_test(integration LIBRARIES libpurify) add_catch_test( + measurement_factory + LIBRARIES libpurify) add_catch_test(measurement_operator LIBRARIES libpurify) + add_catch_test(operators LIBRARIES libpurify) add_catch_test( + parser_test + LIBRARIES libpurify) add_catch_test(purify_fitsio LIBRARIES libpurify) + add_catch_test(read_measurements LIBRARIES libpurify) add_catch_test( + sparse LIBRARIES libpurify) add_catch_test(utils LIBRARIES libpurify) + add_catch_test(uvfits LIBRARIES libpurify) add_catch_test(wavelet_factory LIBRARIES libpurify) add_catch_test( + wide_field_utilities LIBRARIES + libpurify) add_catch_test(wkernel LIBRARIES libpurify) -add_catch_test(algo_factory LIBRARIES libpurify) -add_catch_test(convolution LIBRARIES libpurify) -add_catch_test(distribute LIBRARIES libpurify) -add_catch_test(index_mapping LIBRARIES libpurify) -add_catch_test(integration LIBRARIES libpurify) -add_catch_test(measurement_factory LIBRARIES libpurify) -add_catch_test(measurement_operator LIBRARIES libpurify) -add_catch_test(operators LIBRARIES libpurify) -add_catch_test(parser_test LIBRARIES libpurify) -add_catch_test(purify_fitsio LIBRARIES libpurify) -add_catch_test(read_measurements LIBRARIES libpurify) -add_catch_test(sparse LIBRARIES libpurify) -add_catch_test(utils LIBRARIES libpurify) -add_catch_test(uvfits LIBRARIES libpurify) -add_catch_test(wavelet_factory LIBRARIES libpurify) -add_catch_test(wide_field_utilities LIBRARIES libpurify) -add_catch_test(wkernel LIBRARIES libpurify) + if (PURIFY_CASACORE) add_catch_test(casacore LIBRARIES libpurify ${ + Boost_FILESYSTEM_LIBRARY} ${ + Boost_SYSTEM_LIBRARY} DEPENDS lookup_dependencies) endif() -if(PURIFY_CASACORE) - add_catch_test(casacore LIBRARIES libpurify ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} DEPENDS lookup_dependencies) -endif() + if (PURIFY_ARRAYFIRE) include_directories(${ArrayFire_INCLUDE_DIRS}) add_catch_test( + operators_gpu LIBRARIES + libpurify ${ArrayFire_LIBRARIES}) endif() -if(PURIFY_ARRAYFIRE) - include_directories(${ArrayFire_INCLUDE_DIRS}) - add_catch_test(operators_gpu LIBRARIES libpurify ${ArrayFire_LIBRARIES}) -endif() + if (PURIFY_MPI) + add_library( + common_mpi_catch_main_object OBJECT + "common_mpi_catch_main.cc") + target_include_directories( + common_mpi_catch_main_object PUBLIC + ${PROJECT_BINARY_DIR} / + include + ${MPI_CXX_INCLUDE_PATH}) if (Catch2_FOUND) + target_link_libraries(common_mpi_catch_main_object Catch2::Catch2) endif() if ( + sopt_FOUND) target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${ + sopt_INCLUDE_DIR}) endif() if (EIGEN3_INCLUDE_DIR) + target_include_directories( + common_mpi_catch_main_object SYSTEM + PUBLIC ${EIGEN3_INCLUDE_DIR}) endif() -if(PURIFY_MPI) - add_library(common_mpi_catch_main_object OBJECT "common_mpi_catch_main.cc") - target_include_directories(common_mpi_catch_main_object - PUBLIC ${PROJECT_BINARY_DIR}/include ${MPI_CXX_INCLUDE_PATH}) - if(Catch2_FOUND) - target_link_libraries(common_mpi_catch_main_object Catch2::Catch2) - endif() - if(sopt_FOUND) - target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${sopt_INCLUDE_DIR}) - endif() - if(EIGEN3_INCLUDE_DIR) - target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR}) - endif() + function(add_mpi_test + testname) add_catch_test(${ + testname} COMMON_MAIN common_mpi_catch_main_object NOTEST ${ + ARGN}) unset(arguments) if (CATCH_JUNIT) + set(arguments - r junit - + o ${PROJECT_BINARY_DIR} / Testing / + ${testname}.xml) + endif() if (NOT MPIEXEC_MAX_NUMPROCS) set( + MPIEXEC_MAX_NUMPROCS 4) endif() add_test(NAME ${ + testname} COMMAND ${ + MPIEXEC} ${ + MPIEXEC_NUMPROC_FLAG} ${ + MPIEXEC_MAX_NUMPROCS} $ { + MPIEXEC_PREFLAGS + } "./test_${testname}" ${ + arguments}) set_tests_properties(${ + testname} PROPERTIES LABELS "ca" + "tc" + "h;" + "mp" + "i") endfunction() - function(add_mpi_test testname) - add_catch_test(${testname} COMMON_MAIN common_mpi_catch_main_object NOTEST ${ARGN}) - unset(arguments) - if(CATCH_JUNIT) - set(arguments -r junit -o ${PROJECT_BINARY_DIR}/Testing/${testname}.xml) - endif() - if(NOT MPIEXEC_MAX_NUMPROCS) - set(MPIEXEC_MAX_NUMPROCS 4) - endif() - add_test(NAME ${testname} - COMMAND - ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} - "./test_${testname}" ${arguments}) - set_tests_properties(${testname} PROPERTIES LABELS "catch;mpi") - endfunction() - - add_mpi_test(distribute_sparse_vector LIBRARIES libpurify) - add_mpi_test(kmeans LIBRARIES libpurify) - add_mpi_test(mpi_algo_factory LIBRARIES libpurify) - add_mpi_test(mpi_measurement_factory LIBRARIES libpurify) - add_mpi_test(mpi_measurement_operator LIBRARIES libpurify) - add_mpi_test(mpi_read_measurements LIBRARIES libpurify) - add_catch_test(mpi_utilities LIBRARIES libpurify) - add_mpi_test(mpi_wavelet_factory LIBRARIES libpurify) - add_mpi_test(mpi_wide_field_utilities LIBRARIES libpurify) - add_mpi_test(parallel_mpi_utilities LIBRARIES libpurify) -endif() - -install(DIRECTORY ${CMAKE_SOURCE_DIR}/data DESTINATION .) + add_mpi_test( + distribute_sparse_vector + LIBRARIES + libpurify) add_mpi_test(kmeans LIBRARIES libpurify) + add_mpi_test(mpi_algo_factory LIBRARIES libpurify) add_mpi_test( + mpi_measurement_factory + LIBRARIES libpurify) + add_mpi_test( + mpi_measurement_operator + LIBRARIES + libpurify) + add_mpi_test( + mpi_read_measurements LIBRARIES + libpurify) + add_catch_test( + mpi_utilities LIBRARIES + libpurify) + add_mpi_test( + mpi_wavelet_factory + LIBRARIES + libpurify) + add_mpi_test( + mpi_wide_field_utilities + LIBRARIES + libpurify) + add_mpi_test( + parallel_mpi_utilities LIBRARIES + libpurify) endif() + install( + DIRECTORY + ${CMAKE_SOURCE_DIR} / + data DESTINATION + .) diff --git a/cpp/tests/algo_factory.cc b/cpp/tests/algo_factory.cc index 9a51c68ae..1e7b1ac48 100644 --- a/cpp/tests/algo_factory.cc +++ b/cpp/tests/algo_factory.cc @@ -26,10 +26,8 @@ using namespace purify; TEST_CASE("padmm_factory") { const std::string &test_dir = "expected/padmm/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -81,10 +79,8 @@ TEST_CASE("padmm_factory") { TEST_CASE("primal_dual_factory", "[!shouldfail]") { const std::string &test_dir = "expected/primal_dual/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -136,10 +132,8 @@ TEST_CASE("primal_dual_factory", "[!shouldfail]") { TEST_CASE("fb_factory") { const std::string &test_dir = "expected/fb/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const std::string &result_path = data_filename(test_dir + "fb_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); @@ -192,10 +186,8 @@ TEST_CASE("fb_factory") { TEST_CASE("tf_fb_factory") { const std::string &test_dir = "expected/fb/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const std::string &result_path = data_filename(test_dir + "tf_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); @@ -226,8 +218,7 @@ TEST_CASE("tf_fb_factory") { t_real const beta = sigma * sigma; t_real const gamma = 0.0001; - std::string tf_model_path = - purify::models_directory() + "/snr_15_model_dynamic.onnx"; + std::string tf_model_path = purify::models_directory() + "/snr_15_model_dynamic.onnx"; auto const fb = factory::fb_factory>( factory::algo_distribution::serial, measurements_transform, wavelets, uv_data, sigma, beta, @@ -252,10 +243,8 @@ TEST_CASE("tf_fb_factory") { TEST_CASE("onnx_fb_factory") { const std::string &test_dir = "expected/fb/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const std::string &result_path = data_filename(test_dir + "onnx_result.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -317,10 +306,8 @@ TEST_CASE("onnx_fb_factory") { TEST_CASE("joint_map_factory") { const std::string &test_dir = "expected/joint_map/"; const std::string &input_data_path = data_filename(test_dir + "input_data.vis"); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); diff --git a/cpp/tests/data.in.h b/cpp/tests/data.in.h index 6aacbfc56..414a81e4f 100644 --- a/cpp/tests/data.in.h +++ b/cpp/tests/data.in.h @@ -1,57 +1,53 @@ #ifndef PURIFY_DATA_H #define PURIFY_DATA_H +#include #include -#include #include -#include +#include #include "purify/types.h" #include "purify/directories.h" namespace purify { - //! read real values from data file - template -typename std::enable_if::value, std::vector>::type - read_data(const std::string & filename){ +//! read real values from data file +template +typename std::enable_if::value, std::vector>::type read_data( + const std::string& filename) { std::ifstream data_file(filename); - if (!data_file) - throw std::runtime_error("Test data is missing: "+filename); + if (!data_file) throw std::runtime_error("Test data is missing: " + filename); std::string s; - //read data + // read data std::vector data; - for(std::string s; std::getline(data_file, s, ',');){ + for (std::string s; std::getline(data_file, s, ',');) { data.push_back(std::stod(s)); } return data; - } - //! read complex values from data file - template - typename std::enable_if::value, std::vector>::type - read_data(const std::string & filename){ +} +//! read complex values from data file +template +typename std::enable_if::value, std::vector>::type read_data( + const std::string& filename) { std::ifstream data_file(filename); - if (!data_file) - throw std::runtime_error("Test data is missing: "+filename); + if (!data_file) throw std::runtime_error("Test data is missing: " + filename); std::string real = ""; std::string imag = ""; - //read data + // read data std::vector data; - for(std::string real; std::getline(data_file, real, ',');){ + for (std::string real; std::getline(data_file, real, ',');) { real.erase(0, 1); - if(!std::getline(data_file, imag, ')')) - break; + if (!std::getline(data_file, imag, ')')) break; data.push_back(T(std::stod(real), std::stod(imag))); - real=""; - imag=""; + real = ""; + imag = ""; } return data; - } +} - std::vector read_data(const std::vector & input){ - std::vector output; - for(auto a = input.begin(); a != input.end(); a++ ) - output.push_back(t_complex(*a, 0.)); +std::vector read_data(const std::vector& input) { + std::vector output; + for (auto a = input.begin(); a != input.end(); a++) output.push_back(t_complex(*a, 0.)); return output; - } - } + +} // namespace purify #endif diff --git a/cpp/tests/directories.in.h b/cpp/tests/directories.in.h index 259de5eec..aa95c3517 100644 --- a/cpp/tests/directories.in.h +++ b/cpp/tests/directories.in.h @@ -51,5 +51,5 @@ inline std::string output_filename(std::string const &filename) { } inline std::string ngc3256_ms() { return "@NGC3256_MS@"; } -} +} // namespace purify #endif diff --git a/cpp/tests/mpi_algo_factory.cc b/cpp/tests/mpi_algo_factory.cc index 10a7773d1..5b3351582 100644 --- a/cpp/tests/mpi_algo_factory.cc +++ b/cpp/tests/mpi_algo_factory.cc @@ -76,10 +76,8 @@ TEST_CASE("Serial vs. Serial with MPI PADMM") { auto const diagnostic = (*padmm)(); CHECK(diagnostic.niters == 10); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -112,12 +110,12 @@ TEST_CASE("Serial vs. Serial with MPI PADMM") { // it is hard to know exact precision (might depend on probability theory...) if (world.size() > 2 or world.size() == 0) return; // testing the case where there are two nodes exactly. - const std::string &expected_solution_path = - (world.size() == 2) ? data_filename(test_dir + "mpi_solution.fits") - : data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - (world.size() == 2) ? data_filename(test_dir + "mpi_residual.fits") - : data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = (world.size() == 2) + ? data_filename(test_dir + "mpi_solution.fits") + : data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = (world.size() == 2) + ? data_filename(test_dir + "mpi_residual.fits") + : data_filename(test_dir + "residual.fits"); if (world.size() == 1) CHECK(diagnostic.niters == 10); if (world.size() == 2) CHECK(diagnostic.niters == 11); @@ -181,10 +179,8 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { auto const diagnostic = (*primaldual)(); CHECK(diagnostic.niters == 16); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); @@ -218,12 +214,12 @@ TEST_CASE("Serial vs. Serial with MPI Primal Dual", "[!shouldfail]") { // it is hard to know exact precision (might depend on probability theory...) if (world.size() > 2 or world.size() == 0) return; // testing the case where there are two nodes exactly. - const std::string &expected_solution_path = - (world.size() == 2) ? data_filename(test_dir + "mpi_solution.fits") - : data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - (world.size() == 2) ? data_filename(test_dir + "mpi_residual.fits") - : data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = (world.size() == 2) + ? data_filename(test_dir + "mpi_solution.fits") + : data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = (world.size() == 2) + ? data_filename(test_dir + "mpi_residual.fits") + : data_filename(test_dir + "residual.fits"); if (world.size() == 1) CHECK(diagnostic.niters == 16); if (world.size() == 2) CHECK(diagnostic.niters == 18); const auto solution = pfitsio::read2d(expected_solution_path); @@ -349,10 +345,8 @@ TEST_CASE("Serial vs. Serial with MPI Forward Backward") { auto const diagnostic = (*fb)(); - const std::string &expected_solution_path = - data_filename(test_dir + "solution.fits"); - const std::string &expected_residual_path = - data_filename(test_dir + "residual.fits"); + const std::string &expected_solution_path = data_filename(test_dir + "solution.fits"); + const std::string &expected_residual_path = data_filename(test_dir + "residual.fits"); const auto solution = pfitsio::read2d(expected_solution_path); const auto residual = pfitsio::read2d(expected_residual_path); diff --git a/cpp/tests/operators.cc b/cpp/tests/operators.cc index 194fc7950..1997d01ea 100644 --- a/cpp/tests/operators.cc +++ b/cpp/tests/operators.cc @@ -15,26 +15,25 @@ using namespace purify; namespace operators_test { const std::string test_dir = "expected/operators/"; //! data for u coordinate -const std::vector u = read_data( - data_filename(test_dir + "u_data")); //! data for v coordinate -const std::vector v = - read_data(data_filename(test_dir + "v_data")); +const std::vector u = + read_data(data_filename(test_dir + "u_data")); //! data for v coordinate +const std::vector v = read_data(data_filename(test_dir + "v_data")); //! data for degridding input const std::vector direct_input = read_data(data_filename(test_dir + "direct_input_data")); //! data for degridding output -const std::vector expected_direct = read_data( - data_filename(test_dir + "expected_direct_data")); +const std::vector expected_direct = + read_data(data_filename(test_dir + "expected_direct_data")); //! data for gridding input -const std::vector indirect_input = read_data( - data_filename(test_dir + "indirect_input_data")); +const std::vector indirect_input = + read_data(data_filename(test_dir + "indirect_input_data")); //! data for gridding output -const std::vector expected_indirect = read_data( - data_filename(test_dir + "expected_indirect_data")); +const std::vector expected_indirect = + read_data(data_filename(test_dir + "expected_indirect_data")); //! data for gridding correction -const std::vector expected_S = read_data( - read_data(data_filename(test_dir + "expected_S_data"))); +const std::vector expected_S = + read_data(read_data(data_filename(test_dir + "expected_S_data"))); } // namespace operators_test TEST_CASE("Operators") { diff --git a/cpp/tests/parser_test.cc b/cpp/tests/parser_test.cc index 1fff8ce89..2a3f53fab 100644 --- a/cpp/tests/parser_test.cc +++ b/cpp/tests/parser_test.cc @@ -11,8 +11,7 @@ using namespace purify; TEST_CASE("Yaml parser and setting variables test") { std::string file_path = purify::data_filename("config/config.yaml"); YamlParser yaml_parser = YamlParser(file_path); - std::string file_path_m = - purify::data_filename("config/test_measurements_config.yaml"); + std::string file_path_m = purify::data_filename("config/test_measurements_config.yaml"); YamlParser yaml_parser_m = YamlParser(file_path_m); SECTION("Check the GeneralConfiguration measurement input variables") { REQUIRE(yaml_parser_m.source() == purify::utilities::vis_source::measurements); @@ -28,8 +27,7 @@ TEST_CASE("Yaml parser and setting variables test") { REQUIRE(yaml_parser_m.warm_start() == "/path/to/warm/start/image"); } SECTION("Check the GeneralConfiguration simulation input variables") { - std::string file_path_s = - purify::data_filename("config/test_simulation_config.yaml"); + std::string file_path_s = purify::data_filename("config/test_simulation_config.yaml"); YamlParser yaml_parser_s = YamlParser(file_path_s); REQUIRE(yaml_parser_s.source() == purify::utilities::vis_source::simulation); REQUIRE(yaml_parser_s.measurements() == From f8005a1f9ce8ffc083708e5843a22ccc309eb99c Mon Sep 17 00:00:00 2001 From: Tuomas Koskela Date: Thu, 14 Nov 2024 12:19:05 +0000 Subject: [PATCH 3/4] Revert linting to CMakeLists.txt --- cpp/tests/CMakeLists.txt | 185 +++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 103 deletions(-) diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 29ee57be7..566e2368c 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -1,111 +1,90 @@ -include_directories( - "${PROJECT_SOURCE_DIR}/cpp" - "${PROJECT_BINARY_DIR}/include") add_library(common_catch_main_object OBJECT - "common_catch_main.cc") if (Catch2_FOUND) - target_link_libraries(common_catch_main_object Catch2::Catch2) endif() if ( - EIGEN3_INCLUDE_DIR) target_include_directories(common_catch_main_object SYSTEM PUBLIC ${ - EIGEN3_INCLUDE_DIR}) endif() if (sopt_FOUND) target_include_directories(common_catch_main_object SYSTEM PUBLIC ${ - sopt_INCLUDE_DIR}) endif() target_include_directories(common_catch_main_object PUBLIC - "${EXTERNAL_ROOT}/include/" - "${PROJECT_BINARY_DIR}/" - "include/") file(MAKE_DIRECTORY - "${PROJECT_" - "BINARY_DIR}" - "/outputs") +include_directories("${PROJECT_SOURCE_DIR}/cpp" "${PROJECT_BINARY_DIR}/include") +add_library(common_catch_main_object OBJECT "common_catch_main.cc") +if(Catch2_FOUND) + target_link_libraries(common_catch_main_object Catch2::Catch2) +endif() +if(EIGEN3_INCLUDE_DIR) +target_include_directories(common_catch_main_object SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR}) +endif() +if(sopt_FOUND) + target_include_directories(common_catch_main_object SYSTEM PUBLIC ${sopt_INCLUDE_DIR}) +endif() +target_include_directories(common_catch_main_object PUBLIC + "${EXTERNAL_ROOT}/include/" + "${PROJECT_BINARY_DIR}/include/" +) +file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/outputs") - add_catch_test(algo_factory LIBRARIES libpurify) add_catch_test( - convolution - LIBRARIES libpurify) add_catch_test(distribute LIBRARIES libpurify) - add_catch_test(index_mapping LIBRARIES libpurify) add_catch_test(integration LIBRARIES libpurify) add_catch_test( - measurement_factory - LIBRARIES libpurify) add_catch_test(measurement_operator LIBRARIES libpurify) - add_catch_test(operators LIBRARIES libpurify) add_catch_test( - parser_test - LIBRARIES libpurify) add_catch_test(purify_fitsio LIBRARIES libpurify) - add_catch_test(read_measurements LIBRARIES libpurify) add_catch_test( - sparse LIBRARIES libpurify) add_catch_test(utils LIBRARIES libpurify) - add_catch_test(uvfits LIBRARIES libpurify) add_catch_test(wavelet_factory LIBRARIES libpurify) add_catch_test( - wide_field_utilities LIBRARIES - libpurify) add_catch_test(wkernel LIBRARIES libpurify) - if (PURIFY_CASACORE) add_catch_test(casacore LIBRARIES libpurify ${ - Boost_FILESYSTEM_LIBRARY} ${ - Boost_SYSTEM_LIBRARY} DEPENDS lookup_dependencies) endif() +add_catch_test(algo_factory LIBRARIES libpurify) +add_catch_test(convolution LIBRARIES libpurify) +add_catch_test(distribute LIBRARIES libpurify) +add_catch_test(index_mapping LIBRARIES libpurify) +add_catch_test(integration LIBRARIES libpurify) +add_catch_test(measurement_factory LIBRARIES libpurify) +add_catch_test(measurement_operator LIBRARIES libpurify) +add_catch_test(operators LIBRARIES libpurify) +add_catch_test(parser_test LIBRARIES libpurify) +add_catch_test(purify_fitsio LIBRARIES libpurify) +add_catch_test(read_measurements LIBRARIES libpurify) +add_catch_test(sparse LIBRARIES libpurify) +add_catch_test(utils LIBRARIES libpurify) +add_catch_test(uvfits LIBRARIES libpurify) +add_catch_test(wavelet_factory LIBRARIES libpurify) +add_catch_test(wide_field_utilities LIBRARIES libpurify) +add_catch_test(wkernel LIBRARIES libpurify) - if (PURIFY_ARRAYFIRE) include_directories(${ArrayFire_INCLUDE_DIRS}) add_catch_test( - operators_gpu LIBRARIES - libpurify ${ArrayFire_LIBRARIES}) endif() +if(PURIFY_CASACORE) + add_catch_test(casacore LIBRARIES libpurify ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} DEPENDS lookup_dependencies) +endif() - if (PURIFY_MPI) - add_library( - common_mpi_catch_main_object OBJECT - "common_mpi_catch_main.cc") - target_include_directories( - common_mpi_catch_main_object PUBLIC - ${PROJECT_BINARY_DIR} / - include - ${MPI_CXX_INCLUDE_PATH}) if (Catch2_FOUND) - target_link_libraries(common_mpi_catch_main_object Catch2::Catch2) endif() if ( - sopt_FOUND) target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${ - sopt_INCLUDE_DIR}) endif() if (EIGEN3_INCLUDE_DIR) - target_include_directories( - common_mpi_catch_main_object SYSTEM - PUBLIC ${EIGEN3_INCLUDE_DIR}) endif() +if(PURIFY_ARRAYFIRE) + include_directories(${ArrayFire_INCLUDE_DIRS}) + add_catch_test(operators_gpu LIBRARIES libpurify ${ArrayFire_LIBRARIES}) +endif() - function(add_mpi_test - testname) add_catch_test(${ - testname} COMMON_MAIN common_mpi_catch_main_object NOTEST ${ - ARGN}) unset(arguments) if (CATCH_JUNIT) - set(arguments - r junit - - o ${PROJECT_BINARY_DIR} / Testing / - ${testname}.xml) - endif() if (NOT MPIEXEC_MAX_NUMPROCS) set( - MPIEXEC_MAX_NUMPROCS 4) endif() add_test(NAME ${ - testname} COMMAND ${ - MPIEXEC} ${ - MPIEXEC_NUMPROC_FLAG} ${ - MPIEXEC_MAX_NUMPROCS} $ { - MPIEXEC_PREFLAGS - } "./test_${testname}" ${ - arguments}) set_tests_properties(${ - testname} PROPERTIES LABELS "ca" - "tc" - "h;" - "mp" - "i") endfunction() +if(PURIFY_MPI) + add_library(common_mpi_catch_main_object OBJECT "common_mpi_catch_main.cc") + target_include_directories(common_mpi_catch_main_object + PUBLIC ${PROJECT_BINARY_DIR}/include ${MPI_CXX_INCLUDE_PATH}) + if(Catch2_FOUND) + target_link_libraries(common_mpi_catch_main_object Catch2::Catch2) + endif() + if(sopt_FOUND) + target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${sopt_INCLUDE_DIR}) + endif() + if(EIGEN3_INCLUDE_DIR) + target_include_directories(common_mpi_catch_main_object SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIR}) + endif() - add_mpi_test( - distribute_sparse_vector - LIBRARIES - libpurify) add_mpi_test(kmeans LIBRARIES libpurify) - add_mpi_test(mpi_algo_factory LIBRARIES libpurify) add_mpi_test( - mpi_measurement_factory - LIBRARIES libpurify) - add_mpi_test( - mpi_measurement_operator - LIBRARIES - libpurify) - add_mpi_test( - mpi_read_measurements LIBRARIES - libpurify) - add_catch_test( - mpi_utilities LIBRARIES - libpurify) - add_mpi_test( - mpi_wavelet_factory - LIBRARIES - libpurify) - add_mpi_test( - mpi_wide_field_utilities - LIBRARIES - libpurify) - add_mpi_test( - parallel_mpi_utilities LIBRARIES - libpurify) endif() + function(add_mpi_test testname) + add_catch_test(${testname} COMMON_MAIN common_mpi_catch_main_object NOTEST ${ARGN}) + unset(arguments) + if(CATCH_JUNIT) + set(arguments -r junit -o ${PROJECT_BINARY_DIR}/Testing/${testname}.xml) + endif() + if(NOT MPIEXEC_MAX_NUMPROCS) + set(MPIEXEC_MAX_NUMPROCS 4) + endif() + add_test(NAME ${testname} + COMMAND + ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} + "./test_${testname}" ${arguments}) + set_tests_properties(${testname} PROPERTIES LABELS "catch;mpi") + endfunction() + + add_mpi_test(distribute_sparse_vector LIBRARIES libpurify) + add_mpi_test(kmeans LIBRARIES libpurify) + add_mpi_test(mpi_algo_factory LIBRARIES libpurify) + add_mpi_test(mpi_measurement_factory LIBRARIES libpurify) + add_mpi_test(mpi_measurement_operator LIBRARIES libpurify) + add_mpi_test(mpi_read_measurements LIBRARIES libpurify) + add_catch_test(mpi_utilities LIBRARIES libpurify) + add_mpi_test(mpi_wavelet_factory LIBRARIES libpurify) + add_mpi_test(mpi_wide_field_utilities LIBRARIES libpurify) + add_mpi_test(parallel_mpi_utilities LIBRARIES libpurify) +endif() + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/data DESTINATION .) - install( - DIRECTORY - ${CMAKE_SOURCE_DIR} / - data DESTINATION - .) From 71494fc5a109499fd5f7d65fe4e10de2541d7443 Mon Sep 17 00:00:00 2001 From: Tuomas Koskela Date: Thu, 14 Nov 2024 15:41:21 +0000 Subject: [PATCH 4/4] Remove unnecessary file --- cmake_files/LookUpONNXRT.cmake | 54 ---------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 cmake_files/LookUpONNXRT.cmake diff --git a/cmake_files/LookUpONNXRT.cmake b/cmake_files/LookUpONNXRT.cmake deleted file mode 100644 index a02721674..000000000 --- a/cmake_files/LookUpONNXRT.cmake +++ /dev/null @@ -1,54 +0,0 @@ - -find_package(onnxruntime QUIET) - -if(${onnxruntime_FOUND}) - find_path(onnxruntime_INCLUDE_DIR NAMES onnxruntime_cxx_api.h - HINTS - ENV onnxruntime_ROOT - ENV onnxruntime_ROOT_DIR - ${CMAKE_INSTALL_PREFIX}/include - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES onnxruntime - ) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_INCLUDE_DIR TRUE) - set(onnxruntime_LIBRARIES onnxruntime::onnxruntime) - get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE) - find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib") - set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}") - set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}") -endif() - -if(NOT ${onnxruntime_FOUND}) - message(STATUS "ONNXrt not found. Attempt to install...") - EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCH ) - message( STATUS "Detected architecture: ${ARCH}" ) - if ("${ARCH}" STREQUAL "x86_64") - set(ARCH "x64") - endif() - set(ORT_VERSION "1.16.3") - set(ORT_URL_BASE "https://github.com/microsoft/onnxruntime/releases/download") - set(ORT_TARNAME "onnxruntime-linux-${ARCH}-${ORT_VERSION}") - set(ORT_DEST "${CMAKE_CURRENT_BINARY_DIR}/external/${ORT_TARNAME}.tgz") - set(ORT_URL "${ORT_URL_BASE}/v${ORT_VERSION}/${ORT_TARNAME}.tgz") - # https://cmake.org/cmake/help/latest/policy/CMP0135.html - # - # CMP0135 is for solving re-building and re-downloading. - # The NEW policy suppresses warnings for some CMake versions. - if(POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) - endif() - set(onnxruntime_DIR "${CMAKE_INSTALL_PREFIX}/external") - file(DOWNLOAD ${ORT_URL} ${ORT_DEST} - EXPECTED_HASH SHA256=b072f989d6315ac0e22dcb4771b083c5156d974a3496ac3504c77f4062eb248e - ) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ORT_DEST}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${ORT_TARNAME} ${onnxruntime_DIR}) - set(onnxruntime_INCLUDE_DIR "${onnxruntime_DIR}/include") - set(onnxruntime_LIBRARY_DIR "${onnxruntime_DIR}/lib") - set(onnxruntime_LIBRARIES onnxruntime::onnxruntime) - add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL) - set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so) - set(onnxruntime_FOUND TRUE) -endif() -