Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/scripts/run-codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def codespell_scan():
"codespell",
"-H",
"--quiet-level=3",
"--skip=./.git,./.venv,./.github/workflows/.spellcheck-conf.toml",
"--skip=./.git,./.venv,./.github/workflows/.spellcheck-conf.toml,./src/deps",
],
text=True,
stdout=subprocess.PIPE,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.spellcheck-conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ extend-ignore-words-re = ["ASSER", "Tne", "ba", "BA", "PN", "usm"]

[files]
# completely exclude those files from consideration:
extend-exclude = ["test/supp/*.supp"]
extend-exclude = ["test/supp/*.supp", "src/deps/**"]
122 changes: 120 additions & 2 deletions .github/workflows/reusable_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
cuda_provider: ['ON']
install_tbb: ['ON']
link_hwloc_statically: ['OFF']
use_bundled_hwloc: ['OFF']
cmake_ver: ['default']
include:
- os: ubuntu-22.04
Expand Down Expand Up @@ -135,7 +136,18 @@
link_hwloc_statically: 'ON'
local_hwloc: 'mirror'
cmake_ver: 'default'
name: Basic (${{matrix.os}}, build_type=${{matrix.build_type}}, compilers=${{matrix.compiler.c}}/${{matrix.compiler.cxx}}, shared_library=${{matrix.shared_library}}, level_zero_provider=${{matrix.level_zero_provider}}, cuda_provider=${{matrix.cuda_provider}}, install_tbb=${{matrix.install_tbb}}, link_hwloc_statically=${{matrix.link_hwloc_statically}}, cmake_ver=${{matrix.cmake_ver}}${{ matrix.local_hwloc && format(', local_hwloc={0}', matrix.local_hwloc) || '' }})
# test static hwloc built from the bundled source (UMF_USE_BUNDLED_HWLOC)
- os: ubuntu-22.04
build_type: Release
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
level_zero_provider: 'ON'
cuda_provider: 'ON'
install_tbb: 'ON'
link_hwloc_statically: 'ON'
use_bundled_hwloc: 'ON'
cmake_ver: 'default'
name: Basic (${{matrix.os}}, build_type=${{matrix.build_type}}, compilers=${{matrix.compiler.c}}/${{matrix.compiler.cxx}}, shared_library=${{matrix.shared_library}}, level_zero_provider=${{matrix.level_zero_provider}}, cuda_provider=${{matrix.cuda_provider}}, install_tbb=${{matrix.install_tbb}}, link_hwloc_statically=${{matrix.link_hwloc_statically}}, use_bundled_hwloc=${{matrix.use_bundled_hwloc || 'OFF'}}${{ matrix.local_hwloc && format(', local_hwloc={0}', matrix.local_hwloc) || '' }}, cmake_ver=${{matrix.cmake_ver}})

steps:
- name: Checkout
Expand Down Expand Up @@ -195,6 +207,7 @@
-DUMF_LINK_HWLOC_STATICALLY=${{matrix.link_hwloc_statically}}
${{ matrix.local_hwloc == 'source' && format('-DUMF_HWLOC_SOURCE_DIR={0}', env.HWLOC_SRC_DIR) || '' }}
${{ matrix.local_hwloc == 'mirror' && format('-DUMF_HWLOC_REPO={0}', env.HWLOC_MIRROR_DIR) || '' }}
-DUMF_USE_BUNDLED_HWLOC=${{matrix.use_bundled_hwloc || 'OFF'}}
${{ matrix.build_type == 'Debug' && matrix.compiler.c == 'gcc' && '-DUMF_USE_COVERAGE=ON' || '' }}
${{ matrix.llvm_linker || '' }}

Expand Down Expand Up @@ -238,6 +251,53 @@
--umf-version ${{env.UMF_VERSION}}
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}

ubuntu-static_hwloc_installed_umf:
name: "Ubuntu static UMF + static hwloc, installed UMF (bundled=${{matrix.use_bundled_hwloc}})"
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Release]
use_bundled_hwloc: ['OFF', 'ON']

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libhwloc-dev ${{ matrix.use_bundled_hwloc == 'OFF' && 'autoconf automake libtool' || '' }}

- name: Configure build
run: >
cmake
-B ${{env.BUILD_DIR}}
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DUMF_BUILD_SHARED_LIBRARY=OFF
-DUMF_BUILD_TESTS=OFF
-DUMF_BUILD_EXAMPLES=OFF
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
-DUMF_BUILD_CUDA_PROVIDER=OFF
-DUMF_LINK_HWLOC_STATICALLY=ON
-DUMF_USE_BUNDLED_HWLOC=${{matrix.use_bundled_hwloc}}

