Skip to content

Commit

Permalink
Move to C++17 and ROOT 6.30.02 (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Duswald <[email protected]>
Co-authored-by: Ahmad Hesam <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2024
1 parent 5bd40af commit 675112f
Show file tree
Hide file tree
Showing 45 changed files with 293 additions and 272 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/centos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
yum -y update
yum -y install centos-release-scl epel-release
yum -y install man wget environment-modules libXt-devel libXext-devel ninja-build make \
devtoolset-8-gcc* numactl-devel openmpi3-devel freeglut-devel \
devtoolset-10-gcc* numactl-devel openmpi3-devel freeglut-devel \
scl-utils which xorg-x11-server-Xvfb fontconfig mesa-dri-drivers
yum -y install @development zlib-devel bzip2 bzip2-devel readline-devel sqlite \
sqlite-devel openssl-devel xz xz-devel libffi-devel findutils lapack-devel blas-devel
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
pyenv shell 3.9.1
. scl_source enable devtoolset-8 || true
. scl_source enable devtoolset-10 || true
. /etc/profile.d/modules.sh || true
module load mpi
cmake -G Ninja \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/centos-system-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
pyenv shell 3.9.1
. scl_source enable devtoolset-8 || true
. scl_source enable devtoolset-10 || true
. /etc/profile.d/modules.sh || true
module load mpi
cmake \
Expand All @@ -140,7 +140,7 @@ jobs:
# eval "$(pyenv init --path)"
# eval "$(pyenv init -)"
# pyenv shell 3.9.1
# . scl_source enable devtoolset-8 || true
# . scl_source enable devtoolset-10 || true
# . /etc/profile.d/modules.sh || true
# module load mpi
# cmake \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'LukasBreitwieser/gitpod-vnc'
ref: master
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,39 @@ jobs:
build:
strategy:
matrix:
os: [macos-12, macos-13]
os: [macos-12, macos-13, macos-14]

runs-on: ${{ matrix.os }}

steps:
- name: Make sure Xcode 14.1 is used on macOS 12 as the default /Application/Xcode.app
- name: Make sure Xcode 14.2 is used on macOS 12 as the default /Application/Xcode.app
shell: bash
run: |
sudo mv /Applications/Xcode.app /Applications/Xcode.app-
sudo ln -s /Applications/Xcode_14.1.app /Applications/Xcode.app
sudo ln -s /Applications/Xcode_14.2.app /Applications/Xcode.app
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
if: matrix.os == 'macos-12'

- name: Make sure Xcode 13.1 is used on macOS 11 as the default /Application/Xcode.app
- name: Make sure Xcode 15.2 is used on macOS 13 as the default /Application/Xcode.app
shell: bash
run: |
sudo mv /Applications/Xcode.app /Applications/Xcode.app-
sudo ln -s /Applications/Xcode_13.1.app /Applications/Xcode.app
sudo ln -s /Applications/Xcode_15.2.app /Applications/Xcode.app
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
if: matrix.os == 'macos-11'
if: matrix.os == 'macos-13'

- name: Install dependencies
run: |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew install libomp open-mpi [email protected] wget cmake ninja qt@5 libgit2
- name: Checkout BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Cache Third Party Packages
# uses: actions/cache@v2
# uses: actions/cache@v4
# with:
# path: build/third_party
# key: ${{ runner.os }}-third-party-${{ hashFiles('cmake/external/SHA256Digests.cmake') }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/macos-system-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ jobs:
build:
strategy:
matrix:
os: [macos-12, macos-13]
os: [macos-12, macos-13, macos-14]

runs-on: ${{ matrix.os }}

steps:
- name: Make sure Xcode 14.1 is used on macOS 12 as the default /Application/Xcode.app
- name: Make sure Xcode 14.2 is used on macOS 12 as the default /Application/Xcode.app
shell: zsh {0}
run: |
sudo mv /Applications/Xcode.app /Applications/Xcode.app-
sudo ln -s /Applications/Xcode_14.1.app /Applications/Xcode.app
sudo ln -s /Applications/Xcode_14.2.app /Applications/Xcode.app
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
if: matrix.os == 'macos-12'

- name: Make sure Xcode 13.1 is used on macOS 11 as the default /Application/Xcode.app
- name: Make sure Xcode 15.2 is used on macOS 13 as the default /Application/Xcode.app
shell: bash
run: |
sudo mv /Applications/Xcode.app /Applications/Xcode.app-
sudo ln -s /Applications/Xcode_13.1.app /Applications/Xcode.app
sudo ln -s /Applications/Xcode_15.2.app /Applications/Xcode.app
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
if: matrix.os == 'macos-11'
if: matrix.os == 'macos-13'

- name: Set GHA_BRANCH_NAME
run: |
Expand All @@ -67,7 +67,7 @@ jobs:
find /tmp -iname biodynamo -type d || true
- name: Checkout BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -84,7 +84,7 @@ jobs:
fi
# - name: Cache Third Party Packages
# uses: actions/cache@v2
# uses: actions/cache@v4
# with:
# path: build/third_party
# key: ${{ runner.os }}-third-party-${{ hashFiles('cmake/external/SHA256Digests.cmake') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repository-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
sudo apt install clang-format
- name: Checkout BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run clang-format code style check
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/singularity-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
image: quay.io/singularity/singularity:v3.9.0
options: "--privileged --workdir /data"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Add root user to subuid and subgid...
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- name: Download BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install sonar-scanner and build-wrapper
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
echo "OSVERS=$ID-$VERSION" >> $GITHUB_ENV
- name: Cache pyenv
uses: actions/cache@v2
uses: actions/cache@v4
id: pyenv-cache
with:
path: ~/.pyenv
Expand All @@ -71,12 +71,12 @@ jobs:
pyenv shell 3.9.1
- name: Checkout BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Third Party Packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: build/third_party
key: ${{ env.OSVERS }}-third-party-${{ hashFiles('cmake/external/SHA256Digests.cmake') }}
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/ubuntu-system-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
find /tmp -iname biodynamo -type d || true
- name: Checkout BioDynaMo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -78,7 +78,7 @@ jobs:
fi
- name: Cache pyenv
uses: actions/cache@v2
uses: actions/cache@v4
id: pyenv-cache
with:
path: ~/.pyenv
Expand All @@ -99,7 +99,7 @@ jobs:
pyenv shell 3.9.1
- name: Cache Third Party Packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: build/third_party
key: ${{ env.OSVERS }}-third-party-${{ hashFiles('cmake/external/SHA256Digests.cmake') }}
Expand All @@ -115,7 +115,8 @@ jobs:
fi
# Don't do this in the `Build BioDynaMo step`, because notebooks might time out in GHA
# runners, while waiting for other targets to be compiled
# runners, while waiting for other targets to be compiled. Run notebooks only
# if the event is a pull request, and on ubuntu-22.04.
- name: Run notebooks
shell: bash
run: |
Expand All @@ -126,11 +127,13 @@ jobs:
cmake \
-Dnotebooks=ON \
-Dsbml=OFF \
-Dnuma=OFF \
-DCMAKE_BUILD_TYPE=Release \
-Dreal_t=${{ env.REALT }} \
-B build
cmake --build build --parallel --config Release --target notebooks -- -j1
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-22.04'


- name: Build BioDynaMo
shell: bash
Expand Down
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ if(APPLE)
foreach(_prefix /sw /opt/local)
list(APPEND CMAKE_IGNORE_PATH ${_prefix}/bin ${_prefix}/include ${_prefix}/lib)
endforeach()

# Silence std::experimental::filesystem warning on MacOS.
# Remove after update to c++17
add_definitions("-D_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM")
endif()

if(UNIX AND NOT APPLE)
Expand All @@ -167,6 +163,12 @@ if(real_t)
add_definitions("-DBDM_REALT=${real_t}")
add_definitions("-DBDM_CL_REALT=cl_${real_t}")
set(BDM_CONFIG_REALT "${real_t}")
if(notebooks AND real_t STREQUAL "float")
# This if statement turns of the notebooks when we run with real_t=float.
# Currently, the notebooks do not support BDM with float for unknown reasons.
message(WARNING "Notebooks are not supported with real_t=float. Disabling notebooks.")
set(notebooks OFF)
endif()
else()
message(STATUS "Using default real_t (double)")
set(BDM_CONFIG_REALT "float")
Expand Down Expand Up @@ -580,15 +582,12 @@ file(GLOB_RECURSE KERNELS "${CMAKE_SOURCE_DIR}/src/*.cu")
filter_list(LIB_SOURCES "${LIB_SOURCES}" "paraview/*")
filter_list(HEADERS "${HEADERS}" "paraview/*")

# NB: Remove stdc++fs after switching to c++17
if (LINUX)
set(FS_LIB stdc++fs)
endif()
build_shared_library(biodynamo
SELECTION selection-libbiodynamo.xml
SOURCES ${LIB_SOURCES}
HEADERS ${HEADERS}
LIBRARIES ${BDM_REQUIRED_LIBRARIES} ${ROOT_LIBRARIES} ${FS_LIB})
LIBRARIES ${BDM_REQUIRED_LIBRARIES} ${ROOT_LIBRARIES})

