Use trivalue option for GMX_HWLOC
authorSzilárd Páll <pall.szilard@gmail.com>
Tue, 10 Apr 2018 13:28:11 +0000 (15:28 +0200)
committerSzilárd Páll <pall.szilard@gmail.com>
Fri, 13 Apr 2018 17:45:13 +0000 (19:45 +0200)
Don't run hwloc detection if GMX_HWLOC=OFF. Separated the value of the
variable set by the user from the specification of the default
behaviour and the selected behaviour.

Change-Id: I70dbe9e40857680dc3987eb8b6820c5ccac96b63

CMakeLists.txt
src/config.h.cmakein
src/gromacs/hardware/hardwaretopology.cpp
src/gromacs/hardware/tests/hardwaretopology.cpp
src/gromacs/utility/binaryinformation.cpp

index 1c334e0c3f854a56c23da64450bcb227abb08295..295d6fce4356cce6eeb08227722df7dfc6ea19a5 100644 (file)
@@ -489,32 +489,37 @@ include(gmxManageSharedLibraries)
 #    set(XML_LIBRARIES ${LIBXML2_LIBRARIES})
 #endif()
 
-if(DEFINED HWLOC_LIBRARIES)
-  set(Hwloc_FIND_QUIETLY TRUE)
-endif()
-find_package(Hwloc 1.5)
-if (HWLOC_FOUND)
-    if (HWLOC_LIBRARIES MATCHES ".a$")
-        set(_STATIC_HWLOC TRUE)
+gmx_option_trivalue(
+    GMX_HWLOC
+    "Use hwloc portable hardware locality library"
+    "AUTO")
+
+if (GMX_HWLOC)
+    # Find quietly the second time.
+    if(DEFINED HWLOC_LIBRARIES)
+        set(Hwloc_FIND_QUIETLY TRUE)
     endif()
+    find_package(Hwloc 1.5)
 
-    gmx_check_if_changed(HWLOC_FOUND_CHANGED HWLOC_FOUND)
-    if (_STATIC_HWLOC AND HWLOC_FOUND_CHANGED)
-        message(STATUS "Static hwloc library found, will not attempt using it as it could lead to link-time errors. To use the detected library, manually set GMX_HWLOC=ON and you will likely have to pass appropriate linker flags too to satisfy the link-time dependencies of your hwloc library. Try \"pkg-config --libs --static hwloc\" for suggestions on what you will need.")
-        set(GMX_HWLOC_DEFAULT OFF)
-    else()
-        set(GMX_HWLOC_DEFAULT ON)
-    endif()
-else()
-    set(GMX_HWLOC_DEFAULT OFF)
-endif()
-option(GMX_HWLOC "Add support for hwloc Portable Hardware locality library" ${GMX_HWLOC_DEFAULT})
-if(GMX_HWLOC)
-    if(HWLOC_FOUND)
-        include_directories(SYSTEM ${HWLOC_INCLUDE_DIRS})
-        list(APPEND GMX_EXTRA_LIBRARIES ${HWLOC_LIBRARIES})
-    else()
-        message(FATAL_ERROR "Hwloc package support requested, but not found.")
+    if (HWLOC_FOUND)
+        if (HWLOC_LIBRARIES MATCHES ".a$")
+            set(_STATIC_HWLOC TRUE)
+        endif()
+
+        gmx_check_if_changed(HWLOC_FOUND_CHANGED HWLOC_FOUND)
+        if (_STATIC_HWLOC AND HWLOC_FOUND_CHANGED)
+            message(STATUS "Static hwloc library found, will not attempt using it as it could lead to link-time errors. To use the detected library, manually set GMX_HWLOC=ON and you will likely have to pass appropriate linker flags too to satisfy the link-time dependencies of your hwloc library. Try \"pkg-config --libs --static hwloc\" for suggestions on what you will need.")
+            set(GMX_USE_HWLOC OFF)
+        else()
+            set(GMX_USE_HWLOC ON)
+        endif()
+
+        if (GMX_USE_HWLOC)
+            include_directories(SYSTEM ${HWLOC_INCLUDE_DIRS})
+            list(APPEND GMX_EXTRA_LIBRARIES ${HWLOC_LIBRARIES})
+        endif()
+    elseif(GMX_HWLOC_FORCE)
+        message(FATAL_ERROR "Hwloc package support required, but not found.")
     endif()
 endif()
 
index b71a0a4bef4cc4f0a1737baf6b53f28d6b84a145..a5b359860157a436fd2e069e7ab67e07a410b7d8 100644 (file)
 #cmakedefine01 GMX_OPENMP
 
 /* Use the Portable Hardware Locality package (hwloc) */
-#cmakedefine01 GMX_HWLOC
+#cmakedefine01 GMX_USE_HWLOC
 
 /* Can and should use nice(3) to set priority */
 #cmakedefine01 GMX_USE_NICE
index 44a8a120381d2f3559f057871d5eaf5fce2a5e78..5620915da0f568bdc88c54dad354d00b7ab15a8b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, 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.
@@ -52,7 +52,7 @@
 #include <algorithm>
 #include <vector>
 
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
 #    include <hwloc.h>
 #endif
 
@@ -150,7 +150,7 @@ parseCpuInfo(HardwareTopology::Machine *        machine,
     }
 }
 
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
 
 #if HWLOC_API_VERSION < 0x00010b00
 #    define HWLOC_OBJ_PACKAGE  HWLOC_OBJ_SOCKET
@@ -582,7 +582,7 @@ HardwareTopology HardwareTopology::detect()
 {
     HardwareTopology result;
 
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
     parseHwLoc(&result.machine_, &result.supportLevel_, &result.isThisSystem_);
 #endif
 
index ed7897b015c2ba785dd935d566aa9d12352485de..8f8afc9936443fe5a698ec746fbc8ad10a465e3c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2018, 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.
@@ -76,7 +76,7 @@ TEST(HardwareTopologyTest, Execute)
     << "Please mail gmx-developers@gromacs.org so we can try to fix it.";
 }
 
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
 TEST(HardwareTopologyTest, HwlocExecute)
 {
 #if defined(__linux__)
index b106b884d89b3d65aec6ef834dc00381cddb3d6d..cb138cf36bf94d8fd759abd426747e91db754d03 100644 (file)
@@ -59,7 +59,7 @@
 #include <extrae_user_events.h>
 #endif
 
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
 #include <hwloc.h>
 #endif
 
@@ -262,7 +262,7 @@ void gmx_print_version_info(gmx::TextWriter *writer)
 #else
     writer->writeLine("TNG support:        disabled");
 #endif
-#if GMX_HWLOC
+#if GMX_USE_HWLOC
     writer->writeLine(formatString("Hwloc support:      hwloc-%d.%d.%d",
                                    HWLOC_API_VERSION>>16,
                                    (HWLOC_API_VERSION>>8) & 0xFF,