From 0b95949955fa5667d1d86de1372f07b075d3d1c9 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Thu, 9 Nov 2023 18:58:20 +0100 Subject: [PATCH 01/20] Initial commit, with a few immediate translations Copied over wscript, @vasdommes had already made a few changes from waf to cmake. Cleaned up, and added more TODOs --- CMakeLists.txt | 520 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 520 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..a79a3c90c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,520 @@ +# TODO choose version: +cmake_minimum_required(VERSION 3.16) +project(sdpb LANGUAGES CXX) + +#import os, subprocess + +#def options(opt): +# opt.load(['compiler_cxx','gnu_dirs','cxx17','boost','gmpxx','mpfr', +# 'elemental','libxml2', 'rapidjson', 'libarchive']) + +# Let's try to do these one by one from the list and then potentially refactor. + +# cxx 17 +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +#set(CMAKE_CXX_EXTENSIONS OFF) + +# Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +# compiler_cxx +# TODO +if(DEFINED (ENV{CXX})) + if(ENV{CXX} == "g++" || ENV{CXX} == "icpc") + SET(CMAKE_CXX_COMPILER mpicxx) + endif() +else() + SET(CMAKE_CXX_COMPILER mpicxx) +endif() + +message("Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") + +# TODO gnu_dirs + + +# TODO boost + + +# TODO gmpxx + + +# TODO mpfr + + +# TODO elemental + + +# TODO libxml2 + + +# TODO rapidjson + + +# TODO libarchive + + + +#def configure(conf): +# if not 'CXX' in os.environ or os.environ['CXX']=='g++' or os.environ['CXX']=='icpc': +# conf.environ['CXX']='mpicxx' + +find_package(MPI REQUIRED) +message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS") + +# TODO Refactor into a separate file for Git (see Elemental for example) +# conf.env.git_version=subprocess.check_output('git describe --dirty', universal_newlines=True, shell=True).rstrip() +find_package(Git QUIET REQUIRED) +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/.git") + message(FATAL_ERROR "${PROJECT_SOURCE_DIR}/.git not found") +endif() +execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --dirty + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_DESCRIBE_RESULT + OUTPUT_VARIABLE SDPB_VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT GIT_DESCRIBE_RESULT EQUAL "0") + message(FATAL_ERROR "git describe --always --dirty failed: ${GIT_DESCRIBE_RESULT}.") +endif() + +#def build(bld): +# default_flags=['-Wall', '-Wextra', '-O3', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] +# # default_flags=['-Wall', '-Wextra', '-O3', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] +# # default_flags=['-Wall', '-Wextra', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] + +#TODO -O3 etc is set by choosing cmake debug/release +# TODO -Werror=return-type, but it requires to mark El::RuntimeError as [[noreturn]] +add_compile_options(-Wall -Wextra -DOMPI_SKIP_MPICXX) +add_compile_definitions(SDPB_VERSION_STRING="${SDPB_VERSION_STRING}") +add_compile_definitions(RAPIDJSON_HAS_STDSTRING=1) + +# TODO setup flags for build configurations (debug/release) + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + # This option is okay as-is + set(CMAKE_BUILD_TYPE Release) +elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") + # This option is okay as-is + set(CMAKE_BUILD_TYPE Debug) +else() + message(WARNING "Build mode not specified, defaulting to Release build.") + set(CMAKE_BUILD_TYPE Release) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(SDPB_RELEASE TRUE) +else() + set(SDPB_RELEASE FALSE) +endif() +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) + + +# use_packages=['cxx17','boost','gmpxx','mpfr','elemental','libxml2', 'rapidjson', 'libarchive'] +#TODO + +set(CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH /usr/local/lib) +message("CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}") + +include(FeatureSummary) + +find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +message(STATUS "Boost version: ${Boost_VERSION}") + +set(libxml2_INCLUDE_DIR /usr/include/libxml2) +include(FindLibXml2) +#find_package(libxml2) +#find_library(LIBXML2 libxml2 REQUIRED) + +find_library(MPFR_LIBRARIES mpfr) + +#find_library() +# TODO use target_link_libraries +#link_libraries(cxx17 boost gmpxx mpfr elemental libxml2 rapidjson libarchive) + +find_library(LIBARCHIVE_LIBRARIES archive) + +# TODO This does not work right now and gives undefined variable error, because of which cmake cannot configure the build +find_library(elemental elemental) +link_libraries(elemental) +foreach(LIB El pmrrr ElSuiteSparse) + find_library(Elemental_${LIB}_LIBRARIES ${LIB} + PATHS $ENV{HOME}/install + PATH_SUFFIXES lib lib64) + list(APPEND ELEMENTAL_LIBRARIES "${Elemental_${LIB}_LIBRARIES}") +endforeach() + +# see elemental/cmake/modules/FindGMP.cmake +#find_path(GMP_INCLUDES NAMES gmp.h PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMPHOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR}) +find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPHOME} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR}) + +# see elemental/cmake/modules/FindGMPXX.cmake +#find_path(GMPXX_INCLUDES NAMES gmpxx.h PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_INCLUDE} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR}) +find_library(GMPXX_LIBRARIES gmpxx PATHS $ENV{GMPHOME} $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR}) + +# FIXME This is a hardcoded path +# NOTE FLINT is not required in the current release of SDPB. Commenting it out... +#find_library(FLINT_LIBRARIES flint PATHS /home/vasdommes/install/lib) + +# From FLINT - FindCBLAS +find_path(CBLAS_INCLUDE_DIRS NAMES cblas.h + HINTS CBLAS_ROOT ENV CBLAS_ROOT + PATHS ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/include + PATH_SUFFIXES openblas cblas blis +) + +find_library(CBLAS_LIBRARIES NAMES accelerate openblas cblas blas blis + HINTS CBLAS_ROOT ENV CBLAS_ROOT + PATHS ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/lib + PATH_SUFFIXES openblas cblas blis +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CBLAS + "Could NOT find a BLAS compatible library or 'cblas.h', install BLAS or set CBLAS_ROOT." + CBLAS_INCLUDE_DIRS CBLAS_LIBRARIES) + +mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) + + +include_directories(src) +include_directories(external) +include_directories(SYSTEM elemental/install/include) +include_directories(SYSTEM ${libxml2_INCLUDE_DIR}) +include_directories(SYSTEM /home/vasdommes/install/include) + +add_library(sdp_solve) +target_sources(sdp_solve + #TODO set correct visibility + PUBLIC + src/sdp_solve/Solver_Parameters/Solver_Parameters.cxx + src/sdp_solve/Solver_Parameters/ostream.cxx + src/sdp_solve/Solver_Parameters/to_property_tree.cxx + src/sdp_solve/Archive_Reader/Archive_Reader.cxx + src/sdp_solve/Archive_Reader/underflow.cxx + src/sdp_solve/Block_Info/Block_Info.cxx + src/sdp_solve/Block_Info/read_block_info.cxx + src/sdp_solve/Block_Info/read_block_costs.cxx + src/sdp_solve/Block_Info/allocate_blocks/allocate_blocks.cxx + src/sdp_solve/Block_Info/allocate_blocks/compute_block_grid_mapping.cxx + src/sdp_solve/SDP/SDP/SDP.cxx + src/sdp_solve/SDP/SDP/read_objectives.cxx + src/sdp_solve/SDP/SDP/assign_bilinear_bases_dist.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_blocks.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/read_block_stream.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/EndArray.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/Key.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/StartArray.cxx + src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/String.cxx + src/sdp_solve/SDP/SDP/set_bases_blocks.cxx + src/sdp_solve/SDP_Solver/save_checkpoint.cxx + src/sdp_solve/SDP_Solver/load_checkpoint/load_checkpoint.cxx + src/sdp_solve/SDP_Solver/load_checkpoint/load_binary_checkpoint.cxx + src/sdp_solve/SDP_Solver/load_checkpoint/load_text_checkpoint.cxx + src/sdp_solve/SDP_Solver/SDP_Solver.cxx + src/sdp_solve/SDP_Solver/run/run.cxx + src/sdp_solve/SDP_Solver/run/cholesky_decomposition.cxx + src/sdp_solve/SDP_Solver/run/constraint_matrix_weighted_sum.cxx + src/sdp_solve/SDP_Solver/run/compute_dual_residues_and_error.cxx + src/sdp_solve/SDP_Solver/run/compute_primal_residues_and_error_P_Ax_X.cxx + src/sdp_solve/SDP_Solver/run/compute_primal_residues_and_error_p_b_Bx.cxx + src/sdp_solve/SDP_Solver/run/compute_objectives/compute_objectives.cxx + src/sdp_solve/SDP_Solver/run/compute_objectives/dot.cxx + src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_bilinear_pairings.cxx + src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_A_X_inv.cxx + src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_A_Y.cxx + src/sdp_solve/SDP_Solver/run/compute_feasible_and_termination.cxx + src/sdp_solve/SDP_Solver/run/print_header.cxx + src/sdp_solve/SDP_Solver/run/print_iteration.cxx + src/sdp_solve/SDP_Solver/run/step/step.cxx + src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/initialize_schur_complement_solver.cxx + src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/compute_schur_complement.cxx + #src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/compute_Q.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/compute_block_residues.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/Matrix_Normalizer.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/Fmpz_Matrix.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/Fmpz_Comb.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job_Schedule.cxx + #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/create_blas_job_schedule.cxx + src/sdp_solve/SDP_Solver/run/step/compute_search_direction/compute_search_direction.cxx + src/sdp_solve/SDP_Solver/run/step/compute_search_direction/cholesky_solve.cxx + src/sdp_solve/SDP_Solver/run/step/compute_search_direction/compute_schur_RHS.cxx + src/sdp_solve/SDP_Solver/run/step/compute_search_direction/scale_multiply_add.cxx + src/sdp_solve/SDP_Solver/run/step/compute_search_direction/solve_schur_complement_equation.cxx + src/sdp_solve/SDP_Solver/run/step/predictor_centering_parameter.cxx + src/sdp_solve/SDP_Solver/run/step/corrector_centering_parameter/corrector_centering_parameter.cxx + src/sdp_solve/SDP_Solver/run/step/corrector_centering_parameter/frobenius_product_of_sums.cxx + src/sdp_solve/SDP_Solver/run/step/frobenius_product_symmetric.cxx + src/sdp_solve/SDP_Solver/run/step/step_length/step_length.cxx + src/sdp_solve/SDP_Solver/run/step/step_length/min_eigenvalue.cxx + src/sdp_solve/SDP_Solver/run/step/step_length/lower_triangular_inverse_congruence.cxx + src/sdp_solve/SDP_Solver_Terminate_Reason/ostream.cxx + src/sdp_solve/lower_triangular_transpose_solve.cxx + src/sdp_solve/Block_Diagonal_Matrix/ostream.cxx + src/sdp_solve/Write_Solution.cxx) +# TODO add_subdirectory +target_link_libraries(sdp_solve + Boost::program_options + Boost::serialization + ${MPFR_LIBRARIES} + ${LIBARCHIVE_LIBRARIES} + ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} + ${ELEMENTAL_LIBRARIES} + #${FLINT_LIBRARIES} + ${CBLAS_LIBRARIES}) + + +# SDPB executable +add_executable(sdpb) +target_sources(sdpb + PUBLIC + src/sdpb/main.cxx + src/sdpb/solve.cxx + src/sdpb/write_timing.cxx + src/sdpb/SDPB_Parameters/SDPB_Parameters.cxx + src/sdpb/SDPB_Parameters/to_property_tree.cxx + src/sdpb/SDPB_Parameters/ostream.cxx + src/sdpb/save_solution.cxx) +target_link_libraries(sdpb + sdp_solve + Boost::program_options + Boost::serialization + ${MPFR_LIBRARIES} + ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} + ${ELEMENTAL_LIBRARIES}) + +add_library(sdp_convert) +target_sources(sdp_convert + PUBLIC + src/sdp_convert/Dual_Constraint_Group/Dual_Constraint_Group.cxx + src/sdp_convert/Dual_Constraint_Group/sample_bilinear_basis.cxx + src/sdp_convert/write_block_data.cxx + src/sdp_convert/write_block_info_json.cxx + src/sdp_convert/write_objectives_json.cxx + src/sdp_convert/write_sdpb_input_files.cxx + src/sdp_convert/write_control_json.cxx + src/sdp_convert/Archive_Writer/Archive_Writer.cxx + src/sdp_convert/Archive_Writer/write_entry.cxx + src/sdp_convert/Archive_Entry.cxx) +target_link_libraries(sdp_convert + Boost::iostreams + Boost::serialization + ${LIBARCHIVE_LIBRARIES}) + +add_library(sdp_read) +target_sources(sdp_read + PUBLIC + src/sdp_read/read_input/read_input.cxx + src/sdp_read/read_input/read_json/read_json.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_key.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_string.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_start_array.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_end_array.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_start_object.cxx + src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_end_object.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_key.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_string.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_start_array.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_end_array.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_start_object.cxx + src/sdp_read/read_input/read_json/Damped_Rational_State/json_end_object.cxx + src/sdp_read/read_input/read_json/JSON_Parser/Key.cxx + src/sdp_read/read_input/read_json/JSON_Parser/String.cxx + src/sdp_read/read_input/read_json/JSON_Parser/StartArray.cxx + src/sdp_read/read_input/read_json/JSON_Parser/EndArray.cxx + src/sdp_read/read_input/read_json/JSON_Parser/StartObject.cxx + src/sdp_read/read_input/read_json/JSON_Parser/EndObject.cxx + src/sdp_read/read_input/read_mathematica/read_mathematica.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_SDP.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrices.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_number.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_polynomial.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrix/parse_matrix.cxx + src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrix/parse_damped_rational.cxx + src/sdp_read/read_pvm_input/read_pvm_input.cxx + src/sdp_read/read_pvm_input/read_xml_input/read_xml_input.cxx + src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_start_element.cxx + src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_end_element.cxx + src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_characters.cxx + src/sdp_read/read_nsv_file_list.cxx + src/sdp_read/sample_points.cxx + src/sdp_read/sample_scalings.cxx) +target_link_libraries(sdp_read sdp_convert) + +add_executable(pvm2sdp) +target_sources(pvm2sdp + PUBLIC + src/pvm2sdp/main.cxx + src/pvm2sdp/parse_command_line.cxx + src/pvm2sdp/read_input_files/read_input_files.cxx + src/pvm2sdp/read_input_files/read_xml_input/read_xml_input.cxx + src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_start_element.cxx + src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_end_element.cxx + src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_characters.cxx) +target_link_libraries(pvm2sdp sdp_read) + +add_executable(sdp2input) +target_sources(sdp2input + PUBLIC + src/sdp2input/main.cxx + src/sdp2input/write_output/write_output.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_basis.cxx + src/sdp2input/write_output/bilinear_basis/precompute/precompute.cxx + src/sdp2input/write_output/bilinear_basis/precompute/integral.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_form/bilinear_form.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_form/rest.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_form/dExp.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_form/derivative.cxx + src/sdp2input/write_output/bilinear_basis/bilinear_form/operator_plus_set_Derivative_Term.cxx) +target_link_libraries(sdp2input sdp_read) + +add_library(mesh) +target_sources(mesh + PUBLIC + src/Mesh/Mesh.cxx + src/Mesh/ostream.cxx) + +add_executable(outer_limits) +target_sources(outer_limits + PUBLIC + src/outer_limits/main.cxx + src/outer_limits/power_prefactor.cxx + src/outer_limits/poles_prefactor.cxx + src/outer_limits/Function/eval/eval.cxx + src/outer_limits/compute_optimal/compute_optimal.cxx + src/outer_limits/compute_optimal/compute_y_transform.cxx + src/outer_limits/compute_optimal/setup_constraints.cxx + src/outer_limits/compute_optimal/copy_matrix.cxx + src/outer_limits/compute_optimal/find_new_points/find_new_points.cxx + src/outer_limits/compute_optimal/find_new_points/eval_summed.cxx + src/outer_limits/compute_optimal/find_new_points/get_new_points.cxx + src/outer_limits/compute_optimal/load_checkpoint/load_checkpoint.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/EndArray.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/EndObject.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/Key.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/StartArray.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/StartObject.cxx + src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/String.cxx + src/outer_limits/compute_optimal/save_checkpoint.cxx + src/outer_limits/read_points/read_points.cxx + src/outer_limits/read_points/read_points_json/read_points_json.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/EndArray.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/EndObject.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/Key.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/StartArray.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/StartObject.cxx + src/outer_limits/read_points/read_points_json/Points_Parser/String.cxx + src/outer_limits/read_function_blocks/read_function_blocks.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_end_array.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_end_object.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_key.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_start_array.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_start_object.cxx + src/outer_limits/read_function_blocks/read_json/Function_State/json_string.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/EndArray.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/EndObject.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/Key.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/StartArray.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/StartObject.cxx + src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/String.cxx + src/outer_limits/read_function_blocks/read_json/read_json.cxx + src/outer_limits/Outer_Parameters/Outer_Parameters.cxx + src/outer_limits/Outer_Parameters/to_property_tree.cxx + src/outer_limits/Outer_Parameters/ostream.cxx) +target_link_libraries(outer_limits sdp_read sdp_solve mesh) + +add_executable(approx_objective) +target_sources(approx_objective + PUBLIC + src/approx_objective/main.cxx + src/approx_objective/Approx_Parameters/Approx_Parameters.cxx + src/approx_objective/Approx_Parameters/ostream.cxx + src/approx_objective/Axpy.cxx + src/approx_objective/setup_solver.cxx + src/approx_objective/write_solver_state.cxx + src/approx_objective/Approx_Objective/Approx_Objective/Approx_Objective.cxx + src/approx_objective/Approx_Objective/Approx_Objective/compute_dx_dy.cxx + src/approx_objective/linear_approximate_objectives.cxx + src/approx_objective/quadratic_approximate_objectives.cxx) +target_link_libraries(approx_objective sdp_read sdp_solve) + +add_executable(pvm2functions) +target_sources(pvm2functions + PUBLIC + src/pvm2functions/main.cxx + src/pvm2functions/parse_command_line.cxx + src/pvm2functions/write_functions.cxx) +target_link_libraries(pvm2functions sdp_read) + +add_executable(sdp2functions) +target_sources(sdp2functions + PUBLIC + src/sdp2functions/main.cxx + src/sdp2functions/write_functions.cxx) +target_link_libraries(sdp2functions sdp_read) + +add_executable(spectrum) +target_sources(spectrum + PUBLIC + src/spectrum/main.cxx + src/spectrum/handle_arguments.cxx + src/spectrum/read_x.cxx + src/spectrum/compute_spectrum_pmp.cxx + src/spectrum/compute_spectrum_pvm.cxx + src/spectrum/compute_lambda.cxx + src/spectrum/eval_summed.cxx + src/spectrum/get_zeros.cxx + src/spectrum/write_spectrum/write_spectrum.cxx + src/spectrum/write_spectrum/write_file.cxx) +target_link_libraries(spectrum sdp_read sdp_solve sdp_convert mesh) + +add_executable(unit_tests) +target_compile_definitions(unit_tests PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN) +target_include_directories(unit_tests PUBLIC src test/src) +target_sources(unit_tests + PUBLIC + external/catch2/catch_amalgamated.cpp + test/src/unit_tests/main.cxx + test/src/unit_tests/cases/block_data_serialization.test.cxx + test/src/unit_tests/cases/boost_serialization.test.cxx + #test/src/unit_tests/cases/calculate_matrix_square.test.cxx + #test/src/unit_tests/cases/create_blas_job_schedule.test.cxx + #test/src/unit_tests/cases/LPT_scheduling.test.cxx + #test/src/unit_tests/cases/Matrix_Normalizer.test.cxx + #test/src/unit_tests/cases/shared_window.test.cxx + ) +target_link_libraries(unit_tests + sdp_convert + sdp_solve + ${MPFR_LIBRARIES} + ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} + ${ELEMENTAL_LIBRARIES}) + +add_executable(integration_tests) +target_compile_definitions(integration_tests PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN) +target_include_directories(integration_tests PUBLIC src test/src SYSTEM ${GMPXX_INCLUDES}) +target_sources(integration_tests + PUBLIC + external/catch2/catch_amalgamated.cpp + test/src/integration_tests/main.cxx + test/src/integration_tests/util/Float.cxx + test/src/integration_tests/util/diff_outer_limits.cxx + test/src/integration_tests/util/diff_sdp_zip.cxx + test/src/integration_tests/util/diff_sdpb_out.cxx + test/src/integration_tests/util/diff_spectrum.cxx + test/src/integration_tests/util/Test_Case_Runner.cxx + test/src/integration_tests/cases/end-to-end.test.cxx + test/src/integration_tests/cases/outer_limits.test.cxx + test/src/integration_tests/cases/pvm2sdp.test.cxx + test/src/integration_tests/cases/sdp2input.test.cxx + test/src/integration_tests/cases/sdpb.test.cxx + test/src/integration_tests/cases/spectrum.test.cxx) +target_link_libraries(integration_tests + Boost::serialization + Boost::filesystem + ${MPFR_LIBRARIES} + ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} + ${ELEMENTAL_LIBRARIES} +) From b16b4a4a17c409b9804702e042bdbb10c55693fc Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Thu, 9 Nov 2023 19:33:35 +0100 Subject: [PATCH 02/20] Makes messages look nice --- cmake/CustomMessages.cmake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cmake/CustomMessages.cmake diff --git a/cmake/CustomMessages.cmake b/cmake/CustomMessages.cmake new file mode 100644 index 000000000..08039be20 --- /dev/null +++ b/cmake/CustomMessages.cmake @@ -0,0 +1,30 @@ +if(NOT WIN32) + string(ASCII 27 Esc) + set(ColourReset "${Esc}[m") + set(ColourBold "${Esc}[1m") + set(Red "${Esc}[31m") + set(Green "${Esc}[32m") + set(Yellow "${Esc}[33m") + set(BoldRed "${Esc}[1;31m") + set(BoldYellow "${Esc}[1;33m") + set(BoldCyan "${Esc}[1;36m") +endif() + +function(message) + list(GET ARGV 0 MessageType) + if(MessageType STREQUAL FATAL_ERROR OR MessageType STREQUAL SEND_ERROR) + list(REMOVE_AT ARGV 0) + _message(${MessageType} "${BoldRed}${ARGV}${ColourReset}") + elseif(MessageType STREQUAL WARNING) + list(REMOVE_AT ARGV 0) + _message(${MessageType} "${BoldYellow}${ARGV}${ColourReset}") + elseif(MessageType STREQUAL AUTHOR_WARNING) + list(REMOVE_AT ARGV 0) + _message(${MessageType} "${BoldCyan}${ARGV}${ColourReset}") + elseif(MessageType STREQUAL STATUS) + list(REMOVE_AT ARGV 0) + _message(${MessageType} "${Green}${ARGV}${ColourReset}") + else() + _message("${ARGV}") + endif() +endfunction() \ No newline at end of file From 39219cf1d8c1c4dcd66bbb71a6e2609860cc442d Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Thu, 8 Feb 2024 17:17:34 +0100 Subject: [PATCH 03/20] Code that is able to load boost, mpfr, rapidjson, libarchive --- CMakeLists.txt | 51 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a79a3c90c..1b5083331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,22 +2,18 @@ cmake_minimum_required(VERSION 3.16) project(sdpb LANGUAGES CXX) -#import os, subprocess - -#def options(opt): -# opt.load(['compiler_cxx','gnu_dirs','cxx17','boost','gmpxx','mpfr', -# 'elemental','libxml2', 'rapidjson', 'libarchive']) +# Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -# Let's try to do these one by one from the list and then potentially refactor. # cxx 17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) #set(CMAKE_CXX_EXTENSIONS OFF) -# Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +# We all love some colour don't we +include(CustomMessages) # compiler_cxx # TODO @@ -29,31 +25,55 @@ else() SET(CMAKE_CXX_COMPILER mpicxx) endif() -message("Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") +message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") # TODO gnu_dirs +################################################## +########### Find required dependencies ########### +################################################## + +include(FindPkgConfig) +find_package(PkgConfig REQUIRED) # TODO boost +# TODO Check that the custom approach works. Have not tested. +find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +if(NOT Boost_FOUND) + pkg_check_modules(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +endif() +message(STATUS "Boost version: ${Boost_VERSION}") + +# Omitted the part where boost.py tests for boost by running a small snippet of code. # TODO gmpxx +# NOTE This does not work right now because find_package is not able to find FindGMPXX.cmake +# find_package(GMPXX REQUIRED) +# message(STATUS "GMP version: ${GMPXX_VERSION}") # TODO mpfr - +pkg_check_modules(MPFR REQUIRED mpfr) +message(STATUS "MPFR version: ${MPFR_VERSION}") # TODO elemental # TODO libxml2 - +#find_package(libxml2 REQUIRED) +# if(NOT libxml2_FOUND) +# pkg_check_modules(LIBXML2 REQUIRED libxml-2) +# endif() +# message(STATUS "libxml2 version: ${libxml2_VERSION}") # TODO rapidjson - +pkg_check_modules(RapidJSON REQUIRED RapidJSON) +message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") # TODO libarchive - +pkg_check_modules(libarchive REQUIRED libarchive) +message(STATUS "libarchive version: ${libarchive_VERSION}") #def configure(conf): @@ -118,9 +138,6 @@ message("CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}") include(FeatureSummary) -find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) -message(STATUS "Boost version: ${Boost_VERSION}") - set(libxml2_INCLUDE_DIR /usr/include/libxml2) include(FindLibXml2) #find_package(libxml2) From 4e2f6a728d279dce769fb81d5ae7fef4373e29da Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Sat, 10 Feb 2024 17:51:11 +0100 Subject: [PATCH 04/20] Able to find MPFR now Two things need to be fixed - 1) Make sure that MPFR_REQUIRED is set properly and 2) Resolve missing MPFR_VERSION in the case where find_package is not used --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b5083331..edf97958f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.16) project(sdpb LANGUAGES CXX) +# This is to ensure that CMake also checks lib64 for the dependencies +set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) + # Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") @@ -54,8 +57,37 @@ message(STATUS "Boost version: ${Boost_VERSION}") # TODO mpfr -pkg_check_modules(MPFR REQUIRED mpfr) -message(STATUS "MPFR version: ${MPFR_VERSION}") +find_package(MPFR QUIET) + +if (MPFR_FOUND) + message(STATUS "MPFR version: ${MPFR_VERSION}") +else () + find_path(MPFR_INCLUDE_DIR mpfr.h + PATHS /usr/include /usr/local/include + ) + + find_library(MPFR_LIBRARY mpfr + PATHS /usr/lib64 /usr/local/lib + ) + + if (MPFR_INCLUDE_DIR AND MPFR_LIBRARY) + set(MPFR_FOUND TRUE) + endif () + + if (MPFR_FOUND) + if (NOT MPFR_FIND_QUIETLY) + message(STATUS "Found MPFR: ${MPFR_LIBRARY}") + endif () + else () + if (MPFR_FIND_REQUIRED) + message(FATAL_ERROR "Could not find MPFR") + endif () + endif () + + mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARY) + + message(STATUS "MPFR version: ${MPFR_VERSION}") +endif () # TODO elemental From 8e6f7fe6f2be15a4217e4356f6976700bd47fc8a Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Tue, 27 Feb 2024 23:28:16 +0100 Subject: [PATCH 05/20] libxml and rapidjson work. Finding libarchive fails - possible fix is needing libarchive-dev --- CMakeLists.txt | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edf97958f..abee8baae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,26 @@ -# TODO choose version: -cmake_minimum_required(VERSION 3.16) -project(sdpb LANGUAGES CXX) - -# This is to ensure that CMake also checks lib64 for the dependencies -set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) - # Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") +# Custom colour scheme for logging +include(CustomMessages) + +# TODO choose version, currently working with 3.16 as a temporary measure: +cmake_minimum_required(VERSION 3.16) + +# This is to ensure that CMake also checks lib64 for the dependencies on Linux systems +if(LINUX) + set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) +endif() + +project(sdpb LANGUAGES CXX) +# TODO setting version of SDPB # cxx 17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) #set(CMAKE_CXX_EXTENSIONS OFF) -# We all love some colour don't we -include(CustomMessages) - # compiler_cxx # TODO if(DEFINED (ENV{CXX})) @@ -93,19 +96,26 @@ endif () # TODO libxml2 -#find_package(libxml2 REQUIRED) -# if(NOT libxml2_FOUND) -# pkg_check_modules(LIBXML2 REQUIRED libxml-2) -# endif() -# message(STATUS "libxml2 version: ${libxml2_VERSION}") +find_package(libxml2 REQUIRED) +if(NOT libxml2_FOUND) + pkg_check_modules(LIBXML2 REQUIRED libxml-2) +endif() +message(STATUS "libxml2 version: ${libxml2_VERSION}") # TODO rapidjson -pkg_check_modules(RapidJSON REQUIRED RapidJSON) +find_package(RapidJSON REQUIRED) +# pkg_check_modules(RapidJSON REQUIRED RapidJSON) message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") # TODO libarchive -pkg_check_modules(libarchive REQUIRED libarchive) -message(STATUS "libarchive version: ${libarchive_VERSION}") +find_package(ZLIB REQUIRED) +message(STATUS "ZLIB version: ${ZLIB_VERSION}") +find_package(libarchive REQUIRED) +# if (NOT libarchive_FOUND) +# pkg_check_modules(libarchive REQUIRED libarchive) +# endif() +# find_library(LIBARCHIVE_LIBRARIES archive REQUIRED) +# message(STATUS "libarchive version: ${libarchive_VERSION}") #def configure(conf): From 68a96dc3c1149bd732e920e57db8864b4adaf109 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Fri, 1 Mar 2024 14:59:04 +0100 Subject: [PATCH 06/20] Working solution for Elemental. Fixed incorrect if(LINUX). Cosmetic changes --- CMakeLists.txt | 124 ++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abee8baae..fac686135 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules +# TODO - Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") @@ -9,7 +9,7 @@ include(CustomMessages) cmake_minimum_required(VERSION 3.16) # This is to ensure that CMake also checks lib64 for the dependencies on Linux systems -if(LINUX) +if(UNIX) set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) endif() @@ -42,24 +42,11 @@ message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") include(FindPkgConfig) find_package(PkgConfig REQUIRED) -# TODO boost -# TODO Check that the custom approach works. Have not tested. - -find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) -if(NOT Boost_FOUND) - pkg_check_modules(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +# GMP and GMPXX +# ------------- endif() -message(STATUS "Boost version: ${Boost_VERSION}") - -# Omitted the part where boost.py tests for boost by running a small snippet of code. - -# TODO gmpxx -# NOTE This does not work right now because find_package is not able to find FindGMPXX.cmake -# find_package(GMPXX REQUIRED) -# message(STATUS "GMP version: ${GMPXX_VERSION}") - - -# TODO mpfr +# MPFR +# ---- find_package(MPFR QUIET) if (MPFR_FOUND) @@ -69,17 +56,17 @@ else () PATHS /usr/include /usr/local/include ) - find_library(MPFR_LIBRARY mpfr + find_library(MPFR_LIBRARIES mpfr PATHS /usr/lib64 /usr/local/lib ) - if (MPFR_INCLUDE_DIR AND MPFR_LIBRARY) + if (MPFR_INCLUDE_DIR AND MPFR_LIBRARIES) set(MPFR_FOUND TRUE) endif () if (MPFR_FOUND) if (NOT MPFR_FIND_QUIETLY) - message(STATUS "Found MPFR: ${MPFR_LIBRARY}") + message(STATUS "Found MPFR: ${MPFR_LIBRARIES}") endif () else () if (MPFR_FIND_REQUIRED) @@ -87,41 +74,32 @@ else () endif () endif () - mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARY) + mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARIES) message(STATUS "MPFR version: ${MPFR_VERSION}") endif () - -# TODO elemental - - -# TODO libxml2 -find_package(libxml2 REQUIRED) -if(NOT libxml2_FOUND) +# Boost +# ----- +# TODO Change pkg_check_modules to a solution where you use find_path and find_library pkg_check_modules(LIBXML2 REQUIRED libxml-2) endif() -message(STATUS "libxml2 version: ${libxml2_VERSION}") - -# TODO rapidjson +# RapidJSON +# --------- +# TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(RapidJSON REQUIRED) # pkg_check_modules(RapidJSON REQUIRED RapidJSON) message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") - -# TODO libarchive -find_package(ZLIB REQUIRED) -message(STATUS "ZLIB version: ${ZLIB_VERSION}") -find_package(libarchive REQUIRED) -# if (NOT libarchive_FOUND) -# pkg_check_modules(libarchive REQUIRED libarchive) -# endif() -# find_library(LIBARCHIVE_LIBRARIES archive REQUIRED) -# message(STATUS "libarchive version: ${libarchive_VERSION}") +# libarchive +# ---------- +# TODO Change pkg_check_modules to a solution where you use find_path and find_library #def configure(conf): # if not 'CXX' in os.environ or os.environ['CXX']=='g++' or os.environ['CXX']=='icpc': # conf.environ['CXX']='mpicxx' +# MPI +# --- find_package(MPI REQUIRED) message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS") @@ -191,25 +169,43 @@ find_library(MPFR_LIBRARIES mpfr) # TODO use target_link_libraries #link_libraries(cxx17 boost gmpxx mpfr elemental libxml2 rapidjson libarchive) -find_library(LIBARCHIVE_LIBRARIES archive) - -# TODO This does not work right now and gives undefined variable error, because of which cmake cannot configure the build -find_library(elemental elemental) -link_libraries(elemental) -foreach(LIB El pmrrr ElSuiteSparse) - find_library(Elemental_${LIB}_LIBRARIES ${LIB} - PATHS $ENV{HOME}/install - PATH_SUFFIXES lib lib64) - list(APPEND ELEMENTAL_LIBRARIES "${Elemental_${LIB}_LIBRARIES}") -endforeach() - -# see elemental/cmake/modules/FindGMP.cmake -#find_path(GMP_INCLUDES NAMES gmp.h PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMPHOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR}) -find_library(GMP_LIBRARIES gmp PATHS $ENV{GMPHOME} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR}) +# Elemental +# --------- +find_package(Elemental REQUIRED) +# find_path(Elemental_INCLUDES El.hpp +# PATHS /usr/include /usr/local/include ${CMAKE_PREFIX_PATH} +# ) + +# find_library(Elemental_LIBRARIES El +# PATHS /usr/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH} +# ) + +# if (Elemental_INCLUDES AND Elemental_LIBRARIES) +# set(Elemental_FOUND TRUE) +# endif () + +# if (Elemental_FOUND) +# if (NOT Elemental_FIND_QUIETLY) +# message(STATUS "Found El: ${Elemental_LIBRARIES}") +# endif () +# else () +# if (Elemental_FIND_REQUIRED) +# message(FATAL_ERROR "Could not find Elemental") +# endif () +# endif () +# mark_as_advanced(Elemental_INCLUDES Elemental_LIBRARIES) + +if(Elemental_FOUND AND Elemental_INCLUDE_DIRS) + include_directories(${Elemental_INCLUDE_DIRS}) +endif() -# see elemental/cmake/modules/FindGMPXX.cmake -#find_path(GMPXX_INCLUDES NAMES gmpxx.h PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_INCLUDE} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR}) -find_library(GMPXX_LIBRARIES gmpxx PATHS $ENV{GMPHOME} $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR}) +message(STATUS "El version: ${Elemental_VERSION}") +message(STATUS "Found Elemental: ${Elemental_LIBRARIES}") +# find_library(El El PATHS ${Elemental_DIR} REQUIRED) +find_library(pmrrr pmrrr PATHS ${Elemental_DIR}/external/pmrrr REQUIRED) +find_library(ElSuiteSparse ElSuiteSparse PATHS ${Elemental_DIR}/external/suite_sparse REQUIRED) +list(APPEND Elemental_LIBRARIES "Elemental_pmrrr_LIBRARIES") +list(APPEND Elemental_LIBRARIES "Elemental_ElSuiteSparse_LIBRARIES") # FIXME This is a hardcoded path # NOTE FLINT is not required in the current release of SDPB. Commenting it out... @@ -342,7 +338,7 @@ target_link_libraries(sdpb Boost::serialization ${MPFR_LIBRARIES} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${ELEMENTAL_LIBRARIES}) + ${Elemental_LIBRARIES}) add_library(sdp_convert) target_sources(sdp_convert @@ -549,7 +545,7 @@ target_link_libraries(unit_tests sdp_solve ${MPFR_LIBRARIES} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${ELEMENTAL_LIBRARIES}) + ${Elemental_LIBRARIES}) add_executable(integration_tests) target_compile_definitions(integration_tests PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN) @@ -575,5 +571,5 @@ target_link_libraries(integration_tests Boost::filesystem ${MPFR_LIBRARIES} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${ELEMENTAL_LIBRARIES} + ${Elemental_LIBRARIES} ) From 42090ddead7ebd08178be954fdb5058a4d0de3ec Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Fri, 1 Mar 2024 15:02:33 +0100 Subject: [PATCH 07/20] Fully functional code for GMP, GMPXX, Boost, LibXml2, RapidJSON, LibArchive. Removed few refs to local paths --- CMakeLists.txt | 130 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 118 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac686135..6f39f6c5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,78 @@ find_package(PkgConfig REQUIRED) # GMP and GMPXX # ------------- +find_package(GMP QUIET) + +if (GMP_FOUND) + message(STATUS "GMP version: ${GMP_VERSION}") +else () + find_path(GMP_INCLUDE_DIR + NAMES gmp.h + PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} + ) + + find_library(GMP_LIBRARIES gmp + PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} + ) + + if (GMP_INCLUDE_DIR AND GMP_LIBRARIES) + set(GMP_FOUND TRUE) + endif () + + if (GMP_FOUND) + if (NOT GMP_FIND_QUIETLY) + message(STATUS "Found GMP: ${GMP_LIBRARIES}") + endif () + else () + if (GMP_FIND_REQUIRED) + message(FATAL_ERROR "Could not find GMP") + endif () + endif () + + mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES) + + message(STATUS "GMP version: ${GMP_VERSION}") +endif () +if(GMP_FOUND AND GMP_INCLUDE_DIR) + include_directories(${GMP_INCLUDE_DIR}) endif() + +find_package(GMPXX QUIET) + +if (GMPXX_FOUND) + message(STATUS "GMPXX version: ${GMPXX_VERSION}") +else () + find_path(GMPXX_INCLUDE_DIR + NAMES gmpxx.h + PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_INCLUDE} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} + ) + + find_library(GMPXX_LIBRARIES gmpxx + PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} + ) + + if (GMPXX_INCLUDE_DIR AND GMPXX_LIBRARIES) + set(GMPXX_FOUND TRUE) + endif () + + if (GMPXX_FOUND) + if (NOT GMPXX_FIND_QUIETLY) + message(STATUS "Found GMPXX: ${GMPXX_LIBRARIES}") + endif () + else () + if (GMPXX_FIND_REQUIRED) + message(FATAL_ERROR "Could not find GMPXX") + endif () + endif () + + mark_as_advanced(GMPXX_INCLUDE_DIR GMPXX_LIBRARIES) + + message(STATUS "GMPXX version: ${GMPXX_VERSION}") +endif () +if(GMPXX_FOUND AND GMPXX_INCLUDE_DIR) + include_directories(${GMPXX_INCLUDES}) +endif() + # MPFR # ---- find_package(MPFR QUIET) @@ -78,20 +149,64 @@ else () message(STATUS "MPFR version: ${MPFR_VERSION}") endif () +message(STATUS ${MPFR_INCLUDE_DIR}) + +if(MPFR_FOUND AND MPFR_INCLUDE_DIR) + include_directories(${MPFR_INCLUDE_DIR}) +endif() + + # Boost # ----- # TODO Change pkg_check_modules to a solution where you use find_path and find_library + +find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +if(NOT Boost_FOUND) + pkg_check_modules(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +endif() +message(STATUS "Boost version: ${Boost_VERSION}") +if(Boost_FOUND AND Boost_INCLUDE_DIR) + include_directories(${Boost_INCLUDE_DIR}) +endif() + +# Omitted the part where boost.py tests for boost by running a small snippet of code. +# TODO - Maybe add the tests back again? + +# libxml2 +# ------- +# TODO Change pkg_check_modules to a solution where you use find_path and find_library +find_package(LibXml2 REQUIRED) +if(NOT LIBXML2_FOUND) pkg_check_modules(LIBXML2 REQUIRED libxml-2) endif() +message(STATUS "libxml2 version: ${LIBXML2_VERSION} at ${LIBXML2_DIRECTORY}") +if(LIBXML2_FOUND AND LIBXML2_INCLUDE_DIR) + include_directories(${LIBXML2_INCLUDE_DIR}) +endif() + + # RapidJSON # --------- # TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(RapidJSON REQUIRED) # pkg_check_modules(RapidJSON REQUIRED RapidJSON) message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") +if(RapidJSON_FOUND AND RapidJSON_INCLUDE_DIR) + include_directories(${RapidJSON_INCLUDE_DIR}) +endif() + + # libarchive # ---------- # TODO Change pkg_check_modules to a solution where you use find_path and find_library +find_package(LibArchive REQUIRED) +if (NOT libarchive_FOUND) + pkg_check_modules(libarchive REQUIRED libarchive) +endif() +message(STATUS "libarchive version: ${libarchive_VERSION}") +if(LibArchive_FOUND AND LibArchive_INCLUDE_DIR) + include_directories(${LibArchive_INCLUDE_DIR}) +endif() #def configure(conf): @@ -153,18 +268,11 @@ string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) # use_packages=['cxx17','boost','gmpxx','mpfr','elemental','libxml2', 'rapidjson', 'libarchive'] #TODO -set(CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH /usr/local/lib) -message("CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}") +# set(CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH /usr/local/lib) +# message("CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}") include(FeatureSummary) -set(libxml2_INCLUDE_DIR /usr/include/libxml2) -include(FindLibXml2) -#find_package(libxml2) -#find_library(LIBXML2 libxml2 REQUIRED) - -find_library(MPFR_LIBRARIES mpfr) - #find_library() # TODO use target_link_libraries #link_libraries(cxx17 boost gmpxx mpfr elemental libxml2 rapidjson libarchive) @@ -235,8 +343,6 @@ mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) include_directories(src) include_directories(external) include_directories(SYSTEM elemental/install/include) -include_directories(SYSTEM ${libxml2_INCLUDE_DIR}) -include_directories(SYSTEM /home/vasdommes/install/include) add_library(sdp_solve) target_sources(sdp_solve @@ -316,7 +422,7 @@ target_link_libraries(sdp_solve ${MPFR_LIBRARIES} ${LIBARCHIVE_LIBRARIES} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${ELEMENTAL_LIBRARIES} + ${Elemental_LIBRARIES} #${FLINT_LIBRARIES} ${CBLAS_LIBRARIES}) From db5571dfe55a2b12b8ee79115f23e54ef9ff1dd5 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Fri, 1 Mar 2024 15:07:42 +0100 Subject: [PATCH 08/20] Updated .gitignore to ignore CMake generated files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ec65bcb52..0e7e0ce7b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__/ # cmake cmake-build*/ +build/ # IDE *.code-workspace From ff0110ebd972d65e35e5e1f22457c866b81a19b9 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Sun, 3 Mar 2024 01:25:13 +0100 Subject: [PATCH 09/20] Necessary CMakeLists.txt files to build all libraries and executables, plus additional Boost components. Integration tests pending --- CMakeLists.txt | 452 +++++++--------------------- src/approx_objective/CMakeLists.txt | 18 ++ src/outer_limits/CMakeLists.txt | 27 ++ src/pmp/CMakeLists.txt | 15 + src/pmp2functions/CMakeLists.txt | 17 ++ src/pmp2sdp/CMakeLists.txt | 16 + src/pmp_read/CMakeLists.txt | 21 ++ src/pvm2sdp/CMakeLists.txt | 16 + src/sdp2input/CMakeLists.txt | 16 + src/sdp_solve/CMakeLists.txt | 70 +++++ src/sdpb/CMakeLists.txt | 16 + src/sdpb_util/CMakeLists.txt | 11 + src/spectrum/CMakeLists.txt | 19 ++ 13 files changed, 378 insertions(+), 336 deletions(-) create mode 100644 src/approx_objective/CMakeLists.txt create mode 100644 src/outer_limits/CMakeLists.txt create mode 100644 src/pmp/CMakeLists.txt create mode 100644 src/pmp2functions/CMakeLists.txt create mode 100644 src/pmp2sdp/CMakeLists.txt create mode 100644 src/pmp_read/CMakeLists.txt create mode 100644 src/pvm2sdp/CMakeLists.txt create mode 100644 src/sdp2input/CMakeLists.txt create mode 100644 src/sdp_solve/CMakeLists.txt create mode 100644 src/sdpb/CMakeLists.txt create mode 100644 src/sdpb_util/CMakeLists.txt create mode 100644 src/spectrum/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f39f6c5c..1665b3ccc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,7 +160,18 @@ endif() # ----- # TODO Change pkg_check_modules to a solution where you use find_path and find_library -find_package(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) +find_package(Boost + REQUIRED COMPONENTS + system + filesystem + date_time + program_options + iostreams + serialization + stacktrace_basic + stacktrace_backtrace + stacktrace_addr2line + stacktrace_noop) if(NOT Boost_FOUND) pkg_check_modules(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) endif() @@ -344,338 +355,107 @@ include_directories(src) include_directories(external) include_directories(SYSTEM elemental/install/include) -add_library(sdp_solve) -target_sources(sdp_solve - #TODO set correct visibility - PUBLIC - src/sdp_solve/Solver_Parameters/Solver_Parameters.cxx - src/sdp_solve/Solver_Parameters/ostream.cxx - src/sdp_solve/Solver_Parameters/to_property_tree.cxx - src/sdp_solve/Archive_Reader/Archive_Reader.cxx - src/sdp_solve/Archive_Reader/underflow.cxx - src/sdp_solve/Block_Info/Block_Info.cxx - src/sdp_solve/Block_Info/read_block_info.cxx - src/sdp_solve/Block_Info/read_block_costs.cxx - src/sdp_solve/Block_Info/allocate_blocks/allocate_blocks.cxx - src/sdp_solve/Block_Info/allocate_blocks/compute_block_grid_mapping.cxx - src/sdp_solve/SDP/SDP/SDP.cxx - src/sdp_solve/SDP/SDP/read_objectives.cxx - src/sdp_solve/SDP/SDP/assign_bilinear_bases_dist.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_blocks.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/read_block_stream.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/EndArray.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/Key.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/StartArray.cxx - src/sdp_solve/SDP/SDP/read_blocks/read_block_stream/Block_Parser/String.cxx - src/sdp_solve/SDP/SDP/set_bases_blocks.cxx - src/sdp_solve/SDP_Solver/save_checkpoint.cxx - src/sdp_solve/SDP_Solver/load_checkpoint/load_checkpoint.cxx - src/sdp_solve/SDP_Solver/load_checkpoint/load_binary_checkpoint.cxx - src/sdp_solve/SDP_Solver/load_checkpoint/load_text_checkpoint.cxx - src/sdp_solve/SDP_Solver/SDP_Solver.cxx - src/sdp_solve/SDP_Solver/run/run.cxx - src/sdp_solve/SDP_Solver/run/cholesky_decomposition.cxx - src/sdp_solve/SDP_Solver/run/constraint_matrix_weighted_sum.cxx - src/sdp_solve/SDP_Solver/run/compute_dual_residues_and_error.cxx - src/sdp_solve/SDP_Solver/run/compute_primal_residues_and_error_P_Ax_X.cxx - src/sdp_solve/SDP_Solver/run/compute_primal_residues_and_error_p_b_Bx.cxx - src/sdp_solve/SDP_Solver/run/compute_objectives/compute_objectives.cxx - src/sdp_solve/SDP_Solver/run/compute_objectives/dot.cxx - src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_bilinear_pairings.cxx - src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_A_X_inv.cxx - src/sdp_solve/SDP_Solver/run/compute_bilinear_pairings/compute_A_Y.cxx - src/sdp_solve/SDP_Solver/run/compute_feasible_and_termination.cxx - src/sdp_solve/SDP_Solver/run/print_header.cxx - src/sdp_solve/SDP_Solver/run/print_iteration.cxx - src/sdp_solve/SDP_Solver/run/step/step.cxx - src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/initialize_schur_complement_solver.cxx - src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/compute_schur_complement.cxx - #src/sdp_solve/SDP_Solver/run/step/initialize_schur_complement_solver/compute_Q.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/compute_block_residues.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/Matrix_Normalizer.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/Fmpz_Matrix.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/Fmpz_Comb.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job_Schedule.cxx - #src/sdp_solve/SDP_Solver/run/bigint_syrk/blas_jobs/create_blas_job_schedule.cxx - src/sdp_solve/SDP_Solver/run/step/compute_search_direction/compute_search_direction.cxx - src/sdp_solve/SDP_Solver/run/step/compute_search_direction/cholesky_solve.cxx - src/sdp_solve/SDP_Solver/run/step/compute_search_direction/compute_schur_RHS.cxx - src/sdp_solve/SDP_Solver/run/step/compute_search_direction/scale_multiply_add.cxx - src/sdp_solve/SDP_Solver/run/step/compute_search_direction/solve_schur_complement_equation.cxx - src/sdp_solve/SDP_Solver/run/step/predictor_centering_parameter.cxx - src/sdp_solve/SDP_Solver/run/step/corrector_centering_parameter/corrector_centering_parameter.cxx - src/sdp_solve/SDP_Solver/run/step/corrector_centering_parameter/frobenius_product_of_sums.cxx - src/sdp_solve/SDP_Solver/run/step/frobenius_product_symmetric.cxx - src/sdp_solve/SDP_Solver/run/step/step_length/step_length.cxx - src/sdp_solve/SDP_Solver/run/step/step_length/min_eigenvalue.cxx - src/sdp_solve/SDP_Solver/run/step/step_length/lower_triangular_inverse_congruence.cxx - src/sdp_solve/SDP_Solver_Terminate_Reason/ostream.cxx - src/sdp_solve/lower_triangular_transpose_solve.cxx - src/sdp_solve/Block_Diagonal_Matrix/ostream.cxx - src/sdp_solve/Write_Solution.cxx) -# TODO add_subdirectory -target_link_libraries(sdp_solve - Boost::program_options - Boost::serialization - ${MPFR_LIBRARIES} - ${LIBARCHIVE_LIBRARIES} - ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${Elemental_LIBRARIES} - #${FLINT_LIBRARIES} - ${CBLAS_LIBRARIES}) - - -# SDPB executable -add_executable(sdpb) -target_sources(sdpb - PUBLIC - src/sdpb/main.cxx - src/sdpb/solve.cxx - src/sdpb/write_timing.cxx - src/sdpb/SDPB_Parameters/SDPB_Parameters.cxx - src/sdpb/SDPB_Parameters/to_property_tree.cxx - src/sdpb/SDPB_Parameters/ostream.cxx - src/sdpb/save_solution.cxx) -target_link_libraries(sdpb - sdp_solve - Boost::program_options - Boost::serialization - ${MPFR_LIBRARIES} - ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${Elemental_LIBRARIES}) - -add_library(sdp_convert) -target_sources(sdp_convert - PUBLIC - src/sdp_convert/Dual_Constraint_Group/Dual_Constraint_Group.cxx - src/sdp_convert/Dual_Constraint_Group/sample_bilinear_basis.cxx - src/sdp_convert/write_block_data.cxx - src/sdp_convert/write_block_info_json.cxx - src/sdp_convert/write_objectives_json.cxx - src/sdp_convert/write_sdpb_input_files.cxx - src/sdp_convert/write_control_json.cxx - src/sdp_convert/Archive_Writer/Archive_Writer.cxx - src/sdp_convert/Archive_Writer/write_entry.cxx - src/sdp_convert/Archive_Entry.cxx) -target_link_libraries(sdp_convert - Boost::iostreams - Boost::serialization - ${LIBARCHIVE_LIBRARIES}) - -add_library(sdp_read) -target_sources(sdp_read - PUBLIC - src/sdp_read/read_input/read_input.cxx - src/sdp_read/read_input/read_json/read_json.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_key.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_string.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_start_array.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_end_array.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_start_object.cxx - src/sdp_read/read_input/read_json/Positive_Matrix_With_Prefactor_State/json_end_object.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_key.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_string.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_start_array.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_end_array.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_start_object.cxx - src/sdp_read/read_input/read_json/Damped_Rational_State/json_end_object.cxx - src/sdp_read/read_input/read_json/JSON_Parser/Key.cxx - src/sdp_read/read_input/read_json/JSON_Parser/String.cxx - src/sdp_read/read_input/read_json/JSON_Parser/StartArray.cxx - src/sdp_read/read_input/read_json/JSON_Parser/EndArray.cxx - src/sdp_read/read_input/read_json/JSON_Parser/StartObject.cxx - src/sdp_read/read_input/read_json/JSON_Parser/EndObject.cxx - src/sdp_read/read_input/read_mathematica/read_mathematica.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_SDP.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrices.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_number.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_polynomial.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrix/parse_matrix.cxx - src/sdp_read/read_input/read_mathematica/parse_SDP/parse_matrix/parse_damped_rational.cxx - src/sdp_read/read_pvm_input/read_pvm_input.cxx - src/sdp_read/read_pvm_input/read_xml_input/read_xml_input.cxx - src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_start_element.cxx - src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_end_element.cxx - src/sdp_read/read_pvm_input/read_xml_input/Input_Parser/on_characters.cxx - src/sdp_read/read_nsv_file_list.cxx - src/sdp_read/sample_points.cxx - src/sdp_read/sample_scalings.cxx) -target_link_libraries(sdp_read sdp_convert) - -add_executable(pvm2sdp) -target_sources(pvm2sdp - PUBLIC - src/pvm2sdp/main.cxx - src/pvm2sdp/parse_command_line.cxx - src/pvm2sdp/read_input_files/read_input_files.cxx - src/pvm2sdp/read_input_files/read_xml_input/read_xml_input.cxx - src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_start_element.cxx - src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_end_element.cxx - src/pvm2sdp/read_input_files/read_xml_input/Input_Parser/on_characters.cxx) -target_link_libraries(pvm2sdp sdp_read) - -add_executable(sdp2input) -target_sources(sdp2input - PUBLIC - src/sdp2input/main.cxx - src/sdp2input/write_output/write_output.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_basis.cxx - src/sdp2input/write_output/bilinear_basis/precompute/precompute.cxx - src/sdp2input/write_output/bilinear_basis/precompute/integral.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_form/bilinear_form.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_form/rest.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_form/dExp.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_form/derivative.cxx - src/sdp2input/write_output/bilinear_basis/bilinear_form/operator_plus_set_Derivative_Term.cxx) -target_link_libraries(sdp2input sdp_read) - -add_library(mesh) -target_sources(mesh - PUBLIC - src/Mesh/Mesh.cxx - src/Mesh/ostream.cxx) - -add_executable(outer_limits) -target_sources(outer_limits - PUBLIC - src/outer_limits/main.cxx - src/outer_limits/power_prefactor.cxx - src/outer_limits/poles_prefactor.cxx - src/outer_limits/Function/eval/eval.cxx - src/outer_limits/compute_optimal/compute_optimal.cxx - src/outer_limits/compute_optimal/compute_y_transform.cxx - src/outer_limits/compute_optimal/setup_constraints.cxx - src/outer_limits/compute_optimal/copy_matrix.cxx - src/outer_limits/compute_optimal/find_new_points/find_new_points.cxx - src/outer_limits/compute_optimal/find_new_points/eval_summed.cxx - src/outer_limits/compute_optimal/find_new_points/get_new_points.cxx - src/outer_limits/compute_optimal/load_checkpoint/load_checkpoint.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/EndArray.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/EndObject.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/Key.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/StartArray.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/StartObject.cxx - src/outer_limits/compute_optimal/load_checkpoint/Checkpoint_Parser/String.cxx - src/outer_limits/compute_optimal/save_checkpoint.cxx - src/outer_limits/read_points/read_points.cxx - src/outer_limits/read_points/read_points_json/read_points_json.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/EndArray.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/EndObject.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/Key.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/StartArray.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/StartObject.cxx - src/outer_limits/read_points/read_points_json/Points_Parser/String.cxx - src/outer_limits/read_function_blocks/read_function_blocks.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_end_array.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_end_object.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_key.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_start_array.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_start_object.cxx - src/outer_limits/read_function_blocks/read_json/Function_State/json_string.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/EndArray.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/EndObject.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/Key.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/StartArray.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/StartObject.cxx - src/outer_limits/read_function_blocks/read_json/Function_Blocks_Parser/String.cxx - src/outer_limits/read_function_blocks/read_json/read_json.cxx - src/outer_limits/Outer_Parameters/Outer_Parameters.cxx - src/outer_limits/Outer_Parameters/to_property_tree.cxx - src/outer_limits/Outer_Parameters/ostream.cxx) -target_link_libraries(outer_limits sdp_read sdp_solve mesh) - -add_executable(approx_objective) -target_sources(approx_objective - PUBLIC - src/approx_objective/main.cxx - src/approx_objective/Approx_Parameters/Approx_Parameters.cxx - src/approx_objective/Approx_Parameters/ostream.cxx - src/approx_objective/Axpy.cxx - src/approx_objective/setup_solver.cxx - src/approx_objective/write_solver_state.cxx - src/approx_objective/Approx_Objective/Approx_Objective/Approx_Objective.cxx - src/approx_objective/Approx_Objective/Approx_Objective/compute_dx_dy.cxx - src/approx_objective/linear_approximate_objectives.cxx - src/approx_objective/quadratic_approximate_objectives.cxx) -target_link_libraries(approx_objective sdp_read sdp_solve) - -add_executable(pvm2functions) -target_sources(pvm2functions - PUBLIC - src/pvm2functions/main.cxx - src/pvm2functions/parse_command_line.cxx - src/pvm2functions/write_functions.cxx) -target_link_libraries(pvm2functions sdp_read) - -add_executable(sdp2functions) -target_sources(sdp2functions - PUBLIC - src/sdp2functions/main.cxx - src/sdp2functions/write_functions.cxx) -target_link_libraries(sdp2functions sdp_read) - -add_executable(spectrum) -target_sources(spectrum - PUBLIC - src/spectrum/main.cxx - src/spectrum/handle_arguments.cxx - src/spectrum/read_x.cxx - src/spectrum/compute_spectrum_pmp.cxx - src/spectrum/compute_spectrum_pvm.cxx - src/spectrum/compute_lambda.cxx - src/spectrum/eval_summed.cxx - src/spectrum/get_zeros.cxx - src/spectrum/write_spectrum/write_spectrum.cxx - src/spectrum/write_spectrum/write_file.cxx) -target_link_libraries(spectrum sdp_read sdp_solve sdp_convert mesh) - -add_executable(unit_tests) -target_compile_definitions(unit_tests PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN) -target_include_directories(unit_tests PUBLIC src test/src) -target_sources(unit_tests - PUBLIC - external/catch2/catch_amalgamated.cpp - test/src/unit_tests/main.cxx - test/src/unit_tests/cases/block_data_serialization.test.cxx - test/src/unit_tests/cases/boost_serialization.test.cxx - #test/src/unit_tests/cases/calculate_matrix_square.test.cxx - #test/src/unit_tests/cases/create_blas_job_schedule.test.cxx - #test/src/unit_tests/cases/LPT_scheduling.test.cxx - #test/src/unit_tests/cases/Matrix_Normalizer.test.cxx - #test/src/unit_tests/cases/shared_window.test.cxx - ) -target_link_libraries(unit_tests - sdp_convert - sdp_solve - ${MPFR_LIBRARIES} - ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${Elemental_LIBRARIES}) - -add_executable(integration_tests) -target_compile_definitions(integration_tests PUBLIC CATCH_AMALGAMATED_CUSTOM_MAIN) -target_include_directories(integration_tests PUBLIC src test/src SYSTEM ${GMPXX_INCLUDES}) -target_sources(integration_tests - PUBLIC - external/catch2/catch_amalgamated.cpp - test/src/integration_tests/main.cxx - test/src/integration_tests/util/Float.cxx - test/src/integration_tests/util/diff_outer_limits.cxx - test/src/integration_tests/util/diff_sdp_zip.cxx - test/src/integration_tests/util/diff_sdpb_out.cxx - test/src/integration_tests/util/diff_spectrum.cxx - test/src/integration_tests/util/Test_Case_Runner.cxx - test/src/integration_tests/cases/end-to-end.test.cxx - test/src/integration_tests/cases/outer_limits.test.cxx - test/src/integration_tests/cases/pvm2sdp.test.cxx - test/src/integration_tests/cases/sdp2input.test.cxx - test/src/integration_tests/cases/sdpb.test.cxx - test/src/integration_tests/cases/spectrum.test.cxx) -target_link_libraries(integration_tests - Boost::serialization - Boost::filesystem - ${MPFR_LIBRARIES} - ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} - ${Elemental_LIBRARIES} -) +set(USE_PACKAGES ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} ${MPFR_LIBRARIES} ${Elemental_LIBRARIES} ${LIBXML2_LIBRARIES} ${LibArchive_LIBRARIES}) +message(STATUS ${USE_PACKAGES}) + +add_subdirectory(src/sdpb_util) + +add_subdirectory(src/pmp) + +add_subdirectory(src/pmp2sdp) + +add_subdirectory(src/pmp_read) + +add_subdirectory(src/sdp2input) + +add_subdirectory(src/pvm2sdp) + +# Currently difficult to put the add_executable call to src/pmp2sdp/CMakeLists.txt because between pmp2sdp_lib and pmp2sdp, pmp_read needs to be built +# TODO - Refactor the code below once a resolution to the above conflict has been figured out + +add_executable(pmp2sdp) +target_sources(pmp2sdp + PRIVATE + src/pmp2sdp/main.cxx + src/pmp2sdp/Pmp2sdp_Parameters/Pmp2sdp_Parameters.cxx) +target_link_libraries(pmp2sdp + PRIVATE + ${USE_PACKAGES} + Boost::iostreams + Boost::serialization + Boost::stacktrace_basic + Boost::stacktrace_addr2line + Boost::stacktrace_noop + Boost::program_options + dl + sdpb_util + pmp + pmp_read + pmp2sdp_lib) + +add_subdirectory(src/pmp2functions) + +add_subdirectory(src/sdp_solve) + +add_subdirectory(src/sdpb) + +add_subdirectory(src/outer_limits) + +add_subdirectory(src/approx_objective) + +add_subdirectory(src/spectrum) + +# add_executable(integration_tests) +# target_sources(integration_tests +# PRIVATE +# external/catch2/catch_amalgamated.cpp +# test/src/integration_tests/main.cxx +# test/src/integration_tests/util/Float.cxx +# test/src/integration_tests/util/diff_outer_limits.cxx +# test/src/integration_tests/util/diff_sdp.cxx +# test/src/integration_tests/util/diff_sdpb_out.cxx +# test/src/integration_tests/util/diff_spectrum.cxx +# test/src/integration_tests/util/Test_Case_Runner.cxx +# test/src/integration_tests/cases/end-to-end.test.cxx +# test/src/integration_tests/cases/outer_limits.test.cxx +# test/src/integration_tests/cases/pmp2sdp.test.cxx +# test/src/integration_tests/cases/sdpb.test.cxx) +# target_link_libraries(integration_tests +# PRIVATE +# ${USE_PACKAGES} +# Boost::serialization) +# target_include_directories(integration_tests PRIVATE test/src) +# bld.program(source=['external/catch2/catch_amalgamated.cpp', +# 'test/src/integration_tests/main.cxx', +# 'test/src/integration_tests/util/Float.cxx', +# 'test/src/integration_tests/util/diff_outer_limits.cxx', +# 'test/src/integration_tests/util/diff_sdp.cxx', +# 'test/src/integration_tests/util/diff_sdpb_out.cxx', +# 'test/src/integration_tests/util/diff_spectrum.cxx', +# 'test/src/integration_tests/util/Test_Case_Runner.cxx', +# 'test/src/integration_tests/cases/end-to-end.test.cxx', +# 'test/src/integration_tests/cases/outer_limits.test.cxx', +# 'test/src/integration_tests/cases/pmp2sdp.test.cxx', +# 'test/src/integration_tests/cases/sdpb.test.cxx'], +# target='integration_tests', +# install_path=None, +# cxxflags=default_flags, +# defines=default_defines + ['CATCH_AMALGAMATED_CUSTOM_MAIN'], +# use=use_packages, +# includes=default_includes + ['test/src'] +# ) +# bld.program(source=['external/catch2/catch_amalgamated.cpp', +# 'test/src/unit_tests/main.cxx', +# 'test/src/unit_tests/cases/block_data_serialization.test.cxx', +# 'test/src/unit_tests/cases/block_mapping.test.cxx', +# 'test/src/unit_tests/cases/Boost_Float.test.cxx', +# 'test/src/unit_tests/cases/boost_serialization.test.cxx', +# 'test/src/unit_tests/cases/copy_matrix.test.cxx', +# 'test/src/unit_tests/cases/json.test.cxx', +# 'test/src/unit_tests/cases/shared_window.test.cxx'], +# target='unit_tests', +# cxxflags=default_flags, +# defines=default_defines + ['CATCH_AMALGAMATED_CUSTOM_MAIN'], +# use=use_packages + ['pmp_read', 'pmp2sdp_lib', 'sdp_solve'], +# includes=default_includes + ['test/src'] +# ) \ No newline at end of file diff --git a/src/approx_objective/CMakeLists.txt b/src/approx_objective/CMakeLists.txt new file mode 100644 index 000000000..d26e2ffc4 --- /dev/null +++ b/src/approx_objective/CMakeLists.txt @@ -0,0 +1,18 @@ +add_executable(approx_objective) +target_sources(approx_objective + PRIVATE + main.cxx + Approx_Parameters/Approx_Parameters.cxx + Approx_Parameters/ostream.cxx + Axpy.cxx + setup_solver.cxx + write_solver_state.cxx + Approx_Objective/Approx_Objective/Approx_Objective.cxx + Approx_Objective/Approx_Objective/compute_dx_dy.cxx + linear_approximate_objectives.cxx + quadratic_approximate_objectives.cxx) +target_link_libraries(approx_objective + PRIVATE + ${USE_PACKAGES} + pmp_read + sdp_solve) \ No newline at end of file diff --git a/src/outer_limits/CMakeLists.txt b/src/outer_limits/CMakeLists.txt new file mode 100644 index 000000000..a4603b032 --- /dev/null +++ b/src/outer_limits/CMakeLists.txt @@ -0,0 +1,27 @@ +add_executable(outer_limits) +target_sources(outer_limits + PRIVATE + main.cxx + power_prefactor.cxx + poles_prefactor.cxx + Function/eval/eval.cxx + compute_optimal/compute_optimal.cxx + compute_optimal/compute_y_transform.cxx + compute_optimal/setup_constraints.cxx + compute_optimal/find_new_points/find_new_points.cxx + compute_optimal/find_new_points/eval_summed.cxx + compute_optimal/find_new_points/get_new_points.cxx + compute_optimal/load_checkpoint/load_checkpoint.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/EndArray.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/EndObject.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/Key.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/StartArray.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/StartObject.cxx + compute_optimal/load_checkpoint/Checkpoint_Parser/String.cxx + compute_optimal/save_checkpoint.cxx + read_points/read_points.cxx + read_function_blocks/read_function_blocks.cxx + Outer_Parameters/Outer_Parameters.cxx + Outer_Parameters/to_property_tree.cxx + Outer_Parameters/ostream.cxx) +target_link_libraries(outer_limits PRIVATE ${USE_PACKAGES} sdpb_util pmp_read sdp_solve) \ No newline at end of file diff --git a/src/pmp/CMakeLists.txt b/src/pmp/CMakeLists.txt new file mode 100644 index 000000000..b113fd83f --- /dev/null +++ b/src/pmp/CMakeLists.txt @@ -0,0 +1,15 @@ +add_library(pmp SHARED) +target_sources(pmp + PRIVATE + Polynomial_Vector_Matrix.cxx + convert/sample_points.cxx + convert/sample_scalings.cxx + convert/bilinear_basis/bilinear_basis.cxx + convert/bilinear_basis/precompute/precompute.cxx + convert/bilinear_basis/precompute/integral.cxx + convert/bilinear_basis/bilinear_form/bilinear_form.cxx + convert/bilinear_basis/bilinear_form/rest.cxx + convert/bilinear_basis/bilinear_form/dExp.cxx + convert/bilinear_basis/bilinear_form/derivative.cxx + convert/bilinear_basis/bilinear_form/operator_plus_set_Derivative_Term.cxx) +target_link_libraries(pmp PUBLIC ${USE_PACKAGES}) \ No newline at end of file diff --git a/src/pmp2functions/CMakeLists.txt b/src/pmp2functions/CMakeLists.txt new file mode 100644 index 000000000..2b644ebe7 --- /dev/null +++ b/src/pmp2functions/CMakeLists.txt @@ -0,0 +1,17 @@ +add_executable(pmp2functions) +target_sources(pmp2functions + PRIVATE + main.cxx + Pmp2functions_Parameters.cxx + write_functions.cxx) +target_link_libraries(pmp2functions + PRIVATE + ${USE_PACKAGES} + Boost::iostreams + Boost::stacktrace_basic + Boost::stacktrace_addr2line + Boost::stacktrace_noop + Boost::program_options + dl + sdpb_util + pmp_read) \ No newline at end of file diff --git a/src/pmp2sdp/CMakeLists.txt b/src/pmp2sdp/CMakeLists.txt new file mode 100644 index 000000000..e39c14251 --- /dev/null +++ b/src/pmp2sdp/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(pmp2sdp_lib SHARED) +target_sources(pmp2sdp_lib + PRIVATE + Dual_Constraint_Group/Dual_Constraint_Group.cxx + Dual_Constraint_Group/sample_bilinear_basis.cxx + Output_SDP/Output_SDP.cxx + write_block_data.cxx + write_block_info_json.cxx + write_objectives_json.cxx + write_normalization_json.cxx + write_sdp.cxx + write_control_json.cxx + Archive_Writer/Archive_Writer.cxx + Archive_Writer/write_entry.cxx + Archive_Entry.cxx) +target_link_libraries(pmp2sdp_lib PUBLIC ${USE_PACKAGES} pmp) \ No newline at end of file diff --git a/src/pmp_read/CMakeLists.txt b/src/pmp_read/CMakeLists.txt new file mode 100644 index 000000000..c29fbede8 --- /dev/null +++ b/src/pmp_read/CMakeLists.txt @@ -0,0 +1,21 @@ +add_library(pmp_read SHARED) +target_sources(pmp_read + PRIVATE + collect_files_expanding_nsv.cxx + PMP_File_Parse_Result.cxx + read_nsv_file_list.cxx + read_polynomial_matrix_program.cxx + read_json/read_json.cxx + read_json/Json_PMP_Parser.cxx + read_mathematica/read_mathematica.cxx + read_mathematica/parse_SDP/parse_SDP.cxx + read_mathematica/parse_SDP/parse_matrices.cxx + read_mathematica/parse_SDP/parse_number.cxx + read_mathematica/parse_SDP/parse_polynomial.cxx + read_mathematica/parse_SDP/parse_matrix/parse_matrix.cxx + read_mathematica/parse_SDP/parse_matrix/parse_damped_rational.cxx + read_xml/read_xml.cxx + read_xml/Xml_Parser/on_start_element.cxx + read_xml/Xml_Parser/on_end_element.cxx + read_xml/Xml_Parser/on_characters.cxx) +target_link_libraries(pmp_read PUBLIC ${USE_PACKAGES} pmp pmp2sdp_lib) \ No newline at end of file diff --git a/src/pvm2sdp/CMakeLists.txt b/src/pvm2sdp/CMakeLists.txt new file mode 100644 index 000000000..a0e12e6cb --- /dev/null +++ b/src/pvm2sdp/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable(pvm2sdp) +target_sources(pvm2sdp + PRIVATE + main.cxx + parse_command_line.cxx) +target_link_libraries(pvm2sdp + PUBLIC + ${USE_PACKAGES} + Boost::iostreams + Boost::serialization + Boost::stacktrace_basic + Boost::stacktrace_addr2line + Boost::stacktrace_noop + dl + sdpb_util + pmp_read) \ No newline at end of file diff --git a/src/sdp2input/CMakeLists.txt b/src/sdp2input/CMakeLists.txt new file mode 100644 index 000000000..320372b1a --- /dev/null +++ b/src/sdp2input/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable(sdp2input) +target_sources(sdp2input PRIVATE main.cxx) +target_link_libraries(sdp2input + PUBLIC + ${USE_PACKAGES} + Boost::program_options + Boost::iostreams + Boost::serialization + Boost::stacktrace_basic + Boost::stacktrace_addr2line + Boost::stacktrace_noop + dl + pmp + pmp_read + pmp2sdp_lib + sdpb_util) \ No newline at end of file diff --git a/src/sdp_solve/CMakeLists.txt b/src/sdp_solve/CMakeLists.txt new file mode 100644 index 000000000..b116d3cc2 --- /dev/null +++ b/src/sdp_solve/CMakeLists.txt @@ -0,0 +1,70 @@ +add_library(sdp_solve) +target_sources(sdp_solve + PRIVATE + Solver_Parameters/Solver_Parameters.cxx + Solver_Parameters/ostream.cxx + Solver_Parameters/to_property_tree.cxx + Archive_Reader/Archive_Reader.cxx + Archive_Reader/underflow.cxx + Block_Info/Block_Info.cxx + Block_Info/read_block_info.cxx + Block_Info/read_block_costs.cxx + Block_Info/allocate_blocks.cxx + SDP/SDP/SDP.cxx + SDP/SDP/read_normalization.cxx + SDP/SDP/read_objectives.cxx + SDP/SDP/assign_bilinear_bases_dist.cxx + SDP/SDP/read_block_data/read_block_data.cxx + SDP/SDP/read_block_data/SDP_Block_Data.cxx + SDP/SDP/set_bases_blocks.cxx + SDP_Solver/save_checkpoint.cxx + SDP_Solver/load_checkpoint/load_checkpoint.cxx + SDP_Solver/load_checkpoint/load_binary_checkpoint.cxx + SDP_Solver/load_checkpoint/load_text_checkpoint.cxx + SDP_Solver/SDP_Solver.cxx + SDP_Solver/run/run.cxx + SDP_Solver/run/cholesky_decomposition.cxx + SDP_Solver/run/constraint_matrix_weighted_sum.cxx + SDP_Solver/run/compute_dual_residues_and_error.cxx + SDP_Solver/run/compute_primal_residues_and_error_P_Ax_X.cxx + SDP_Solver/run/compute_primal_residues_and_error_p_b_Bx.cxx + SDP_Solver/run/compute_objectives/compute_objectives.cxx + SDP_Solver/run/compute_objectives/dot.cxx + SDP_Solver/run/compute_bilinear_pairings/compute_bilinear_pairings.cxx + SDP_Solver/run/compute_bilinear_pairings/compute_A_X_inv.cxx + SDP_Solver/run/compute_bilinear_pairings/compute_A_Y.cxx + SDP_Solver/run/compute_feasible_and_termination.cxx + SDP_Solver/run/print_header.cxx + SDP_Solver/run/print_iteration.cxx + SDP_Solver/run/step/step.cxx + SDP_Solver/run/step/initialize_schur_complement_solver/initialize_schur_complement_solver.cxx + SDP_Solver/run/step/initialize_schur_complement_solver/compute_schur_complement.cxx + SDP_Solver/run/step/initialize_schur_complement_solver/initialize_Q_group.cxx + SDP_Solver/run/step/initialize_schur_complement_solver/synchronize_Q.cxx + SDP_Solver/run/step/compute_search_direction/compute_search_direction.cxx + SDP_Solver/run/step/compute_search_direction/cholesky_solve.cxx + SDP_Solver/run/step/compute_search_direction/compute_schur_RHS.cxx + SDP_Solver/run/step/compute_search_direction/scale_multiply_add.cxx + SDP_Solver/run/step/compute_search_direction/solve_schur_complement_equation.cxx + SDP_Solver/run/step/predictor_centering_parameter.cxx + SDP_Solver/run/step/corrector_centering_parameter/corrector_centering_parameter.cxx + SDP_Solver/run/step/corrector_centering_parameter/frobenius_product_of_sums.cxx + SDP_Solver/run/step/frobenius_product_symmetric.cxx + SDP_Solver/run/step/step_length/step_length.cxx + SDP_Solver/run/step/step_length/min_eigenvalue.cxx + SDP_Solver/run/step/step_length/lower_triangular_inverse_congruence.cxx + SDP_Solver_Terminate_Reason/ostream.cxx + lower_triangular_transpose_solve.cxx + Block_Diagonal_Matrix/ostream.cxx + Write_Solution.cxx) +target_link_libraries(sdp_solve + PRIVATE + ${USE_PACKAGES} + Boost::iostreams + Boost::stacktrace_basic + Boost::stacktrace_addr2line + Boost::stacktrace_noop + Boost::program_options + dl + sdpb_util + pmp2sdp_lib) \ No newline at end of file diff --git a/src/sdpb/CMakeLists.txt b/src/sdpb/CMakeLists.txt new file mode 100644 index 000000000..3923928a7 --- /dev/null +++ b/src/sdpb/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable(sdpb) +target_sources(sdpb + PRIVATE + main.cxx + solve.cxx + write_timing.cxx + SDPB_Parameters/SDPB_Parameters.cxx + SDPB_Parameters/to_property_tree.cxx + SDPB_Parameters/ostream.cxx + save_solution.cxx) +target_link_libraries(sdpb + PRIVATE + ${USE_PACKAGES} + Boost::serialization + sdpb_util + sdp_solve) \ No newline at end of file diff --git a/src/sdpb_util/CMakeLists.txt b/src/sdpb_util/CMakeLists.txt new file mode 100644 index 000000000..d46aba571 --- /dev/null +++ b/src/sdpb_util/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(sdpb_util SHARED) +target_sources(sdpb_util + PRIVATE + copy_matrix.cxx + Environment.cxx + Mesh.cxx + Proc_Meminfo.cxx + Timers/Scoped_Timer.cxx + Timers/Timer.cxx + Timers/Timers.cxx) +target_link_libraries(sdpb_util PUBLIC ${GMPXX_LIBRARIES} Boost::iostreams Boost::serialization Boost::filesystem ${Elemental_LIBRARIES}) diff --git a/src/spectrum/CMakeLists.txt b/src/spectrum/CMakeLists.txt new file mode 100644 index 000000000..da82857e1 --- /dev/null +++ b/src/spectrum/CMakeLists.txt @@ -0,0 +1,19 @@ +add_executable(spectrum) +target_sources(spectrum + PRIVATE + main.cxx + handle_arguments.cxx + read_x.cxx + compute_spectrum.cxx + compute_lambda.cxx + eval_summed.cxx + get_zeros.cxx + write_spectrum/write_spectrum.cxx + write_spectrum/write_file.cxx) +target_link_libraries(spectrum + PRIVATE + ${USE_PACKAGES} + pmp_read + sdp_solve + pmp2sdp_lib + sdpb_util) \ No newline at end of file From 0fa667b6a289424e7f39f0dae50f9eacb90a1daa Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Sun, 3 Mar 2024 01:25:29 +0100 Subject: [PATCH 10/20] Cosmetic changes --- CMakeLists.txt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1665b3ccc..4ad99bb20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# TODO choose version, currently working with 3.16 as a temporary measure: +cmake_minimum_required(VERSION 3.16) + +project(sdpb LANGUAGES CXX) +# TODO setting version of SDPB + # TODO - Currently we are working with a single CMake file but it is better to refactor parts of this file and put them inside cmake/modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") @@ -5,17 +11,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") # Custom colour scheme for logging include(CustomMessages) -# TODO choose version, currently working with 3.16 as a temporary measure: -cmake_minimum_required(VERSION 3.16) - # This is to ensure that CMake also checks lib64 for the dependencies on Linux systems if(UNIX) set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) endif() -project(sdpb LANGUAGES CXX) -# TODO setting version of SDPB - # cxx 17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -321,10 +321,11 @@ endif() message(STATUS "El version: ${Elemental_VERSION}") message(STATUS "Found Elemental: ${Elemental_LIBRARIES}") # find_library(El El PATHS ${Elemental_DIR} REQUIRED) -find_library(pmrrr pmrrr PATHS ${Elemental_DIR}/external/pmrrr REQUIRED) -find_library(ElSuiteSparse ElSuiteSparse PATHS ${Elemental_DIR}/external/suite_sparse REQUIRED) -list(APPEND Elemental_LIBRARIES "Elemental_pmrrr_LIBRARIES") -list(APPEND Elemental_LIBRARIES "Elemental_ElSuiteSparse_LIBRARIES") +find_library(PMRRR_LIBRARIES pmrrr PATHS ${Elemental_DIR}/external/pmrrr REQUIRED) +find_library(ELSUITESPARSE_LIBRARIES ElSuiteSparse PATHS ${Elemental_DIR}/external/suite_sparse REQUIRED) +list(APPEND Elemental_LIBRARIES ${PMRRR_LIBRARIES}) +list(APPEND Elemental_LIBRARIES ${ELSUITESPARSE_LIBRARIES}) +message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") # FIXME This is a hardcoded path # NOTE FLINT is not required in the current release of SDPB. Commenting it out... From 71faa0eeb0f5f00e69a3dda67d6af8a69784c600 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Mon, 4 Mar 2024 19:19:37 +0100 Subject: [PATCH 11/20] Refactored GMP, GMPXX, MPFR. Removed pkg_check_module calls, commented pkgconfig --- CMakeLists.txt | 126 ++-------------------------------- cmake/modules/FindGMP.cmake | 12 ++++ cmake/modules/FindGMPXX.cmake | 13 ++++ cmake/modules/FindMPFR.cmake | 13 ++++ 4 files changed, 45 insertions(+), 119 deletions(-) create mode 100644 cmake/modules/FindGMP.cmake create mode 100644 cmake/modules/FindGMPXX.cmake create mode 100644 cmake/modules/FindMPFR.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ad99bb20..d71bea2e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,121 +39,18 @@ message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") ########### Find required dependencies ########### ################################################## -include(FindPkgConfig) -find_package(PkgConfig REQUIRED) +# include(FindPkgConfig) +# find_package(PkgConfig REQUIRED) # GMP and GMPXX # ------------- -find_package(GMP QUIET) - -if (GMP_FOUND) - message(STATUS "GMP version: ${GMP_VERSION}") -else () - find_path(GMP_INCLUDE_DIR - NAMES gmp.h - PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} - ) - - find_library(GMP_LIBRARIES gmp - PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} - ) - - if (GMP_INCLUDE_DIR AND GMP_LIBRARIES) - set(GMP_FOUND TRUE) - endif () - - if (GMP_FOUND) - if (NOT GMP_FIND_QUIETLY) - message(STATUS "Found GMP: ${GMP_LIBRARIES}") - endif () - else () - if (GMP_FIND_REQUIRED) - message(FATAL_ERROR "Could not find GMP") - endif () - endif () - - mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES) - - message(STATUS "GMP version: ${GMP_VERSION}") -endif () -if(GMP_FOUND AND GMP_INCLUDE_DIR) - include_directories(${GMP_INCLUDE_DIR}) -endif() +find_package(GMP REQUIRED) -find_package(GMPXX QUIET) - -if (GMPXX_FOUND) - message(STATUS "GMPXX version: ${GMPXX_VERSION}") -else () - find_path(GMPXX_INCLUDE_DIR - NAMES gmpxx.h - PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_INCLUDE} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} - ) - - find_library(GMPXX_LIBRARIES gmpxx - PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} - ) - - if (GMPXX_INCLUDE_DIR AND GMPXX_LIBRARIES) - set(GMPXX_FOUND TRUE) - endif () - - if (GMPXX_FOUND) - if (NOT GMPXX_FIND_QUIETLY) - message(STATUS "Found GMPXX: ${GMPXX_LIBRARIES}") - endif () - else () - if (GMPXX_FIND_REQUIRED) - message(FATAL_ERROR "Could not find GMPXX") - endif () - endif () - - mark_as_advanced(GMPXX_INCLUDE_DIR GMPXX_LIBRARIES) - - message(STATUS "GMPXX version: ${GMPXX_VERSION}") -endif () -if(GMPXX_FOUND AND GMPXX_INCLUDE_DIR) - include_directories(${GMPXX_INCLUDES}) -endif() +find_package(GMPXX REQUIRED) # MPFR # ---- -find_package(MPFR QUIET) - -if (MPFR_FOUND) - message(STATUS "MPFR version: ${MPFR_VERSION}") -else () - find_path(MPFR_INCLUDE_DIR mpfr.h - PATHS /usr/include /usr/local/include - ) - - find_library(MPFR_LIBRARIES mpfr - PATHS /usr/lib64 /usr/local/lib - ) - - if (MPFR_INCLUDE_DIR AND MPFR_LIBRARIES) - set(MPFR_FOUND TRUE) - endif () - - if (MPFR_FOUND) - if (NOT MPFR_FIND_QUIETLY) - message(STATUS "Found MPFR: ${MPFR_LIBRARIES}") - endif () - else () - if (MPFR_FIND_REQUIRED) - message(FATAL_ERROR "Could not find MPFR") - endif () - endif () - - mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARIES) - - message(STATUS "MPFR version: ${MPFR_VERSION}") -endif () -message(STATUS ${MPFR_INCLUDE_DIR}) - -if(MPFR_FOUND AND MPFR_INCLUDE_DIR) - include_directories(${MPFR_INCLUDE_DIR}) -endif() +find_package(MPFR REQUIRED) # Boost @@ -171,10 +68,8 @@ find_package(Boost stacktrace_basic stacktrace_backtrace stacktrace_addr2line - stacktrace_noop) -if(NOT Boost_FOUND) - pkg_check_modules(Boost REQUIRED COMPONENTS system filesystem date_time program_options iostreams serialization) -endif() + stacktrace_noop + REQUIRED) message(STATUS "Boost version: ${Boost_VERSION}") if(Boost_FOUND AND Boost_INCLUDE_DIR) include_directories(${Boost_INCLUDE_DIR}) @@ -187,9 +82,6 @@ endif() # ------- # TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(LibXml2 REQUIRED) -if(NOT LIBXML2_FOUND) - pkg_check_modules(LIBXML2 REQUIRED libxml-2) -endif() message(STATUS "libxml2 version: ${LIBXML2_VERSION} at ${LIBXML2_DIRECTORY}") if(LIBXML2_FOUND AND LIBXML2_INCLUDE_DIR) include_directories(${LIBXML2_INCLUDE_DIR}) @@ -200,7 +92,6 @@ endif() # --------- # TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(RapidJSON REQUIRED) -# pkg_check_modules(RapidJSON REQUIRED RapidJSON) message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") if(RapidJSON_FOUND AND RapidJSON_INCLUDE_DIR) include_directories(${RapidJSON_INCLUDE_DIR}) @@ -211,9 +102,6 @@ endif() # ---------- # TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(LibArchive REQUIRED) -if (NOT libarchive_FOUND) - pkg_check_modules(libarchive REQUIRED libarchive) -endif() message(STATUS "libarchive version: ${libarchive_VERSION}") if(LibArchive_FOUND AND LibArchive_INCLUDE_DIR) include_directories(${LibArchive_INCLUDE_DIR}) diff --git a/cmake/modules/FindGMP.cmake b/cmake/modules/FindGMP.cmake new file mode 100644 index 000000000..ac7559129 --- /dev/null +++ b/cmake/modules/FindGMP.cmake @@ -0,0 +1,12 @@ +find_path(GMP_INCLUDE_DIR + NAMES gmp.h + PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} + ) + +find_library(GMP_LIBRARIES gmp + PATHS $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} + ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GMP DEFAULT_MSG + GMP_INCLUDE_DIR GMP_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindGMPXX.cmake b/cmake/modules/FindGMPXX.cmake new file mode 100644 index 000000000..40f95a300 --- /dev/null +++ b/cmake/modules/FindGMPXX.cmake @@ -0,0 +1,13 @@ +find_path(GMPXX_INCLUDE_DIR + NAMES gmpxx.h + PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_INCLUDE} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_INCLUDE} ${INCLUDE_INSTALL_DIR} + ) + +find_library(GMPXX_LIBRARIES gmpxx + PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} + ) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GMPXX DEFAULT_MSG + GMPXX_INCLUDE_DIR GMPXX_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindMPFR.cmake b/cmake/modules/FindMPFR.cmake new file mode 100644 index 000000000..408302803 --- /dev/null +++ b/cmake/modules/FindMPFR.cmake @@ -0,0 +1,13 @@ +set(MPFR_FIND_REQUIRED) + +find_path(MPFR_INCLUDE_DIR mpfr.h + PATHS ${GMPDIR} ${MPFRDIR} ${INCLUDE_INSTALL_DIR} +) + +find_library(MPFR_LIBRARIES mpfr + PATHS ${GMPDIR} ${MPFRDIR} ${INCLUDE_INSTALL_DIR} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MPFR DEFAULT_MSG + MPFR_INCLUDE_DIR MPFR_LIBRARIES) \ No newline at end of file From fe7e2f2203902c75b1d13b1ad1c88585ef560348 Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Thu, 7 Mar 2024 23:13:54 +0100 Subject: [PATCH 12/20] Added install directives for `make install` --- CMakeLists.txt | 1 + src/approx_objective/CMakeLists.txt | 3 ++- src/outer_limits/CMakeLists.txt | 3 ++- src/pmp/CMakeLists.txt | 3 ++- src/pmp2functions/CMakeLists.txt | 3 ++- src/pmp2sdp/CMakeLists.txt | 9 ++++++++- src/pmp_read/CMakeLists.txt | 3 ++- src/pvm2sdp/CMakeLists.txt | 3 ++- src/sdp2input/CMakeLists.txt | 3 ++- src/sdp_solve/CMakeLists.txt | 3 ++- src/sdpb/CMakeLists.txt | 3 ++- src/sdpb_util/CMakeLists.txt | 1 + src/spectrum/CMakeLists.txt | 3 ++- 13 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d71bea2e1..df4eb3a14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,6 +281,7 @@ target_link_libraries(pmp2sdp pmp pmp_read pmp2sdp_lib) + install(TARGETS pmp2sdp RUNTIME) add_subdirectory(src/pmp2functions) diff --git a/src/approx_objective/CMakeLists.txt b/src/approx_objective/CMakeLists.txt index d26e2ffc4..28036f83c 100644 --- a/src/approx_objective/CMakeLists.txt +++ b/src/approx_objective/CMakeLists.txt @@ -15,4 +15,5 @@ target_link_libraries(approx_objective PRIVATE ${USE_PACKAGES} pmp_read - sdp_solve) \ No newline at end of file + sdp_solve) +install(TARGETS approx_objective RUNTIME) \ No newline at end of file diff --git a/src/outer_limits/CMakeLists.txt b/src/outer_limits/CMakeLists.txt index a4603b032..9bc8e6fac 100644 --- a/src/outer_limits/CMakeLists.txt +++ b/src/outer_limits/CMakeLists.txt @@ -24,4 +24,5 @@ target_sources(outer_limits Outer_Parameters/Outer_Parameters.cxx Outer_Parameters/to_property_tree.cxx Outer_Parameters/ostream.cxx) -target_link_libraries(outer_limits PRIVATE ${USE_PACKAGES} sdpb_util pmp_read sdp_solve) \ No newline at end of file +target_link_libraries(outer_limits PRIVATE ${USE_PACKAGES} sdpb_util pmp_read sdp_solve) +install(TARGETS outer_limits RUNTIME) \ No newline at end of file diff --git a/src/pmp/CMakeLists.txt b/src/pmp/CMakeLists.txt index b113fd83f..4e9ca72ab 100644 --- a/src/pmp/CMakeLists.txt +++ b/src/pmp/CMakeLists.txt @@ -12,4 +12,5 @@ target_sources(pmp convert/bilinear_basis/bilinear_form/dExp.cxx convert/bilinear_basis/bilinear_form/derivative.cxx convert/bilinear_basis/bilinear_form/operator_plus_set_Derivative_Term.cxx) -target_link_libraries(pmp PUBLIC ${USE_PACKAGES}) \ No newline at end of file +target_link_libraries(pmp PUBLIC ${USE_PACKAGES}) +install(TARGETS pmp LIBRARY) \ No newline at end of file diff --git a/src/pmp2functions/CMakeLists.txt b/src/pmp2functions/CMakeLists.txt index 2b644ebe7..1826dcf3a 100644 --- a/src/pmp2functions/CMakeLists.txt +++ b/src/pmp2functions/CMakeLists.txt @@ -14,4 +14,5 @@ target_link_libraries(pmp2functions Boost::program_options dl sdpb_util - pmp_read) \ No newline at end of file + pmp_read) +install(TARGETS pmp2functions RUNTIME) \ No newline at end of file diff --git a/src/pmp2sdp/CMakeLists.txt b/src/pmp2sdp/CMakeLists.txt index e39c14251..0c4207da7 100644 --- a/src/pmp2sdp/CMakeLists.txt +++ b/src/pmp2sdp/CMakeLists.txt @@ -13,4 +13,11 @@ target_sources(pmp2sdp_lib Archive_Writer/Archive_Writer.cxx Archive_Writer/write_entry.cxx Archive_Entry.cxx) -target_link_libraries(pmp2sdp_lib PUBLIC ${USE_PACKAGES} pmp) \ No newline at end of file +target_link_libraries(pmp2sdp_lib + PUBLIC + ${USE_PACKAGES} + Boost::iostreams + Boost::serialization + sdpb_util + pmp) +install(TARGETS pmp2sdp_lib LIBRARY) \ No newline at end of file diff --git a/src/pmp_read/CMakeLists.txt b/src/pmp_read/CMakeLists.txt index c29fbede8..ae2cc45e0 100644 --- a/src/pmp_read/CMakeLists.txt +++ b/src/pmp_read/CMakeLists.txt @@ -18,4 +18,5 @@ target_sources(pmp_read read_xml/Xml_Parser/on_start_element.cxx read_xml/Xml_Parser/on_end_element.cxx read_xml/Xml_Parser/on_characters.cxx) -target_link_libraries(pmp_read PUBLIC ${USE_PACKAGES} pmp pmp2sdp_lib) \ No newline at end of file +target_link_libraries(pmp_read PUBLIC ${USE_PACKAGES} pmp pmp2sdp_lib) +install(TARGETS pmp_read LIBRARY) \ No newline at end of file diff --git a/src/pvm2sdp/CMakeLists.txt b/src/pvm2sdp/CMakeLists.txt index a0e12e6cb..6f6887cd8 100644 --- a/src/pvm2sdp/CMakeLists.txt +++ b/src/pvm2sdp/CMakeLists.txt @@ -13,4 +13,5 @@ target_link_libraries(pvm2sdp Boost::stacktrace_noop dl sdpb_util - pmp_read) \ No newline at end of file + pmp_read) +install(TARGETS pvm2sdp RUNTIME) \ No newline at end of file diff --git a/src/sdp2input/CMakeLists.txt b/src/sdp2input/CMakeLists.txt index 320372b1a..bfb143db5 100644 --- a/src/sdp2input/CMakeLists.txt +++ b/src/sdp2input/CMakeLists.txt @@ -13,4 +13,5 @@ target_link_libraries(sdp2input pmp pmp_read pmp2sdp_lib - sdpb_util) \ No newline at end of file + sdpb_util) +install(TARGETS sdp2input RUNTIME) \ No newline at end of file diff --git a/src/sdp_solve/CMakeLists.txt b/src/sdp_solve/CMakeLists.txt index b116d3cc2..d4f5419f3 100644 --- a/src/sdp_solve/CMakeLists.txt +++ b/src/sdp_solve/CMakeLists.txt @@ -67,4 +67,5 @@ target_link_libraries(sdp_solve Boost::program_options dl sdpb_util - pmp2sdp_lib) \ No newline at end of file + pmp2sdp_lib) +install(TARGETS sdp_solve LIBRARY) \ No newline at end of file diff --git a/src/sdpb/CMakeLists.txt b/src/sdpb/CMakeLists.txt index 3923928a7..6b9c2c563 100644 --- a/src/sdpb/CMakeLists.txt +++ b/src/sdpb/CMakeLists.txt @@ -13,4 +13,5 @@ target_link_libraries(sdpb ${USE_PACKAGES} Boost::serialization sdpb_util - sdp_solve) \ No newline at end of file + sdp_solve) +install(TARGETS sdpb RUNTIME) \ No newline at end of file diff --git a/src/sdpb_util/CMakeLists.txt b/src/sdpb_util/CMakeLists.txt index d46aba571..6bac062ce 100644 --- a/src/sdpb_util/CMakeLists.txt +++ b/src/sdpb_util/CMakeLists.txt @@ -9,3 +9,4 @@ target_sources(sdpb_util Timers/Timer.cxx Timers/Timers.cxx) target_link_libraries(sdpb_util PUBLIC ${GMPXX_LIBRARIES} Boost::iostreams Boost::serialization Boost::filesystem ${Elemental_LIBRARIES}) +install(TARGETS sdpb_util LIBRARY) \ No newline at end of file diff --git a/src/spectrum/CMakeLists.txt b/src/spectrum/CMakeLists.txt index da82857e1..6229b7294 100644 --- a/src/spectrum/CMakeLists.txt +++ b/src/spectrum/CMakeLists.txt @@ -16,4 +16,5 @@ target_link_libraries(spectrum pmp_read sdp_solve pmp2sdp_lib - sdpb_util) \ No newline at end of file + sdpb_util) +install(TARGETS spectrum RUNTIME) \ No newline at end of file From 09a198a270540c8fc6f8aeccd1d471a70897e5df Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Thu, 7 Mar 2024 23:15:11 +0100 Subject: [PATCH 13/20] Added _GNU_SOURCE compile definition for macs Avoids issue with boost/stacktrace when building on macOS. See https://github.com/boostorg/stacktrace/issues/88 and comments therein. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index df4eb3a14..0fc2590fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,11 @@ if(UNIX) set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) endif() +# Specific definition for an issue with boost/stacktrace when building on macOS. See https://github.com/boostorg/stacktrace/issues/88 and comments therein. +if(APPLE) + add_compile_definitions(_GNU_SOURCE) +endif() + # cxx 17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) From 1222b893a316c0365c8aef796c69bd06e255a8d0 Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Thu, 7 Mar 2024 23:17:42 +0100 Subject: [PATCH 14/20] Added custom solution for Elemental for Docker The Docker image bootstrapcollaboration/elemental:master does not come with ElementalConfig.cmake, thus custom solution needed --- CMakeLists.txt | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fc2590fd..bffd52109 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,29 +183,29 @@ include(FeatureSummary) # Elemental # --------- -find_package(Elemental REQUIRED) -# find_path(Elemental_INCLUDES El.hpp -# PATHS /usr/include /usr/local/include ${CMAKE_PREFIX_PATH} -# ) - -# find_library(Elemental_LIBRARIES El -# PATHS /usr/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH} -# ) - -# if (Elemental_INCLUDES AND Elemental_LIBRARIES) -# set(Elemental_FOUND TRUE) -# endif () - -# if (Elemental_FOUND) -# if (NOT Elemental_FIND_QUIETLY) -# message(STATUS "Found El: ${Elemental_LIBRARIES}") -# endif () -# else () -# if (Elemental_FIND_REQUIRED) -# message(FATAL_ERROR "Could not find Elemental") -# endif () -# endif () -# mark_as_advanced(Elemental_INCLUDES Elemental_LIBRARIES) +find_package(Elemental QUIET) +find_path(Elemental_INCLUDES El.hpp + PATHS /usr/include /usr/local/include ${Elemental_DIR} +) + +find_library(Elemental_LIBRARIES El + PATHS /usr/lib /usr/local/lib ${Elemental_DIR} +) + +if (Elemental_INCLUDES AND Elemental_LIBRARIES) + set(Elemental_FOUND TRUE) +endif () + +if (Elemental_FOUND) + if (NOT Elemental_FIND_QUIETLY) + message(STATUS "Found El: ${Elemental_LIBRARIES}") + endif () +else () + if (Elemental_FIND_REQUIRED) + message(FATAL_ERROR "Could not find Elemental") + endif () +endif () +mark_as_advanced(Elemental_INCLUDES Elemental_LIBRARIES) if(Elemental_FOUND AND Elemental_INCLUDE_DIRS) include_directories(${Elemental_INCLUDE_DIRS}) @@ -214,8 +214,8 @@ endif() message(STATUS "El version: ${Elemental_VERSION}") message(STATUS "Found Elemental: ${Elemental_LIBRARIES}") # find_library(El El PATHS ${Elemental_DIR} REQUIRED) -find_library(PMRRR_LIBRARIES pmrrr PATHS ${Elemental_DIR}/external/pmrrr REQUIRED) -find_library(ELSUITESPARSE_LIBRARIES ElSuiteSparse PATHS ${Elemental_DIR}/external/suite_sparse REQUIRED) +find_library(PMRRR_LIBRARIES pmrrr PATHS ${Elemental_DIR} ${Elemental_DIR}/external/pmrrr REQUIRED) +find_library(ELSUITESPARSE_LIBRARIES ElSuiteSparse PATHS ${Elemental_DIR} ${Elemental_DIR}/external/suite_sparse REQUIRED) list(APPEND Elemental_LIBRARIES ${PMRRR_LIBRARIES}) list(APPEND Elemental_LIBRARIES ${ELSUITESPARSE_LIBRARIES}) message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") From 56032d574663b535cf0155b09ec3a6d77ba033d6 Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Thu, 7 Mar 2024 23:19:00 +0100 Subject: [PATCH 15/20] Added Docker targets cmake-build, cmake-install, and (non-functional) cmake-test --- Dockerfile | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/Dockerfile b/Dockerfile index bef857e02..140a7df32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,9 @@ # # Note: 'mpirun --oversubscribe' is necessary only if your environment has less than 6 CPUs available +# Build using waf +# --------------- + # Elemental binaries built from https://gitlab.com/bootstrapcollaboration/elemental.git # based on the same alpine:3.18 build as below FROM bootstrapcollaboration/elemental:master AS build @@ -94,6 +97,87 @@ COPY --from=build /usr/local/src/sdpb/test test RUN chown -R testuser test USER testuser:testgroup +# Build using CMake +# --------------- + +# Elemental binaries built from https://gitlab.com/bootstrapcollaboration/elemental.git +# based on the same alpine:3.18 build as below +FROM bootstrapcollaboration/elemental:master AS cmake-build + +RUN apk add \ + binutils \ + cmake \ + g++ \ + git \ + make \ + python3 \ + unzip \ + boost-dev \ + gmp-dev \ + libarchive-dev \ + libxml2-dev \ + mpfr-dev \ + openblas-dev \ + openmpi \ + openmpi-dev \ + rapidjson-dev +WORKDIR /usr/local/src/sdpb +# Build SDPB from current sources, print build/config.log in configuration failed +COPY . . +# RUN ls /usr/local/ \ +# ls /usr/local/lib \ +# ls /usr/local/bin \ +# ls /usr/local/include \ +# ls /usr/local/share +RUN mkdir -p build && cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local && \ + make -j`nproc` && make install + + +# Take only sdpb binaries + load necessary dynamic libraries +# Unfortunately, boost1.82-stacktrace_addr2line does not exist as a standalone package in Alpine Linux repo. +# Thus we have to load the whole boost-dev (~180MB extra) +# TODO: for some reason, function names and source locations are not printed in stacktrace. +# FIXME: Platform declaration required for the image on run on M series processors on MacBooks. Come up with a solution +FROM --platform=linux/amd64 alpine:3.18 as cmake-install +RUN apk add \ + binutils \ + boost-dev \ + boost1.82-date_time \ + boost1.82-filesystem \ + boost1.82-iostreams \ + boost1.82-program_options \ + boost1.82-serialization \ + boost1.82-system \ + gmp \ + libarchive \ + libgmpxx \ + libstdc++ \ + libxml2 \ + mpfr \ + openblas \ + openmpi \ + openssh +COPY --from=cmake-build /usr/local/bin /usr/local/bin +COPY --from=cmake-build /usr/local/lib /usr/local/lib + +# Separate test target, see +# https://docs.docker.com/language/java/run-tests/#multi-stage-dockerfile-for-testing +# Contains /home/testuser/sdpb/build and /home/testuser/sdpb/test folders, +# which is sufficient to run tests as shown below: +# +# docker build -t sdpb-test --target test +# docker run sdpb-test ./test/run_all_tests.sh mpirun --oversubscribe +FROM cmake-install as cmake-test +# Create testuser to run Docker non-root (and avoid 'mpirun --allow-run-as-root' warning) +RUN addgroup --gid 10000 testgroup && \ + adduser --disabled-password --uid 10000 --ingroup testgroup --shell /bin/sh testuser +WORKDIR /home/testuser/sdpb +COPY --from=cmake-build /usr/local/src/sdpb/build build +COPY --from=cmake-build /usr/local/src/sdpb/test test +RUN chown -R testuser test +USER testuser:testgroup + # Resulting image FROM install # TODO best practices suggest to run containter as non-root. From 87c6a0919a81d1286b86e246d02b1a8e7d014e0b Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Mon, 11 Mar 2024 18:44:36 +0100 Subject: [PATCH 16/20] Set up release and debug build types. Reorder git handling --- CMakeLists.txt | 98 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bffd52109..ab8e98a65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,52 @@ message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") # TODO gnu_dirs +# TODO Refactor into a separate file for Git (see Elemental for example) +# conf.env.git_version=subprocess.check_output('git describe --dirty', universal_newlines=True, shell=True).rstrip() +find_package(Git QUIET REQUIRED) +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/.git") + message(FATAL_ERROR "${PROJECT_SOURCE_DIR}/.git not found") +endif() +execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --dirty + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_DESCRIBE_RESULT + OUTPUT_VARIABLE SDPB_VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT GIT_DESCRIBE_RESULT EQUAL "0") + message(FATAL_ERROR "git describe --always --dirty failed: ${GIT_DESCRIBE_RESULT}.") +endif() + +# Compiler flags used in waf +#def build(bld): +# default_flags=['-Wall', '-Wextra', '-O3', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] +# # default_flags=['-Wall', '-Wextra', '-O3', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] +# # default_flags=['-Wall', '-Wextra', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] + +# TODO -Werror=return-type, but it requires to mark El::RuntimeError as [[noreturn]] + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + # This option is okay as-is + set(CMAKE_BUILD_TYPE Release) +elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") + # This option is okay as-is + set(CMAKE_BUILD_TYPE Debug) +else() + message(WARNING "Build mode not specified, defaulting to Release build.") + set(CMAKE_BUILD_TYPE Release) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(SDPB_RELEASE TRUE) + add_compile_options(-O3 -DOMPI_SKIP_MPICXX) +else() + set(SDPB_RELEASE FALSE) + add_compile_options(-Wall -Wextra -g -DOMPI_SKIP_MPICXX) +endif() +string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) + +add_compile_definitions(SDPB_VERSION_STRING="${SDPB_VERSION_STRING}") +add_compile_definitions(RAPIDJSON_HAS_STDSTRING=1) + ################################################## ########### Find required dependencies ########### ################################################## @@ -122,58 +168,6 @@ endif() find_package(MPI REQUIRED) message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS") -# TODO Refactor into a separate file for Git (see Elemental for example) -# conf.env.git_version=subprocess.check_output('git describe --dirty', universal_newlines=True, shell=True).rstrip() -find_package(Git QUIET REQUIRED) -if(NOT EXISTS "${PROJECT_SOURCE_DIR}/.git") - message(FATAL_ERROR "${PROJECT_SOURCE_DIR}/.git not found") -endif() -execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --dirty - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE GIT_DESCRIBE_RESULT - OUTPUT_VARIABLE SDPB_VERSION_STRING - OUTPUT_STRIP_TRAILING_WHITESPACE) -if(NOT GIT_DESCRIBE_RESULT EQUAL "0") - message(FATAL_ERROR "git describe --always --dirty failed: ${GIT_DESCRIBE_RESULT}.") -endif() - -#def build(bld): -# default_flags=['-Wall', '-Wextra', '-O3', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] -# # default_flags=['-Wall', '-Wextra', '-O3', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] -# # default_flags=['-Wall', '-Wextra', '-g', '-DOMPI_SKIP_MPICXX', '-D SDPB_VERSION_STRING="' + bld.env.git_version + '"'] - -#TODO -O3 etc is set by choosing cmake debug/release -# TODO -Werror=return-type, but it requires to mark El::RuntimeError as [[noreturn]] -add_compile_options(-Wall -Wextra -DOMPI_SKIP_MPICXX) -add_compile_definitions(SDPB_VERSION_STRING="${SDPB_VERSION_STRING}") -add_compile_definitions(RAPIDJSON_HAS_STDSTRING=1) - -# TODO setup flags for build configurations (debug/release) - -if(CMAKE_BUILD_TYPE STREQUAL "Release") - # This option is okay as-is - set(CMAKE_BUILD_TYPE Release) -elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") - # This option is okay as-is - set(CMAKE_BUILD_TYPE Debug) -else() - message(WARNING "Build mode not specified, defaulting to Release build.") - set(CMAKE_BUILD_TYPE Release) -endif() - -if(CMAKE_BUILD_TYPE STREQUAL "Release") - set(SDPB_RELEASE TRUE) -else() - set(SDPB_RELEASE FALSE) -endif() -string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) - - -# use_packages=['cxx17','boost','gmpxx','mpfr','elemental','libxml2', 'rapidjson', 'libarchive'] -#TODO - -# set(CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH /usr/local/lib) -# message("CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}") include(FeatureSummary) From 9baff5eee14954ddcf9ddd608b1a618fb97709ad Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Mon, 11 Mar 2024 18:46:18 +0100 Subject: [PATCH 17/20] Comment out CBLAS, remove unnecessary backtrace, clean up comments CBLAS commented out because it is not necessary for the current set of build sources. Will be required later, together with FLINT, for the implementation of Chinese remainder theorem --- CMakeLists.txt | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab8e98a65..ccd6a9e9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,6 @@ find_package(MPFR REQUIRED) # Boost # ----- -# TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(Boost REQUIRED COMPONENTS @@ -117,7 +116,6 @@ find_package(Boost iostreams serialization stacktrace_basic - stacktrace_backtrace stacktrace_addr2line stacktrace_noop REQUIRED) @@ -131,7 +129,6 @@ endif() # libxml2 # ------- -# TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(LibXml2 REQUIRED) message(STATUS "libxml2 version: ${LIBXML2_VERSION} at ${LIBXML2_DIRECTORY}") if(LIBXML2_FOUND AND LIBXML2_INCLUDE_DIR) @@ -141,7 +138,6 @@ endif() # RapidJSON # --------- -# TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(RapidJSON REQUIRED) message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") if(RapidJSON_FOUND AND RapidJSON_INCLUDE_DIR) @@ -151,7 +147,6 @@ endif() # libarchive # ---------- -# TODO Change pkg_check_modules to a solution where you use find_path and find_library find_package(LibArchive REQUIRED) message(STATUS "libarchive version: ${libarchive_VERSION}") if(LibArchive_FOUND AND LibArchive_INCLUDE_DIR) @@ -171,10 +166,6 @@ message(STATUS "Run: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} include(FeatureSummary) -#find_library() -# TODO use target_link_libraries -#link_libraries(cxx17 boost gmpxx mpfr elemental libxml2 rapidjson libarchive) - # Elemental # --------- find_package(Elemental QUIET) @@ -219,24 +210,24 @@ message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") #find_library(FLINT_LIBRARIES flint PATHS /home/vasdommes/install/lib) # From FLINT - FindCBLAS -find_path(CBLAS_INCLUDE_DIRS NAMES cblas.h - HINTS CBLAS_ROOT ENV CBLAS_ROOT - PATHS ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/include - PATH_SUFFIXES openblas cblas blis -) - -find_library(CBLAS_LIBRARIES NAMES accelerate openblas cblas blas blis - HINTS CBLAS_ROOT ENV CBLAS_ROOT - PATHS ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/lib - PATH_SUFFIXES openblas cblas blis -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CBLAS - "Could NOT find a BLAS compatible library or 'cblas.h', install BLAS or set CBLAS_ROOT." - CBLAS_INCLUDE_DIRS CBLAS_LIBRARIES) - -mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) +# find_path(CBLAS_INCLUDE_DIRS NAMES cblas.h +# HINTS CBLAS_ROOT ENV CBLAS_ROOT +# PATHS ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/include +# PATH_SUFFIXES openblas cblas blis +# ) + +# find_library(CBLAS_LIBRARIES NAMES accelerate openblas cblas blas blis +# HINTS CBLAS_ROOT ENV CBLAS_ROOT +# PATHS ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/lib +# PATH_SUFFIXES openblas cblas blis +# ) + +# include(FindPackageHandleStandardArgs) +# find_package_handle_standard_args(CBLAS +# "Could NOT find a BLAS compatible library or 'cblas.h', install BLAS or set CBLAS_ROOT." +# CBLAS_INCLUDE_DIRS CBLAS_LIBRARIES) + +# mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) include_directories(src) From f599a086c7349baa168d676bec6a3201c5a9361a Mon Sep 17 00:00:00 2001 From: Bharath Radhakrishnan Date: Sat, 16 Mar 2024 14:24:32 +0100 Subject: [PATCH 18/20] Tests build now. WIP - Dependence on Catch2 unclear --- CMakeLists.txt | 71 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd6a9e9b..25bcc4876 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,7 @@ message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") # mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) +# find_package(Catch2 REQUIRED) include_directories(src) include_directories(external) @@ -285,26 +286,31 @@ add_subdirectory(src/approx_objective) add_subdirectory(src/spectrum) -# add_executable(integration_tests) -# target_sources(integration_tests -# PRIVATE -# external/catch2/catch_amalgamated.cpp -# test/src/integration_tests/main.cxx -# test/src/integration_tests/util/Float.cxx -# test/src/integration_tests/util/diff_outer_limits.cxx -# test/src/integration_tests/util/diff_sdp.cxx -# test/src/integration_tests/util/diff_sdpb_out.cxx -# test/src/integration_tests/util/diff_spectrum.cxx -# test/src/integration_tests/util/Test_Case_Runner.cxx -# test/src/integration_tests/cases/end-to-end.test.cxx -# test/src/integration_tests/cases/outer_limits.test.cxx -# test/src/integration_tests/cases/pmp2sdp.test.cxx -# test/src/integration_tests/cases/sdpb.test.cxx) -# target_link_libraries(integration_tests -# PRIVATE -# ${USE_PACKAGES} -# Boost::serialization) -# target_include_directories(integration_tests PRIVATE test/src) +add_compile_definitions(CATCH_AMALGAMATED_CUSTOM_MAIN) + +add_executable(integration_tests) +target_sources(integration_tests + PRIVATE + external/catch2/catch_amalgamated.cpp + test/src/integration_tests/main.cxx + test/src/integration_tests/util/Float.cxx + test/src/integration_tests/util/diff_outer_limits.cxx + test/src/integration_tests/util/diff_sdp.cxx + test/src/integration_tests/util/diff_sdpb_out.cxx + test/src/integration_tests/util/diff_spectrum.cxx + test/src/integration_tests/util/Test_Case_Runner.cxx + test/src/integration_tests/cases/end-to-end.test.cxx + test/src/integration_tests/cases/outer_limits.test.cxx + test/src/integration_tests/cases/pmp2sdp.test.cxx + test/src/integration_tests/cases/sdpb.test.cxx) +target_link_libraries(integration_tests + PRIVATE + ${USE_PACKAGES} + # Catch2::Catch2 + Boost::filesystem + Boost::serialization) +target_include_directories(integration_tests PRIVATE test/src) +install(TARGETS integration_tests RUNTIME) # bld.program(source=['external/catch2/catch_amalgamated.cpp', # 'test/src/integration_tests/main.cxx', # 'test/src/integration_tests/util/Float.cxx', @@ -324,6 +330,31 @@ add_subdirectory(src/spectrum) # use=use_packages, # includes=default_includes + ['test/src'] # ) + +add_executable(unit_tests) +target_sources(unit_tests + PRIVATE + external/catch2/catch_amalgamated.cpp + test/src/unit_tests/main.cxx + test/src/unit_tests/cases/block_data_serialization.test.cxx + test/src/unit_tests/cases/block_mapping.test.cxx + test/src/unit_tests/cases/Boost_Float.test.cxx + test/src/unit_tests/cases/boost_serialization.test.cxx + test/src/unit_tests/cases/copy_matrix.test.cxx + test/src/unit_tests/cases/json.test.cxx + test/src/unit_tests/cases/shared_window.test.cxx) +target_link_libraries(unit_tests + PRIVATE + ${USE_PACKAGES} + # Catch2::Catch2 + Boost::filesystem + Boost::serialization + sdpb_util + pmp2sdp_lib + sdp_solve) +target_include_directories(unit_tests PRIVATE test/src) +install(TARGETS unit_tests RUNTIME) + # bld.program(source=['external/catch2/catch_amalgamated.cpp', # 'test/src/unit_tests/main.cxx', # 'test/src/unit_tests/cases/block_data_serialization.test.cxx', From a6b3c2c1a93a9471194375b708a56d8478f5af28 Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Wed, 20 Mar 2024 16:15:20 +0100 Subject: [PATCH 19/20] Resolve linker and pthreads issues. Update paths to binaries --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++------------- test/run_all_tests.sh | 4 ++-- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25bcc4876..c029688a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,13 +28,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # compiler_cxx # TODO -if(DEFINED (ENV{CXX})) - if(ENV{CXX} == "g++" || ENV{CXX} == "icpc") - SET(CMAKE_CXX_COMPILER mpicxx) - endif() -else() - SET(CMAKE_CXX_COMPILER mpicxx) -endif() +# if(DEFINED (ENV{CXX})) +# if(ENV{CXX} == "g++" || ENV{CXX} == "icpc") +# SET(CMAKE_CXX_COMPILER mpicxx) +# endif() +# else() +# SET(CMAKE_CXX_COMPILER mpicxx) +# endif() message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") @@ -76,10 +76,10 @@ endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") set(SDPB_RELEASE TRUE) - add_compile_options(-O3 -DOMPI_SKIP_MPICXX) + add_compile_options(-O3 -DOMPI_SKIP_MPICXX -pthread) else() set(SDPB_RELEASE FALSE) - add_compile_options(-Wall -Wextra -g -DOMPI_SKIP_MPICXX) + add_compile_options(-Wall -Wextra -g -DOMPI_SKIP_MPICXX -pthread) endif() string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) @@ -118,6 +118,7 @@ find_package(Boost stacktrace_basic stacktrace_addr2line stacktrace_noop + thread REQUIRED) message(STATUS "Boost version: ${Boost_VERSION}") if(Boost_FOUND AND Boost_INCLUDE_DIR) @@ -229,7 +230,18 @@ message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") # mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) -# find_package(Catch2 REQUIRED) +find_package(Catch2 QUIET) +if(NOT Catch2_FOUND) + Include(FetchContent) + + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.5.3 # or a later release + ) + + FetchContent_MakeAvailable(Catch2) +endif() include_directories(src) include_directories(external) @@ -306,9 +318,11 @@ target_sources(integration_tests target_link_libraries(integration_tests PRIVATE ${USE_PACKAGES} - # Catch2::Catch2 + Catch2::Catch2 Boost::filesystem - Boost::serialization) + Boost::serialization + pthread + dl) target_include_directories(integration_tests PRIVATE test/src) install(TARGETS integration_tests RUNTIME) # bld.program(source=['external/catch2/catch_amalgamated.cpp', @@ -351,7 +365,8 @@ target_link_libraries(unit_tests Boost::serialization sdpb_util pmp2sdp_lib - sdp_solve) + sdp_solve + pthread) target_include_directories(unit_tests PRIVATE test/src) install(TARGETS unit_tests RUNTIME) diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index 541095feb..3cb5f3a14 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -28,11 +28,11 @@ fi # https://github.com/catchorg/Catch2/blob/devel/docs/command-line.md # unit_tests: run 2 processes -echo time $MPI_RUN_COMMAND -n 2 ./build/unit_tests --durations yes +echo time $MPI_RUN_COMMAND -n 2 ./build/bin/unit_tests --durations yes time $MPI_RUN_COMMAND -n 2 ./build/unit_tests --durations yes || { exit $?; } # integration_tests -echo time ./build/integration_tests --durations yes --mpirun="$MPI_RUN_COMMAND" +echo time ./build/bin/integration_tests --durations yes --mpirun="$MPI_RUN_COMMAND" time ./build/integration_tests --durations yes --mpirun="$MPI_RUN_COMMAND" || { exit $?; } echo "$0: ALL TESTS PASSED" \ No newline at end of file From 4f652ef28e229d4fb3c4feed96f38a4fb07390ac Mon Sep 17 00:00:00 2001 From: Bharathkumar Radhakrishnan Date: Mon, 17 Jun 2024 11:37:01 +0200 Subject: [PATCH 20/20] Cleanup of paths to match with upstream changes --- CMakeLists.txt | 38 ++++++++++++++--------------------- cmake/modules/FindGMPXX.cmake | 1 - cmake/modules/FindMPFR.cmake | 4 ++-- src/sdp_solve/CMakeLists.txt | 22 ++++++++++++++++---- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c029688a1..93c16ee16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ include(CustomMessages) # This is to ensure that CMake also checks lib64 for the dependencies on Linux systems if(UNIX) - set(CMAKE_PREFIX_PATH "/usr/lib64" ${CMAKE_PREFIX_PATH}) + list(APPEND CMAKE_PREFIX_PATH "/usr/lib64") endif() # Specific definition for an issue with boost/stacktrace when building on macOS. See https://github.com/boostorg/stacktrace/issues/88 and comments therein. @@ -28,13 +28,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # compiler_cxx # TODO -# if(DEFINED (ENV{CXX})) -# if(ENV{CXX} == "g++" || ENV{CXX} == "icpc") -# SET(CMAKE_CXX_COMPILER mpicxx) -# endif() -# else() -# SET(CMAKE_CXX_COMPILER mpicxx) -# endif() +if(DEFINED (ENV{CXX})) + if(ENV{CXX} == "g++" || ENV{CXX} == "icpc") + SET(CMAKE_CXX_COMPILER mpicxx) + endif() +else() + SET(CMAKE_CXX_COMPILER mpicxx) +endif() message(STATUS "Found g++ compiler (C++ compiler): ${CMAKE_CXX_COMPILER}") @@ -154,6 +154,13 @@ if(LibArchive_FOUND AND LibArchive_INCLUDE_DIR) include_directories(${LibArchive_INCLUDE_DIR}) endif() +find_package(BLAS REQUIRED) +message(STATUS "BLAS version: ${libarchive_VERSION}") +if(BLAS_FOUND AND BLAS_INCLUDE_DIR) + include_directories(${BLAS_INCLUDE_DIR}) +endif() + +find_package(FLINT REQUIRED) #def configure(conf): # if not 'CXX' in os.environ or os.environ['CXX']=='g++' or os.environ['CXX']=='icpc': @@ -230,19 +237,6 @@ message(STATUS "Elemental Libraries - ${Elemental_LIBRARIES}") # mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS) -find_package(Catch2 QUIET) -if(NOT Catch2_FOUND) - Include(FetchContent) - - FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.5.3 # or a later release - ) - - FetchContent_MakeAvailable(Catch2) -endif() - include_directories(src) include_directories(external) include_directories(SYSTEM elemental/install/include) @@ -318,7 +312,6 @@ target_sources(integration_tests target_link_libraries(integration_tests PRIVATE ${USE_PACKAGES} - Catch2::Catch2 Boost::filesystem Boost::serialization pthread @@ -360,7 +353,6 @@ target_sources(unit_tests target_link_libraries(unit_tests PRIVATE ${USE_PACKAGES} - # Catch2::Catch2 Boost::filesystem Boost::serialization sdpb_util diff --git a/cmake/modules/FindGMPXX.cmake b/cmake/modules/FindGMPXX.cmake index 40f95a300..03a23a8a4 100644 --- a/cmake/modules/FindGMPXX.cmake +++ b/cmake/modules/FindGMPXX.cmake @@ -7,7 +7,6 @@ find_library(GMPXX_LIBRARIES gmpxx PATHS $ENV{GMPXXDIR} $ENV{GMPXX_HOME} $ENV{GMPXX_LIB} $ENV{GMPDIR} $ENV{GMP_HOME} $ENV{GMP_LIB} ${LIB_INSTALL_DIR} ) - include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GMPXX DEFAULT_MSG GMPXX_INCLUDE_DIR GMPXX_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindMPFR.cmake b/cmake/modules/FindMPFR.cmake index 408302803..64b79cacf 100644 --- a/cmake/modules/FindMPFR.cmake +++ b/cmake/modules/FindMPFR.cmake @@ -1,11 +1,11 @@ set(MPFR_FIND_REQUIRED) find_path(MPFR_INCLUDE_DIR mpfr.h - PATHS ${GMPDIR} ${MPFRDIR} ${INCLUDE_INSTALL_DIR} + PATHS $ENV{GMPDIR} $ENV{MPFRDIR} ${INCLUDE_INSTALL_DIR} ) find_library(MPFR_LIBRARIES mpfr - PATHS ${GMPDIR} ${MPFRDIR} ${INCLUDE_INSTALL_DIR} + PATHS $ENV{GMPDIR} $ENV{MPFRDIR} ${INCLUDE_INSTALL_DIR} ) include(FindPackageHandleStandardArgs) diff --git a/src/sdp_solve/CMakeLists.txt b/src/sdp_solve/CMakeLists.txt index d4f5419f3..4fae810b9 100644 --- a/src/sdp_solve/CMakeLists.txt +++ b/src/sdp_solve/CMakeLists.txt @@ -39,8 +39,21 @@ target_sources(sdp_solve SDP_Solver/run/step/step.cxx SDP_Solver/run/step/initialize_schur_complement_solver/initialize_schur_complement_solver.cxx SDP_Solver/run/step/initialize_schur_complement_solver/compute_schur_complement.cxx - SDP_Solver/run/step/initialize_schur_complement_solver/initialize_Q_group.cxx - SDP_Solver/run/step/initialize_schur_complement_solver/synchronize_Q.cxx + SDP_Solver/run/step/initialize_schur_complement_solver/compute_Q.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/BigInt_Shared_Memory_Syrk_Context.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/bigint_syrk_blas.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/clear_residues.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/compute_block_residues.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/get_blas_job_schedule.cxx + SDP_Solver/run/bigint_syrk/BigInt_Shared_Memory_Syrk_Context/restore_and_reduce.cxx + SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job.cxx + SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job_Cost.cxx + SDP_Solver/run/bigint_syrk/blas_jobs/Blas_Job_Schedule.cxx + SDP_Solver/run/bigint_syrk/blas_jobs/create_blas_job_schedule.cxx + SDP_Solver/run/bigint_syrk/fmpz/Fmpz_BigInt.cxx + SDP_Solver/run/bigint_syrk/fmpz/Fmpz_Matrix.cxx + SDP_Solver/run/bigint_syrk/fmpz/Fmpz_Comb.cxx + SDP_Solver/run/bigint_syrk/Matrix_Normalizer.cxx SDP_Solver/run/step/compute_search_direction/compute_search_direction.cxx SDP_Solver/run/step/compute_search_direction/cholesky_solve.cxx SDP_Solver/run/step/compute_search_direction/compute_schur_RHS.cxx @@ -56,7 +69,7 @@ target_sources(sdp_solve SDP_Solver_Terminate_Reason/ostream.cxx lower_triangular_transpose_solve.cxx Block_Diagonal_Matrix/ostream.cxx - Write_Solution.cxx) + Write_Solution.cxx) target_link_libraries(sdp_solve PRIVATE ${USE_PACKAGES} @@ -67,5 +80,6 @@ target_link_libraries(sdp_solve Boost::program_options dl sdpb_util - pmp2sdp_lib) + pmp2sdp_lib + BLAS::BLAS) install(TARGETS sdp_solve LIBRARY) \ No newline at end of file