Skip to content

Commit 93c9ab0

Browse files
authored
Merge pull request #1324 from bratpiorka/rrudnick_ba_lib
compile utils and Base Alloc as static libs
2 parents c67d32e + 03fa803 commit 93c9ab0

16 files changed

+187
-224
lines changed

CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,23 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES
632632
set(CMAKE_UMF_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
633633
endif()
634634

635+
# Valgrind
636+
if(UMF_USE_VALGRIND)
637+
if(UMF_USE_ASAN
638+
OR UMF_USE_TSAN
639+
OR UMF_USE_UBSAN
640+
OR UMF_USE_MSAN)
641+
message(FATAL_ERROR "Cannot use valgrind and sanitizers together")
642+
endif()
643+
644+
if(PkgConfig_FOUND)
645+
pkg_check_modules(VALGRIND valgrind)
646+
endif()
647+
if(NOT VALGRIND_FOUND)
648+
find_package(VALGRIND REQUIRED valgrind)
649+
endif()
650+
endif()
651+
635652
# Sanitizer flags
636653
if(UMF_USE_ASAN)
637654
add_sanitizer_flag(address)
@@ -953,12 +970,11 @@ if(UMF_FORMAT_CODE_STYLE)
953970
COMMENT "Format C/C++, CMake, and Python files")
954971
message(
955972
STATUS
956-
" Adding convenience targets 'format-check' and 'format-apply'."
957-
)
973+
"Adding convenience targets 'format-check' and 'format-apply'.")
958974
else()
959975
message(
960976
STATUS
961-
" Convenience targets 'format-check' and 'format-apply' are "
977+
"Convenience targets 'format-check' and 'format-apply' are "
962978
"not available. Use commands specific for found tools (see the log above)."
963979
)
964980
endif()

cmake/FindCUDA.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ else()
3434
if(CUDA_FIND_REQUIRED)
3535
message(FATAL_ERROR ${MSG_NOT_FOUND})
3636
else()
37-
message(WARNING ${MSG_NOT_FOUND})
37+
message(STATUS ${MSG_NOT_FOUND})
3838
endif()
3939
endif()

cmake/FindJEMALLOC.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ else()
2323
if(JEMALLOC_FIND_REQUIRED)
2424
message(FATAL_ERROR ${MSG_NOT_FOUND})
2525
else()
26-
message(WARNING ${MSG_NOT_FOUND})
26+
message(STATUS ${MSG_NOT_FOUND})
2727
endif()
2828
endif()
2929

@@ -41,6 +41,6 @@ else()
4141
if(JEMALLOC_FIND_REQUIRED)
4242
message(FATAL_ERROR ${MSG_NOT_FOUND})
4343
else()
44-
message(WARNING ${MSG_NOT_FOUND})
44+
message(STATUS ${MSG_NOT_FOUND})
4545
endif()
4646
endif()

cmake/FindLIBHWLOC.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ else()
7676
if(LIBHWLOC_FIND_REQUIRED)
7777
message(FATAL_ERROR ${MSG_NOT_FOUND})
7878
else()
79-
message(WARNING ${MSG_NOT_FOUND})
79+
message(STATUS ${MSG_NOT_FOUND})
8080
endif()
8181
endif()

cmake/FindLIBNUMA.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2024 Intel Corporation
1+
# Copyright (C) 2024-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

@@ -15,6 +15,6 @@ else()
1515
if(LIBNUMA_FIND_REQUIRED)
1616
message(FATAL_ERROR ${MSG_NOT_FOUND})
1717
else()
18-
message(WARNING ${MSG_NOT_FOUND})
18+
message(STATUS ${MSG_NOT_FOUND})
1919
endif()
2020
endif()

cmake/FindTBB.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2024 Intel Corporation
1+
# Copyright (C) 2024-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

@@ -21,7 +21,7 @@ else()
2121
if(TBB_FIND_REQUIRED)
2222
message(FATAL_ERROR ${MSG_NOT_FOUND})
2323
else()
24-
message(WARNING ${MSG_NOT_FOUND})
24+
message(STATUS ${MSG_NOT_FOUND})
2525
endif()
2626
endif()
2727

@@ -45,6 +45,6 @@ else()
4545
if(TBB_FIND_REQUIRED)
4646
message(FATAL_ERROR ${MSG_NOT_FOUND})
4747
else()
48-
message(WARNING ${MSG_NOT_FOUND})
48+
message(STATUS ${MSG_NOT_FOUND})
4949
endif()
5050
endif()

cmake/FindZE_LOADER.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ else()
3434
if(ZE_LOADER_FIND_REQUIRED)
3535
message(FATAL_ERROR ${MSG_NOT_FOUND})
3636
else()
37-
message(WARNING ${MSG_NOT_FOUND})
37+
message(STATUS ${MSG_NOT_FOUND})
3838
endif()
3939
endif()

