Skip to content

Commit 13d7b52

Browse files
Merge pull request #432 from kswiecicki/hwloc-fix
Add requirement for HWLOC version
2 parents 1c5a95d + dad37db commit 13d7b52

File tree

7 files changed

+64
-5
lines changed

7 files changed

+64
-5
lines changed

.github/scripts/install_hwloc.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
# install_hwloc.sh - Script for building and installing HWLOC library from source code
7+
8+
set -e
9+
10+
git clone -b hwloc-2.3.0 https://github.com/open-mpi/hwloc.git
11+
pushd hwloc
12+
./autogen.sh
13+
./configure
14+
make -j$(nproc)
15+
sudo make install -j$(nproc)
16+
popd

.github/workflows/basic.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ jobs:
127127
- name: Install apt packages
128128
run: |
129129
sudo apt-get update
130-
sudo apt-get install -y clang cmake libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev
130+
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev libtbb-dev
131131
132132
- name: Install g++-7
133133
if: matrix.compiler.cxx == 'g++-7'
134134
run: sudo apt-get install -y ${{matrix.compiler.cxx}}
135135

136+
- name: Install libhwloc
137+
run: .github/scripts/install_hwloc.sh
138+
136139
- name: Configure build
137140
run: >
138141
cmake

.github/workflows/qemu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,5 @@ jobs:
123123
fi
124124
125125
scp -P 2222 ${{github.workspace}}/scripts/qemu/run-build.sh [email protected]:/home/cxltest
126+
scp -P 2222 ${{github.workspace}}/.github/scripts/install_hwloc.sh [email protected]:/home/cxltest
126127
ssh [email protected] -p 2222 -t "bash /home/cxltest/run-build.sh https://github.com/$CI_REPO ${{env.CI_BRANCH}}"

CMakeLists.txt

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

173-
pkg_check_modules(LIBHWLOC hwloc)
173+
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
174174
if(NOT LIBHWLOC_FOUND)
175-
find_package(LIBHWLOC REQUIRED hwloc)
175+
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
176176
endif()
177177
# add PATH to DLL on Windows
178178
set(DLL_PATH_LIST

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using the Level Zero API and UMF Level Zero memory provider.
3030
### Requirements
3131

3232
Required packages:
33-
- libhwloc-dev (Linux) / hwloc (Windows)
33+
- libhwloc-dev >= 2.3.0 (Linux) / hwloc >= 2.3.0 (Windows)
3434
- C compiler
3535
- [CMake](https://cmake.org/) >= 3.14.0
3636

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(FATAL_ERROR "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)")

scripts/qemu/run-build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ repo=$1
1010
branch=$2
1111

1212
echo password | sudo -Sk apt update
13-
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev libhwloc-dev
13+
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev
14+
15+
# install packages required for building hwloc from source
16+
echo password | sudo -Sk apt install -y autoconf libtool
17+
source install_hwloc.sh
1418

1519
numactl -H
1620

0 commit comments

Comments
 (0)