Skip to content

Commit

Permalink
switch to C++20 (#5246)
Browse files Browse the repository at this point in the history
* switch to C++

- update docuemntation
- update CI tests
  - remove HIP 5.X
  - remove CUDA 11.X
  - remove GCC9
- set in all CMake files the C++ standard to C++20

* change required CMake to 3.25+

* fix CI compile issues

- `boost::call_traits` run into compile issues when using clang 18 and cuda 12.1 and boost 1.77
- fix `CONST_VECTOR`
  - for clang CUDA the guard macros was wrongly set

* Squashed 'thirdParty/mallocMC/' changes from 89c9597c91..8624e978e8

8624e978e8 Merge pull request #276 from chillenzer/fix-submodules
209ac2ff50 Fix submodules
127b29fabb Merge pull request #271 from chillenzer/topic-flatterScatter
7846a36fc7 Add submodule to CI
42a96e94ae Remove redundant memset
36e91a9dcf Update license headers
660ad4fffd Minor adjustments to CI
7665162fa1 Update CMakeLists.txt including version bump for Catch2
10221ebded Add catch2 as submodule
8115fc93c6 Update tests
8485629cf2 Update examples
4d0b90b6fc Update LICENSE, README and Usage
745cb2a333 Add FlatterScatter
0bdd7b5117 Run clang-format
2596432b50 Update utils
e8529c4575 Update XMallocSIMD
d752602f19 Update old creation policies
4058862dcc Update device_allocator.hpp
b48b750431 Update allocator.hpp
76c4f46a61 Merge pull request #270 from chillenzer/update-before-flatterscatter
363090535e Merge pull request #269 from chillenzer/update-zenodo
16c5d0de5b Run clang-format
61154b1098 Update utils
0b69f038ff Update XMallocSIMD
79c1962f99 Update old creation policies
4a6a444911 Update device_allocator.hpp
2a9e806119 Update allocator.hpp
1fc71c5294 Update .zenodo.json
f6af760bd7 Merge pull request #268 from chillenzer/update-tooling
8c897de3d4 Merge pull request #267 from chillenzer/update-clang-format
8a1281a0bb Update .gitignore
14ef1ec4c0 Minor tweaks in github action
e7450d9f44 Clean and add to .clang-tidy
fbefa18015 Run clang-format
1fea13bb87 Copy .clang-format from alpaka
29d275791d Merge pull request #266 from chillenzer/add-pre-commit
bd28b52b32 Remove outdated enforce-ascii from pre-commit config
66a7d41914 Add pre-commit lite action
85a1e480b1 Run pre-commit
ff530bb0b5 Add .pre-commit-config.yaml
486a2956d0 Merge pull request #264 from chillenzer/bump-C++20
602e95db5f Bump C++ version to 20
0b9231a754 Merge pull request #263 from chillenzer/alpaka-1.2.0
fa52618c4f Run clang-format
c9c5ae94e4 Bump version of clang-format, its action and checkout
25f42e3aea Update alpaka version number in INSTALL.md
1e6f75bbf8 Merge commit '30ee4f3ab8d7e42ef20cb5495cc3a94b15193abb' as 'alpaka'
30ee4f3ab8 Squashed 'alpaka/' content from commit fe9436d5
4513a7a81c Remove alpaka to pull the latest release
2689825301 LICENSE file remove C-comment (#262)
7bf50bf587 Bump version to 3.0.0 (#261)
REVERT: 89c9597c91 Release 2.6.0 (#260)

git-subtree-dir: thirdParty/mallocMC
git-subtree-split: 8624e978e87644ee7c59f66a3c242aa969c01fc0

* CI: remove HIP (temporary)

Remove testing HIP because the container environment with ubuntu 20.04
is not C++20 ready.
libstdc++ is not supporting C++20 and using libc++ from clang is not
possible.

---------

Co-authored-by: Third Party <[email protected]>
  • Loading branch information
psychocoderHPC and Third Party authored Jan 22, 2025
1 parent 74990f4 commit f7b5239
Show file tree
Hide file tree
Showing 73 changed files with 6,215 additions and 20,187 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# General options
Language: Cpp
Standard: c++17
Standard: c++20
DisableFormat: false

AccessModifierOffset: -4
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ pypicongpu-compiling-test:
CI_CONTAINER_NAME: 'ubuntu20.04'
PYTHON_VERSION: '3.11.*'
CXX_VERSION: 'g++-11'
CMAKE_VERSION: '3.22'
CMAKE_VERSION: '3.25'
BOOST_VERSION: '1.75.0'
PYTHON_COMPILING_TEST: 'ON'
10 changes: 5 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ Mandatory

Compiler
""""""""
- C++17 supporting compiler, e.g. GCC 9+ or Clang 11+
- C++20 supporting compiler, e.g. GCC 10+ or Clang 11+
- if you want to build for Nvidia GPUs, check the `CUDA supported compilers <https://gist.github.com/ax3l/9489132>`_ page
- *note:* be sure to build all libraries/dependencies with the *same* compiler version
- *Debian/Ubuntu:*

- ``sudo apt-get install gcc-9 g++-9 build-essential``
- ``sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9``
- ``sudo apt-get install gcc-10 g++-10 build-essential``
- ``sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10``
- *Arch Linux:*

- ``sudo pacman --sync base-devel``
Expand All @@ -48,7 +48,7 @@ Compiler

CMake
"""""
- 3.22.0 or higher
- 3.25.0 or higher
- *Debian/Ubuntu:* ``sudo apt-get install cmake file cmake-curses-gui``
- *Arch Linux:* ``sudo pacman --sync cmake``
- *Spack:* ``spack install cmake``
Expand Down Expand Up @@ -82,7 +82,7 @@ Boost
- ``tar -xzf boost_1_74_0.tar.gz``
- ``cd boost_1_74_0``
- ``./bootstrap.sh --with-libraries=atomic,program_options --prefix=$HOME/lib/boost``
- ``./b2 cxxflags="-std=c++17" -j4 && ./b2 install``
- ``./b2 cxxflags="-std=c++20" -j4 && ./b2 install``
- *environment:* (assumes install from source in ``$HOME/lib/boost``)

- ``export CMAKE_PREFIX_PATH=$HOME/lib/boost:$CMAKE_PREFIX_PATH``
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ repository should *not* be made in the `thirdParty/` directory but in
for further reference.

- `thirdParty/alpaka`:
The alpaka library is a header-only C++17 abstraction library for accelerator development.
The alpaka library is a header-only C++20 abstraction library for accelerator development.
It aims to provide performance portability across accelerators through the abstraction (not hiding!)
of the underlying levels of parallelism.
Please visit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PIConGPU - Particle-in-Cell Simulations for the Exascale Era
[![Code Status dev](https://gitlab.com/hzdr/crp/picongpu/badges/dev/pipeline.svg?key_text=dev)](https://gitlab.com/hzdr/crp/picongpu/pipelines/dev/latest)
[![Documentation Status](https://readthedocs.org/projects/picongpu/badge/?version=latest)](http://picongpu.readthedocs.io)
[![Doxygen](https://img.shields.io/badge/API-Doxygen-blue.svg)](http://computationalradiationphysics.github.io/picongpu)
[![Language](https://img.shields.io/badge/language-C%2B%2B17-orange.svg)](https://isocpp.org/)
[![Language](https://img.shields.io/badge/language-C%2B%2B20-orange.svg)](https://isocpp.org/)
[![License PIConGPU](https://img.shields.io/badge/license-GPLv3-blue.svg?label=PIConGPU)](https://www.gnu.org/licenses/gpl-3.0.html)
[![License PMacc](https://img.shields.io/badge/license-LGPLv3-blue.svg?label=PMacc)](https://www.gnu.org/licenses/lgpl-3.0.html)

Expand Down
6 changes: 3 additions & 3 deletions include/mpiInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Required cmake version
################################################################################

cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)


################################################################################
Expand Down Expand Up @@ -68,10 +68,10 @@ option(MPIINFO_ADD_RPATH "Add RPATH's to binary." ON)
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


################################################################################
Expand Down
8 changes: 4 additions & 4 deletions include/picongpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Required cmake version
################################################################################

cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)


################################################################################
Expand Down Expand Up @@ -118,10 +118,10 @@ endif()
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


################################################################################
Expand Down Expand Up @@ -654,7 +654,7 @@ if(${CLANG_TIDY_RETURN} EQUAL 0)
# -checks='-*,modernize-use-using'
# -fix # -fix-errors
--
-std=c++17
-std=c++20
${OpenMP_CXX_FLAGS}
${ALL_INCLUDES_STR}
${ALL_DEFINES_STR}
Expand Down
6 changes: 3 additions & 3 deletions include/pmacc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# PMacc tests
################################################################################

cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)
project(PMaccTest)

# set helper pathes to find libraries and packages
Expand Down Expand Up @@ -53,10 +53,10 @@ endif()
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


################################################################################
Expand Down
6 changes: 3 additions & 3 deletions include/pmacc/PMaccConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
###############################################################################
# PMacc
###############################################################################
cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)

# set helper pathes to find libraries and packages
# Add specific hints
Expand Down Expand Up @@ -194,10 +194,10 @@ endif()
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


###############################################################################
Expand Down
8 changes: 4 additions & 4 deletions include/pmacc/math/ConstVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
using namespace PMACC_JOIN(pmacc_static_const_vector_host, id)
#endif

#if defined(__CUDACC__) || BOOST_COMP_HIP
#if BOOST_LANG_CUDA || BOOST_LANG_HIP
# define PMACC_STATIC_CONST_VECTOR_DIM_DEF_CUDA(id, Name, Type, ...) \
namespace PMACC_JOIN(pmacc_static_const_vector_device, id) \
{ \
Expand Down Expand Up @@ -83,12 +83,12 @@
} /* namespace pmacc_static_const_storage + id */ \
using namespace PMACC_JOIN(pmacc_static_const_storage, id)

#if defined(__CUDACC__) || BOOST_COMP_HIP
#if BOOST_LANG_CUDA || BOOST_LANG_HIP
# define PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE_CUDA(Name, id) \
namespace PMACC_JOIN(pmacc_static_const_vector_device, id) \
{ \
/* create const instance on device */ \
[[maybe_unused]] __device__ const PMACC_JOIN(Name, _t) Name; \
[[maybe_unused]] __device__ constexpr PMACC_JOIN(Name, _t) Name{}; \
} /* namespace pmacc_static_const_vector_device + id */
#else
# define PMACC_STATIC_CONST_VECTOR_DIM_INSTANCE_CUDA(Name, id)
Expand All @@ -104,7 +104,7 @@
namespace PMACC_JOIN(pmacc_static_const_vector_host, id) \
{ \
/* create const instance on host*/ \
[[maybe_unused]] constexpr PMACC_JOIN(Name, _t) Name; \
[[maybe_unused]] constexpr PMACC_JOIN(Name, _t) Name{}; \
} /* namespace pmacc_static_const_vector_host + id */ \
} /* namespace pmacc_static_const_storage + id */

Expand Down
7 changes: 3 additions & 4 deletions include/pmacc/math/vector/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ namespace pmacc
using Storage = T_Storage;
using type = T_Type;
static constexpr uint32_t dim = T_dim;
using ParamType = typename boost::call_traits<type>::param_type;

/*Vectors without elements are not allowed*/
PMACC_CASSERT_MSG(math_Vector__with_DIM_0_is_not_allowed, dim > 0u);
Expand Down Expand Up @@ -185,7 +184,7 @@ namespace pmacc

constexpr Vector operator-() const
{
return Vector([=](uint32_t const i) constexpr { return -(*this)[i]; });
return Vector([this](uint32_t const i) constexpr { return -(*this)[i]; });
}

/** assign operator
Expand Down Expand Up @@ -514,7 +513,7 @@ namespace pmacc
template<typename T_Type, uint32_t T_dim, typename T_Storage> \
constexpr auto operator op( \
const Vector<T_Type, T_dim, T_Storage>& lhs, \
typename Vector<T_Type, T_dim, T_Storage>::ParamType rhs) \
typename Vector<T_Type, T_dim, T_Storage>::type rhs) \
{ \
/* to avoid allocation side effects the result is always a vector \
* with default policies \
Expand All @@ -526,7 +525,7 @@ namespace pmacc
} \
template<typename T_Type, uint32_t T_dim, typename T_Storage> \
constexpr auto operator op( \
typename Vector<T_Type, T_dim, T_Storage>::ParamType lhs, \
typename Vector<T_Type, T_dim, T_Storage>::type lhs, \
const Vector<T_Type, T_dim, T_Storage>& rhs) \
{ \
/* to avoid allocation side effects the result is always a vector \
Expand Down
6 changes: 3 additions & 3 deletions include/pmacc/test/random/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# If not, see <http://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)
project("TestRandomGenerators")

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../..")
Expand All @@ -28,10 +28,10 @@ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../..")
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


################################################################################
Expand Down
6 changes: 3 additions & 3 deletions share/ci/install/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ set -o pipefail

cd $CI_PROJECT_DIR

cmake_version="cmake@3.22"
cmake_version="cmake@3.25"
echo "CMake-version: $cmake_version"
if agc-manager -e $cmake_version ; then
export PATH=$(agc-manager -b cmake@3.22)/bin:$PATH
export PATH=$(agc-manager -b cmake@3.25)/bin:$PATH
else
# throw only a warning because for pypicongpu test we do not need CMake
echo "WARNING: CMake 3.22 is not available" >&2
echo "WARNING: CMake 3.25 is not available" >&2
fi
60 changes: 14 additions & 46 deletions share/ci/n_wise_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ def is_valid_combination(row):
# hipcc is only valid in one combination
if is_hip:
if is_hipcc and is_clang:
if 5.3 <= v_hip <= 5.4 and v_compiler == 15:
return True
if 5.5 <= v_hip <= 5.6 and v_compiler == 16:
return True
if 5.7 <= v_hip <= 6.1 and v_compiler == 17:
if v_hip < 6.0:
return False
if 6.0 <= v_hip <= 6.1 and v_compiler == 17:
return True
if v_hip == 6.2 and v_compiler == 18:
return True
Expand All @@ -144,53 +142,33 @@ def is_valid_combination(row):
if is_clang_cuda:
if not is_cuda:
return False
# alpaka version 1.X enforces at least clang 14 to compile CUDA
# code with clang
if v_compiler < 14:
return False
if 11.0 <= v_cuda <= 11.5 and 14 <= v_compiler <= 15:
return True
if 11.0 <= v_cuda <= 11.8 and v_compiler == 17:
return True
if 11.0 <= v_cuda <= 12.3 and v_compiler == 18:
if 12.0 <= v_cuda <= 12.3 and v_compiler == 18:
return True
return False

# nvcc compatibility
if is_cuda and is_nvcc:
# for C++20 support CUDA >= 12 is required
if v_cuda < 12.0:
return False

if is_gnu:
# disabled due to a bug in CUDA 12.4 with gcc 13
# /usr/include/x86_64-linux-gnu/bits/floatn-common.h(214):
# error: invalid combination of type specifiers
# typedef float _Float32;
if 12.4 == v_cuda and v_compiler == 13:
return False
# official g++ 9 and CUDA is supported but due to many
# compile issue we do not support this combination anymore
if v_compiler <= 9:
return False
if 11.1 <= v_cuda <= 11.3 and v_compiler <= 10:
if v_compiler == 10:
# nvcc + gcc 10.3 bug see:
# https://github.com/alpaka-group/alpaka/issues/1297
return False
else:
return True
# nvcc 11.4/11.5 does not work with gcc 11.4 (11.3 is working)
if 11.4 <= v_cuda <= 11.5 and v_compiler == 11:
# for C++20 add least gcc 10 is required
if v_compiler < 10:
return False
if 11.4 <= v_cuda <= 11.8 and v_compiler <= 11:
return True
if 12.0 <= v_cuda <= 12.3 and v_compiler <= 12:
return True
if 12.4 <= v_cuda <= 12.5 and v_compiler <= 13:
return True

if is_clang:
# for C++17 support CUDA >= 11 is required
if v_cuda == 11.0 and v_compiler <= 9:
return True
if 11.1 <= v_cuda <= 12.0 and v_compiler <= 10:
if v_cuda == 12.0 and v_compiler == 10:
return True
if v_cuda == 12.1 and v_compiler == 14:
return True
Expand All @@ -214,7 +192,7 @@ def is_valid_combination(row):
("clang++", 17),
("clang++", 18),
]
gnu_compilers = [("g++", 9), ("g++", 10), ("g++", 11), ("g++", 13)]
gnu_compilers = [("g++", 10), ("g++", 11), ("g++", 13)]
compilers = [clang_compiers, gnu_compilers]

# generate clang cuda compiler list
Expand Down Expand Up @@ -242,18 +220,8 @@ def is_valid_combination(row):
# tuple with two components (backend name, version)
# version is only required for the cuda backend
backends = [
("hip", 5.4),
("hip", 5.5),
("hip", 5.6),
("hip", 5.7),
("hip", 6.0),
("hip", 6.1),
("cuda", 11.3),
("cuda", 11.4),
("cuda", 11.5),
("cuda", 11.6),
("cuda", 11.7),
("cuda", 11.8),
# ("hip", 6.0),
# ("hip", 6.1),
("cuda", 12.0),
("cuda", 12.1),
("cuda", 12.2),
Expand Down
6 changes: 3 additions & 3 deletions share/picongpu/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
# If not, see <http://www.gnu.org/licenses/>.
#

cmake_minimum_required(VERSION 3.22.0)
cmake_minimum_required(VERSION 3.25.0)
project("UnitTest")

###############################################################################
# Language Flags
###############################################################################

# enforce C++17
# enforce C++20
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)


################################################################################
Expand Down
Loading

0 comments on commit f7b5239

Please sign in to comment.