#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2015,2016,2017,2018, by the GROMACS development team, led by
+# Copyright (c) 2015,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.
message(STATUS "Error executing hwloc-info: ${HWLOC_INFO_ERR}")
endif()
string(REGEX MATCH "[0-9]+.*[0-9]+" HWLOC_INFO_OUT "${HWLOC_INFO_OUT}")
- set(HWLOC_VERSION ${HWLOC_INFO_OUT} CACHE STRING "Hwloc library version")
+ set(HWLOC_LIBRARY_VERSION ${HWLOC_INFO_OUT} CACHE STRING "Hwloc library version")
endif()
endif()
endif()
# Parse header if cross-compiling, or if hwloc-info was not found
- if(NOT HWLOC_VERSION)
- # Hwloc is never installed as a framework on OS X, so this should always work.
- file(READ "${HWLOC_INCLUDE_DIRS}/hwloc.h"
- HEADER_CONTENTS LIMIT 16384)
- string(REGEX REPLACE ".*#define HWLOC_API_VERSION (0[xX][0-9a-fA-F]+).*" "\\1"
- HWLOC_API_VERSION "${HEADER_CONTENTS}")
- string(SUBSTRING "${HWLOC_API_VERSION}" 4 2 HEX_MAJOR)
- string(SUBSTRING "${HWLOC_API_VERSION}" 6 2 HEX_MINOR)
- string(SUBSTRING "${HWLOC_API_VERSION}" 8 2 HEX_PATCH)
- hex2dec(${HEX_MAJOR} DEC_MAJOR)
- hex2dec(${HEX_MINOR} DEC_MINOR)
- hex2dec(${HEX_PATCH} DEC_PATCH)
- set(HWLOC_VERSION "${DEC_MAJOR}.${DEC_MINOR}.${DEC_PATCH}" CACHE STRING "Hwloc library version")
+ # Also used to check that library and header versions match
+ # HWLOC is never installed as a framework on OS X, so this should always work.
+ file(READ "${HWLOC_INCLUDE_DIRS}/hwloc.h"
+ HEADER_CONTENTS LIMIT 16384)
+ string(REGEX REPLACE ".*#define HWLOC_API_VERSION (0[xX][0-9a-fA-F]+).*" "\\1"
+ HWLOC_API_VERSION "${HEADER_CONTENTS}")
+ string(SUBSTRING "${HWLOC_API_VERSION}" 4 2 HEX_MAJOR)
+ string(SUBSTRING "${HWLOC_API_VERSION}" 6 2 HEX_MINOR)
+ string(SUBSTRING "${HWLOC_API_VERSION}" 8 2 HEX_PATCH)
+ hex2dec(${HEX_MAJOR} DEC_MAJOR)
+ hex2dec(${HEX_MINOR} DEC_MINOR)
+ hex2dec(${HEX_PATCH} DEC_PATCH)
+ set(HWLOC_HEADER_VERSION "${DEC_MAJOR}.${DEC_MINOR}.${DEC_PATCH}")
+ if (HWLOC_LIBRARY_VERSION AND HWLOC_HEADER_VERSION)
+ string(SUBSTRING "${HWLOC_LIBRARY_VERSION}" 0 1 LIBRARY_MAJOR)
+ string(SUBSTRING "${HWLOC_HEADER_VERSION}" 0 1 HEADER_MAJOR)
+ string(COMPARE EQUAL "${LIBRARY_MAJOR}" "${HEADER_MAJOR}" HWLOC_VERSION_CHECK)
+ if(NOT HWLOC_VERSION_CHECK)
+ message(FATAL_ERROR "Detected version mismatch between HWLOC headers and library. "
+ "Library version is ${HWLOC_LIBRARY_VERSION}, but header version is ${HWLOC_HEADER_VERSION}. "
+ "Make sure that you have the correct include and library directory set for HWLOC")
+ endif()
+ endif()
+ if (HWLOC_LIBRARY_VERSION)
+ set(HWLOC_VERSION ${HWLOC_LIBRARY_VERSION} CACHE STRING "HWLOC library version")
+ else()
+ set(HWLOC_VERSION ${HWLOC_HEADER_VERSION} CACHE STRING "HWLOC library version")
endif()
+ set(GMX_HWLOC_API_VERSION ${HWLOC_API_VERSION} CACHE STRING "HWLOC API version during configuration time")
endif()
include(FindPackageHandleStandardArgs)
Fixes that affect portability
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Check that libhwloc headers and runtime match
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+It could happen that the libhwloc headers and library detection would
+lead to a mismatch at compile or runtime that could cause cryptic
+crashes while using mdrun.
+
+:issue:`3200`
+
Miscellaneous
^^^^^^^^^^^^^
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,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.
/* Use the Portable Hardware Locality package (hwloc) */
#cmakedefine01 GMX_USE_HWLOC
+/* Library version found for hwloc during configuration time */
+#define GMX_HWLOC_API_VERSION @GMX_HWLOC_API_VERSION@
+
/* Can and should use nice(3) to set priority */
#cmakedefine01 GMX_USE_NICE
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,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.
#endif
// Preprocessor variable for if hwloc api is version 1.x.x or 2.x.x
-#if HWLOC_API_VERSION >= 0x00020000
-# define GMX_HWLOC_API_VERSION_IS_2XX 1
-#else
-# define GMX_HWLOC_API_VERSION_IS_2XX 0
-#endif
+# if HWLOC_API_VERSION >= 0x00020000
+# define GMX_HWLOC_API_VERSION_IS_2XX 1
+# if GMX_HWLOC_API_VERSION < 0x00020000
+# error "HWLOC library major version set during configuration is 1, but currently using version 2 headers"
+# endif
+# else
+# define GMX_HWLOC_API_VERSION_IS_2XX 0
+# if GMX_HWLOC_API_VERSION >= 0x00020000
+# error "HWLOC library major version set during configuration is 2, but currently using version 1 headers"
+# endif
+# endif
/*****************************************************************************
* *
}
// Flags to look for io devices
-#if GMX_HWLOC_API_VERSION_IS_2XX
+# if GMX_HWLOC_API_VERSION_IS_2XX
+ GMX_RELEASE_ASSERT(
+ (hwloc_get_api_version() >= 0x20000),
+ "Mismatch between hwloc headers and library, using v2 headers with v1 library");
hwloc_topology_set_io_types_filter(topo, HWLOC_TYPE_FILTER_KEEP_IMPORTANT);
-#else
+# else
+ GMX_RELEASE_ASSERT(
+ (hwloc_get_api_version() < 0x20000),
+ "Mismatch between hwloc headers and library, using v1 headers with v2 library");
hwloc_topology_set_flags(topo, HWLOC_TOPOLOGY_FLAG_IO_DEVICES);
#endif