#####################################################################
# The cmake/Check{C,CXX}CompilerFlag.cmake files in the GROMACS distribution
-# are used with permission from CMake v2.8.9 so that GROMACS can detect
-# invalid options with the Intel Compilers.
+# are used with permission from CMake v3.0.0 so that GROMACS can detect
+# invalid options with the Intel Compilers, and we have added a line
+# to detect warnings with the Fujitsu compilers on K computer.
+# CMake-3.0 also has a bug where the FAIL_REGEX pattern for AIX contains
+# a semicolon. Since this is also used as a separator in lists inside CMake,
+# that string ends up being split into two separate patterns, and the last
+# part is just a single word that also matches other messages. We solved this
+# by replacing the semicolon with a period that matches any character.
+#
# These files should be removed from the source tree when a CMake version that
# includes the features in question becomes required for building GROMACS.
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
-
include(gmxCFlags)
gmx_c_flags()
check_function_exists(_commit HAVE__COMMIT)
check_function_exists(sigaction HAVE_SIGACTION)
check_function_exists(sysconf HAVE_SYSCONF)
-check_function_exists(sched_setaffinity HAVE_SCHED_SETAFFINITY)
-check_function_exists(sched_getaffinity HAVE_SCHED_GETAFFINITY)
check_function_exists(rsqrt HAVE_RSQRT)
check_function_exists(rsqrtf HAVE_RSQRTF)
check_function_exists(sqrtf HAVE_SQRTF)
check_library_exists(m sqrt "" HAVE_LIBM)
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
+include(TestSchedAffinity)
+test_sched_affinity(HAVE_SCHED_AFFINITY)
+
include(TestBigEndian)
test_big_endian(GMX_INTEGER_BIG_ENDIAN)
FAIL_REGEX "[Uu]nknown option" # HP
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
FAIL_REGEX "command option .* is not recognized" # XL
+ FAIL_REGEX "command option .* contains an incorrect subargument" # XL
+ FAIL_REGEX "not supported in this configuration. ignored" # AIX
+ FAIL_REGEX "File with unknown suffix passed to linker" # PGI
FAIL_REGEX "WARNING: unknown flag:" # Open64
+ FAIL_REGEX "Incorrect command line option:" # Borland
+ FAIL_REGEX "Warning: illegal option" # SunStudio 12
+ FAIL_REGEX "[Ww]arning: Invalid" # Fujitsu
)
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_C_COMPILER_FLAG)
FAIL_REGEX "[Uu]nknown option" # HP
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
FAIL_REGEX "command option .* is not recognized" # XL
- FAIL_REGEX "not supported in this configuration. ignored" # AIX
+ FAIL_REGEX "command option .* contains an incorrect subargument" # XL
+ FAIL_REGEX "not supported in this configuration. ignored" # AIX
FAIL_REGEX "File with unknown suffix passed to linker" # PGI
FAIL_REGEX "WARNING: unknown flag:" # Open64
+ FAIL_REGEX "Incorrect command line option:" # Borland
+ FAIL_REGEX "Warning: illegal option" # SunStudio 12
+ FAIL_REGEX "[Ww]arning: Invalid" # Fujitsu
)
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_CXX_COMPILER_FLAG)
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2014, 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.
# To help us fund GROMACS development, we humbly ask that you cite
# the research papers on the package. Check out http://www.gromacs.org.
-# GMock uses tuples extensively, and MSVC bundles a tuple library that
-# is not compatible with the standard. r675 of googletest works around
-# this properly, but that's not in GMock 1.7.0. That logic is
-# duplicated here. See
-# https://code.google.com/p/googletest/source/detail?r=675#, but note
-# that its summary does not represent its code correctly.
-#
-# This function should be called to get the compile definitions
-# suitable for working around MSVC to compile GMock, if any.
-# Returns a string of options in VARIABLE
-function(GET_MSVC_TUPLE_WORKAROUND_DEFINITIONS VARIABLE)
- set(${VARIABLE} "")
- if(MSVC AND MSVC_VERSION VERSION_EQUAL 1700)
- # Fixes Visual Studio 2012
- set(${VARIABLE} "_VARIADIC_MAX=10")
- endif()
- set(${VARIABLE} ${${VARIABLE}} PARENT_SCOPE)
-endfunction()
+# - Define macro to check if all of the following work:
+# sched_getaffinity()
+# sched_setaffinity()
+# CPU_ZERO()
+# CPU_SET()
+# CPU_ISSET()
+# CPU_CLR()
+# CPU_COUNT()
+
+# test_sched_affinity(VARIABLE)
+#
+# VARIABLE will be set to true if all of the functions link fine.
+
+MACRO(test_sched_affinity VARIABLE)
+
+ if(NOT DEFINED sched_affinity_compile)
+ MESSAGE(STATUS "Checking for sched.h GNU affinity API")
+
+ check_c_source_compiles(
+ "#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include <sched.h>
+int main(void) {
+ int i;
+ cpu_set_t mask;
+ CPU_ZERO(&mask);
+ sched_getaffinity(0, sizeof(cpu_set_t), &mask);
+ if(CPU_ISSET(0,&mask))
+ {
+ CPU_CLR(0,&mask);
+ CPU_SET(0,&mask);
+ }
+ sched_setaffinity(0, sizeof(cpu_set_t), &mask);
+ return CPU_COUNT(&mask);
+}" sched_affinity_compile)
+ endif(NOT DEFINED sched_affinity_compile)
+
+ if(sched_affinity_compile)
+ set(${VARIABLE} 1 CACHE INTERNAL "Result of test for sched.h GNU affinity API" FORCE)
+ else()
+ set(${VARIABLE} 0 CACHE INTERNAL "Result of test for sched.h GNU affinity API" FORCE)
+ endif()
+ENDMACRO(test_sched_affinity VARIABLE)
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2014, 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.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+# GMock uses tuples extensively, but since it is part of tr1 we cannot
+# assume it is present - the Fujitsu compilers on K computer is one
+# example of a system where it is not, and this is likely the case for many
+# embedded systems too.
+#
+# In general, we can ask gmock to use its own internal implementation by
+# defining GTEST_USE_OWN_TR1_TUPLE=1. This is safe for Gromacs, since we do
+# not use tr1/tuple.h elsewhere. However, this workaround itself will not
+# compile on MSVC - but this is the only architecture we know where it does
+# not work. To make things even worse, on MSVC even the standard tr1/tuple
+# implementation is not fully compatible, but we can make it work by setting
+# _VARIADIC_MAX=10. This is similar to r675 of googletest, which is still not
+# present in GMock 1.7.0. See
+# https://code.google.com/p/googletest/source/detail?r=675#, but note
+# that its summary does not represent its code correctly.
+#
+# To make all this work without user intervention, we first check what compiler
+# we have, and if it is not MSVC we simply use the internal version. If we are
+# using MSVC, we rely on the compiler's version, but set the variable necessary
+# to make it compatible.
+#
+# This function should be called to get the compile definitions
+# suitable for making sure we have a tuple implementation that works with gmock.
+#
+# Returns a string of options in VARIABLE
+function(GET_GMOCK_TUPLE_WORKAROUND VARIABLE)
+ set(${VARIABLE} "")
+ if(MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Intel"))
+ if(MSVC_VERSION VERSION_EQUAL 1700)
+ # Fixes Visual Studio 2012
+ set(${VARIABLE} "_VARIADIC_MAX=10")
+ endif()
+ # For MSVC different from 2012, or Intel on Windows, we reply on tr1/tuple working.
+ else()
+ # Use the built-in version on all other compilers.
+ set(${VARIABLE} "GTEST_USE_OWN_TR1_TUPLE=1")
+ endif()
+ set(${VARIABLE} ${${VARIABLE}} PARENT_SCOPE)
+endfunction()
/* Define to 1 if you have the sysconf() function */
#cmakedefine HAVE_SYSCONF
-/* Define to 1 if you have the sched_getaffinity() function */
-#cmakedefine HAVE_SCHED_GETAFFINITY
-
-/* Define to 1 if you have the sched_setaffinity() function */
-#cmakedefine HAVE_SCHED_SETAFFINITY
+/* Define to 1 if you have the all the affinity functions in sched.h */
+#cmakedefine HAVE_SCHED_AFFINITY
/* Bytes in IEEE fp word are in big-endian order if set, little-endian if not.
Only relevant when FLOAT_FORMAT_IEEE754 is defined. */
1) Download Boost (current minimal version is derived from 1.55.0)
2) Extract
3) Edit Boost files to uncomment unnessary includes (search for GMX in minimal version and copy all changes)
-4) run bcp with required files (currently exception/all.hpp, scoped_ptr.hpp)
-5) delete source files which are not required. Currently:
- libs/smart_ptr/src/sp_collector.cpp
- libs/smart_ptr/src/sp_debug_hooks.cpp
+4) Make sure our subset works even with compilers not listed
+ among the boost ones (in particular, Fujistu in native mode):
+ - Edit config/select_compiler_config.hpp to add the fallback
+ to a generic compiler capability file at the end.
+ - Add the generic compiler capability file config/compiler/generic.hpp
+5) run bcp with required files (currently exception/all.hpp, scoped_ptr.hpp)
+6) delete source files which are not required. Currently:
+ - libs/smart_ptr/src/sp_collector.cpp
+ - libs/smart_ptr/src/sp_debug_hooks.cpp
Make sure that they are really not needed.If any source files are added make sure to add them to cmake.
--- /dev/null
+// File created by Erik Lindahl July 2014 by copying most of the pathscale.hpp
+// compiler definition in Boost-1.55.
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for most recent version.
+
+// Settings for a generic compiler. We assume that long long exists,
+// remove all C++11 support, and assume threads work.
+
+#ifndef BOOST_COMPILER
+# define BOOST_COMPILER "Generic compiler"
+#endif
+
+// It might seem stupid to assume a generic compiler to have threads, but it
+// appears some Boost reference counting might not be thread-safe without this.
+#define BOOST_HAS_THREADS
+#define BOOST_HAS_PTHREADS
+
+#define BOOST_HAS_LONG_LONG
+#define BOOST_NO_CXX11_VARIADIC_TEMPLATES
+#define BOOST_NO_CXX11_UNICODE_LITERALS
+#define BOOST_NO_CXX11_TEMPLATE_ALIASES
+#define BOOST_NO_CXX11_STATIC_ASSERT
+#define BOOST_NO_SFINAE_EXPR
+#define BOOST_NO_CXX11_SCOPED_ENUMS
+#define BOOST_NO_CXX11_RVALUE_REFERENCES
+#define BOOST_NO_CXX11_RANGE_BASED_FOR
+#define BOOST_NO_CXX11_RAW_LITERALS
+#define BOOST_NO_CXX11_NULLPTR
+#define BOOST_NO_CXX11_NUMERIC_LIMITS
+#define BOOST_NO_CXX11_NOEXCEPT
+#define BOOST_NO_CXX11_LAMBDAS
+#define BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
+#define BOOST_NO_MS_INT64_NUMERIC_LIMITS
+#define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
+#define BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+#define BOOST_NO_CXX11_DELETED_FUNCTIONS
+#define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
+#define BOOST_NO_CXX11_DECLTYPE
+#define BOOST_NO_CXX11_DECLTYPE_N3276
+#define BOOST_NO_CXX11_CONSTEXPR
+#define BOOST_NO_COMPLETE_VALUE_INITIALIZATION
+#define BOOST_NO_CXX11_CHAR32_T
+#define BOOST_NO_CXX11_CHAR16_T
+#define BOOST_NO_CXX11_AUTO_MULTIDECLARATIONS
+#define BOOST_NO_CXX11_AUTO_DECLARATIONS
+#define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
+#define BOOST_NO_CXX11_HDR_UNORDERED_SET
+#define BOOST_NO_CXX11_HDR_UNORDERED_MAP
+#define BOOST_NO_CXX11_HDR_TYPEINDEX
+#define BOOST_NO_CXX11_HDR_TUPLE
+#define BOOST_NO_CXX11_HDR_THREAD
+#define BOOST_NO_CXX11_HDR_SYSTEM_ERROR
+#define BOOST_NO_CXX11_HDR_REGEX
+#define BOOST_NO_CXX11_HDR_RATIO
+#define BOOST_NO_CXX11_HDR_RANDOM
+#define BOOST_NO_CXX11_HDR_MUTEX
+#define BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+#define BOOST_NO_CXX11_HDR_FUTURE
+#define BOOST_NO_CXX11_HDR_FORWARD_LIST
+#define BOOST_NO_CXX11_HDR_CONDITION_VARIABLE
+#define BOOST_NO_CXX11_HDR_CODECVT
+#define BOOST_NO_CXX11_HDR_CHRONO
+#define BOOST_NO_CXX11_USER_DEFINED_LITERALS
+#define BOOST_NO_CXX11_ALIGNAS
+#define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
+#define BOOST_NO_CXX11_INLINE_NAMESPACES
+
// example) also #define _MSC_VER
# define BOOST_COMPILER_CONFIG "boost/config/compiler/visualc.hpp"
-#elif defined (BOOST_ASSERT_CONFIG)
-// this must come last - generate an error if we don't
-// recognise the compiler:
-# error "Unknown compiler - please configure (http://www.boost.org/libs/config/config.htm#configuring) and report the results to the main boost mailing list (http://www.boost.org/more/mailing_lists.htm#main)"
+#else
+
+# warning Unknown boost compiler; using generic settings not tested for this compiler.
+# define BOOST_COMPILER_CONFIG "boost/config/compiler/generic.hpp"
+
#endif
# As stated in README.Gromacs, this file is not part of GMock, but is written
# specifically for the GROMACS build system from scratch.
-include(gmxGetMsvcTupleWorkaround)
-get_msvc_tuple_workaround_definitions(GMOCK_COMPILE_DEFINITIONS)
+include(gmxGetGmockTupleWorkaround)
+get_gmock_tuple_workaround(GMOCK_COMPILE_DEFINITIONS)
set(GMOCK_COMPILE_DEFINITIONS ${GMOCK_COMPILE_DEFINITIONS} PARENT_SCOPE)
# GTest/GMock suggest linking with pthreads when available for thread safety
The file CMakeLists.txt in this directory is part of the Gromacs build system
and has been written from scratch.
+
+In the default version, gmock-1.7.0 assumes wcscasecmp() to be present on Linux.
+This is not the case on all platforms, so on line 1610 of gtest/src/gtest.cc
+we have added a define to only use this if GTEST_HAS_WCSCASECMP is set. Since
+we never set this define, we fall back on the alternative internal implementation
+which should be perfectly fine for now.
#if GTEST_OS_WINDOWS
return _wcsicmp(lhs, rhs) == 0;
-#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
+#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID && GTEST_HAS_WCSCASECMP
return wcscasecmp(lhs, rhs) == 0;
#else
// Android, Mac OS X and Cygwin don't define wcscasecmp.
#elif defined(__FUJITSU) && defined(__sparc__)
/* Fujitsu FX10 SPARC compiler requires gcc compatibility with -Xg */
-#error Atomics support for Fujitsu FX10 compiler requires -Xg (gcc compatibility)
+#warning Atomics support for Fujitsu FX10 compiler requires -Xg (gcc compatibility)
+#define TMPI_NO_ATOMICS
#elif defined(_CRAYC)
#endif
#ifdef HAVE_SCHED_H
-#define _GNU_SOURCE
-#include <sched.h>
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+# include <sched.h>
#endif
#include <stdio.h>
/* Query APIC information on AMD */
if (max_extfn >= 0x80000008)
{
-#if (defined HAVE_SCHED_H && defined HAVE_SCHED_SETAFFINITY && defined HAVE_SYSCONF && defined __linux__)
+#if (defined HAVE_SCHED_AFFINITY && defined HAVE_SYSCONF && defined __linux__)
/* Linux */
unsigned int i;
cpu_set_t cpuset, save_cpuset;
if (max_stdfn >= 0xB)
{
/* Query x2 APIC information from cores */
-#if (defined HAVE_SCHED_H && defined HAVE_SCHED_SETAFFINITY && defined HAVE_SYSCONF && defined __linux__)
+#if (defined HAVE_SCHED_AFFINITY && defined HAVE_SYSCONF && defined __linux__)
/* Linux */
unsigned int i;
cpu_set_t cpuset, save_cpuset;
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GETAFFINITY)
-#define _GNU_SOURCE
-#include <sched.h>
-#include <sys/syscall.h>
+#if defined(HAVE_SCHED_H)
+# ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+# endif
+# include <sched.h>
+# include <sys/syscall.h>
#endif
#include <string.h>
#include <errno.h>
int gmx_unused nthreads_hw_avail,
gmx_bool gmx_unused bAfterOpenmpInit)
{
-#ifdef HAVE_SCHED_GETAFFINITY
+#ifdef HAVE_SCHED_AFFINITY
cpu_set_t mask_current;
int i, ret, cpu_count, cpu_set;
gmx_bool bAllSet;
fprintf(debug, "Default affinity mask found\n");
}
}
-#endif /* HAVE_SCHED_GETAFFINITY */
+#endif /* HAVE_SCHED_AFFINITY */
}
std::string toUpperCase(const std::string &text)
{
std::string result(text);
- transform(result.begin(), result.end(), result.begin(), toupper);
+ std::transform(result.begin(), result.end(), result.begin(), toupper);
return result;
}