Skip to content

Add requirement for HWLOC version #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/scripts/install_hwloc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# install_hwloc.sh - Script for building and installing HWLOC library from source code

set -e

git clone -b hwloc-2.3.0 https://github.com/open-mpi/hwloc.git
pushd hwloc
./autogen.sh
./configure
make -j$(nproc)
sudo make install -j$(nproc)
popd
5 changes: 4 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,15 @@ jobs:
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev libtbb-dev

- name: Install g++-7
if: matrix.compiler.cxx == 'g++-7'
run: sudo apt-get install -y ${{matrix.compiler.cxx}}

- name: Install libhwloc
run: .github/scripts/install_hwloc.sh

- name: Configure build
run: >
cmake
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@ jobs:
fi

scp -P 2222 ${{github.workspace}}/scripts/qemu/run-build.sh [email protected]:/home/cxltest
scp -P 2222 ${{github.workspace}}/.github/scripts/install_hwloc.sh [email protected]:/home/cxltest
ssh [email protected] -p 2222 -t "bash /home/cxltest/run-build.sh https://github.com/$CI_REPO ${{env.CI_BRANCH}}"
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ if(WINDOWS)
)
endif()

pkg_check_modules(LIBHWLOC hwloc)
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
if(NOT LIBHWLOC_FOUND)
find_package(LIBHWLOC REQUIRED hwloc)
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
endif()
# add PATH to DLL on Windows
set(DLL_PATH_LIST
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ which includes the code of the basic [example](https://github.com/oneapi-src/uni
### Requirements

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

Expand Down
35 changes: 35 additions & 0 deletions cmake/FindLIBHWLOC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ find_file(LIBHWLOC_HEADER NAMES hwloc.h)
get_filename_component(LIBHWLOC_INCLUDE_DIR ${LIBHWLOC_HEADER} DIRECTORY)
set(LIBHWLOC_INCLUDE_DIRS ${LIBHWLOC_INCLUDE_DIR})

if(LIBHWLOC_INCLUDE_DIR)
if(EXISTS "${LIBHWLOC_INCLUDE_DIR}/hwloc/autogen/config.h")
file(
STRINGS "${LIBHWLOC_INCLUDE_DIR}/hwloc/autogen/config.h"
LIBHWLOC_VERSION
REGEX
"#define[ \t]HWLOC_VERSION[ \t]\"([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\""
)
string(
REGEX
REPLACE
"#define[ \t]HWLOC_VERSION[ \t]\"([0-9]+.[0-9]+.[0-9]+(rc[0-9])?)(-git)?\""
"\\1"
LIBHWLOC_VERSION
"${LIBHWLOC_VERSION}")
else()
message(
WARNING
"LIBHWLOC_INCLUDE_DIR found, but header with version info is missing"
)
endif()
endif()

if(WINDOWS)
find_file(LIBHWLOC_DLL NAMES "bin/hwloc-15.dll" "bin/libhwloc-15.dll")
get_filename_component(LIBHWLOC_DLL_DIR ${LIBHWLOC_DLL} DIRECTORY)
Expand All @@ -25,9 +48,21 @@ if(LIBHWLOC_LIBRARY)
message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
message(STATUS " LIBHWLOC_VERSION = ${LIBHWLOC_VERSION}")
if(WINDOWS)
message(STATUS " LIBHWLOC_DLL_DIRS = ${LIBHWLOC_DLL_DIRS}")
endif()

if(LIBHWLOC_FIND_VERSION)
if(NOT LIBHWLOC_VERSION)
message(FATAL_ERROR "Failed to retrieve libhwloc version")
elseif(NOT LIBHWLOC_VERSION VERSION_GREATER_EQUAL LIBHWLOC_FIND_VERSION)
message(
FATAL_ERROR
" Required version: ${LIBHWLOC_FIND_VERSION}, found ${LIBHWLOC_VERSION}"
)
endif()
endif()
else()
set(MSG_NOT_FOUND
"libhwloc NOT found (set CMAKE_PREFIX_PATH to point the location)")
Expand Down
6 changes: 5 additions & 1 deletion scripts/qemu/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ repo=$1
branch=$2

echo password | sudo -Sk apt update
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev libhwloc-dev
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev

# install packages required for building hwloc from source
echo password | sudo -Sk apt install -y autoconf libtool
source install_hwloc.sh

numactl -H

Expand Down