Skip to content

Commit bbdb3f4

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 20e0751 commit bbdb3f4

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ if(WINDOWS)
167167
)
168168
endif()
169169

170-
pkg_check_modules(LIBHWLOC hwloc)
170+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
171171
if(NOT LIBHWLOC_FOUND)
172-
find_package(LIBHWLOC REQUIRED hwloc)
172+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
173173
endif()
174174
# add PATH to DLL on Windows
175175
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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ 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(STRINGS "${LIBHWLOC_INCLUDE_DIR}/hwloc/autogen/config.h"
20+
LIBHWLOC_VERSION
21+
REGEX "#define[ \t]HWLOC_VERSION[ \t]\"[0-9]+.[0-9]+.[0-9]+\"")
22+
string(
23+
REGEX
24+
REPLACE "#define[ \t]HWLOC_VERSION[ \t]\"([0-9]+.[0-9]+.[0-9]+)\""
25+
"\\1" LIBHWLOC_VERSION ${LIBHWLOC_VERSION})
26+
else()
27+
message(
28+
WARNING
29+
"LIBHWLOC_INCLUDE_DIR found, but header with version info is missing"
30+
)
31+
endif()
32+
endif()
33+
1734
if(WINDOWS)
1835
find_file(LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll")
1936
get_filename_component(LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY)
@@ -25,9 +42,20 @@ if(LIBHWLOC_LIBRARY)
2542
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
2643
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
2744
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
45+
message(STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION}")
2846
if(WINDOWS)
2947
message(STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS}")
3048
endif()
49+
50+
if(LIBHWLOC_FIND_VERSION)
51+
if(NOT LIBHWLOC_VERSION OR NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL
52+
LIBHWLOC_FIND_VERSION)
53+
message(
54+
FATAL_ERROR
55+
" Required version: ${LIBHWLOC_FIND_VERSION}, found ${LIBHWLOC_VERSION}"
56+
)
57+
endif()
58+
endif()
3159
else()
3260
set(MSG_NOT_FOUND
3361
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)")

0 commit comments

Comments
 (0)