diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8c074b603..afbc93bc9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,9 +17,6 @@ env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release OMP_NUM_THREADS: 2 - CONAN_PRINT_RUN_COMMANDS: 1 - CONAN_CPU_COUNT: 2 - CONAN_SKIP_BROKEN_SYMLINKS_CHECK: 'True' jobs: build: @@ -49,11 +46,11 @@ jobs: - g++-11 - clang++ mpi: - - "on" - - "off" + - "ON" + - "OFF" omp: - - "on" - - "off" + - "ON" + - "OFF" exclude: - cc: gcc-11 cxx: clang++ @@ -76,55 +73,19 @@ jobs: cc: gcc-11 - os: macos-14 mpi: "on" + - os: macos-14 + cxx: g++-11 - cxx: clang++ omp: "on" steps: - - uses: actions/checkout@v3 - with: - submodules: recursive + - uses: actions/checkout@v4 # Enable tmate debugging of manually-triggered workflows if the input option was provided - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} - - name: Install Dependencies on Ubunutu - if: ${{ contains(matrix.os, 'ubuntu') }} - run: | - sudo apt update - sudo apt install openmpi-bin libopenmpi-dev ccache casacore-dev - pip install conan - - - name: Install Dependencies on MacOS - if: ${{ contains(matrix.os, 'macos') }} - run: | - brew install gcc libtiff open-mpi libomp libyaml ccache conan - echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV - echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH - - - name: Install Tensorflow API on Ubuntu - # TODO could this be combined with mac version somehow? if/else? - if: ${{ contains(matrix.os, 'ubuntu') }} - uses: UCL/install-tensorflow-action@main - with: - version: 2.11.0 - os: linux - - - name: Install Tensorflow API on MacOS - if: ${{ contains(matrix.os, 'macos') }} - uses: UCL/install-tensorflow-action@main - with: - version: 2.11.0 - os: darwin - - - name: Select Python 3.10 - # otherwise turtlebrowser/get-conan@v1.1 fails on macos-12 - # ref: https://github.com/turtlebrowser/get-conan/issues/4 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Prepare ccache timestamp id: ccache_cache_timestamp run: echo "{date_and_time}={$(date +'%Y-%m-%d-%H;%M;%S')}" >> $GITHUB_OUTPUT @@ -145,20 +106,70 @@ jobs: # - name: Clear ccache # run: ccache --clear - - name: Build sopt + - name: Install Dependencies on Ubunutu + if: ${{ contains(matrix.os, 'ubuntu') }} run: | - conan profile detect - conan create ${{github.workspace}}/sopt --build missing -s compiler.cppstd=17 -o dompi=${{matrix.mpi}} -o openmp=${{matrix.omp}} + sudo apt update + sudo apt install openmpi-bin libopenmpi-dev ccache graphviz libeigen3-dev libspdlog-dev libtiff-dev libcfitsio-dev libbenchmark-dev libboost-all-dev libyaml-cpp-dev - - name: Dependencies - run: conan install ${{github.workspace}} -of ${{github.workspace}}/build -s compiler.cppstd=17 --build missing -o docasa=off -o dompi=${{matrix.mpi}} -o openmp=${{matrix.omp}} + - name: Install Dependencies on MacOS + if: ${{ contains(matrix.os, 'macos') }} + run: | + brew install gcc libtiff open-mpi libomp eigen libyaml ccache cfitsio boost yaml-cpp + echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV + echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH + + - name: Checkout Catch2 + uses: actions/checkout@v4 + with: + repository: catchorg/Catch2.git + path: Catch2 + ref: v3.4.0 + + - name: Build Catch2 + run: | + mkdir Catch2/build + cd Catch2/build + cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local + make -j$(nproc --ignore 1) install + + - name: Install FFTW + run: | + wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz; + cd fftw-3.3.10 + ./configure --prefix=${{github.workspace}}/local --enable-shared + make -j$(nproc --ignore 1) install CFLAGS=-fPIC + # Fix bug in FFT3 (cf. https://github.com/FFTW/fftw3/issues/332) + sed -i -e 's/^.*FFTW3LibraryDepends.cmake.*$//1' ${{github.workspace}}/local/lib*/cmake/*/FFTW3Config.cmake + + - name: Checkout SOPT + uses: actions/checkout@v4 + with: + repository: astro-informatics/sopt.git + path: sopt + ref: development + + - name: Build sopt + run: | + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH + mkdir -p ${{github.workspace}}/sopt/build + cd ${{github.workspace}}/sopt/build + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=OFF -Dexamples=OFF + make -j$(nproc --ignore 1) install - name: Install # Build your program with the given configuration - run: conan build ${{github.workspace}} -of ${{github.workspace}}/build -s compiler.cppstd=17 -o docasa=off -o dompi=${{matrix.mpi}} -o openmp=${{matrix.omp}} + run: | + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH + mkdir -p ${{github.workspace}}/build + cd ${{github.workspace}}/build + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} + make -j$(nproc --ignore 1) install - name: Test working-directory: ${{github.workspace}}/build # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + run: | + export LD_LIBRARY_PATH=${{github.workspace}}/local/lib:${{github.workspace}}/local/external/lib:${LD_LIBRARY_PATH} + ctest -C ${{env.BUILD_TYPE}} --output-on-failure diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 3f82fa0d6..259e25345 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -7,9 +7,6 @@ on: branches: [ development ] if: github.event.pull_request.draft == false -env: - USE_CONAN: 0 - jobs: make-documentation: runs-on: ubuntu-20.04 @@ -23,52 +20,31 @@ jobs: - name: Install dependencies run: | sudo apt update - sudo apt install openmpi-bin libopenmpi-dev ccache casacore-dev doxygen graphviz - if [[ "$USE_CONAN" = 1 ]]; then - pip install conan - else - sudo apt install libeigen3-dev libspdlog-dev libtiff-dev libcfitsio-dev - sudo apt install libbenchmark-dev libboost-all-dev libyaml-cpp-dev - git clone https://github.com/catchorg/Catch2.git -b v3.4.0 - mkdir Catch2/build - cd Catch2/build - cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build - make -j$(nproc --ignore 1) install - cd - - wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz; - cd fftw-3.3.10 - ./configure --prefix=${{github.workspace}}/build --enable-shared - make -j$(nproc --ignore 1) install CFLAGS=-fPIC - # Fix bug in FFT3 (cf. https://github.com/FFTW/fftw3/issues/332) - sed -i -e 's/^.*FFTW3LibraryDepends.cmake.*$//1' ${{github.workspace}}/build/lib*/cmake/*/FFTW3Config.cmake - cd - - fi + sudo apt install openmpi-bin libopenmpi-dev ccache casacore-dev doxygen graphviz libeigen3-dev libspdlog-dev libtiff-dev libcfitsio-dev libbenchmark-dev libboost-all-dev libyaml-cpp-dev + wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz; - - name: Install Tensorflow API on Ubuntu - uses: UCL/install-tensorflow-action@main + - name: Checkout Catch2 + uses: actions/checkout@v4 with: - version: 2.11.0 - os: linux + repository: catchorg/Catch2.git + path: Catch2 + ref: v3.4.0 - - name: Checkout cppflow repo - uses: actions/checkout@v3 - with: - repository: UCL/cppflow.git - path: cppflow - ref: master + - name: Build Catch2 + run: | + mkdir Catch2/build + cd Catch2/build + cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local + make -j$(nproc --ignore 1) install - - name: Create cppflow package + - name: Install FFTW run: | - if [[ "USE_CONAN" = 1 ]]; then - conan detect profile - conan create ./cppflow -s compiler.cppstd=17 - else - mkdir cppflow/build - cd cppflow/build - cmake .. -DCMAKE_INSTALL_PREFIX=${PWD} - #cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build - make -j$(nproc --ignore 1) install - fi + wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz; + cd fftw-3.3.10 + ./configure --prefix=${{github.workspace}}/local --enable-shared + make -j$(nproc --ignore 1) install CFLAGS=-fPIC + # Fix bug in FFT3 (cf. https://github.com/FFTW/fftw3/issues/332) + sed -i -e 's/^.*FFTW3LibraryDepends.cmake.*$//1' ${{github.workspace}}/local/lib*/cmake/*/FFTW3Config.cmake - name: Checkout SOPT uses: actions/checkout@v3 @@ -79,48 +55,19 @@ jobs: - name: Create SOPT package run : | - if [[ "USE_CONAN" = 1 ]]; then - conan create ./sopt -s compiler.cppstd=17 --build missing -o dompi=off -o docasa=off -o openmp=off -o docs=off -o cppflow=on - else - export CMAKE_PREFIX_PATH=${{github.workspace}}/cppflow/build:$CMAKE_PREFIX_PATH - #export CMAKE_PREFIX_PATH=${{github.workspace}}/Catch2/build/lib/cmake:$CMAKE_PREFIX_PATH - export CMAKE_PREFIX_PATH=${{github.workspace}}/build:$CMAKE_PREFIX_PATH - #export CMAKE_PREFIX_PATH=${{github.workspace}}/build/lib/cmake:$CMAKE_PREFIX_PATH - mkdir sopt/build - cd sopt/build - cmake .. -DCMAKE_INSTALL_PREFIX=${PWD} -Ddocasa=OFF -Ddompi=OFF -Dopenmp=OFF -Ddocs=OFF -Dcppflow=ON - #cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build -Ddompi=OFF -Dopenmp=OFF -Ddocs=OFF -Dcppflow=ON - make -j$(nproc --ignore 1) install - fi + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH + mkdir sopt/build + cd sopt/build + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=OFF -Dopenmp=OFF -Ddocs=OFF -Dtests=OFF -Dexamples=OFF + make -j$(nproc --ignore 1) install - name: Configure run: | - if [[ "USE_CONAN" = 1 ]]; then - # Doxygen currently broken in Conan v1 and v2 - #conan install doxygen/1.9.4@#2af713e135f12722e3536808017ba086 --update - conan install ${{github.workspace}} -if ${{github.workspace}}/build -s compiler.cppstd=17 --build missing -o docasa=off -o dompi=off -o openmp=off -o docs=on -o cppflow=on - else - export CMAKE_PREFIX_PATH=${{github.workspace}}/cppflow/build:$CMAKE_PREFIX_PATH - export CMAKE_PREFIX_PATH=${{github.workspace}}/build:$CMAKE_PREFIX_PATH - mkdir -p ${{github.workspace}}/build - cd ${{github.workspace}}/build - cmake .. -DCMAKE_INSTALL_PREFIX=${PWD} -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON -Dcppflow=ON - fi - - - name: Build - run: | - if [[ "USE_CONAN" = 1 ]]; then - conan build ${{github.workspace}} -of ${{github.workspace}}/build -s compiler.cppstd=17 -o docasa=off -o dompi=off -o openmp=off -o docs=on -o cppflow=on - else - export CMAKE_PREFIX_PATH=${{github.workspace}}/cppflow/build:$CMAKE_PREFIX_PATH - ##export CMAKE_PREFIX_PATH=${{github.workspace}}/fftw-3.3.10/build/lib/cmake:$CMAKE_PREFIX_PATH - #export CMAKE_PREFIX_PATH=${{github.workspace}}/fftw-3.3.10/build:$CMAKE_PREFIX_PATH - #export CMAKE_PREFIX_PATH=${{github.workspace}}/Catch2/build/lib/cmake:$CMAKE_PREFIX_PATH - ##export CMAKE_PREFIX_PATH=${{github.workspace}}/sopt/build:$CMAKE_PREFIX_PATH - export CMAKE_PREFIX_PATH=${{github.workspace}}/build:$CMAKE_PREFIX_PATH - cd ${{github.workspace}}/build - make -j$(nproc --ignore 1) install - fi + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH + mkdir -p ${{github.workspace}}/build + cd ${{github.workspace}}/build + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON + make -j$(nproc --ignore 1) install - name: Deploy to GH pages if: ${{github.event_name == 'push'}} diff --git a/CMakeLists.txt b/CMakeLists.txt index ac2d65a5c..49b136fdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ option(docimg "Enable CImg" off) option(docasa "Enable CASA" off) option(docs "Build documentation" off) option(coverage "Build coverage" off) -option(cppflow "Build with TensorFlow interface" off) +option(onnxrt "Build with ONNXruntime interface" off) if(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") @@ -29,7 +29,6 @@ set(Sopt_GIT_TAG "development" CACHE STRING "Branch/tag when downloading sopt") ## we are doing c++11 #include(AddCPP11Flags) -# c++17 is required when using cppflow with learned algorithms set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/README.md b/README.md index 5a8118fa1..e7fbef17e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Description -**PURIFY** is an open-source collection of routines written in `C++` available under the [license](#license) below. It implements different tools and high-level to perform radio interferometric imaging, _i.e._ to recover images from the Fourier measurements taken by radio interferometric telescopes. +**PURIFY** is an open-source collection of routines written in `C++` available under the [license](#license) below. It implements different tools and high-level to perform radio interferometric imaging, _i.e._ to recover images from the Fourier measurements taken by radio interferometric telescopes. **PURIFY** leverages recent developments in the field of compressive sensing and convex optimization. Low-level functionality to solve the resulting convex optimisation is factored into the open-source companion code, [**SOPT**](https://github.com/astro-informatics/sopt), also written by the authors of **PURIFY**. For further background please see the [reference](#references-and-citation) section. @@ -14,92 +14,36 @@ This documentation outlines the necessary and optional [dependencies](#dependenc ## Dependencies installation -**PURIFY** is written in `C++11`. Required software and libraries, and their minimum supported versions, are listed below. The build system will attempt to automatically download and build the automatically included libraries. (an internet connection is required for this). Most dependencies are handled by the `conan` package manager. +**PURIFY** is written in `C++11`. Required software and libraries, and their minimum supported versions, are listed below. The build system will attempt to automatically download and build the automatically included libraries. (an internet connection is required for this). `C++` dependencies: -### User-provided libraries - -In order to build **PURIFY**, you should have the following installed on your system. - - [CMake](http://www.cmake.org/) v3.5.1 A free software that allows cross-platform compilation -- [conan](https://conan.io/) v2.0.11 `C/C++` package manager. **NOTE** Conan v1 is no loner supported. - [GCC](https://gcc.gnu.org) v7.3.0 GNU compiler for `C++` - [OpenMP](http://openmp.org/wp/) v4.8.4 - Optional - Speeds up some of the operations. - [MPI](https://www.open-mpi.org) v3.1.1 - Optional - Parallelisation paradigm to speed up operations. - -### Automatically included libraries - -The build system of **PURIFY** will attempt to download and build these additional dependencies, depending on the build options passed to `conan`. Most of them are automatically handled by `conan`. - -- [astro-informatics/sopt](https://github.com/astro-informatics/sopt) v4.0.0: Sparse Optimization +- [astro-informatics/sopt](https://github.com/astro-informatics/sopt) v4.1.0: Sparse Optimization Compressed Sensing library. Included as a submodule. -- [UCL/GreatCMakeCookOff](https://github.com/UCL/GreatCMakeCookOff) Collection of `CMake` recipes. - Downloaded automatically if absent. - [Boost](https://www.boost.org/) v1.78.0: A set of free peer-reviewed - portable C++ libraries. Downloaded automatically by conan. -- [fftw3](www.fftw.org) v3.3.9: Fastest Fourier Transform in the West. Downloaded automatically by conan. -- [Eigen3](http://eigen.tuxfamily.org/index.php?title=Main_Page) v3.3.7: Modern `C++` linear algebra. Downloaded automatically by conan. -- [tiff](http://www.libtiff.org/) v4.0.9: Tag Image File Format library. Downloaded automatically by conan. -- [cfitsio](http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html): v4.0.0: Library of `C` and `Fortran` subroutines for reading and writing data files in FITS (Flexible Image Transport System) data format. Downloaded automatically by conan. -- [yaml-cpp](https://github.com/jbeder/yaml-cpp) v0.6.3: YAML parser and emitter in `C++`. Downloaded automatically by conan. + portable C++ libraries. +- [fftw3](www.fftw.org) v3.3.9: Fastest Fourier Transform in the West. +- [Eigen3](http://eigen.tuxfamily.org/index.php?title=Main_Page) v3.3.7: Modern `C++` linear algebra. +- [tiff](http://www.libtiff.org/) v4.0.9: Tag Image File Format library. +- [cfitsio](http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html): v4.0.0: Library of `C` and `Fortran` subroutines for reading and writing data files in FITS (Flexible Image Transport System) data format. +- [yaml-cpp](https://github.com/jbeder/yaml-cpp) v0.6.3: YAML parser and emitter in `C++`. - [casacore](http://casacore.github.io/casacore/) - Optional - Needed to interface with measurement +- [ONNXruntime](https://onnxruntime.ai/) v1.17.1 - Optional - a cross-platform runtime engine based on the Open Neural Network eXchange format. sets. The main **PURIFY** program requires this library (and its dependencies) -- [spdlog](https://github.com/gabime/spdlog) v1.9.2: Optional - Logging library. Downloaded automatically by conan. - [Catch2](https://github.com/catchorg/Catch2) v2.13.9: Optional - A `C++` - unit-testing framework only needed for testing. Downloaded automatically by conan. + unit-testing framework only needed for testing. - [google/benchmark](https://github.com/google/benchmark) v1.6.0: Optional - A `C++` - micro-benchmarking framework only needed for benchmarks. Downloaded automatically by conan. + micro-benchmarking framework only needed for benchmarks. +For examples on how to install dependencies on Ubuntu and MacOS, see the +[cmake.yml](https://github.com/astro-informatics/purify/blob/development/.github/workflows/cmake.yml). ## Installing and building PURIFY -**Using Conan v2 (recommended)** - -[Conan](https://docs.conan.io/en/latest/installation.html) is a C++ package manager that helps deal with most of the -C++ dependencies as well as the **PURIFY** installation: - -1. Once the mandatory user-provided dependencies are present, - `git clone` from the [GitHub repository](https://github.com/astro-informatics/purify): - - ``` bash - git clone --recurse-submodules https://github.com/astro-informatics/purify.git - ``` -1. Create a `conan` package for `sopt` - - ```bash - conan create /path/to/purify/sopt/ --build missing - ``` - If you get an error about broken symlinks you can set `skip_broken_symlinks_check = True` in - your `~/.conan/conan.conf` file or - [set an environment variable](https://docs.conan.io/en/1.46/reference/env_vars.html#conan-skip-broken-symlinks-check) -1. Then, the program can be built using `conan`: - - ``` bash - cd /path/to/purify - mkdir build - cd build - conan install .. -of . --build missing - conan build .. -of . - ``` - -You can turn the various options on and off by adding flags to the `conan install` command, e.g. - - ```bash - conan install .. -of . --build missing -o cppflow=on -o openmp=on -o mpi=off - conan build .. -of . - ``` - -The full list of build options can be found in the [conanfile](./conanfile.py). -To install in directory `INSTALL_FOLDER`, add the following options to the conan build command: - - ``` bash - conan build .. -of INSTALL_FOLDER - ``` - - -**Using CMake** - If the dependencies are already available on your system, you can also install **PURIFY** manually like so ``` bash @@ -118,36 +62,12 @@ On MacOS, you can also install most of the dependencies with Homebrew e.g. ``` -### TensorFlow support +### Machine-learning models -The **SOPT** library includes an interface to TensorFlow for using trained models +The **SOPT** library includes an interface to ONNXrt for using trained models as priors in the Forward-Backward optimization algorithm. To build **PURIFY** with -TensorFlow capability, some extra steps are currently required. -We aim to simplify the build process in a future release. - -1. Install the [TensorFlow C API](https://www.tensorflow.org/install/lang_c) -1. Clone the UCL fork of `cppflow` and create a `conan` package using - - ``` bash - git clone git@github.com:UCL/cppflow.git - conan create /path/to/cppflow/ - ``` -1. Follow the nominal build instructions, making sure you enable the `cppflow` - option when building **SOPT** ... - - ```bash - conan create /path/to/purify/sopt/ --build missing -o cppflow=on - ``` - -1. ... and **PURIFY**: - - ``` bash - cd /path/to/purify - mkdir build - cd build - conan install .. --build missing -o cppflow=on - conan build .. - ``` +ONNXrt capability, you need to enable `ONNXrt` support also in **SOPT** using +the `onnxrt` option when running the `cmake` command. ## Testing diff --git a/cmake_files/LookUpCubature.cmake b/cmake_files/LookUpCubature.cmake index ac8b2504f..64c4f27ba 100644 --- a/cmake_files/LookUpCubature.cmake +++ b/cmake_files/LookUpCubature.cmake @@ -14,6 +14,7 @@ if(NOT Cubature_GIT_TAG) set(Cubature_GIT_TAG master) endif() +set(Cubature_DIR "${CMAKE_INSTALL_PREFIX}/external") ExternalProject_Add( Lookup-Cubature GIT_REPOSITORY ${Cubature_GIT_REPOSITORY} @@ -21,7 +22,7 @@ ExternalProject_Add( PREFIX "${CMAKE_BINARY_DIR}/external" #INSTALL_DIR ${EXTERNAL_ROOT} CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external + -DCMAKE_INSTALL_PREFIX=${Cubature_DIR} -DCMAKE_INSTALL_LIBDIR=${CMAKE_SHARED_LIBRARY_PREFIX} # Wrap download, configure and build steps in a script to log output UPDATE_COMMAND "" @@ -30,8 +31,6 @@ ExternalProject_Add( LOG_BUILD ON LOG_INSTALL ON ) -ExternalProject_Get_Property(Lookup-Cubature install_dir) -set(Cubature_DIR "${install_dir}") set(Cubature_INCLUDE_DIR "${Cubature_DIR}/include") set(Cubature_LIBRARY_DIR "${Cubature_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}") set(Cubature_LIBRARIES "cubature") diff --git a/cmake_files/dependencies.cmake b/cmake_files/dependencies.cmake index 14518ce20..0cc2da4cb 100644 --- a/cmake_files/dependencies.cmake +++ b/cmake_files/dependencies.cmake @@ -19,11 +19,20 @@ endif() find_package(CFitsIO MODULE REQUIRED) +cmake_policy(SET CMP0167 OLD) find_package(Boost COMPONENTS system filesystem REQUIRED) find_package(yaml-cpp REQUIRED) find_package(sopt REQUIRED) +set(PURIFY_ONNXRT FALSE) +if (onnxrt) + if (${sopt_HAS_ORT}) + set(PURIFY_ONNXRT TRUE) + else() + message(FATAL_ERROR "SOPT built without ONNXrt support") + endif() +endif() find_package(Cubature QUIET) if(NOT Cubature_FOUND) @@ -49,14 +58,9 @@ if(examples) find_package(TIFF REQUIRED) endif() - -if(cppflow) - find_package(cppflow) - find_library(TENSORFLOW_LIB tensorflow REQUIRED) -endif() - # Always find open-mp, since it may be used by sopt if (openmp) + cmake_policy(SET CMP0074 NEW) find_package(OpenMP) if (OPENMP_FOUND) # Set PURIFY_OPENMP to TRUE when OpenMP is both found and requested @@ -100,12 +104,5 @@ if(docasa) set(PURIFY_CASACORE TRUE) endif() -set(PURIFY_CPPFLOW FALSE) -if(cppflow) - find_package(cppflow) - find_library(TENSORFLOW_LIB tensorflow REQUIRED) - set(PURIFY_CPPFLOW TRUE) -endif() - # Add script to execute to make sure libraries in the build tree can be found add_to_ld_path("${EXTERNAL_ROOT}/lib") diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index d7094e990..000000000 --- a/conanfile.py +++ /dev/null @@ -1,113 +0,0 @@ -from conan import ConanFile -from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps -from conan.tools.files import symlinks -import os - -class PurifyConan(ConanFile): - name = "purify" - version = "3.0.1" - url = "https://github.com/astro-informatics/purify" - license = "GPL-2.0" - description = "PURIFY is an open-source collection of routines written in C++ available under the license below. It implements different tools and high-level to perform radio interferometric imaging, i.e. to recover images from the Fourier measurements taken by radio interferometric telescopes." - - - settings = "os", "compiler", "build_type", "arch" - requires = ["fftw/3.3.9", "eigen/3.4.0","catch2/3.4.0","benchmark/1.8.2","yaml-cpp/0.7.0", "boost/1.82.0", "cfitsio/4.2.0", "sopt/4.0.0"] - #generators = "CMakeDeps" - exports_sources = "cpp/*", "cmake_files/*", "CMakeLists.txt" - options = {"docs":['on','off'], - "examples":['on','off'], - "tests":['on','off'], - "benchmarks":['on','off'], - "openmp":['on','off'], - "dompi":['on','off'], - "coverage":['on','off'], - "af": ['on', 'off'], - "cimg": ['on','off'], - "docasa": ['on','off'], - "cppflow": ['on', 'off']} - default_options = {"docs": 'off', - "examples":'off', - "tests": 'on', - "benchmarks": 'off', - "openmp": 'off', - "dompi": 'off', - "coverage": 'off', - "af": 'off', - "cimg": 'off', - "docasa": 'on', - "cppflow": 'off'} - - def configure(self): - - self.options["sopt"].cppflow = self.options.cppflow - self.options["sopt"].dompi = self.options.dompi - self.options["sopt"].openmp = self.options.openmp - # When building the sopt package, switch off sopt tests and examples, - # they are not going to be run. - self.options["sopt"].examples = 'off' - self.options["sopt"].tests = 'off' - - # Exclude boost features we don't need. without_fiber is required when - # building from source on MacOS with gcc. - # The rest are to speed up building from source. - self.options["boost"].without_fiber = True - self.options["boost"].without_python = True - - def requirements(self): - # Override version of zlib to prevent a conflict between versions of zlib required by depedencies - self.requires("zlib/1.2.12", override=True) - - if self.options.examples == 'on': - self.requires("libtiff/4.5.1") - - if self.options.docs == 'on': - self.requires("doxygen/1.9.2") - - if self.options.cimg == 'on': - self.requires("cimg/3.0.2") - - if self.options.cppflow == 'on': - self.requires("cppflow/2.0.0") - - def generate(self): - tc = CMakeToolchain(self) - - tc.cache_variables['docs'] = self.options.docs - tc.cache_variables['examples'] = self.options.examples - tc.cache_variables['tests'] = self.options.tests - tc.cache_variables['benchmarks'] = self.options.benchmarks - tc.cache_variables['openmp'] = self.options.openmp - tc.cache_variables['dompi'] = self.options.dompi - tc.cache_variables['coverage'] = self.options.coverage - tc.cache_variables['doaf'] = self.options.af - tc.cache_variables['docimg'] = self.options.cimg - tc.cache_variables['docasa'] = self.options.docasa - tc.cache_variables['cppflow'] = self.options.cppflow - - # List cases where we don't use ccache - if ('GITHUB_ACTIONS' in os.environ.keys() and self.options.docs == 'off'): - tc.cache_variables['CMAKE_C_COMPILER_LAUNCHER'] = "ccache" - tc.cache_variables['CMAKE_CXX_COMPILER_LAUNCHER'] = "ccache" - - tc.cache_variables['CMAKE_VERBOSE_MAKEFILE:BOOL'] = "ON" - tc.cache_variables['MPIEXEC_MAX_NUMPROCS'] = 2 - tc.generate() - - deps = CMakeDeps(self) - deps.generate() - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def package(self): - cmake = CMake(self) - cmake.configure() - cmake.install() - - def package_info(self): - self.cpp_info.libs = ["purify"] - - diff --git a/cpp/purify/CMakeLists.txt b/cpp/purify/CMakeLists.txt index 8a1e75075..1e56b6ecb 100644 --- a/cpp/purify/CMakeLists.txt +++ b/cpp/purify/CMakeLists.txt @@ -75,19 +75,6 @@ target_include_directories(libpurify PUBLIC $ $) -if (cppflow) - target_link_libraries(libpurify "${TENSORFLOW_LIB}") - # Make cppflow include directory public. Install interface can't point to source directory, - # so it needs to be separately defined, explained in - # https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source - # Add /usr/local/include for default location of TensorFlow headers - target_include_directories(libpurify PUBLIC - $ - $ - $ - ) -endif() - add_include_dir( ${EIGEN3_INCLUDE_DIR} ${Boost_INCLUDE_DIR} @@ -124,12 +111,6 @@ if(PURIFY_CASACORE_LOOKUP) add_dependencies(libpurify Lookup-CasaCore) endif() -# Add spdlog as direct dependency -if(spdlog_FOUND) - target_link_libraries(libpurify spdlog::spdlog) - target_include_directories(libpurify SYSTEM PUBLIC ${spdlog_INCLUDE_DIR}) -endif() - install(FILES ${HEADERS} DESTINATION include/purify) install(TARGETS libpurify EXPORT PurifyTargets diff --git a/cpp/purify/algorithm_factory.h b/cpp/purify/algorithm_factory.h index 752225a95..057a4b1f2 100644 --- a/cpp/purify/algorithm_factory.h +++ b/cpp/purify/algorithm_factory.h @@ -24,7 +24,7 @@ #include #include #include -#ifdef PURIFY_CPPFLOW +#ifdef PURIFY_ONNXRT #include #endif @@ -201,13 +201,13 @@ fb_factory(const algo_distribution dist, break; } case (g_proximal_type::TFGProximal): { -#ifdef PURIFY_CPPFLOW +#ifdef PURIFY_ONNXRT // Create a shared pointer to an instance of the TFGProximal class gp = std::make_shared>(model_path); break; #else throw std::runtime_error( - "Type TFGProximal not recognized because purify was built with cppflow=off"); + "Type TFGProximal not recognized because purify was built with onnxrt=off"); #endif } default: { diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 21929136f..b5f8cc9ac 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -1,9 +1,6 @@ include_directories("${PROJECT_SOURCE_DIR}/cpp" "${PROJECT_BINARY_DIR}/include") add_library(common_catch_main_object OBJECT "common_catch_main.cc") -if(spdlog_FOUND) - target_link_libraries(common_catch_main_object spdlog::spdlog) -endif() if(Catch2_FOUND) target_link_libraries(common_catch_main_object Catch2::Catch2) endif() @@ -51,9 +48,6 @@ if(PURIFY_MPI) add_library(common_mpi_catch_main_object OBJECT "common_mpi_catch_main.cc") target_include_directories(common_mpi_catch_main_object PUBLIC ${PROJECT_BINARY_DIR}/include ${MPI_CXX_INCLUDE_PATH}) - if(spdlog_FOUND) - target_link_libraries(common_mpi_catch_main_object spdlog::spdlog) - endif() if(Catch2_FOUND) target_link_libraries(common_mpi_catch_main_object Catch2::Catch2) endif()