Skip to content

Commit a5ead3e

Browse files
committed
Add requirement for HWLOC version
HWLOC library needs to be at least version 2.3.0 as it introduces the API used in NUMA node property querying used for memspace creation.
1 parent 86d1067 commit a5ead3e

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ if(WINDOWS)
169169
)
170170
endif()
171171

172-
pkg_check_modules(LIBHWLOC hwloc)
172+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
173173
if(NOT LIBHWLOC_FOUND)
174-
find_package(LIBHWLOC REQUIRED hwloc)
174+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
175175
endif()
176176
# add PATH to DLL on Windows
177177
set(DLL_PATH_LIST

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ which includes the code of the basic [example](https://github.com/oneapi-src/uni
2525
### Requirements
2626

2727
Required packages:
28-
- libhwloc-dev (Linux) / hwloc (Windows)
28+
- libhwloc-dev >= 2.3.0 (Linux) / hwloc >= 2.3.0 (Windows)
2929
- C compiler
3030
- [CMake](https://cmake.org/) >= 3.14.0
3131

cmake/FindLIBHWLOC.cmake

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,32 @@ find_file(LIBHWLOC_HEADER NAMES hwloc.h)
1414
get_filename_component(LIBHWLOC_INCLUDE_DIR ${LIBHWLOC_HEADER} DIRECTORY)
1515
set(LIBHWLOC_INCLUDE_DIRS ${LIBHWLOC_INCLUDE_DIR})
1616

17+
if(LIBHWLOC_INCLUDE_DIR)
18+
if(EXISTS "${LIBHWLOC_INCLUDE_DIR}/hwloc/autogen/config.h")
19+
file(
20+
STRINGS "${LIBHWLOC_INCLUDE_DIR}/hwloc/autogen/config.h"
21+
LIBHWLOC_VERSION
22+
REGEX
23+
"#define[ \t]HWLOC_VERSION[ \t]\"([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\""
24+
)
25+
string(
26+
REGEX
27+
REPLACE
28+
"#define[ \t]HWLOC_VERSION[ \t]\"([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\""
29+
"\\1"
30+
LIBHWLOC_VERSION
31+
"${LIBHWLOC_VERSION}")
32+
else()
33+
message(
34+
WARNING
35+
"LIBHWLOC_INCLUDE_DIR found, but header with version info is missing"
36+
)
37+
endif()
38+
endif()
39+
1740
if(WINDOWS)
18-
find_file(LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll")
41+
file(GLOB LIBHWLOC_DLL "${LIBHWLOC_LIB_DIR}/bin/hwloc-*.dll"
42+
"${LIBHWLOC_LIB_DIR}/bin/libhwloc-*.dll")
1943
get_filename_component(LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY)
2044
set(LIBHWLOC_DLL_DIRS ${LIBHWLOC_DLL_DIR})
2145
endif()
@@ -25,9 +49,21 @@ if(LIBHWLOC_LIBRARY)
2549
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
2650
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
2751
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
52+
message(STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION}")
2853
if(WINDOWS)
2954
message(STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS}")
3055
endif()
56+
57+
if(LIBHWLOC_FIND_VERSION)
58+
if(NOT LIBHWLOC_VERSION)
59+
message(WARNING "Failed to retrieve libhwloc version")
60+
elseif(NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL LIBHWLOC_FIND_VERSION)
61+
message(
62+
FATAL_ERROR
63+
" Required version: ${LIBHWLOC_FIND_VERSION}, found ${LIBHWLOC_VERSION}"
64+
)
65+
endif()
66+
endif()
3167
else()
3268
set(MSG_NOT_FOUND
3369
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)")

0 commit comments

Comments
 (0)