Skip to content

Commit

Permalink
Merge branch 'master' into tswhison/cmp0148
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Whisonant authored Sep 19, 2023
2 parents 166e62f + 5c51b08 commit 42b9425
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 10 deletions.
68 changes: 67 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mark_as_advanced(OPAE_WITH_SPDLOG)
option(OPAE_WITH_LIBEDIT "Enable use of libedit" ON)
mark_as_advanced(OPAE_WITH_LIBEDIT)

option(OPAE_WITH_PYBIND11 "Enable use of pybind11." ON)
option(OPAE_WITH_PYBIND11 "Enable use of pybind11" ON)
mark_as_advanced(OPAE_WITH_PYBIND11)

option(OPAE_WITH_HWLOC "Enable use of hwloc" ON)
Expand All @@ -65,6 +65,9 @@ mark_as_advanced(OPAE_WITH_HWLOC)
option(OPAE_WITH_TBB "Enable use of tbb" ON)
mark_as_advanced(OPAE_WITH_TBB)

option(OPAE_WITH_NUMA "Enable use of numa" ON)
mark_as_advanced(OPAE_WITH_NUMA)

option(OPAE_MINIMAL_BUILD "Enable minimal build" OFF)
mark_as_advanced(OPAE_MINIMAL_BUILD)

Expand Down Expand Up @@ -565,6 +568,68 @@ if (OPAE_WITH_TBB)

endif(OPAE_WITH_TBB)

################################################################################
# numa
################################################################################

set(NUMA_URL
https://github.com/numactl/numactl.git
CACHE STRING "URL for numa")
set(NUMA_VERSION
2.0.16
CACHE STRING "Version for numa")
set(NUMA_TAG
v${NUMA_VERSION}
CACHE STRING "Tag for numa")

if (OPAE_WITH_NUMA)

if (NOT numa_FOUND)
find_package(numa ${NUMA_VERSION})
endif(NOT numa_FOUND)

if (NOT numa_FOUND)
include(ExternalProject)

message(WARNING "Building libnuma.so from source is experimental. "
"To avoid this build path, please install the libnuma-dev "
"/ numactl-devel package, which provides libnuma.so.")

ExternalProject_Add(numa
GIT_REPOSITORY ${NUMA_URL}
GIT_TAG ${NUMA_TAG}
CONFIGURE_COMMAND ./autogen.sh && ./configure
BUILD_COMMAND make libnuma.la
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
)

set(numa_ROOT ${CMAKE_CURRENT_BINARY_DIR}/numa-prefix/src/numa CACHE PATH "base dir for numa" FORCE)
set(numa_INCLUDE_DIRS ${numa_ROOT}
CACHE STRING "Path to numa" FORCE)
set(numa_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/numa-prefix/src/numa/.libs/libnuma.so
CACHE STRING "Path to numa libraries" FORCE)
set(numa_DEFINITIONS "" CACHE STRING "numa built from source" FORCE)
set(numa_FOUND TRUE CACHE BOOL "numa built from source" FORCE)

add_library(numa_IMPORT SHARED IMPORTED)
set_property(
TARGET numa_IMPORT
PROPERTY
IMPORTED_LOCATION "${numa_LIBRARIES}"
)
set(numa_IMPORTED TRUE CACHE BOOL "numa imported from source" FORCE)
add_dependencies(numa_IMPORT numa)

endif(NOT numa_FOUND)

message(STATUS "numa_ROOT ${numa_ROOT}")
message(STATUS "numa_INCLUDE_DIRS ${numa_INCLUDE_DIRS}")
message(STATUS "numa_LIBRARIES ${numa_LIBRARIES}")
message(STATUS "numa_DEFINITIONS ${numa_DEFINITIONS}")

endif(OPAE_WITH_NUMA)

################################################################################
# googletest
################################################################################
Expand Down Expand Up @@ -693,6 +758,7 @@ if (OPAE_MINIMAL_BUILD)
set(OPAE_WITH_PYBIND11 OFF CACHE BOOL "Enable use of pybind11" FORCE)
set(OPAE_WITH_HWLOC OFF CACHE BOOL "Enable use of hwloc" FORCE)
set(OPAE_WITH_TBB OFF CACHE BOOL "Enable use of tbb" FORCE)
set(OPAE_WITH_NUMA OFF CACHE BOOL "Enable use of numa" FORCE)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "" FORCE)
endif(OPAE_MINIMAL_BUILD)

