Skip to content

commits for 0.9x rc2 #652

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 16 commits into from
Jul 30, 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
20 changes: 19 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
shared_library: ['OFF']
level_zero_provider: ['ON']
install_tbb: ['ON']
disable_hwloc: ['OFF']
link_hwloc_statically: ['OFF']
include:
- os: 'ubuntu-20.04'
build_type: Release
Expand Down Expand Up @@ -69,6 +71,20 @@ jobs:
shared_library: 'ON'
level_zero_provider: 'ON'
install_tbb: 'OFF'
- os: 'ubuntu-22.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
level_zero_provider: 'ON'
install_tbb: 'ON'
disable_hwloc: 'ON'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
shared_library: 'ON'
level_zero_provider: 'ON'
install_tbb: 'ON'
link_hwloc_statically: 'ON'
runs-on: ${{matrix.os}}

steps:
Expand Down Expand Up @@ -122,6 +138,8 @@ jobs:
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
-DUMF_TESTS_FAIL_ON_SKIP=ON
-DUMF_DISABLE_HWLOC=${{matrix.disable_hwloc}}
-DUMF_LINK_HWLOC_STATICALLY=${{matrix.link_hwloc_statically}}

- name: Build UMF
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
Expand All @@ -144,7 +162,7 @@ jobs:
--build-type ${{matrix.build_type}}
--disjoint-pool
--jemalloc-pool
${{ matrix.install_tbb == 'ON' && '--proxy' || '' }}
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && matrix.link_hwloc_statically != 'ON' && '--proxy' || '' }}
--umf-version ${{env.UMF_VERSION}}
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ jobs:
working-directory: ${{env.BUILD_DIR}}
run: >
${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh &&' || ''}}
GTEST_FILTER="-*umfProviderTest.alloc_page64_align_0*" ctest --output-on-failure
# TO DO: fix umf-provider_os_memory test for sanitizers
# issue 581: https://github.com/oneapi-src/unified-memory-framework/issues/581
ctest --output-on-failure

windows-build:
name: cl and clang-cl on Windows
Expand Down
130 changes: 105 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

list(APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR}/cmake")
include(helpers)
# Use full path of the helpers module (to omit potential conflicts with others)
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

# We use semver aligned version, set via git tags. We parse git output to
# establih the version of UMF to be used in CMake, Win dll's, and within the
Expand Down Expand Up @@ -47,8 +48,10 @@ 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_LINK_HWLOC_STATICALLY
"Link UMF with HWLOC library statically (supported for Linux, MacOS and Release build on Windows)"
OFF)
option(UMF_FORMAT_CODE_STYLE
"Add clang, cmake, and black -format-check and -format-apply targets"
OFF)
Expand All @@ -60,6 +63,10 @@ option(USE_TSAN "Enable ThreadSanitizer checks" OFF)
option(USE_MSAN "Enable MemorySanitizer checks" OFF)
option(USE_VALGRIND "Enable Valgrind instrumentation" OFF)
option(USE_GCOV "Enable gcov support" OFF)
option(
UMF_DISABLE_HWLOC
"Disable features that requires hwloc (OS provider, memory targets, topolgy discovery)"
OFF)

# set UMF_PROXY_LIB_BASED_ON_POOL to one of: SCALABLE or JEMALLOC
set(KNOWN_PROXY_LIB_POOLS SCALABLE JEMALLOC)
Expand Down Expand Up @@ -93,27 +100,42 @@ else()
message(FATAL_ERROR "Unknown OS type")
endif()

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.10.0)
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)
if(NOT UMF_DISABLE_HWLOC)
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"
)
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()
elseif(WINDOWS AND NOT UMF_DISABLE_HWLOC)
include(FetchContent)
set(HWLOC_ENABLE_TESTING OFF)
set(HWLOC_SKIP_LSTOPO ON)
set(HWLOC_SKIP_TOOLS ON)

message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")

FetchContent_Declare(
hwloc_targ
GIT_REPOSITORY "https://github.com/open-mpi/hwloc.git"
GIT_TAG hwloc-2.10.0
GIT_REPOSITORY ${UMF_HWLOC_REPO}
GIT_TAG ${UMF_HWLOC_TAG}
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)

FetchContent_GetProperties(hwloc_targ)
Expand All @@ -126,6 +148,57 @@ else()
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}")
elseif(NOT UMF_DISABLE_HWLOC)
include(FetchContent)
message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")

FetchContent_Declare(
hwloc_targ
GIT_REPOSITORY ${UMF_HWLOC_REPO}
GIT_TAG ${UMF_HWLOC_TAG})

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

add_custom_command(
COMMAND ./autogen.sh
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
OUTPUT ${hwloc_targ_SOURCE_DIR}/configure)
add_custom_command(
COMMAND
./configure --prefix=${hwloc_targ_BINARY_DIR} --enable-static=yes
--enable-shared=no --disable-libxml2 --disable-levelzero
CFLAGS=-fPIC CXXFLAGS=-fPIC
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
OUTPUT ${hwloc_targ_SOURCE_DIR}/Makefile
DEPENDS ${hwloc_targ_SOURCE_DIR}/configure)
add_custom_command(
COMMAND make
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
OUTPUT ${hwloc_targ_SOURCE_DIR}/lib/libhwloc.la
DEPENDS ${hwloc_targ_SOURCE_DIR}/Makefile)
add_custom_command(
COMMAND make install
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
OUTPUT ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a
DEPENDS ${hwloc_targ_SOURCE_DIR}/lib/libhwloc.la)

