Skip to content

Commit

Permalink
Merge pull request #342 from astro-informatics/debugging
Browse files Browse the repository at this point in the history
Various build fixes from LEXCI in-person meeting
  • Loading branch information
mmcleod89 authored May 29, 2024
2 parents 0557c99 + a899adc commit 5301bb7
Show file tree
Hide file tree
Showing 34 changed files with 461 additions and 292 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ jobs:
matrix:
os:
- ubuntu-20.04
- macos-11
- macos-14
cc:
- gcc-10
- gcc-11
- clang
cxx:
- g++-10
- g++-11
- clang++
mpi:
- "on"
Expand All @@ -53,14 +55,26 @@ jobs:
- "on"
- "off"
exclude:
- cc: gcc-11
cxx: clang++
- cc: clang
cxx: g++-11
- cc: gcc-10
cxx: clang++
- cc: clang
cxx: g++-10
- os: ubuntu-20.04
cc: clang
cxx: clang++
- os: macos-11
- os: macos-14
cxx: g++-10
- os: macos-14
cc: gcc-10
- os: ubuntu-20.04
cxx: g++-11
- os: ubuntu-20.04
cc: gcc-11
- os: macos-14
mpi: "on"
- cxx: clang++
omp: "on"
Expand All @@ -80,17 +94,14 @@ jobs:
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 update has bugs but we don't seem to be affected, see
# https://github.com/actions/setup-python/issues/577
# brew update is very slow because it's updating a lot of unrelated packages
# workflow seems to run fine with default versions
# brew update
brew install open-mpi libomp ccache
echo "CMAKE_PREFIX_PATH=/usr/local/opt/libomp" >> $GITHUB_ENV
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?
Expand All @@ -114,12 +125,6 @@ jobs:
with:
python-version: '3.10'

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.60.1

- name: Prepare ccache timestamp
id: ccache_cache_timestamp
run: echo "{date_and_time}={$(date +'%Y-%m-%d-%H;%M;%S')}" >> $GITHUB_OUTPUT
Expand All @@ -140,25 +145,17 @@ jobs:
# - name: Clear ccache
# run: ccache --clear

- name: create sopt package on gcc
if: ${{ contains(matrix.cxx, 'g++-10') }}
run: conan create ${{github.workspace}}/sopt --build missing -s:b compiler.libcxx=libstdc++11 -o:b mpi=${{matrix.mpi}} -o:b openmp=${{matrix.omp}} -pr:h=default -pr:b=default

- name: create sopt package on apple-clang
if: ${{ contains(matrix.cxx, 'clang++') }}
run: conan create ${{github.workspace}}/sopt --build missing -o:b mpi=${{matrix.mpi}} -o:b openmp=${{matrix.omp}} -pr:h=default -pr:b=default

- name: Conan install on gcc
if: ${{ contains(matrix.cxx, 'g++-10') }}
run: conan install ${{github.workspace}} -if ${{github.workspace}}/build -s compiler.libcxx=libstdc++11 --build missing -o mpi=${{matrix.mpi}} -o openmp=${{matrix.omp}} -pr:h=default -pr:b=default
- name: Build sopt
run: |
conan profile detect
conan create ${{github.workspace}}/sopt --build missing -s compiler.cppstd=17 -o dompi=${{matrix.mpi}} -o openmp=${{matrix.omp}}
- name: Conan install on apple-clang
if: ${{ contains(matrix.cxx, 'clang++') }}
run: conan install ${{github.workspace}} -if ${{github.workspace}}/build --build missing -o mpi=${{matrix.mpi}} -o openmp=${{matrix.omp}} -pr:h=default -pr:b=default
- 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: Build
- name: Install
# Build your program with the given configuration
run: conan build ${{github.workspace}} -bf ${{github.workspace}}/build
run: conan build ${{github.workspace}} -of ${{github.workspace}}/build -s compiler.cppstd=17 -o docasa=off -o dompi=${{matrix.mpi}} -o openmp=${{matrix.omp}}