Expand Down
93 changes: 93 additions & 0 deletions cmake/modules/Findnuma.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/cmake -P
## Copyright(c) 2023, Intel Corporation
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright notice,
## this list of conditions and the following disclaimer in the documentation
## and/or other materials provided with the distribution.
## * Neither the name of Intel Corporation nor the names of its contributors
## may be used to endorse or promote products derived from this software
## without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
## POSSIBILITY OF SUCH DAMAGE

# - Try to find numa
# Once done, this will define
#
# numa_FOUND - system has numa
# numa_ROOT - base dir for numa
# numa_INCLUDE_DIRS - the numa include directories
# numa_DEFINITIONS - preprocessor defines for numa
# numa_LIBRARIES - link these to use numa

find_package(PkgConfig)
pkg_check_modules(PC_NUMA QUIET numa)

execute_process(COMMAND pkg-config --cflags-only-I numa --silence-errors
COMMAND cut -d I -f 2
OUTPUT_VARIABLE NUMA_PKG_CONFIG_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND pkg-config --cflags-only-other numa --silence-errors
OUTPUT_VARIABLE NUMA_PKG_CONFIG_DEFINITIONS
OUTPUT_STRIP_TRAILING_WHITESPACE)

if (NUMA_PKG_CONFIG_DEFINITIONS)
set(numa_DEFINITIONS ${NUMA_PKG_CONFIG_DEFINITIONS})
else(NUMA_PKG_CONFIG_DEFINITIONS)
set(numa_DEFINITIONS "")
endif(NUMA_PKG_CONFIG_DEFINITIONS)

find_path(numa_ROOT NAMES include/numa.h)

find_path(numa_INCLUDE_DIRS
NAMES numa.h
HINTS ${numa_ROOT}/include
PATHS ${numa_ROOT}/include
${NUMA_PKG_CONFIG_INCLUDE_DIRS}
/usr/local/include
/usr/include
${CMAKE_EXTRA_INCLUDES}
)

if (pkgcfg_lib_PC_NUMA_numa)
set(numa_LIBRARIES ${pkgcfg_lib_PC_NUMA_numa})
else (pkgcfg_lib_PC_NUMA_numa)
find_library(numa_LIBRARIES
NAMES numa
PATHS ${numa_ROOT}/lib
/usr/local/lib
/usr/lib
/lib
/usr/lib/x86_64-linux-gnu
${CMAKE_EXTRA_LIBS}
)
endif (pkgcfg_lib_PC_NUMA_numa)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(numa
FOUND_VAR
numa_FOUND
REQUIRED_VARS
numa_ROOT numa_INCLUDE_DIRS numa_LIBRARIES
)

set(numa_FOUND ${numa_FOUND} CACHE BOOL "numa status" FORCE)
set(numa_ROOT ${numa_ROOT} CACHE PATH "base dir for numa" FORCE)
set(numa_INCLUDE_DIRS ${numa_INCLUDE_DIRS} CACHE STRING "numa include dirs" FORCE)
set(numa_LIBRARIES ${numa_LIBRARIES} CACHE STRING "numa libraries" FORCE)
set(numa_DEFINITIONS ${numa_DEFINITIONS} CACHE STRING "numa preprocessor defines" FORCE)
21 changes: 21 additions & 0 deletions cmake/modules/OPAECompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ function(opae_add_executable)
endif(NEED_EXTERNAL_HWLOC)
endif(hwloc_IMPORTED)

if (numa_IMPORTED)
string(REGEX MATCH "${numa_LIBRARIES}" NEED_EXTERNAL_NUMA "${OPAE_ADD_EXECUTABLE_LIBS}")
if (NEED_EXTERNAL_NUMA)
add_dependencies(${OPAE_ADD_EXECUTABLE_TARGET} numa_IMPORT)
endif(NEED_EXTERNAL_NUMA)
endif(numa_IMPORTED)

opae_coverage_build(TARGET ${OPAE_ADD_EXECUTABLE_TARGET} SOURCE ${OPAE_ADD_EXECUTABLE_SOURCE})
set_install_rpath(${OPAE_ADD_EXECUTABLE_TARGET})