add_custom_target(hwloc_prod
DEPENDS ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)
add_library(hwloc INTERFACE)
target_link_libraries(hwloc
INTERFACE ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)
add_dependencies(hwloc hwloc_prod)

set(LIBHWLOC_LIBRARY_DIRS ${hwloc_targ_BINARY_DIR}/lib)
set(LIBHWLOC_INCLUDE_DIRS ${hwloc_targ_BINARY_DIR}/include)
set(LIBHWLOC_LIBRARIES ${hwloc_targ_BINARY_DIR}/lib/libhwloc.a)

message(STATUS " LIBHWLOC_LIBRARIES = ${LIBHWLOC_LIBRARIES}")
message(STATUS " LIBHWLOC_INCLUDE_DIRS = ${LIBHWLOC_INCLUDE_DIRS}")
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
Expand Down Expand Up @@ -317,6 +390,18 @@ else()
)
endif()

set(UMF_OPTIONAL_SYMBOLS_LINUX "")
set(UMF_OPTIONAL_SYMBOLS_WINDOWS "")

# Conditional configuration for Level Zero provider
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
add_optional_symbol(umfLevelZeroMemoryProviderOps)
endif()

if(NOT UMF_DISABLE_HWLOC)
add_optional_symbol(umfOsMemoryProviderOps)
endif()

add_subdirectory(src)

if(UMF_BUILD_TESTS)
Expand All @@ -328,20 +413,13 @@ if(UMF_BUILD_BENCHMARKS)
endif()

if(UMF_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Conditional configuration for Level Zero provider
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
set(OPTIONAL_SYMBOLS "umfLevelZeroMemoryProviderOps")
else()
set(OPTIONAL_SYMBOLS "")
if(NOT UMF_DISABLE_HWLOC)
add_subdirectory(examples)
else()
message(WARNING "Examples cannot be build - hwloc disabled")
endif()
endif()

# Configure the DEF file based on whether Level Zero provider is built
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libumf.def.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/libumf.def" @ONLY)

if(UMF_FORMAT_CODE_STYLE)
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0
clang-format)
Expand Down Expand Up @@ -522,8 +600,10 @@ endif()
# Configure make install/uninstall and packages
# --------------------------------------------------------------------------- #
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE.TXT
${CMAKE_SOURCE_DIR}/third-party-programs.txt
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/")
install(
FILES ${CMAKE_SOURCE_DIR}/licensing/third-party-programs.txt
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}/licensing/")

install(DIRECTORY examples DESTINATION "${CMAKE_INSTALL_DOCDIR}")

Expand Down
31 changes: 29 additions & 2 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,33 @@ function(get_program_version_major_minor name ret)
PARENT_SCOPE)
endfunction()

# Checks compiler for given ${flag}, stores the output in C_HAS_${flag} and
# CXX_HAS_${flag} (if compiler supports C++)
function(check_compilers_flag flag)
check_c_compiler_flag("${flag}" "C_HAS_${flag}")
if(CMAKE_CXX_COMPILE_FEATURES)
check_cxx_compiler_flag("${flag}" "CXX_HAS_${flag}")
endif()
endfunction()

function(check_add_target_compile_options target)
foreach(option ${ARGN})
check_compilers_flag(${option})
if(C_HAS_${option} AND CXX_HAS_${option})
target_compile_options(${target} PRIVATE ${option})
endif()
endforeach()
endfunction()

function(add_umf_target_compile_options name)
check_add_target_compile_options(${name} "-Wno-covered-switch-default")

if(NOT MSVC)
target_compile_options(
${name}
PRIVATE -fPIC
-Wall
-Wextra
-Werror
-Wpedantic
-Wempty-body
-Wunused-parameter
Expand Down Expand Up @@ -213,7 +232,6 @@ function(add_umf_target_compile_options name)
/analyze
/DYNAMICBASE
/W4
/WX
/Gy
/GS
# disable warning 6326: Potential comparison of a constant
Expand Down Expand Up @@ -399,3 +417,12 @@ macro(add_sanitizer_flag flag)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
endmacro()

function(add_optional_symbol symbol)
set(UMF_OPTIONAL_SYMBOLS_WINDOWS
"${UMF_OPTIONAL_SYMBOLS_WINDOWS} \n ${symbol}"
PARENT_SCOPE)
set(UMF_OPTIONAL_SYMBOLS_LINUX
"${UMF_OPTIONAL_SYMBOLS_LINUX} \n ${symbol};"
PARENT_SCOPE)
endfunction()
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 hwloc)
LIBS umf ${LIBHWLOC_LIBRARIES})

target_include_directories(
${EXAMPLE_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/utils
Expand Down
File renamed without changes.
Loading
Loading