- name: Test
working-directory: ${{github.workspace}}/build
Expand Down
24 changes: 10 additions & 14 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install openmpi-bin libopenmpi-dev casacore-dev doxygen graphviz
if [[ "$USE_CONAN" = 0 ]]; then
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
Expand All @@ -48,13 +50,6 @@ jobs:
version: 2.11.0
os: linux

- name: Install Conan
id: conan
if: env.USE_CONAN != '0'
uses: turtlebrowser/get-conan@main
with:
version: 1.60.1

- name: Checkout cppflow repo
uses: actions/checkout@v3
with:
Expand All @@ -65,7 +60,8 @@ jobs:
- name: Create cppflow package
run: |
if [[ "USE_CONAN" = 1 ]]; then
conan create ./cppflow/ -pr:h=default -pr:b=default
conan detect profile
conan create ./cppflow -s compiler.cppstd=17
else
mkdir cppflow/build
cd cppflow/build
Expand All @@ -84,15 +80,15 @@ jobs:
- name: Create SOPT package
run : |
if [[ "USE_CONAN" = 1 ]]; then
conan create ./sopt --build missing -o mpi=off -o openmp=off -o docs=off -o cppflow=on -pr:h=default -pr:b=default
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} -Ddompi=OFF -Dopenmp=OFF -Ddocs=OFF -Dcppflow=ON
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
Expand All @@ -102,7 +98,7 @@ jobs:
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 --build missing -o mpi=off -o openmp=off -o docs=on -o cppflow=on -pr:h=default -pr:b=default
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
Expand All @@ -114,7 +110,7 @@ jobs:
- name: Build
run: |
if [[ "USE_CONAN" = 1 ]]; then
conan build ${{github.workspace}} -bf ${{github.workspace}}/build
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
Expand Down
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ option(tests "Enable testing" on)
option(examples "Compile examples" off)
option(benchmarks "Enable benchmarking" off)
option(openmp "Enable OpenMP" on)
option(logging "Enable logging" on)
option(dompi "Enable MPI" on)
option(doaf "Enable ArrayFire" off)
option(docimg "Enable CImg" off)
Expand Down Expand Up @@ -38,15 +37,15 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# sets up rpath so libraries can be found
include(rpath)

# adds logging variables
include(logging)

# include exernal dependencies
include(dependencies)

set(PURIFY_TEST_LOG_LEVEL critical CACHE STRING "Level when logging tests")
set_property(CACHE PURIFY_TEST_LOG_LEVEL
PROPERTY STRINGS off critical error warn info debug trace)

# If PURIFY_OPENMP is set to False in dependencies, link libpthread here so that the linker finds it
# Following advice from https://stackoverflow.com/questions/1620918/cmake-and-libpthread