Expand Down Expand Up @@ -313,6 +320,13 @@ function(opae_add_shared_library)
endif(NEED_EXTERNAL_HWLOC)
endif(hwloc_IMPORTED)

if (numa_IMPORTED)
string(REGEX MATCH "${numa_LIBRARIES}" NEED_EXTERNAL_NUMA "${OPAE_ADD_SHARED_LIBRARY_LIBS}")
if (NEED_EXTERNAL_NUMA)
add_dependencies(${OPAE_ADD_SHARED_LIBRARY_TARGET} numa_IMPORT)
endif(NEED_EXTERNAL_NUMA)
endif(numa_IMPORTED)

opae_coverage_build(TARGET ${OPAE_ADD_SHARED_LIBRARY_TARGET} SOURCE ${OPAE_ADD_SHARED_LIBRARY_SOURCE})
set_install_rpath(${OPAE_ADD_SHARED_LIBRARY_TARGET})

Expand Down Expand Up @@ -396,6 +410,13 @@ function(opae_add_module_library)
endif(NEED_EXTERNAL_HWLOC)
endif(hwloc_IMPORTED)

if (numa_IMPORTED)
string(REGEX MATCH "${numa_LIBRARIES}" NEED_EXTERNAL_NUMA "${OPAE_ADD_MODULE_LIBRARY_LIBS}")
if (NEED_EXTERNAL_NUMA)
add_dependencies(${OPAE_ADD_MODULE_LIBRARY_TARGET} numa_IMPORT)
endif(NEED_EXTERNAL_NUMA)
endif(numa_IMPORTED)

opae_coverage_build(TARGET ${OPAE_ADD_MODULE_LIBRARY_TARGET} SOURCE ${OPAE_ADD_MODULE_LIBRARY_SOURCE})

if(OPAE_ADD_MODULE_LIBRARY_COMPONENT)
Expand Down
7 changes: 7 additions & 0 deletions cmake/modules/OPAETest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ function(opae_test_add_static_lib)
endif(NEED_EXTERNAL_HWLOC)
endif(hwloc_IMPORTED)

if (numa_IMPORTED)
string(REGEX MATCH "${numa_LIBRARIES}" NEED_EXTERNAL_NUMA "${OPAE_TEST_ADD_STATIC_LIB_LIBS}")
if (NEED_EXTERNAL_NUMA)
add_dependencies(${OPAE_TEST_ADD_STATIC_LIB_TARGET} numa_IMPORT)
endif(NEED_EXTERNAL_NUMA)
endif(numa_IMPORTED)

opae_coverage_build(TARGET ${OPAE_TEST_ADD_STATIC_LIB_TARGET}
SOURCE ${OPAE_TEST_ADD_STATIC_LIB_SOURCE})
endfunction()
2 changes: 1 addition & 1 deletion docker/fedora37/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM fedora:37
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git make cmake libuuid-devel json-c-devel gcc clang gcc-c++ libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel systemd
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git make cmake libuuid-devel json-c-devel gcc clang gcc-c++ libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel systemd numactl-devel
RUN python3 -m pip install setuptools --upgrade --prefix=/usr
RUN python3 -m pip install pyyaml jsonschema
WORKDIR /root
Expand Down
2 changes: 1 addition & 1 deletion docker/fedora38/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM fedora:38
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git make cmake libuuid-devel json-c-devel gcc clang gcc-c++ libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel systemd
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git make cmake libuuid-devel json-c-devel gcc clang gcc-c++ libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel systemd numactl-devel
RUN python3 -m pip install setuptools --upgrade --prefix=/usr
RUN python3 -m pip install pyyaml jsonschema
WORKDIR /root
Expand Down
4 changes: 2 additions & 2 deletions docker/rockylinux8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN dnf config-manager --set-enabled powertools
RUN dnf install -y epel-release
RUN dnf check-update || true
RUN dnf upgrade -y
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml gdb vim git gcc gcc-c++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel cli11-devel spdlog-devel libedit-devel systemd-devel doxygen python3-sphinx pandoc rpm-build rpmdevtools python3-virtualenv yaml-cpp-devel libudev-devel libcap-devel sudo
RUN dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml gdb vim git gcc gcc-c++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel cli11-devel spdlog-devel libedit-devel systemd-devel doxygen python3-sphinx pandoc rpm-build rpmdevtools python3-virtualenv yaml-cpp-devel libudev-devel libcap-devel sudo numactl-devel

