project(Gromacs)
-if (MSVC)
- set(CMAKE_CXX_STANDARD 14)
-else()
- set(CMAKE_CXX_STANDARD 11)
-endif()
+set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(gmxDetectTargetArchitecture)
gmx_detect_target_architecture()
-include(CheckCCompilerFlag)
-include(CheckCXXCompilerFlag)
-
########################################################################
# User input options #
########################################################################
# Test MPI with CUDA
# Test MPI with gcc
# Test MPMD PME with library MPI
-gcc-5 gpuhw=nvidia cuda-8.0 cmake-3.10.0 mpi npme=1 nranks=2 openmp
+# TODO: reenable after minimum CUDA version is compatible with C++14 host build
+# gcc-5 gpuhw=nvidia cuda-8.0 cmake-3.10.0 mpi npme=1 nranks=2 openmp
# Test non-default use of mdrun -gpu_id
# Test newest gcc supported by newest CUDA at time of release
set(GMX_CXX_STANDARD_COMPILE_OPTION "${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
endif()
else()
- set(GMX_CXX_STANDARD_COMPILE_OPTION "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}")
+ set(GMX_CXX_STANDARD_COMPILE_OPTION "${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
endif()
list(APPEND GMX_CUDA_NVCC_FLAGS "${GMX_CXX_STANDARD_COMPILE_OPTION}")
Portability considerations
^^^^^^^^^^^^^^^^^^^^^^^^^^
-|Gromacs| uses C99 for C files and C++11 for C++ files.
+Most |Gromacs| files compile as C++14, but some files remain that compile as C99.
C++ has a lot of features, but to keep the source code maintainable and easy to read,
we will avoid using some of them in |Gromacs| code. The basic principle is to keep things
as simple as possible.
these standards fully.
* MSVC supports only a subset of C99 and work-arounds are required in those cases.
-* Before 7.0 (partial support in 6.5) CUDA didn't support C++11. Therefore any
- header file which is needed (or likely will be nedded) by CUDA should not use C++11.
-* We should be able to use virtually all C++ features outside of the header files
- required by CUDA code (and OpenCL kernels), since we have gradually moved to
- compilers that have full support for C++11.
+* We should be able to use virtually all C++11 features outside of OpenCL kernels
+ (which compile as C), and for consistency also in CUDA kernels.
C++ Standard Library
--------------------
-|Gromacs| code must support the lowest common denominator of C++11 standard library
+|Gromacs| code must support the lowest common denominator of C++14 standard library
features available on supported platforms.
Some modern features are useful enough to warrant back-porting.
Consistent and forward-compatible headers are provided in ``src/gromacs/compat/``
make sure that they do what you
want). ``src/gromacs/utility/classhelpers.h`` has some convenience
macros for doing this well.
- Starting from c++11, you can also use deleted functions in this case.
+ You can also use deleted functions in this case.
* Declare all constructors with one parameter as explicit unless you
really know what you are doing. Otherwise, they can be used for
implicit type conversions, which can make the code difficult to
Compiler
^^^^^^^^
-|Gromacs| can be compiled on any platform with ANSI C99 and C++11
+|Gromacs| can be compiled on any platform with ANSI C99 and C++14
compilers, and their respective standard C/C++ libraries. Good
performance on an OS and architecture requires choosing a good
compiler. We recommend gcc, because it is free, widely available and
frequently provides the best performance.
You should strive to use the most recent version of your
-compiler. Since we require full C++11 support the minimum supported
+compiler. Since we require full C++14 support the minimum supported
compiler versions are
* GNU (gcc) 5.1
* Intel (icc) 17.0.1
* LLVM (clang) 3.6
-* Microsoft (MSVC) 2017 (C++14 is used)
+* Microsoft (MSVC) 2017
Other compilers may work (Cray, Pathscale, older clang) but do
not offer competitive performance. We recommend against PGI because
components beside the compiler itself (e.g. assembler or linker);
these are often shipped by your OS distribution's binutils package.
-C++11 support requires adequate support in both the compiler and the
+C++14 support requires adequate support in both the compiler and the
C++ library. The gcc and MSVC compilers include their own standard
libraries and require no further configuration. For configuration of
other compilers, read on.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* Adapted from the Guidelines Support Library v2.0.0. at
* https://github.com/Microsoft/GSL
*
- * \todo Replace comments referring to c++14-constexpr with constexpr
- * when we require C++14.
- *
* \author Mark Abraham <mark.j.abraham@gmail.com>
* \ingroup module_compat
* \inlibraryapi
//! Move constructor. Asserts in debug mode if \c is nullptr.
template <typename U, typename = typename std::enable_if<std::is_convertible<U, T>::value>::type >
- /*c++14-constexpr*/ explicit not_null(U &&u) : ptr_(std::forward<U>(u))
+ constexpr explicit not_null(U &&u) : ptr_(std::forward<U>(u))
{
Expects(ptr_ != nullptr);
}
//! Simple constructor. Asserts in debug mode if \c u is nullptr.
template <typename = typename std::enable_if<!std::is_same<std::nullptr_t, T>::value>::type >
- /*c++14-constexpr*/ explicit not_null(T u) : ptr_(u)
+ constexpr explicit not_null(T u) : ptr_(u)
{
Expects(ptr_ != nullptr);
}
//! Getters
//! \{
- /*c++14-constexpr*/ T get() const
+ constexpr T get() const
{
Ensures(ptr_ != nullptr);
return ptr_;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
storage_(),
unpaddedEnd_(begin())
{}
- /*! \brief Constructor that specifes the initial size.
- *
- * \todo This should also be specialized by allocator, but
- * std::vector for storage_ doesn't have such a constructor
- * before C++14. Resolve. */
- explicit PaddedVector(size_type count) :
- storage_(count),
+ /*! \brief Constructor that specifes the initial size. */
+ explicit PaddedVector(size_type count,
+ const allocator_type &allocator = Allocator()) :
+ storage_(count, allocator),
unpaddedEnd_(begin() + count)
{
// The count elements have been default inserted, and now
// the padding elements are added
resizeWithPadding(count);
}
- /*! \brief Constructor that specifes the initial size and an element to copy.
- *
- * \todo This should also be specialized by allocator, but
- * std::vector for storage_ doesn't have such a constructor
- * before C++14. Resolve. */
- explicit PaddedVector(size_type count, value_type const &v) :
- storage_(count, v),
+ /*! \brief Constructor that specifes the initial size and an element to copy. */
+ explicit PaddedVector(size_type count,
+ value_type const &v,
+ const allocator_type &allocator = Allocator()) :
+ storage_(count, v, allocator),
unpaddedEnd_(begin() + count)
{
// The count elements have been default inserted, and now