Skip to content

Commit

Permalink
C++17 Transition (AMReX-Codes#2992)
Browse files Browse the repository at this point in the history
## Summary

Update AMReX to require C++17 or newer.

- [x] docs
- [x] CMake
- [x] GNUmake
- [x] CI

## Additional background

Requires a mature [C++17](https://en.wikipedia.org/wiki/C%2B%2B17)
compiler, e.g., GCC 8, Clang 7, NVCC 11.0, MSVC 19.15 or newer.

Already used since 1+ year in production by downstream codes such as
Castro and WarpX. Needed for modernization and new features such as
AMReX-Codes#2878

Co-authored-by: Weiqun Zhang <weiqunzhang@lbl.gov>
  • Loading branch information
ax3l and WeiqunZhang committed Nov 1, 2022
1 parent d2b8293 commit c4a4811
Show file tree
Hide file tree
Showing 32 changed files with 195 additions and 311 deletions.
26 changes: 12 additions & 14 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
# Build and install libamrex as AMReX CMake project
# Note: this is an intentional "minimal" build that does not enable (many) options
library_clang:
name: Clang@6.0 C++14 SP NOMPI Debug [lib]
runs-on: ubuntu-18.04
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -Wnon-virtual-dtor"}
name: Clang@7.0 C++17 SP NOMPI Debug [lib]
runs-on: ubuntu-20.04
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wnon-virtual-dtor"}
steps:
- uses: actions/checkout@v3
- name: Dependencies
run: .github/workflows/dependencies/dependencies_clang6.sh
run: .github/workflows/dependencies/dependencies_clang7.sh
- name: Build & Install
run: |
mkdir build
Expand All @@ -34,7 +34,6 @@ jobs:
-DAMReX_PLOTFILE_TOOLS=ON \
-DAMReX_PRECISION=SINGLE \
-DAMReX_PARTICLES_PRECISION=SINGLE \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_Fortran_COMPILER=$(which gfortran)
Expand All @@ -48,14 +47,14 @@ jobs:
ctest --output-on-failure
tests_clang:
name: Clang@6.0 C++14 SP Particles DP Mesh Debug [tests]
runs-on: ubuntu-18.04
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -Wno-c++17-extensions -O1 -Wnon-virtual-dtor"}
name: Clang@7.0 C++17 SP Particles DP Mesh Debug [tests]
runs-on: ubuntu-20.04
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -O1 -Wnon-virtual-dtor"}
# It's too slow with -O0
steps:
- uses: actions/checkout@v3
- name: Dependencies
run: .github/workflows/dependencies/dependencies_clang6.sh
run: .github/workflows/dependencies/dependencies_clang7.sh
- name: Build & Install
run: |
mkdir build
Expand All @@ -70,7 +69,6 @@ jobs:
-DAMReX_PARTICLES=ON \
-DAMReX_PRECISION=DOUBLE \
-DAMReX_PARTICLES_PRECISION=SINGLE \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_Fortran_COMPILER=$(which gfortran)
Expand All @@ -80,14 +78,14 @@ jobs:
# Build 2D libamrex with configure
configure-2d:
name: Clang@6.0 NOMPI Release [configure 2D]
runs-on: ubuntu-18.04
name: Clang@7.0 NOMPI Release [configure 2D]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Dependencies
run: .github/workflows/dependencies/dependencies_clang6.sh
run: .github/workflows/dependencies/dependencies_clang7.sh
- name: Build & Install
run: |
./configure --dim 2 --with-fortran no --comp llvm --with-mpi no
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS="-fno-operator-names -Wno-c++17-extensions"
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS="-fno-operator-names"
make install
39 changes: 2 additions & 37 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,6 @@ concurrency:
cancel-in-progress: true

jobs:
# Build libamrex and all tests with CUDA 10.2
tests-cuda10:
name: CUDA@10.2 GNU@6.5.0 C++14 Release [tests]
runs-on: ubuntu-18.04
env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wunreachable-code -Wnon-virtual-dtor -Wlogical-op -Wmisleading-indentation -Wduplicated-cond"}
steps:
- uses: actions/checkout@v3
- name: Dependencies
run: .github/workflows/dependencies/dependencies_nvcc10.sh
- name: Build & Install
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
which nvcc || echo "nvcc not in PATH!"
mkdir build
cd build
cmake .. \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DAMReX_EB=OFF \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_FORTRAN=OFF \
-DAMReX_PARTICLES=ON \
-DAMReX_GPU_BACKEND=CUDA \
-DCMAKE_C_COMPILER=$(which gcc-6) \
-DCMAKE_CXX_COMPILER=$(which g++-6) \
-DCMAKE_CUDA_HOST_COMPILER=$(which g++-6) \
-DCMAKE_Fortran_COMPILER=$(which gfortran-6) \
-DAMReX_CUDA_ARCH=7.0 \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON
make -j 2
# Build libamrex and all tests with CUDA 11.0.2 (recent supported)
tests-cuda11:
name: CUDA@11.2 GNU@9.3.0 C++17 Release [tests]
Expand All @@ -64,9 +33,7 @@ jobs:
-DCMAKE_CXX_COMPILER=$(which g++) \
-DCMAKE_CUDA_HOST_COMPILER=$(which g++) \
-DCMAKE_Fortran_COMPILER=$(which gfortran) \
-DCMAKE_CUDA_STANDARD=17 \
-DCMAKE_CXX_STANDARD=17 \
-DAMReX_CUDA_ARCH=8.0 \
-DAMReX_CUDA_ARCH=7.0 \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON \
-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON
Expand Down Expand Up @@ -106,8 +73,6 @@ jobs:
-DCMAKE_CXX_COMPILER=$(which nvc++) \
-DCMAKE_CUDA_HOST_COMPILER=$(which nvc++) \
-DCMAKE_Fortran_COMPILER=$(which nvfortran) \
-DCMAKE_CUDA_STANDARD=17 \
-DCMAKE_CXX_STANDARD=17 \
-DAMReX_CUDA_ARCH=8.0 \
-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON \
-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON
Expand All @@ -126,5 +91,5 @@ jobs:
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
./configure --dim 3 --with-cuda yes --enable-eb yes --enable-xsdk-defaults yes --with-fortran no
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names CXXSTD=c++17
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names
make install
2 changes: 1 addition & 1 deletion .github/workflows/dependencies/dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright 2020 The AMReX Community
# Copyright 2020-2022 The AMReX Community
#
# License: BSD-3-Clause-LBNL
# Authors: Axel Huebl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright 2020 The AMReX Community
# Copyright 2020-2022 The AMReX Community
#
# License: BSD-3-Clause-LBNL
# Authors: Axel Huebl
Expand All @@ -11,4 +11,4 @@ sudo apt-get update

sudo apt-get install -y \
build-essential \
clang gfortran
clang-7 gfortran
17 changes: 17 additions & 0 deletions .github/workflows/dependencies/dependencies_gcc8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Copyright 2020-2022 The AMReX Community
#
# License: BSD-3-Clause-LBNL
# Authors: Axel Huebl

set -eu -o pipefail

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update

sudo apt-get install -y --no-install-recommends \
build-essential \
g++-8 gfortran-8 \
libopenmpi-dev \
openmpi-bin
3 changes: 2 additions & 1 deletion .github/workflows/dependencies/dependencies_nofortran.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
#
# Copyright 2020 Axel Huebl
# Copyright 2020-2022 The AMReX Community
#
# License: BSD-3-Clause-LBNL
# Authors: Axel Huebl

# search recursive inside a folder if a file contains tabs
#
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/dependencies/dependencies_nvcc10.sh

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/dependencies/dependencies_nvcc11.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright 2020 Axel Huebl
# Copyright 2020-2022 Axel Huebl
#
# License: BSD-3-Clause-LBNL

Expand All @@ -19,9 +19,8 @@ sudo apt-get install -y \
pkg-config \
wget

sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 /" \
| sudo tee /etc/apt/sources.list.d/cuda.list
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get install -y \
cuda-command-line-tools-11-2 \
Expand Down
Loading

0 comments on commit c4a4811

Please sign in to comment.