- name: Build and install UMF
run: |
cmake --build ${{env.BUILD_DIR}} -j $(nproc)
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
cmake --install ${{env.BUILD_DIR}}
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

- name: Build and run consumer of installed UMF
run: |
cmake -S ${{github.workspace}}/test/install_test -B ${{github.workspace}}/install_test-build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_PREFIX_PATH="${{env.INSTL_DIR}}" -DUMF_TEST_LINK_USER_HWLOC=ON
cmake --build ${{github.workspace}}/install_test-build -j $(nproc)
ctest --test-dir ${{github.workspace}}/install_test-build --output-on-failure

windows-build:
env:
BUILD_DEBUG_DIR : "${{github.workspace}}/debug/build"
Expand Down Expand Up @@ -493,10 +553,11 @@
key: ${{ steps.cache.outputs.cache-primary-key }}

windows-dynamic_build_hwloc:
name: "Windows dynamic UMF + static hwloc"
name: "Windows dynamic UMF + static hwloc (bundled=${{matrix.use_bundled_hwloc}})"
strategy:
matrix:
build_type: [Release]
use_bundled_hwloc: ['OFF', 'ON']

runs-on: 'windows-latest'

Expand All @@ -520,6 +581,7 @@
-DUMF_BUILD_CUDA_PROVIDER=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_LINK_HWLOC_STATICALLY=ON
-DUMF_USE_BUNDLED_HWLOC=${{matrix.use_bundled_hwloc}}

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
Expand Down Expand Up @@ -576,6 +638,62 @@
working-directory: ${{env.BUILD_DIR}}
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test

windows-static_hwloc_installed_umf:
name: "Windows static UMF + static hwloc, installed UMF (bundled=${{matrix.use_bundled_hwloc}})"
strategy:
matrix:
build_type: [Release]
use_bundled_hwloc: ['OFF', 'ON']

runs-on: 'windows-latest'

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed

- name: Configure build
run: >
cmake
-B ${{env.BUILD_DIR}}
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
-DUMF_BUILD_SHARED_LIBRARY=OFF
-DUMF_BUILD_TESTS=OFF
-DUMF_BUILD_EXAMPLES=OFF
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
-DUMF_BUILD_CUDA_PROVIDER=OFF
-DUMF_LINK_HWLOC_STATICALLY=ON
-DUMF_USE_BUNDLED_HWLOC=${{matrix.use_bundled_hwloc}}

- name: Build and install UMF
run: |
cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
Comment thread
bratpiorka marked this conversation as resolved.
Dismissed
cmake --install ${{env.BUILD_DIR}} --config ${{matrix.build_type}}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

# The bundled hwloc uses the umf_hwloc_ symbol prefix, so a consumer may
# link its own hwloc alongside the installed static UMF.
- name: Install user hwloc
if: matrix.use_bundled_hwloc == 'ON'
run: |
vcpkg install --classic hwloc:x64-windows
echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" >> $env:GITHUB_PATH

- name: Build and run test of installed UMF
run: |
$extraArgs = @()
$prefixPath = "${{env.INSTL_DIR}}"
if ('${{matrix.use_bundled_hwloc}}' -eq 'ON') {
$prefixPath += ";$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows"
$extraArgs += '-DUMF_TEST_LINK_USER_HWLOC=ON'
}
cmake -S ${{github.workspace}}/test/install_test -B ${{github.workspace}}/install_test-build -DCMAKE_PREFIX_PATH="$prefixPath" @extraArgs
cmake --build ${{github.workspace}}/install_test-build --config ${{matrix.build_type}}
ctest --test-dir ${{github.workspace}}/install_test-build -C ${{matrix.build_type}} --output-on-failure

macos-build:
strategy:
matrix:
Expand Down
77 changes: 72 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ umf_option(
UMF_LINK_HWLOC_STATICALLY
"Link UMF with HWLOC library statically (proxy library will be disabled on Windows+Debug build)"
OFF)
umf_option(UMF_USE_BUNDLED_HWLOC
"Use the prebuilt x86-64 static hwloc library in src/deps/hwloc" OFF)
if(UMF_USE_BUNDLED_HWLOC AND NOT UMF_LINK_HWLOC_STATICALLY)
message(
FATAL_ERROR
"UMF_USE_BUNDLED_HWLOC requires UMF_LINK_HWLOC_STATICALLY=ON")
endif()
set(UMF_HWLOC_NAME
"hwloc"
CACHE STRING "Custom name for hwloc library w/o extension")
Expand Down Expand Up @@ -295,7 +302,55 @@ if(NOT UMF_LINK_HWLOC_STATICALLY)
endif()
endif()

