Skip to content

compile utils and Base Alloc as static libs #1324

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,23 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
endif()

# Valgrind
if(UMF_USE_VALGRIND)
if(UMF_USE_ASAN
OR UMF_USE_TSAN
OR UMF_USE_UBSAN
OR UMF_USE_MSAN)
message(FATAL_ERROR "Cannot use valgrind and sanitizers together")
endif()

if(PkgConfig_FOUND)
pkg_check_modules(VALGRIND valgrind)
endif()
if(NOT VALGRIND_FOUND)
find_package(VALGRIND REQUIRED valgrind)
endif()
endif()

# Sanitizer flags
if(UMF_USE_ASAN)
add_sanitizer_flag(address)
Expand Down Expand Up @@ -953,12 +970,11 @@ if(UMF_FORMAT_CODE_STYLE)
COMMENT "Format C/C++, CMake, and Python files")
message(
STATUS
" Adding convenience targets 'format-check' and 'format-apply'."
)
"Adding convenience targets 'format-check' and 'format-apply'.")
else()
message(
STATUS
" Convenience targets 'format-check' and 'format-apply' are "
"Convenience targets 'format-check' and 'format-apply' are "
"not available. Use commands specific for found tools (see the log above)."
)
endif()
Expand Down
1 change: 1 addition & 0 deletions _deps/cuda-headers-src
Submodule cuda-headers-src added at a63ea5
1 change: 1 addition & 0 deletions _deps/googletest-src
Submodule googletest-src added at b514bd
2 changes: 1 addition & 1 deletion cmake/FindCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ else()
if(CUDA_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/FindJEMALLOC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else()
if(JEMALLOC_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()

Expand All @@ -41,6 +41,6 @@ else()
if(JEMALLOC_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/FindLIBHWLOC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ else()
if(LIBHWLOC_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/FindLIBNUMA.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Intel Corporation
# Copyright (C) 2024-2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Expand All @@ -15,6 +15,6 @@ else()
if(LIBNUMA_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
6 changes: 3 additions & 3 deletions cmake/FindTBB.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Intel Corporation
# Copyright (C) 2024-2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Expand All @@ -21,7 +21,7 @@ else()
if(TBB_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()

Expand All @@ -45,6 +45,6 @@ else()
if(TBB_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/FindZE_LOADER.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ else()
if(ZE_LOADER_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
message(STATUS ${MSG_NOT_FOUND})
endif()
endif()
8 changes: 7 additions & 1 deletion cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ endfunction()

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

target_compile_definitions(${name}
PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
if(NOT MSVC)
target_compile_options(
${name}
Expand Down Expand Up @@ -260,6 +261,10 @@ function(add_umf_target_compile_options name)
-g -O0)
endif()
endif()
if(UMF_USE_VALGRIND)
target_compile_definitions(${name} PRIVATE "UMF_VG_ENABLED=1")
target_include_directories(${name} PRIVATE ${VALGRIND_INCLUDE_DIRS})
endif()
elseif(MSVC)
target_compile_options(
${name}
Expand Down Expand Up @@ -386,6 +391,7 @@ function(add_umf_library)
target_include_directories(
${ARG_NAME}
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src
${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc
${UMF_CMAKE_SOURCE_DIR}/src/coarse)
Expand Down
32 changes: 4 additions & 28 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,16 @@ set(UMF_COMMON_COMPILE_DEFINITIONS
${UMF_COMMON_COMPILE_DEFINITIONS} UMF_VERSION=${UMF_VERSION}
UMF_ALL_CMAKE_VARIABLES="${UMF_ALL_CMAKE_VARIABLES}")

set(BA_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc.c
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linear.c
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_global.c)

add_subdirectory(utils)
add_subdirectory(base_alloc)
add_subdirectory(coarse)

set(UMF_LIBS $<BUILD_INTERFACE:umf_utils> $<BUILD_INTERFACE:coarse>)

set(CTL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ctl/ctl.c)

if(LINUX)
set(BA_SOURCES ${BA_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
elseif(WINDOWS)
set(BA_SOURCES ${BA_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_windows.c)
elseif(MACOSX)
set(BA_SOURCES ${BA_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
endif()

set(BA_SOURCES
${BA_SOURCES}
PARENT_SCOPE)
set(UMF_LIBS umf_utils umf_ba umf_coarse)

set(HWLOC_DEPENDENT_SOURCES topology.c)

set(UMF_SOURCES
${BA_SOURCES}
${CTL_SOURCES}
ctl/ctl.c
libumf.c
ipc.c
ipc_cache.c
Expand Down Expand Up @@ -178,7 +156,7 @@ target_include_directories(umf PRIVATE ${UMF_PRIVATE_INCLUDE_DIRS})
target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})
target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})

add_dependencies(umf coarse)
add_dependencies(umf umf_ba umf_coarse umf_utils)

if(UMF_LINK_HWLOC_STATICALLY)
add_dependencies(umf ${UMF_HWLOC_NAME})
Expand Down Expand Up @@ -228,8 +206,6 @@ target_include_directories(

install(TARGETS umf EXPORT ${PROJECT_NAME}-targets)

add_subdirectory(pool)

if(UMF_PROXY_LIB_ENABLED)
add_subdirectory(proxy_lib)
endif()
28 changes: 28 additions & 0 deletions src/base_alloc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (C) 2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

set(UMF_BA_SOURCES_COMMON base_alloc_global.c base_alloc.c base_alloc_linear.c)
set(UMF_BA_SOURCES_LINUX base_alloc_linux.c)
set(UMF_BA_SOURCES_WINDOWS base_alloc_windows.c)

if(LINUX OR MACOSX)
set(UMF_BA_SOURCES ${UMF_BA_SOURCES_COMMON} ${UMF_BA_SOURCES_LINUX})
elseif(WINDOWS)
set(UMF_BA_SOURCES ${UMF_BA_SOURCES_COMMON} ${UMF_BA_SOURCES_WINDOWS})
endif()

add_umf_library(
NAME umf_ba
TYPE STATIC
SRCS ${UMF_BA_SOURCES}
LIBS umf_utils)

target_include_directories(umf_ba
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)

if(NOT UMF_BUILD_SHARED_LIBRARY)
install(TARGETS umf_ba EXPORT ${PROJECT_NAME}-targets)
endif()
26 changes: 12 additions & 14 deletions src/coarse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@

include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

set(COARSE_SOURCES coarse.c ../ravl/ravl.c)

if(UMF_BUILD_SHARED_LIBRARY AND (NOT WINDOWS))
set(COARSE_EXTRA_SRCS ${BA_SOURCES})
set(COARSE_EXTRA_LIBS $<BUILD_INTERFACE:umf_utils>)
endif()
set(UMF_COARSE_SOURCES coarse.c ${UMF_CMAKE_SOURCE_DIR}/src/ravl/ravl.c)
set(UMF_COARSE_LIBS umf_utils umf_ba)

add_umf_library(
NAME coarse
NAME umf_coarse
TYPE STATIC
SRCS ${COARSE_SOURCES} ${COARSE_EXTRA_SRCS}
LIBS ${COARSE_EXTRA_LIBS})
SRCS ${UMF_COARSE_SOURCES}
LIBS ${UMF_COARSE_LIBS})

target_include_directories(
coarse
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/ravl>)
umf_coarse
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/coarse
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc
${UMF_CMAKE_SOURCE_DIR}/src/ravl)

add_library(${PROJECT_NAME}::coarse ALIAS coarse)
if(NOT UMF_BUILD_SHARED_LIBRARY)
install(TARGETS umf_coarse EXPORT ${PROJECT_NAME}-targets)
endif()
10 changes: 0 additions & 10 deletions src/pool/CMakeLists.txt

This file was deleted.

50 changes: 20 additions & 30 deletions src/proxy_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
# Copyright (C) 2023-2024 Intel Corporation
# Copyright (C) 2023-2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)

set(PROXY_SOURCES proxy_lib.c)
set(UMF_PROXY_SOURCES_COMMON proxy_lib.c)
set(UMF_PROXY_SOURCES_LINUX proxy_lib_linux.c)
set(UMF_PROXY_SOURCES_WINDOWS proxy_lib_windows.c)

set(PROXY_SOURCES_LINUX proxy_lib_linux.c)

set(PROXY_SOURCES_WINDOWS proxy_lib_windows.c)

set(PROXY_SOURCES_MACOSX proxy_lib_linux.c)

if(LINUX)
set(PROXY_SOURCES ${PROXY_SOURCES} ${PROXY_SOURCES_LINUX})
if(LINUX OR MACOSX)
set(UMF_PROXY_SOURCES ${UMF_PROXY_SOURCES_COMMON}
${UMF_PROXY_SOURCES_LINUX})
elseif(WINDOWS)
set(PROXY_SOURCES ${PROXY_SOURCES} ${PROXY_SOURCES_WINDOWS})

set(UMF_PROXY_SOURCES ${UMF_PROXY_SOURCES_COMMON}
${UMF_PROXY_SOURCES_WINDOWS})
# Add resource file needed for Windows to fill metadata in binary files
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/proxy_lib.rc.in"
"${CMAKE_CURRENT_BINARY_DIR}/proxy_lib.rc" IMMEDIATE @ONLY)
set(PROXY_SOURCES ${PROXY_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/proxy_lib.rc)
elseif(MACOSX)
set(PROXY_SOURCES ${PROXY_SOURCES} ${PROXY_SOURCES_MACOSX})
set(UMF_PROXY_SOURCES ${UMF_PROXY_SOURCES_COMMON}
${CMAKE_CURRENT_BINARY_DIR}/proxy_lib.rc)
endif()

add_umf_library(
NAME umf_proxy
TYPE SHARED
SRCS ${BA_SOURCES} ${PROXY_SOURCES}
LIBS umf_utils ${PROXY_LIBS}
SRCS ${UMF_PROXY_SOURCES}
LIBS umf umf_utils umf_ba
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/proxy_lib.map
WINDOWS_DEF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/proxy_lib.def)
set_target_properties(umf_proxy PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})

add_library(${PROJECT_NAME}::proxy ALIAS umf_proxy)

target_link_directories(umf_proxy PRIVATE ${LIBHWLOC_LIBRARY_DIRS})

target_compile_definitions(umf_proxy PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
set_target_properties(umf_proxy PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})

if(PROXY_LIB_USES_SCALABLE_POOL)
target_compile_definitions(umf_proxy PRIVATE PROXY_LIB_USES_SCALABLE_POOL=1)
target_compile_definitions(umf_proxy
PRIVATE "PROXY_LIB_USES_SCALABLE_POOL=1")
elseif(PROXY_LIB_USES_JEMALLOC_POOL)
target_compile_definitions(umf_proxy PRIVATE PROXY_LIB_USES_JEMALLOC_POOL=1)
target_compile_definitions(umf_proxy
PRIVATE "PROXY_LIB_USES_JEMALLOC_POOL=1")
endif()

target_include_directories(
umf_proxy
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/utils>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
umf_proxy PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/base_alloc
${UMF_CMAKE_SOURCE_DIR}/src/ravl)

install(TARGETS umf_proxy EXPORT ${PROJECT_NAME}-targets)
Loading
Loading