Require C++14
authorRoland Schulz <roland.schulz@intel.com>
Thu, 15 Nov 2018 02:38:03 +0000 (18:38 -0800)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 25 Jan 2019 17:57:52 +0000 (18:57 +0100)
The current minimum compiler versions tested in Jenkins are already
sufficient. Leaves for a future change whether for CUDA C++11 or C++14
is used.

Addresses C++14 TODO in compat/pointers.h and stophandler.cpp.

Update developer guide

Refs #2831

Change-Id: Ib4329b96327d15c22328715172a9930092ecb64f

CMakeLists.txt
admin/builds/pre-submit-matrix.txt
cmake/gmxManageNvccConfig.cmake
docs/dev-manual/language-features.rst
docs/install-guide/index.rst
src/gromacs/compat/pointers.h
src/gromacs/math/paddedvector.h

index ea9a2e856eb56e0c0b6125b43100c74c2346efc5..04c82a569c874f6b727eae4d422b21826de9b646 100644 (file)
@@ -40,11 +40,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_
 
 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)
 
@@ -147,9 +143,6 @@ endif()
 include(gmxDetectTargetArchitecture)
 gmx_detect_target_architecture()
 
-include(CheckCCompilerFlag)
-include(CheckCXXCompilerFlag)
-
 ########################################################################
 # User input options                                                   #
 ########################################################################
index b4720073e0690b9d3297fe0e409a5660a1052379..44efc07b5bd449a141904a351ed7fc0f6acad23f 100644 (file)
@@ -21,7 +21,8 @@
 # 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
index 1b26a8a26fd01ff52e2e68aa9ce1274c6ffc9874..6139d62e911adc04709aa36a57f4237235b92e27 100644 (file)
@@ -173,7 +173,7 @@ if (MSVC)
         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}")
 
index aca8891e19a3448fba24e007692bf672741ed6ef..07f7d1014163272f4929c6cc467a48f90a86457a 100644 (file)
@@ -7,7 +7,7 @@ reason for deviating from them.
 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.
@@ -15,16 +15,13 @@ For compatiblity, certain work-arounds are required because not all compilers su
 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/``
@@ -108,7 +105,7 @@ a release.
   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
index e30e4d5e187e28f09489f2021cb8d0e598906966..c616337c9c43cb172f9c90face16a56c3ed245e1 100644 (file)
@@ -104,20 +104,20 @@ PowerPC including POWER8, ARM v7, ARM v8, and SPARC VIII.
 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
@@ -131,7 +131,7 @@ You may also need the most recent version of other compiler toolchain
 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.
index 403918ce34aba114bb97a23bb45a731ecab11c79..ee9d8c63c91bb9bf029433fc2c99324dd7aacd2a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -39,9 +39,6 @@
  * 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
@@ -96,14 +93,14 @@ class not_null
 
         //! 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);
         }
@@ -123,7 +120,7 @@ class not_null
 
         //! Getters
         //! \{
-        /*c++14-constexpr*/ T get() const
+        constexpr T get() const
         {
             Ensures(ptr_ != nullptr);
             return ptr_;
index 36d507fdb7d9d256982f0322eb18a6f3440d385a..fa66983af828a899ea0eb6530d05bd42a44bb621 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
@@ -231,26 +231,21 @@ class PaddedVector
             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