RUN python3 -m pip install --user jsonschema virtualenv pudb pyyaml pybind11 && \
# setuptools < ~51.x will fail to process the pyproject.toml successfully, so we upgrade
Expand All @@ -18,4 +18,4 @@ WORKDIR /root

COPY scripts/test-rpms.sh /scripts/test-rpms.sh

ENTRYPOINT ["/opae-rockylinux8/opae-sdk/packaging/opae/rpm/create", "unrestricted"]
ENTRYPOINT ["/opae-rockylinux8/opae-sdk/packaging/opae/rpm/create", "unrestricted"]
2 changes: 1 addition & 1 deletion docker/ubuntu22/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:22.04
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev python3-pybind11 git gcc g++ make cmake doxygen pandoc uuid-dev libjson-c-dev libhwloc-dev libtbb-dev libedit-dev libspdlog-dev libcli11-dev libudev-dev bsdmainutils devscripts debhelper dh-python doxygen
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev python3-pybind11 git gcc g++ make cmake doxygen pandoc uuid-dev libjson-c-dev libhwloc-dev libtbb-dev libedit-dev libspdlog-dev libcli11-dev libudev-dev bsdmainutils devscripts debhelper dh-python doxygen libnuma-dev
RUN python3 -m pip install setuptools --upgrade --prefix=/usr
RUN python3 -m pip install pyyaml jsonschema pybind11
WORKDIR /root
Expand Down
2 changes: 1 addition & 1 deletion setup/centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled powertools
dnf install -y epel-release
dnf check-update || true
dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pybind11 git gcc gcc-c++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel cli11-devel spdlog-devel libedit-devel systemd-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel
dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pybind11 git gcc gcc-c++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel cli11-devel spdlog-devel libedit-devel systemd-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel numactl-devel
python3 -m pip install --user jsonschema pyyaml
2 changes: 1 addition & 1 deletion setup/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ set -e
set -x

dnf check-update || true
dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git gcc g++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel
dnf install -y python3 python3-pip python3-devel python3-jsonschema python3-pyyaml python3-pybind11 git gcc g++ make cmake libuuid-devel json-c-devel hwloc-devel tbb-devel libedit-devel rpm-build rpmdevtools pybind11-devel python3-virtualenv yaml-cpp-devel libudev-devel cli11-devel spdlog-devel numactl-devel

pip3 install jsonschema pyyaml pybind11
2 changes: 1 addition & 1 deletion setup/opensuse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
set -e
set -x

zypper install -y python3 python3-pip python3-devel python3-jsonschema python3-PyYAML python3-pybind11 gdb vim git gcc gcc-c++ make cmake libuuid-devel libjson-c-devel hwloc-devel tbb-devel libedit-devel doxygen python3-Sphinx pandoc rpmdevtools python3-pybind11-devel python3-virtualenv yaml-cpp-devel systemd-devel libcap-devel cli11-devel spdlog-devel netcat rsync sudo shadow
zypper install -y python3 python3-pip python3-devel python3-jsonschema python3-PyYAML python3-pybind11 gdb vim git gcc gcc-c++ make cmake libuuid-devel libjson-c-devel hwloc-devel tbb-devel libedit-devel doxygen python3-Sphinx pandoc rpmdevtools python3-pybind11-devel python3-virtualenv yaml-cpp-devel systemd-devel libcap-devel cli11-devel spdlog-devel netcat rsync sudo shadow libnuma-devel
zypper remove -y busybox-which
zypper install -y rpm-build git
pip3 install jsonschema pyyaml
2 changes: 1 addition & 1 deletion setup/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ set -e
set -x

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev git gcc g++ make cmake uuid-dev libjson-c-dev libhwloc-dev libtbb-dev libedit-dev libudev-dev bsdmainutils pandoc devscripts debhelper doxygen
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev git gcc g++ make cmake uuid-dev libjson-c-dev libhwloc-dev libtbb-dev libedit-dev libudev-dev bsdmainutils pandoc devscripts debhelper doxygen libnuma-dev

pip3 install jsonschema pyyaml pybind11

0 comments on commit 42b9425

Please sign in to comment.