if(UMF_LINK_HWLOC_STATICALLY)
if(UMF_USE_BUNDLED_HWLOC)
if(NOT LINUX AND NOT WINDOWS)
message(
FATAL_ERROR "Bundled hwloc is only available on Linux and Windows")
endif()
set(UMF_BUNDLED_HWLOC_ARCH "${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
if(NOT WINDOWS OR NOT UMF_BUNDLED_HWLOC_ARCH)
set(UMF_BUNDLED_HWLOC_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
endif()
if(NOT UMF_BUNDLED_HWLOC_ARCH MATCHES "^(x86_64|AMD64|amd64|x64)$")
message(
FATAL_ERROR
"Bundled hwloc is available only for x86-64, but the target "
"architecture is '${UMF_BUNDLED_HWLOC_ARCH}' "
"Set UMF_USE_BUNDLED_HWLOC=OFF to build hwloc from sources.")
endif()
set(UMF_BUNDLED_HWLOC_DIR "${UMF_CMAKE_SOURCE_DIR}/src/deps/hwloc")
set(LIBHWLOC_LIBRARY_DIRS "${UMF_BUNDLED_HWLOC_DIR}/${OS_NAME}")
set(LIBHWLOC_INCLUDE_DIRS "${LIBHWLOC_LIBRARY_DIRS}/include"
"${UMF_BUNDLED_HWLOC_DIR}/include")
Comment thread
Copilot marked this conversation as resolved.
if(WINDOWS)
set(LIBHWLOC_LIBRARIES "${LIBHWLOC_LIBRARY_DIRS}/hwloc.lib")
else()
set(LIBHWLOC_LIBRARIES "${LIBHWLOC_LIBRARY_DIRS}/libhwloc.a")
endif()

foreach(
HWLOC_REQUIRED_FILE IN
ITEMS "${LIBHWLOC_LIBRARIES}"
"${UMF_BUNDLED_HWLOC_DIR}/include/hwloc.h"
"${LIBHWLOC_LIBRARY_DIRS}/include/hwloc/autogen/config.h")
if(NOT EXISTS "${HWLOC_REQUIRED_FILE}")
message(
FATAL_ERROR
"Bundled hwloc file not found: ${HWLOC_REQUIRED_FILE}")
endif()
endforeach()

message(STATUS "Using bundled hwloc from ${UMF_BUNDLED_HWLOC_DIR}")

add_library(${UMF_HWLOC_NAME} INTERFACE)
target_link_libraries(${UMF_HWLOC_NAME} INTERFACE "${LIBHWLOC_LIBRARIES}")
target_include_directories(${UMF_HWLOC_NAME}
INTERFACE ${LIBHWLOC_INCLUDE_DIRS})
Comment thread
bratpiorka marked this conversation as resolved.
Comment on lines +345 to +348
set(LIBHWLOC_FOUND TRUE)
elseif(UMF_LINK_HWLOC_STATICALLY)
if(NOT DEFINED UMF_HWLOC_REPO)
set(UMF_HWLOC_REPO "https://github.com/open-mpi/hwloc.git")
endif()
if(NOT DEFINED UMF_HWLOC_TAG)
set(UMF_HWLOC_TAG hwloc-2.13.0)
endif()
Expand Down Expand Up @@ -398,6 +453,9 @@ if(UMF_LINK_HWLOC_STATICALLY)
)
endif()

# All symbols defined in the hwloc library must have the 'umf_hwloc_'
# prefix, so that they do not conflict with other hwloc instances linked
# into the same application.
ExternalProject_Add(
hwloc_targ
PREFIX ${hwloc_targ_PREFIX}
Expand All @@ -412,9 +470,10 @@ if(UMF_LINK_HWLOC_STATICALLY)
${CMAKE_COMMAND} -E env "CC=${UMF_HWLOC_CC}"
"CXX=${UMF_HWLOC_CXX}" <SOURCE_DIR>/configure
--prefix=<INSTALL_DIR> --enable-static=yes --enable-shared=no
--disable-libxml2 --disable-pci --disable-levelzero
--disable-opencl --disable-cuda --disable-nvml --disable-libudev
--disable-rsmi CFLAGS=-fPIC CXXFLAGS=-fPIC
--with-hwloc-symbol-prefix=umf_hwloc_ --disable-libxml2
--disable-pci --disable-levelzero --disable-opencl
--disable-cuda --disable-nvml --disable-libudev --disable-rsmi
"CFLAGS=-O2 -fPIC" "CXXFLAGS=-O2 -fPIC"
BUILD_COMMAND make
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND make install
Expand Down Expand Up @@ -596,6 +655,7 @@ if(WINDOWS AND UMF_USE_DEBUG_POSTFIX)
-DUMF_BUILD_EXAMPLES=OFF -DUMF_BUILD_GPU_EXAMPLES=OFF
-DUMF_BUILD_FUZZTESTS=OFF
-DUMF_LINK_HWLOC_STATICALLY=${UMF_LINK_HWLOC_STATICALLY}
-DUMF_USE_BUNDLED_HWLOC=${UMF_USE_BUNDLED_HWLOC}
-DUMF_HWLOC_NAME=${UMF_HWLOC_NAME}
-DUMF_HWLOC_SOURCE_DIR="${UMF_HWLOC_SOURCE_DIR}"
-DUMF_HWLOC_REPO="${UMF_HWLOC_REPO}"
Expand Down Expand Up @@ -921,6 +981,13 @@ if(UMF_FORMAT_CODE_STYLE)
"${DIR}/**/*.cpp")
endforeach()
file(GLOB_RECURSE format_list ${format_clang_glob})
# exclude files in the src/deps/ directory from formatting checks
list(
FILTER
format_list
EXCLUDE
REGEX
"/src/deps/")

message(
STATUS
Expand Down Expand Up @@ -1087,7 +1154,7 @@ install(TARGETS umf_headers EXPORT ${PROJECT_NAME}-targets)

# Add the list of installed targets to the install. This includes the namespace
# which all installed targets will be prefixed with, e.g. for the headers target
# users will depend on ${PROJECT_NAME}::headers.
# users will depend on ${PROJECT_NAME}::umf_headers.
install(
EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ List of options provided by CMake:
| UMF_LINK_HWLOC_STATICALLY | Link UMF with HWLOC library statically (proxy library will be disabled on Windows+Debug build) | ON/OFF | OFF |
| UMF_HWLOC_SOURCE_DIR | Path to local hwloc sources used instead of fetching them (with UMF_LINK_HWLOC_STATICALLY) | path | "" |
| UMF_HWLOC_REPO | hwloc git repository URL or local mirror path (with UMF_LINK_HWLOC_STATICALLY) | URL/path | https://github.com/open-mpi/hwloc.git |
| UMF_USE_BUNDLED_HWLOC | Use prebuilt x86-64 hwloc from `src/deps/hwloc` (requires `UMF_LINK_HWLOC_STATICALLY=ON`) | ON/OFF | OFF |

## Architecture: memory pools and providers

Expand Down
1 change: 1 addition & 0 deletions scripts/check_license/file-exceptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ grep -v -E -e 'benchmark/ubench.h' \
-e 'licensing/third-party-programs.txt' \
-e 'scripts/assets/images/.*' \
-e 'scripts/qemu/requirements.txt' \
-e '^src/deps/' \
-e 'src/uthash/.*' \
-e 'src/uthash/utlist.h' \
-e 'src/uthash/uthash.h' \
Expand Down
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ if(UMF_BUILD_SHARED_LIBRARY)
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
else()
if(UMF_LINK_HWLOC_STATICALLY)
# hwloc fetched on Windows installs its own archive
if(UMF_USE_BUNDLED_HWLOC OR NOT WINDOWS)
# A UMF-specific name, so find_library(hwloc) never picks this copy
set(UMF_HWLOC_ARCHIVE_NAME
"${CMAKE_STATIC_LIBRARY_PREFIX}umf_hwloc${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
install(
FILES "${LIBHWLOC_LIBRARIES}"
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RENAME ${UMF_HWLOC_ARCHIVE_NAME})
else()
get_filename_component(UMF_HWLOC_ARCHIVE_NAME
"${LIBHWLOC_LIBRARIES}" NAME)
endif()
set(UMF_LIBS
${UMF_LIBS}
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_LIBDIR}/${UMF_HWLOC_ARCHIVE_NAME}>"
)
endif()

add_umf_library(
NAME umf
TYPE STATIC
Expand Down
Loading
Loading