# libbiodynamo must be built before optimlib; otherwise optimlib could be missing during
# the linking stage of libbiodynamo
add_dependencies(biodynamo optim)
Expand Down Expand Up @@ -651,7 +650,7 @@ if (CUDA_FOUND)
message("CUDA Debug mode")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g -G -O0" )
endif()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++17")

target_link_libraries(biodynamo ${CUDA_LIBRARIES})
cuda_include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_TOOLKIT_ROOT_DIR})
Expand Down Expand Up @@ -714,11 +713,12 @@ if (test)
${CMAKE_SOURCE_DIR}/test/unit/core/visualization/*.h
${CMAKE_SOURCE_DIR}/test/unit/core/visualization/paraview/*.h
${CMAKE_SOURCE_DIR}/test/unit/neuroscience/*.h)
# NB: Remove stdc++fs after switching to c++17

bdm_add_test_executable(biodynamo-unit-tests
SOURCES ${TEST_SOURCES}
HEADERS ${TEST_HEADERS}
LIBRARIES ${REQUIRED_PARAVIEW_LIBRARIES} ${FS_LIB})
LIBRARIES ${REQUIRED_PARAVIEW_LIBRARIES})

# separate test binaries - each source file is compiled into a separate binary
# file(GLOB TEST_SOURCES ${CMAKE_SOURCE_DIR}/test/unit/separate_binary/*.cc)
# file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/empty_header.h "")
Expand Down
14 changes: 7 additions & 7 deletions cmake/CheckCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ else()
IF(${DETECTED_OS} MATCHES "centos.*")
if (NOT DEFINED ENV{CXX})
UNSET(CMAKE_CXX_COMPILER CACHE)
SET(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-8/root/usr/bin/g++")
link_directories(/opt/rh/devtoolset-8/root/usr/lib)
link_directories(/opt/rh/devtoolset-8/root/usr/lib/dyninst)
link_directories(/opt/rh/devtoolset-8/root/usr/lib64)
link_directories(/opt/rh/devtoolset-8/root/usr/lib64/dyninst)
SET(CMAKE_CXX_COMPILER "/opt/rh/devtoolset-10/root/usr/bin/g++")
link_directories(/opt/rh/devtoolset-10/root/usr/lib)
link_directories(/opt/rh/devtoolset-10/root/usr/lib/dyninst)
link_directories(/opt/rh/devtoolset-10/root/usr/lib64)
link_directories(/opt/rh/devtoolset-10/root/usr/lib64/dyninst)
endif()
if (NOT DEFINED ENV{CC})
UNSET(CMAKE_C_COMPILER CACHE)
SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-8/root/usr/bin/gcc")
SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-10/root/usr/bin/gcc")
endif()
enable_language(CXX)
endif()
Expand All @@ -47,7 +47,7 @@ else()
IF(${DETECTED_OS} MATCHES "centos.*")
if (NOT DEFINED ENV{CC})
UNSET(CMAKE_C_COMPILER CACHE)
SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-8/root/usr/bin/gcc")
SET(CMAKE_C_COMPILER "/opt/rh/devtoolset-10/root/usr/bin/gcc")
endif()
endif()
enable_language(C)
Expand Down
27 changes: 19 additions & 8 deletions cmake/SetCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,31 @@

# This file sets all compiler flags

# check if compiler supports C++14
# check if compiler supports C++17
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(NOT COMPILER_SUPPORTS_CXX14)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORTS_CXX17)
if(NOT COMPILER_SUPPORTS_CXX17)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# turn off compiler specific extensions e.g. gnu++14
# turn off compiler specific extensions e.g. gnu++17
set(CMAKE_CXX_EXTENSIONS OFF)

# get machine architecture
execute_process(COMMAND arch OUTPUT_VARIABLE DISTRO_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)

# general flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-missing-braces -m64 -fPIC ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-missing-braces -m64 -fPIC ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-missing-braces -fPIC ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-missing-braces -fPIC ${OpenMP_C_FLAGS}")
if(${DISTRO_ARCH} STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
endif()
if(${DISTRO_ARCH} STREQUAL "aarch64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=native")
endif()

# suppress OpenCL-generated warnings
if (OPENCL_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion cmake/env/thisbdm.fish
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ function source_thisbdm
if test "$os_id" = 'centos'
set -gx MESA_GL_VERSION_OVERRIDE "3.3"
if test -z "$CXX"; and test -z "$CC"
. scl_source enable devtoolset-8; or return 1
. scl_source enable devtoolset-10; or return 1
end

. /etc/profile.d/modules.sh; or return 1
Expand Down
Loading

0 comments on commit 675112f

Please sign in to comment.