diff --git a/.gitignore b/.gitignore index a9998d24..239d7dda 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ __pycache__/ /waf-tools/*.pyc # cmake +cmake-build*/ +build/ /cmake-build*/ # IDE diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..93c16ee1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,379 @@ +# 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") + +# Custom colour scheme for logging +include(CustomMessages) + +# This is to ensure that CMake also checks lib64 for the dependencies on Linux systems +if(UNIX) + 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. +if(APPLE) + add_compile_definitions(_GNU_SOURCE) +endif() + +# cxx 17 +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +#set(CMAKE_CXX_EXTENSIONS OFF) + +# 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(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 -pthread) +else() + set(SDPB_RELEASE FALSE) + add_compile_options(-Wall -Wextra -g -DOMPI_SKIP_MPICXX -pthread) +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 ########### +################################################## + +# include(FindPkgConfig) +# find_package(PkgConfig REQUIRED) + +# GMP and GMPXX +# ------------- +find_package(GMP REQUIRED) + +find_package(GMPXX REQUIRED) + +# MPFR +# ---- +find_package(MPFR REQUIRED) + + +# Boost +# ----- + +find_package(Boost + REQUIRED COMPONENTS + system + filesystem + date_time + program_options + iostreams + serialization + stacktrace_basic + stacktrace_addr2line + stacktrace_noop + thread + REQUIRED) +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 +# ------- +find_package(LibXml2 REQUIRED) +message(STATUS "libxml2 version: ${LIBXML2_VERSION} at ${LIBXML2_DIRECTORY}") +if(LIBXML2_FOUND AND LIBXML2_INCLUDE_DIR) + include_directories(${LIBXML2_INCLUDE_DIR}) +endif() + + +# RapidJSON +# --------- +find_package(RapidJSON REQUIRED) +message(STATUS "RapidJSON version: ${RapidJSON_VERSION}") +if(RapidJSON_FOUND AND RapidJSON_INCLUDE_DIR) + include_directories(${RapidJSON_INCLUDE_DIR}) +endif() + + +# libarchive +# ---------- +find_package(LibArchive REQUIRED) +message(STATUS "libarchive version: ${libarchive_VERSION}") +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': +# 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") + + +include(FeatureSummary) + +# Elemental +# --------- +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}) +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} ${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}") + +# 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) + +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) + install(TARGETS pmp2sdp RUNTIME) + +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_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} + Boost::filesystem + 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', +# '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'] +# ) + +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} + Boost::filesystem + Boost::serialization + sdpb_util + pmp2sdp_lib + sdp_solve + pthread) +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', +# '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/Dockerfile b/Dockerfile index f9233b2f..5c4749c4 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 @@ -102,6 +105,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. diff --git a/cmake/CustomMessages.cmake b/cmake/CustomMessages.cmake new file mode 100644 index 00000000..08039be2 --- /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 diff --git a/cmake/modules/FindFLINT.cmake b/cmake/modules/FindFLINT.cmake new file mode 100644 index 00000000..3363de61 --- /dev/null +++ b/cmake/modules/FindFLINT.cmake @@ -0,0 +1,13 @@ +set(FLINT_FIND_REQUIRED) + +find_path(FLINT_INCLUDE_DIR flint/flint.h flint/fmpz.h flint/nmod.h flint/nmod_vec.h flint/fmpz_mat.h + PATHS $ENV{CPATH} $ENV{GMPDIR} $ENV{MPFRDIR} ${INCLUDE_INSTALL_DIR} +) + +find_library(FLINT_LIBRARIES flint + PATHS $ENV{LIBRARY_PATH} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FLINT DEFAULT_MSG + FLINT_INCLUDE_DIR FLINT_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindGMP.cmake b/cmake/modules/FindGMP.cmake new file mode 100644 index 00000000..ac755912 --- /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 00000000..03a23a8a --- /dev/null +++ b/cmake/modules/FindGMPXX.cmake @@ -0,0 +1,12 @@ +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 00000000..64b79cac --- /dev/null +++ b/cmake/modules/FindMPFR.cmake @@ -0,0 +1,13 @@ +set(MPFR_FIND_REQUIRED) + +find_path(MPFR_INCLUDE_DIR mpfr.h + PATHS $ENV{GMPDIR} $ENV{MPFRDIR} ${INCLUDE_INSTALL_DIR} +) + +find_library(MPFR_LIBRARIES mpfr + PATHS $ENV{GMPDIR} $ENV{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 diff --git a/src/approx_objective/CMakeLists.txt b/src/approx_objective/CMakeLists.txt new file mode 100644 index 00000000..28036f83 --- /dev/null +++ b/src/approx_objective/CMakeLists.txt @@ -0,0 +1,19 @@ +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) +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 new file mode 100644 index 00000000..9bc8e6fa --- /dev/null +++ b/src/outer_limits/CMakeLists.txt @@ -0,0 +1,28 @@ +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) +install(TARGETS outer_limits RUNTIME) \ No newline at end of file diff --git a/src/pmp/CMakeLists.txt b/src/pmp/CMakeLists.txt new file mode 100644 index 00000000..4e9ca72a --- /dev/null +++ b/src/pmp/CMakeLists.txt @@ -0,0 +1,16 @@ +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}) +install(TARGETS pmp LIBRARY) \ No newline at end of file diff --git a/src/pmp2functions/CMakeLists.txt b/src/pmp2functions/CMakeLists.txt new file mode 100644 index 00000000..1826dcf3 --- /dev/null +++ b/src/pmp2functions/CMakeLists.txt @@ -0,0 +1,18 @@ +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) +install(TARGETS pmp2functions RUNTIME) \ No newline at end of file diff --git a/src/pmp2sdp/CMakeLists.txt b/src/pmp2sdp/CMakeLists.txt new file mode 100644 index 00000000..0c4207da --- /dev/null +++ b/src/pmp2sdp/CMakeLists.txt @@ -0,0 +1,23 @@ +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} + 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 new file mode 100644 index 00000000..ae2cc45e --- /dev/null +++ b/src/pmp_read/CMakeLists.txt @@ -0,0 +1,22 @@ +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) +install(TARGETS pmp_read LIBRARY) \ No newline at end of file diff --git a/src/pvm2sdp/CMakeLists.txt b/src/pvm2sdp/CMakeLists.txt new file mode 100644 index 00000000..6f6887cd --- /dev/null +++ b/src/pvm2sdp/CMakeLists.txt @@ -0,0 +1,17 @@ +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) +install(TARGETS pvm2sdp RUNTIME) \ No newline at end of file diff --git a/src/sdp2input/CMakeLists.txt b/src/sdp2input/CMakeLists.txt new file mode 100644 index 00000000..bfb143db --- /dev/null +++ b/src/sdp2input/CMakeLists.txt @@ -0,0 +1,17 @@ +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) +install(TARGETS sdp2input RUNTIME) \ 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 00000000..4fae810b --- /dev/null +++ b/src/sdp_solve/CMakeLists.txt @@ -0,0 +1,85 @@ +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/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 + 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 + BLAS::BLAS) +install(TARGETS sdp_solve LIBRARY) \ No newline at end of file diff --git a/src/sdpb/CMakeLists.txt b/src/sdpb/CMakeLists.txt new file mode 100644 index 00000000..6b9c2c56 --- /dev/null +++ b/src/sdpb/CMakeLists.txt @@ -0,0 +1,17 @@ +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) +install(TARGETS sdpb RUNTIME) \ 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 00000000..6bac062c --- /dev/null +++ b/src/sdpb_util/CMakeLists.txt @@ -0,0 +1,12 @@ +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}) +install(TARGETS sdpb_util LIBRARY) \ No newline at end of file diff --git a/src/spectrum/CMakeLists.txt b/src/spectrum/CMakeLists.txt new file mode 100644 index 00000000..6229b729 --- /dev/null +++ b/src/spectrum/CMakeLists.txt @@ -0,0 +1,20 @@ +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) +install(TARGETS spectrum RUNTIME) \ No newline at end of file diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index 988747da..f7bfc453 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -32,7 +32,7 @@ echo time $MPI_RUN_COMMAND -n 6 ./build/unit_tests --durations yes time $MPI_RUN_COMMAND -n 6 ./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 +echo "$0: ALL TESTS PASSED"