cmake/helpers.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ endfunction()
225225

226226
function(add_umf_target_compile_options name)
227227
check_add_target_compile_options(${name} "-Wno-covered-switch-default")
228-
228+
target_compile_definitions(${name}
229+
PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
229230
if(NOT MSVC)
230231
target_compile_options(
231232
${name}
@@ -260,6 +261,10 @@ function(add_umf_target_compile_options name)
260261
-g -O0)
261262
endif()
262263
endif()
264+
if(UMF_USE_VALGRIND)
265+
target_compile_definitions(${name} PRIVATE "UMF_VG_ENABLED=1")
266+
target_include_directories(${name} PRIVATE ${VALGRIND_INCLUDE_DIRS})
267+
endif()
263268
elseif(MSVC)
264269
target_compile_options(
265270
${name}
@@ -386,6 +391,7 @@ function(add_umf_library)
386391
target_include_directories(
387392
${ARG_NAME}
388393
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
394+
${UMF_CMAKE_SOURCE_DIR}/src
389395
${UMF_CMAKE_SOURCE_DIR}/src/utils
390396
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc
391397
${UMF_CMAKE_SOURCE_DIR}/src/coarse)

src/CMakeLists.txt

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,16 @@ set(UMF_COMMON_COMPILE_DEFINITIONS
3030
${UMF_COMMON_COMPILE_DEFINITIONS} UMF_VERSION=${UMF_VERSION}
3131
UMF_ALL_CMAKE_VARIABLES="${UMF_ALL_CMAKE_VARIABLES}")
3232

33-
set(BA_SOURCES
34-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc.c
35-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linear.c
36-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_global.c)
37-
3833
add_subdirectory(utils)
34+
add_subdirectory(base_alloc)
3935
add_subdirectory(coarse)
4036

41-
set(UMF_LIBS $<BUILD_INTERFACE:umf_utils> $<BUILD_INTERFACE:coarse>)
42-
43-
set(CTL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ctl/ctl.c)
44-
45-
if(LINUX)
46-
set(BA_SOURCES ${BA_SOURCES}
47-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
48-
elseif(WINDOWS)
49-
set(BA_SOURCES ${BA_SOURCES}
50-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_windows.c)
51-
elseif(MACOSX)
52-
set(BA_SOURCES ${BA_SOURCES}
53-
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
54-
endif()
55-
56-
set(BA_SOURCES
57-
${BA_SOURCES}
58-
PARENT_SCOPE)
37+
set(UMF_LIBS umf_utils umf_ba umf_coarse)
5938

6039
set(HWLOC_DEPENDENT_SOURCES topology.c)
6140

6241
set(UMF_SOURCES
63-
${BA_SOURCES}
64-
${CTL_SOURCES}
42+
ctl/ctl.c
6543
libumf.c
6644
ipc.c
6745
ipc_cache.c
@@ -178,7 +156,7 @@ target_include_directories(umf PRIVATE ${UMF_PRIVATE_INCLUDE_DIRS})
178156
target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})
179157
target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
180158

181-
add_dependencies(umf coarse)
159+
add_dependencies(umf umf_ba umf_coarse umf_utils)
182160

183161
if(UMF_LINK_HWLOC_STATICALLY)
184162
add_dependencies(umf ${UMF_HWLOC_NAME})
@@ -228,8 +206,6 @@ target_include_directories(
228206

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

231-
add_subdirectory(pool)
232-
233209
if(UMF_PROXY_LIB_ENABLED)
234210
add_subdirectory(proxy_lib)
235211
endif()

src/base_alloc/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake)
6+
7+
set(UMF_BA_SOURCES_COMMON base_alloc_global.c base_alloc.c base_alloc_linear.c)
8+
set(UMF_BA_SOURCES_LINUX base_alloc_linux.c)
9+
set(UMF_BA_SOURCES_WINDOWS base_alloc_windows.c)
10+
11+
if(LINUX OR MACOSX)
12+
set(UMF_BA_SOURCES ${UMF_BA_SOURCES_COMMON} ${UMF_BA_SOURCES_LINUX})
13+
elseif(WINDOWS)
14+
set(UMF_BA_SOURCES ${UMF_BA_SOURCES_COMMON} ${UMF_BA_SOURCES_WINDOWS})
15+
endif()
16+
17+
add_umf_library(
18+
NAME umf_ba
19+
TYPE STATIC
20+
SRCS ${UMF_BA_SOURCES}
21+
LIBS umf_utils)
22+
23+
target_include_directories(umf_ba
24+
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/src/base_alloc)
25+
26+
if(NOT UMF_BUILD_SHARED_LIBRARY)
27+
install(TARGETS umf_ba EXPORT ${PROJECT_NAME}-targets)
28+
endif()

0 commit comments

Comments
 (0)