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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -953,12 +953,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
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()
4 changes: 2 additions & 2 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 Down
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()
1 change: 1 addition & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,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)
32 changes: 13 additions & 19 deletions src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)
include(FindThreads)

set(UMF_UTILS_SOURCES_COMMON utils_common.c utils_log.c utils_load_library.c)

set(UMF_UTILS_SOURCES_POSIX utils_posix_common.c utils_posix_concurrency.c)

set(UMF_UTILS_SOURCES_LINUX utils_linux_common.c)

set(UMF_UTILS_SOURCES_MACOSX utils_macosx_common.c)

set(UMF_UTILS_SOURCES_WINDOWS utils_windows_common.c
utils_windows_concurrency.c)

Expand Down Expand Up @@ -48,24 +44,22 @@ elseif(WINDOWS)
${UMF_UTILS_SOURCES_WINDOWS})
endif()

add_library(umf_utils INTERFACE)
add_library(${PROJECT_NAME}::utils ALIAS umf_utils)
add_umf_library(
NAME umf_utils
TYPE STATIC
SRCS ${UMF_UTILS_SOURCES}
LIBS ${UMF_UTILS_LIBS} ${CMAKE_THREAD_LIBS_INIT})

target_sources(umf_utils INTERFACE ${UMF_UTILS_SOURCES})
target_link_libraries(umf_utils INTERFACE ${CMAKE_THREAD_LIBS_INIT}
${UMF_UTILS_LIBS})

target_include_directories(
umf_utils
INTERFACE ${VALGRIND_INCLUDE_DIRS}
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(umf_utils PRIVATE ${VALGRIND_INCLUDE_DIRS})

if(UMF_USE_VALGRIND)
set(UMF_UTILS_INTERFACE_DEFS "UMF_VG_ENABLED=1")
set(UMF_UTILS_DEFS "UMF_VG_ENABLED=1")
endif()

set(UMF_UTILS_INTERFACE_DEFS ${UMF_UTILS_INTERFACE_DEFS}
${UMF_COMMON_COMPILE_DEFINITIONS})
set(UMF_UTILS_DEFS ${UMF_UTILS_DEFS} ${UMF_COMMON_COMPILE_DEFINITIONS})

target_compile_definitions(umf_utils PRIVATE ${UMF_UTILS_DEFS})

target_compile_definitions(umf_utils INTERFACE ${UMF_UTILS_INTERFACE_DEFS})
if(NOT UMF_BUILD_SHARED_LIBRARY)
install(TARGETS umf_utils EXPORT ${PROJECT_NAME}-targets)
endif()
Loading
Loading