Skip to content
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
70 changes: 70 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,76 @@ jobs:
--umf-version ${{env.UMF_VERSION}}
${{ matrix.shared_library == 'ON' && '--shared-library' || ''}}

windows-dynamic_build_hwloc:
name: "Windows dynamic UMF + static hwloc"
env:
BUILD_DIR : "${{github.workspace}}/build/${{matrix.build_type}}"
strategy:
matrix:
build_type: [Release]

runs-on: 'windows-2022'

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Configure build
run: >
cmake
-B ${{env.BUILD_DIR}}
-DUMF_BUILD_SHARED_LIBRARY=ON
-DUMF_BUILD_EXAMPLES=OFF
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_LINK_HWLOC_STATICALLY=ON

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS

- name: Run tests
working-directory: ${{env.BUILD_DIR}}
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test

windows-static_build_hwloc:
name: "Windows static UMF + static hwloc"
env:
BUILD_DIR : "${{github.workspace}}/build/${{matrix.build_type}}"
strategy:
matrix:
build_type: [Release]

runs-on: 'windows-2022'

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Configure build
run: >
cmake
-B ${{env.BUILD_DIR}}
-DUMF_BUILD_SHARED_LIBRARY=OFF
-DUMF_BUILD_EXAMPLES=OFF
-DUMF_FORMAT_CODE_STYLE=OFF
-DUMF_DEVELOPER_MODE=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_LINK_HWLOC_STATICALLY=ON

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS

- name: Run tests
working-directory: ${{env.BUILD_DIR}}
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test

macos-build:
name: MacOS
strategy:
Expand Down
76 changes: 58 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR}/cmake")
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

include(CTest)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
find_package(PkgConfig)

# CMAKE_PROJECT_VERSION[_MAJOR|_MINOR|_PATCH] variables are set via 'project'
# command. They cannot contain any "pre-release" part, though. We use custom
# "UMF_SRC_VERSION" to store more accurate (source) version - this var should be
Expand All @@ -39,6 +44,8 @@ option(UMF_BUILD_EXAMPLES "Build UMF examples" ON)
option(UMF_BUILD_FUZZTESTS "Build UMF fuzz tests" OFF)
option(UMF_BUILD_GPU_EXAMPLES "Build UMF GPU examples" OFF)
option(UMF_DEVELOPER_MODE "Enable additional developer checks" OFF)
option(UMF_LINK_HWLOC_STATICALLY
"Link UMF with HWLOC library statically (Windows+Release only)" OFF)
option(UMF_FORMAT_CODE_STYLE
"Add clang, cmake, and black -format-check and -format-apply targets"
OFF)
Expand Down Expand Up @@ -83,6 +90,44 @@ else()
message(FATAL_ERROR "Unknown OS type")
endif()

if(NOT UMF_LINK_HWLOC_STATICALLY)
pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
if(NOT LIBHWLOC_FOUND)
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
endif()
# add PATH to DLL on Windows
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin"
)
else()
if(NOT WINDOWS)
message(FATAL_ERROR "hwloc can be statically linked only on Windows")
endif()
include(FetchContent)
set(HWLOC_ENABLE_TESTING OFF)
set(HWLOC_SKIP_LSTOPO ON)
set(HWLOC_SKIP_TOOLS ON)
FetchContent_Declare(
hwloc_targ
GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
GIT_TAG hwloc-2.10.0
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)

FetchContent_GetProperties(hwloc_targ)
if(NOT hwloc_targ_POPULATED)
FetchContent_MakeAvailable(hwloc_targ)
endif()

set(LIBHWLOC_INCLUDE_DIRS
${hwloc_targ_SOURCE_DIR}/include;${hwloc_targ_BINARY_DIR}/include)
set(LIBHWLOC_LIBRARY_DIRS
${hwloc_targ_BINARY_DIR}/Release;${hwloc_targ_BINARY_DIR}/Debug)

message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
endif()

# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
# set, because in this case the build type is determined after a CMake
# configuration is done (at the build time)
Expand Down Expand Up @@ -130,11 +175,6 @@ foreach(option_name ${OPTIONS_REQUIRING_CXX})
endif()
endforeach()

include(CTest)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
find_package(PkgConfig)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand Down Expand Up @@ -186,7 +226,8 @@ if(WINDOWS)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# set PATH to DLLs on Windows
set(DLL_PATH_LIST
"PATH=path_list_append:${PROJECT_BINARY_DIR}/bin/$<CONFIG>")
"${DLL_PATH_LIST};PATH=path_list_append:${PROJECT_BINARY_DIR}/bin/$<CONFIG>"
)
# add path to the proxy lib DLL
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${PROJECT_BINARY_DIR}/src/proxy_lib"
Expand All @@ -197,14 +238,6 @@ if(WINDOWS)
)
endif()

pkg_check_modules(LIBHWLOC hwloc>=2.3.0)
if(NOT LIBHWLOC_FOUND)
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
endif()
# add PATH to DLL on Windows
set(DLL_PATH_LIST
"${DLL_PATH_LIST};PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}/../bin")

pkg_check_modules(TBB tbb)
if(NOT TBB_FOUND)
find_package(TBB OPTIONAL_COMPONENTS tbb)
Expand Down Expand Up @@ -240,10 +273,17 @@ if(WINDOWS)
# In MSVC builds, there is no way to determine the actual build type during
# the CMake configuration step. Therefore, this message is printed in all
# MSVC builds.
message(
STATUS
"The proxy library will be built, however it is supported only in the Release build on Windows"
)
if(UMF_LINK_HWLOC_STATICALLY)
message(
STATUS
"The proxy library will be disabled - static linkage with hwloc is not supported yet"
)
else()
message(
STATUS
"The proxy library will be built, however it is supported only in the Release build on Windows"
)
endif()
endif()
if(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
if(UMF_POOL_SCALABLE_ENABLED)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ List of options provided by CMake:
| USE_MSAN | Enable MemorySanitizer checks | ON/OFF | OFF |
| USE_VALGRIND | Enable Valgrind instrumentation | ON/OFF | OFF |
| USE_GCOV | Enable gcov support (Linux only) | ON/OFF | OFF |
| UMF_LINK_HWLOC_STATICALLY | Link UMF with HWLOC library statically (Windows+Release only) | ON/OFF | OFF |

## Architecture: memory pools and providers

Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(EXAMPLE_NAME umf_example_basic)
add_umf_executable(
NAME ${EXAMPLE_NAME}
SRCS basic/basic.c
LIBS umf)
LIBS umf hwloc)

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand Down
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if(UMF_BUILD_SHARED_LIBRARY)
NAME umf
TYPE SHARED
SRCS ${UMF_SOURCES}
LIBS ${UMF_LIBS}
LIBS ${UMF_LIBS} hwloc
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def)
set(UMF_PRIVATE_COMPILE_DEFINITIONS ${UMF_PRIVATE_COMPILE_DEFINITIONS}
Expand All @@ -133,6 +133,10 @@ else()
LIBS ${UMF_LIBS})
endif()

if(UMF_LINK_HWLOC_STATICALLY)
add_dependencies(umf hwloc)
endif()

target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})

target_compile_definitions(umf PRIVATE ${UMF_PRIVATE_COMPILE_DEFINITIONS})
Expand Down Expand Up @@ -176,6 +180,6 @@ install(TARGETS umf EXPORT ${PROJECT_NAME}-targets)

add_subdirectory(pool)

if(UMF_PROXY_LIB_ENABLED)
if(UMF_PROXY_LIB_ENABLED AND NOT UMF_LINK_HWLOC_STATICALLY)
add_subdirectory(proxy_lib)
endif()