[Openmp-commits] [PATCH] D142036: [OpenMP] Add HWLOC compatibility check

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Jan 18 15:33:56 PST 2023


tianshilei1992 updated this revision to Diff 490320.
tianshilei1992 added a comment.

fix comment and refine the logic


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142036/new/

https://reviews.llvm.org/D142036

Files:
  openmp/runtime/cmake/config-ix.cmake


Index: openmp/runtime/cmake/config-ix.cmake
===================================================================
--- openmp/runtime/cmake/config-ix.cmake
+++ openmp/runtime/cmake/config-ix.cmake
@@ -339,23 +339,39 @@
 
 # Check if HWLOC support is available
 if(${LIBOMP_USE_HWLOC})
+  # Check the header
   find_path(LIBOMP_HWLOC_INCLUDE_DIR NAMES hwloc.h HINTS ${LIBOMP_HWLOC_INSTALL_DIR} PATH_SUFFIXES include)
   set(CMAKE_REQUIRED_INCLUDES ${LIBOMP_HWLOC_INCLUDE_DIR})
   check_include_file(hwloc.h LIBOMP_HAVE_HWLOC_H)
   set(CMAKE_REQUIRED_INCLUDES)
+  if(LIBOMP_HAVE_HWLOC_H)
+    include(CheckStructHasMember)
+    # Check if struct hwloc_group_attr_s has kind as it is a new feature in HWLOC 2 and we need that.
+    check_struct_has_member("struct hwloc_group_attr_s" "kind" hwloc.h LIBOMP_HAVE_REQUIRED_HWLOC_H)
+    if(NOT LIBOMP_HAVE_REQUIRED_HWLOC_H)
+      set(LIBOMP_HAVE_HWLOC_H FALSE)
+    endif()
+  endif()
+
+  # Check the library
   find_library(LIBOMP_HWLOC_LIBRARY
     NAMES hwloc libhwloc
     HINTS ${LIBOMP_HWLOC_INSTALL_DIR}/lib)
   if(LIBOMP_HWLOC_LIBRARY)
     check_library_exists(${LIBOMP_HWLOC_LIBRARY} hwloc_topology_init
       ${LIBOMP_HWLOC_INSTALL_DIR}/lib LIBOMP_HAVE_LIBHWLOC)
-    get_filename_component(LIBOMP_HWLOC_LIBRARY_DIR ${LIBOMP_HWLOC_LIBRARY} PATH)
+    if (NOT LIBOMP_HAVE_LIBHWLOC)
+      set(LIBOMP_HWLOC_LIBRARY FALSE)
+    else()
+      get_filename_component(LIBOMP_HWLOC_LIBRARY_DIR ${LIBOMP_HWLOC_LIBRARY} PATH)
+    endif()
   endif()
-  if(LIBOMP_HAVE_HWLOC_H AND LIBOMP_HAVE_LIBHWLOC AND LIBOMP_HWLOC_LIBRARY)
+
+  if(LIBOMP_HAVE_HWLOC_H AND LIBOMP_HWLOC_LIBRARY)
     set(LIBOMP_HAVE_HWLOC TRUE)
   else()
     set(LIBOMP_HAVE_HWLOC FALSE)
-    libomp_say("Could not find hwloc")
+    libomp_say("Could not find required hwloc (version 2+)")
   endif()
 endif()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142036.490320.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230118/45581425/attachment-0001.bin>


More information about the Openmp-commits mailing list