diff --git a/CMakeLists.txt b/CMakeLists.txt index a327e86af073..22baec6187ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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 ################################################################################ @@ -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) diff --git a/cmake/modules/Findnuma.cmake b/cmake/modules/Findnuma.cmake new file mode 100644 index 000000000000..86af81783bce --- /dev/null +++ b/cmake/modules/Findnuma.cmake @@ -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) diff --git a/cmake/modules/OPAECompiler.cmake b/cmake/modules/OPAECompiler.cmake index f31b0df16e6c..e96022e32848 100644 --- a/cmake/modules/OPAECompiler.cmake +++ b/cmake/modules/OPAECompiler.cmake @@ -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}) @@ -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}) @@ -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) diff --git a/cmake/modules/OPAETest.cmake b/cmake/modules/OPAETest.cmake index 7ad014087325..4c3674f26873 100644 --- a/cmake/modules/OPAETest.cmake +++ b/cmake/modules/OPAETest.cmake @@ -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() diff --git a/docker/fedora37/Dockerfile b/docker/fedora37/Dockerfile index 20ffc9aebe71..97b47c18f5fb 100644 --- a/docker/fedora37/Dockerfile +++ b/docker/fedora37/Dockerfile @@ -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 diff --git a/docker/fedora38/Dockerfile b/docker/fedora38/Dockerfile index d7013aa7509d..265db8f6a6c0 100644 --- a/docker/fedora38/Dockerfile +++ b/docker/fedora38/Dockerfile @@ -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 diff --git a/docker/rockylinux8/Dockerfile b/docker/rockylinux8/Dockerfile index f131d696af0a..bfad93653144 100644 --- a/docker/rockylinux8/Dockerfile +++ b/docker/rockylinux8/Dockerfile @@ -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 @@ -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"] \ No newline at end of file +ENTRYPOINT ["/opae-rockylinux8/opae-sdk/packaging/opae/rpm/create", "unrestricted"] diff --git a/docker/ubuntu22/Dockerfile b/docker/ubuntu22/Dockerfile index b971d33d0ccf..a1b14db45fa8 100644 --- a/docker/ubuntu22/Dockerfile +++ b/docker/ubuntu22/Dockerfile @@ -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 diff --git a/setup/centos.sh b/setup/centos.sh index b71ac24fabd2..5d1805e93c6d 100755 --- a/setup/centos.sh +++ b/setup/centos.sh @@ -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 diff --git a/setup/fedora.sh b/setup/fedora.sh index 76b607609d7b..5acc17ee4c9d 100755 --- a/setup/fedora.sh +++ b/setup/fedora.sh @@ -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 diff --git a/setup/opensuse.sh b/setup/opensuse.sh index 78d640c973c9..9f5d110c886f 100755 --- a/setup/opensuse.sh +++ b/setup/opensuse.sh @@ -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 diff --git a/setup/ubuntu.sh b/setup/ubuntu.sh index 7f33f689f0e9..694e09252ea9 100755 --- a/setup/ubuntu.sh +++ b/setup/ubuntu.sh @@ -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