Skip to content

Commit 6ac0019

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 6ac0019

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,29 @@ 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)
1841
find_file(LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll")
1942
get_filename_component(LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY)
@@ -25,9 +48,21 @@ if(LIBHWLOC_LIBRARY)
2548
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
2649
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
2750
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
51+
message(STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION}")
2852
if(WINDOWS)
2953
message(STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS}")
3054
endif()
55+
56+
if(LIBHWLOC_FIND_VERSION)
57+
if(NOT LIBHWLOC_VERSION)
58+
message(WARNING "Failed to retrieve libhwloc version")
59+
elseif(NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL LIBHWLOC_FIND_VERSION)
60+
message(
61+
FATAL_ERROR
62+
" Required version: ${LIBHWLOC_FIND_VERSION}, found ${LIBHWLOC_VERSION}"
63+
)
64+
endif()
65+
endif()
3166
else()
3267
set(MSG_NOT_FOUND
3368
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)")

0 commit comments

Comments
 (0)