Skip to content

Commit

Permalink
C++17, CMake 3.17+ (ECP-WarpX#2300)
Browse files Browse the repository at this point in the history
* C++17, CMake 3.17+

Update C++ requirements to compile with C++17 or newer.

* Superbuild: C++17 in AMReX/PICSAR/openPMD-api

* Summit: `cuda/11.0.3` -> `cuda/11.3.1`

When compiling AMReX in C++17 on Summit, the `cuda/11.0.3` module
(`nvcc 11.0.2211`) dies with:
```
... Base/AMReX_TinyProfiler.cpp
nvcc error   : 'cicc' died due to signal 11 (Invalid memory reference)
nvcc error   : 'cicc' core dumped
```

Although this usually is a memory issue, it also appears in `-j1`
compiles.
  • Loading branch information
ax3l authored Dec 8, 2021
1 parent c76787d commit 6577874
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ jobs:
if [[ "${WARPX_CI_RZ_OR_NOMPI:-FALSE}" == "TRUE" || "${WARPX_CI_PYTHON_MAIN:-FALSE}" == "TRUE" ]]; then
cmake-easyinstall --prefix=/usr/local git+https://bitbucket.org/icl/blaspp.git \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_CXX_STANDARD=17 \
-Duse_openmp=OFF -Dbuild_tests=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
cmake-easyinstall --prefix=/usr/local git+https://bitbucket.org/icl/lapackpp.git \
-DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
-DCMAKE_CXX_STANDARD=17 \
-Duse_cmake_find_lapack=ON -Dbuild_tests=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
fi
rm -rf ${CEI_TMP}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ jobs:
run: |
.github/workflows/dependencies/nvcc11.sh
export CEI_SUDO="sudo"
cmake-easyinstall --prefix=/usr/local git+https://github.com/openPMD/[email protected] -DopenPMD_USE_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DBUILD_CLI_TOOLS=OFF
cmake-easyinstall --prefix=/usr/local \
git+https://github.com/openPMD/[email protected] \
-DopenPMD_USE_PYTHON=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_CLI_TOOLS=OFF \
-DCMAKE_VERBOSE_MAKEFILE=ON
- name: build WarpX
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
Expand Down
33 changes: 19 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Preamble ####################################################################
#
cmake_minimum_required(VERSION 3.15.0)
cmake_minimum_required(VERSION 3.17.0)
project(WarpX VERSION 21.12)

include(${WarpX_SOURCE_DIR}/cmake/WarpXFunctions.cmake)
Expand All @@ -19,11 +19,18 @@ endif()
# AMReX 21.06+ supports CUDA_ARCHITECTURES with CMake 3.20+
# CMake 3.18+: CMAKE_CUDA_ARCHITECTURES
# https://cmake.org/cmake/help/latest/policy/CMP0104.html
if(CMAKE_VERSION VERSION_LESS 3.20)
#if(CMAKE_VERSION VERSION_LESS 3.20)
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
endif()
endif()
#endif()


# C++ Standard in Superbuilds #################################################
#
# This is the easiest way to push up a C++17 requirement for AMReX, PICSAR and
# openPMD-api until they increase their requirement.
set_cxx17_superbuild()


# CCache Support ##############################################################
Expand Down Expand Up @@ -192,9 +199,9 @@ add_subdirectory(Source/Particles)
add_subdirectory(Source/Python)
add_subdirectory(Source/Utils)

# C++ properties: at least a C++14 capable compiler is needed
# C++ properties: at least a C++17 capable compiler is needed
foreach(warpx_tgt IN LISTS _ALL_TARGETS)
target_compile_features(${warpx_tgt} PUBLIC cxx_std_14)
target_compile_features(${warpx_tgt} PUBLIC cxx_std_17)
endforeach()
set_target_properties(${_ALL_TARGETS} PROPERTIES
CXX_EXTENSIONS OFF
Expand Down Expand Up @@ -236,15 +243,13 @@ if(WarpX_COMPUTE STREQUAL CUDA)
foreach(warpx_tgt IN LISTS _ALL_TARGETS)
setup_target_for_cuda_compilation(${warpx_tgt})
endforeach()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
foreach(warpx_tgt IN LISTS _ALL_TARGETS)
target_compile_features(${warpx_tgt} PUBLIC cuda_std_14)
endforeach()
set_target_properties(${_ALL_TARGETS} PROPERTIES
CUDA_EXTENSIONS OFF
CUDA_STANDARD_REQUIRED ON
)
endif()
foreach(warpx_tgt IN LISTS _ALL_TARGETS)
target_compile_features(${warpx_tgt} PUBLIC cuda_std_17)
endforeach()
set_target_properties(${_ALL_TARGETS} PROPERTIES
CUDA_EXTENSIONS OFF
CUDA_STANDARD_REQUIRED ON
)
endif()

# fancy binary name for build variants
Expand Down
6 changes: 3 additions & 3 deletions Docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Dependencies
WarpX depends on the following popular third party software.
Please see installation instructions below.

- a mature `C++14 <https://en.wikipedia.org/wiki/C%2B%2B14>`__ compiler: e.g. GCC 5, Clang 3.6 or newer
- `CMake 3.15.0+ <https://cmake.org>`__
- a mature `C++17 <https://en.wikipedia.org/wiki/C%2B%2B17>`__ compiler, e.g., GCC 7, Clang 6, NVCC 11.0, MSVC 19.15 or newer
- `CMake 3.17.0+ <https://cmake.org>`__
- `Git 2.18+ <https://git-scm.com>`__
- `AMReX <https://amrex-codes.github.io>`__: we automatically download and compile a copy of AMReX
- `PICSAR <https://github.com/ECP-WarpX/picsar>`__: we automatically download and compile a copy of PICSAR

Optional dependencies include:

- `MPI 3.0+ <https://www.mpi-forum.org/docs/>`__: for multi-node and/or multi-GPU execution
- `CUDA Toolkit 9.0+ <https://developer.nvidia.com/cuda-downloads>`__: for Nvidia GPU support (see `matching host-compilers <https://gist.github.com/ax3l/9489132>`_)
- `CUDA Toolkit 11.0+ <https://developer.nvidia.com/cuda-downloads>`__: for Nvidia GPU support (see `matching host-compilers <https://gist.github.com/ax3l/9489132>`_)
- `OpenMP 3.1+ <https://www.openmp.org>`__: for threaded CPU execution (currently not fully accelerated)
- `FFTW3 <http://www.fftw.org>`_: for spectral solver (PSATD) support
- `BLAS++ <https://bitbucket.org/icl/blaspp>`_ and `LAPACK++ <https://bitbucket.org/icl/lapackpp>`_: for spectral solver (PSATD) support in RZ geometry
Expand Down
8 changes: 4 additions & 4 deletions Docs/source/install/hpc/cori.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ And install ADIOS2, BLAS++ and LAPACK++:
# BLAS++ (for PSATD+RZ)
git clone https://bitbucket.org/icl/blaspp.git src/blaspp
rm -rf src/blaspp-knl-build
cmake -S src/blaspp -B src/blaspp-knl-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_INSTALL_PREFIX=$HOME/sw/blaspp-master-knl-install
cmake -S src/blaspp -B src/blaspp-knl-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/blaspp-master-knl-install
cmake --build src/blaspp-knl-build --target install --parallel 16
# LAPACK++ (for PSATD+RZ)
git clone https://bitbucket.org/icl/lapackpp.git src/lapackpp
rm -rf src/lapackpp-knl-build
CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-knl-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_INSTALL_PREFIX=$HOME/sw/lapackpp-master-knl-install
CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-knl-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/lapackpp-master-knl-install
cmake --build src/lapackpp-knl-build --target install --parallel 16
For PICMI and Python workflows, also install a virtual environment:
Expand Down Expand Up @@ -132,13 +132,13 @@ And install ADIOS2, BLAS++ and LAPACK++:
# BLAS++ (for PSATD+RZ)
git clone https://bitbucket.org/icl/blaspp.git src/blaspp
rm -rf src/blaspp-haswell-build
cmake -S src/blaspp -B src/blaspp-haswell-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_INSTALL_PREFIX=$HOME/sw/blaspp-master-haswell-install
cmake -S src/blaspp -B src/blaspp-haswell-build -Duse_openmp=ON -Duse_cmake_find_blas=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/blaspp-master-haswell-install
cmake --build src/blaspp-haswell-build --target install --parallel 16
# LAPACK++ (for PSATD+RZ)
git clone https://bitbucket.org/icl/lapackpp.git src/lapackpp
rm -rf src/lapackpp-haswell-build
CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-haswell-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_INSTALL_PREFIX=$HOME/sw/lapackpp-master-haswell-install
CXXFLAGS="-DLAPACK_FORTRAN_ADD_" cmake -S src/lapackpp -B src/lapackpp-haswell-build -Duse_cmake_find_lapack=ON -DBLAS_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DLAPACK_LIBRARIES=${CRAY_LIBSCI_PREFIX_DIR}/lib/libsci_gnu.a -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=$HOME/sw/lapackpp-master-haswell-install
cmake --build src/lapackpp-haswell-build --target install --parallel 16
For PICMI and Python workflows, also install a virtual environment:
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/install/hpc/quartz.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We use the following modules and environments on the system (``$HOME/warpx.profi
# required dependencies
module load cmake/3.20.2
module load intel/19.1.2
module load intel/2021.4
module load mvapich2/2.3
# optional: for PSATD support
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/install/hpc/summit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ We use the following modules and environments on the system (``$HOME/warpx.profi
# required dependencies
module load cmake/3.20.2
module load gcc/9.3.0
module load cuda/11.0.3
module load cuda/11.3.1
# optional: faster re-builds
module load ccache
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Supported Platforms](https://img.shields.io/badge/platforms-linux%20|%20osx%20|%20win-blue)](https://warpx.readthedocs.io/en/latest/install/users.html)
[![GitHub commits since last release](https://img.shields.io/github/commits-since/ECP-WarpX/WarpX/latest/development.svg)](https://github.com/ECP-WarpX/WarpX/compare/development)
[![Exascale Computing Project](https://img.shields.io/badge/supported%20by-ECP-orange)](https://www.exascaleproject.org/research/)
[![Language: C++14](https://img.shields.io/badge/language-C%2B%2B14-orange.svg)](https://isocpp.org/)
[![Language: C++17](https://img.shields.io/badge/language-C%2B%2B17-orange.svg)](https://isocpp.org/)
[![Language: Python](https://img.shields.io/badge/language-Python-orange.svg)](https://python.org/)
[![License WarpX](https://img.shields.io/badge/license-BSD--3--Clause--LBNL-blue.svg)](https://spdx.org/licenses/BSD-3-Clause-LBNL.html)
[![DOI (source)](https://img.shields.io/badge/DOI%20(source)-10.5281/zenodo.4571577-blue.svg)](https://doi.org/10.5281/zenodo.4571577)
Expand Down
6 changes: 1 addition & 5 deletions Source/Make.WarpX
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ USE_PARTICLES = TRUE
USE_RPATH = TRUE
USE_GPU_RDC = FALSE
BL_NO_FORT = TRUE
ifeq ($(USE_DPCPP),TRUE)
CXXSTD = c++17
else
CXXSTD = c++14
endif
CXXSTD = c++17

# required for AMReX async I/O
MPI_THREAD_MULTIPLE = TRUE
Expand Down
28 changes: 28 additions & 0 deletions cmake/WarpXFunctions.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# Set C++17 for the whole build if not otherwise requested
#
# This is the easiest way to push up a C++17 requirement for AMReX, PICSAR and
# openPMD-api until they increase their requirement.
#
macro(set_cxx17_superbuild)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 17)
endif()
if(NOT DEFINED CMAKE_CUDA_EXTENSIONS)
set(CMAKE_CUDA_EXTENSIONS OFF)
endif()
if(NOT DEFINED CMAKE_CUDA_STANDARD_REQUIRED)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
endmacro()


# find the CCache tool and use it if found
#
macro(set_ccache)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
requires = [
"setuptools>=42",
"wheel",
"cmake>=3.15.0,<4.0.0"
"cmake>=3.17.0,<4.0.0"
]
build-backend = "setuptools.build_meta"
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def run(self):
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError(
"CMake 3.15.0+ must be installed to build the following " +
"CMake 3.17.0+ must be installed to build the following " +
"extensions: " +
", ".join(e.name for e in self.extensions))

cmake_version = LooseVersion(re.search(
r'version\s*([\d.]+)',
out.decode()
).group(1))
if cmake_version < '3.15.0':
raise RuntimeError("CMake >= 3.15.0 is required")
if cmake_version < '3.17.0':
raise RuntimeError("CMake >= 3.17.0 is required")

for ext in self.extensions:
self.build_extension(ext)
Expand Down

0 comments on commit 6577874

Please sign in to comment.