if(NOT PURIFY_OPENMP)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This documentation outlines the necessary and optional [dependencies](#dependenc
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/) v1.60.1 `C/C++` package manager. **NOTE** Conan 2.0 and later are not supported.
- [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.
Expand Down
37 changes: 9 additions & 28 deletions cmake_files/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif(THREADS_FOUND)
endif()

if(logging)
find_package(spdlog REQUIRED)
endif()

if(docs)
cmake_policy(SET CMP0057 NEW)
find_package(Doxygen REQUIRED dot)
Expand All @@ -60,30 +56,15 @@ if(cppflow)
endif()

# Always find open-mp, since it may be used by sopt
find_package(OpenMP)
if(openmp AND NOT OPENMP_FOUND)
message(STATUS "Could not find OpenMP. Compiling without.")
endif()
set(PURIFY_OPENMP_FFTW FALSE)
if(openmp AND OPENMP_FOUND)
# Set PURIFY_OPENMP to TRUE when OpenMP is both found and requested
set(PURIFY_OPENMP TRUE)

# Add the OpenMP Library
add_library(openmp::openmp INTERFACE IMPORTED GLOBAL)

# Set compiler and linker options to the defaults for CXX
# TODO: Should this be done automatically?
# Check when we update CMake and the OpenMP linking to
# https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html
# possibly using
# https://cmake.org/cmake/help/latest/module/FindOpenMP.html
set_target_properties(openmp::openmp PROPERTIES
INTERFACE_COMPILE_OPTIONS "${OpenMP_CXX_FLAGS}"
INTERFACE_LINK_LIBRARIES "${OpenMP_CXX_FLAGS}")
else()
# Set to FALSE when OpenMP is not found or not requested
set(PURIFY_OPENMP FALSE)
if (openmp)
find_package(OpenMP)
if (OPENMP_FOUND)
# Set PURIFY_OPENMP to TRUE when OpenMP is both found and requested
set(PURIFY_OPENMP TRUE)
else()
# Set to FALSE when OpenMP is not found or not requested
message(STATUS "Could not find OpenMP. Compiling without.")
endif()
endif()

find_package(fftw3 NAMES FFTW3 REQUIRED)
Expand Down
13 changes: 0 additions & 13 deletions cmake_files/logging.cmake

This file was deleted.

59 changes: 24 additions & 35 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PurifyConan(ConanFile):
version = "3.0.1"
url = "https://github.com/astro-informatics/purify"
license = "GPL-2.0"
descpriton = "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."
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"
Expand All @@ -19,37 +19,30 @@ class PurifyConan(ConanFile):
"examples":['on','off'],
"tests":['on','off'],
"benchmarks":['on','off'],
"logging":['on','off'],
"openmp":['on','off'],
"mpi":['on','off'],
"dompi":['on','off'],
"coverage":['on','off'],
"af": ['on', 'off'],
"cimg": ['on','off'],
"casa": ['on','off'],
"docasa": ['on','off'],
"cppflow": ['on', 'off']}
default_options = {"docs": 'off',
"examples":'off',
"tests": 'on',
"benchmarks": 'off',
"logging": 'on',
"openmp": 'on',
"mpi": 'on',
"openmp": 'off',
"dompi": 'off',
"coverage": 'off',
"af": 'off',
"cimg": 'off',
"casa": 'off',
"docasa": 'on',
"cppflow": 'off'}

def configure(self):

if self.options.cppflow == 'on':
self.options["sopt"].cppflow = 'on'
if self.options.logging == 'off':
self.options["sopt"].logging = 'off'
if self.options.mpi == 'off':
self.options["sopt"].mpi = 'off'
if self.options.openmp == 'off':
self.options["sopt"].openmp = 'off'
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'
Expand All @@ -68,9 +61,6 @@ def requirements(self):
if self.options.examples == 'on':
self.requires("libtiff/4.5.1")

if self.options.logging == 'on':
self.requires("spdlog/1.12.0")

if self.options.docs == 'on':
self.requires("doxygen/1.9.2")

Expand All @@ -83,26 +73,25 @@ def requirements(self):
def generate(self):
tc = CMakeToolchain(self)

tc.variables['docs'] = self.options.docs
tc.variables['examples'] = self.options.examples
tc.variables['tests'] = self.options.tests
tc.variables['benchmarks'] = self.options.benchmarks
tc.variables['logging'] = self.options.logging
tc.variables['openmp'] = self.options.openmp
tc.variables['dompi'] = self.options.mpi
tc.variables['coverage'] = self.options.coverage
tc.variables['doaf'] = self.options.af
tc.variables['docimg'] = self.options.cimg
tc.variables['docasa'] = self.options.casa
tc.variables['cppflow'] = self.options.cppflow
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.variables['CMAKE_C_COMPILER_LAUNCHER'] = "ccache"
tc.variables['CMAKE_CXX_COMPILER_LAUNCHER'] = "ccache"
tc.cache_variables['CMAKE_C_COMPILER_LAUNCHER'] = "ccache"
tc.cache_variables['CMAKE_CXX_COMPILER_LAUNCHER'] = "ccache"

tc.variables['CMAKE_VERBOSE_MAKEFILE:BOOL'] = "ON"
tc.variables['MPIEXEC_MAX_NUMPROCS'] = 2
tc.cache_variables['CMAKE_VERBOSE_MAKEFILE:BOOL'] = "ON"
tc.cache_variables['MPIEXEC_MAX_NUMPROCS'] = 2
tc.generate()

deps = CMakeDeps(self)
Expand Down
Loading

0 comments on commit 5301bb7

Please sign in to comment.