Skip to content

Make umf_utils an interface library #391

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 1 commit into from
Mar 26, 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
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()

add_subdirectory(utils)

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

set(BA_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc.c
Expand Down
9 changes: 5 additions & 4 deletions src/pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
if(UMF_BUILD_SHARED_LIBRARY)
set(POOL_EXTRA_SRCS ${BA_SOURCES})
set(POOL_COMPILE_DEFINITIONS UMF_SHARED_LIBRARY)
set(POOL_EXTRA_LIBS $<BUILD_INTERFACE:umf_utils>)
endif()

# libumf_pool_disjoint
Expand All @@ -13,7 +14,7 @@ if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
NAME disjoint_pool
TYPE STATIC
SRCS pool_disjoint.cpp ${POOL_EXTRA_SRCS}
LIBS umf_utils)
LIBS ${POOL_EXTRA_LIBS})
target_compile_definitions(disjoint_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})

add_library(${PROJECT_NAME}::disjoint_pool ALIAS disjoint_pool)
Expand All @@ -36,7 +37,7 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
NAME jemalloc_pool
TYPE STATIC
SRCS pool_jemalloc.c ${POOL_EXTRA_SRCS}
LIBS jemalloc umf_utils)
LIBS jemalloc ${POOL_EXTRA_LIBS})
target_include_directories(jemalloc_pool PRIVATE ${JEMALLOC_INCLUDE_DIRS})
target_compile_definitions(jemalloc_pool PUBLIC ${POOL_COMPILE_DEFINITIONS})
add_library(${PROJECT_NAME}::jemalloc_pool ALIAS jemalloc_pool)
Expand All @@ -46,9 +47,9 @@ endif()
# libumf_pool_scalable
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
if(LINUX)
set(LIBS_POOL_SCALABLE dl umf_utils)
set(LIBS_POOL_SCALABLE dl ${POOL_EXTRA_LIBS})
else()
set(LIBS_POOL_SCALABLE umf_utils)
set(LIBS_POOL_SCALABLE ${POOL_EXTRA_LIBS})
endif()

add_umf_library(
Expand Down
21 changes: 8 additions & 13 deletions src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,18 @@ elseif(WINDOWS)
${UMF_UTILS_SOURCES_WINDOWS})
endif()

add_umf_library(
NAME umf_utils
TYPE STATIC
SRCS ${UMF_UTILS_SOURCES}
LIBS ${CMAKE_THREAD_LIBS_INIT})

add_library(umf_utils INTERFACE)
add_library(${PROJECT_NAME}::utils ALIAS umf_utils)

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

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

if(USE_VALGRIND)
target_compile_definitions(umf_utils PUBLIC UMF_VG_ENABLED=1)
target_compile_definitions(umf_utils INTERFACE UMF_VG_ENABLED=1)
endif()

install(TARGETS umf_utils EXPORT ${PROJECT_NAME}-targets)
39 changes: 24 additions & 15 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function(add_umf_test)
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src
${UMF_CMAKE_SOURCE_DIR}/src/base_alloc
${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_TEST_DIR}/common
${UMF_TEST_DIR})

Expand Down Expand Up @@ -94,14 +95,22 @@ add_umf_test(NAME base SRCS base.cpp)
add_umf_test(NAME memoryPool SRCS memoryPoolAPI.cpp malloc_compliance_tests.cpp)
add_umf_test(NAME memoryProvider SRCS memoryProviderAPI.cpp)

add_umf_test(
NAME logger
SRCS utils/utils_log.cpp
LIBS umf_utils)
if(UMF_BUILD_SHARED_LIBRARY)
# if build as shared library, utils symbols won't be visible in tests
set(UMF_UTILS_FOR_TEST umf_utils)
endif()

if(UMF_BUILD_SHARED_LIBRARY)
add_umf_test(NAME logger SRCS utils/utils_log.cpp
../src/utils/utils_common.c)
else()
add_umf_test(NAME logger SRCS utils/utils_log.cpp)
endif()

add_umf_test(
NAME utils_common
SRCS utils/utils.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})

if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
add_umf_test(
Expand Down Expand Up @@ -149,27 +158,27 @@ if(LINUX) # OS-specific functions are implemented only for Linux now
add_umf_test(
NAME provider_os_memory
SRCS provider_os_memory.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})
add_umf_test(
NAME provider_os_memory_multiple_numa_nodes
SRCS provider_os_memory_multiple_numa_nodes.cpp
LIBS umf_utils ${LIBNUMA_LIBRARIES})
LIBS ${UMF_UTILS_FOR_TEST} ${LIBNUMA_LIBRARIES})
add_umf_test(
NAME memspace_numa
SRCS memspaces/memspace_numa.cpp
LIBS ${LIBNUMA_LIBRARIES})
add_umf_test(
NAME provider_os_memory_config
SRCS provider_os_memory_config.cpp
LIBS umf_utils ${LIBNUMA_LIBRARIES})
LIBS ${UMF_UTILS_FOR_TEST} ${LIBNUMA_LIBRARIES})
add_umf_test(
NAME memspace_host_all
SRCS memspaces/memspace_host_all.cpp
LIBS umf_utils ${LIBNUMA_LIBRARIES})
LIBS ${UMF_UTILS_FOR_TEST} ${LIBNUMA_LIBRARIES})
add_umf_test(
NAME memspace_highest_capacity
SRCS memspaces/memspace_highest_capacity.cpp
LIBS umf_utils ${LIBNUMA_LIBRARIES})
LIBS ${UMF_UTILS_FOR_TEST} ${LIBNUMA_LIBRARIES})
endif()

# TODO add support for Windows
Expand All @@ -182,12 +191,12 @@ if(UMF_BUILD_GPU_TESTS
add_umf_test(
NAME provider_level_zero
SRCS providers/provider_level_zero.cpp
LIBS umf_utils ze_loader)
LIBS ${UMF_UTILS_FOR_TEST} ze_loader)

add_umf_test(
NAME provider_level_zero_dlopen
SRCS providers/provider_level_zero.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})
target_compile_definitions(umf_test-provider_level_zero_dlopen
PUBLIC USE_DLOPEN=1)
endif()
Expand All @@ -200,17 +209,17 @@ endif()
add_umf_test(
NAME base_alloc
SRCS ${BA_SOURCES_FOR_TEST} test_base_alloc.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})
add_umf_test(
NAME base_alloc_linear
SRCS ${BA_SOURCES_FOR_TEST} test_base_alloc_linear.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})

add_umf_test(
NAME base_alloc_global
SRCS ${BA_SOURCES_FOR_TEST} pools/pool_base_alloc.cpp
malloc_compliance_tests.cpp
LIBS umf_utils)
LIBS ${UMF_UTILS_FOR_TEST})

# tests for the proxy library
if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY)
Expand Down
1 change: 0 additions & 1 deletion test/memspaces/memspace_highest_capacity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "memspace_helpers.hpp"
#include "memspace_internal.h"
#include "test_helpers.h"
#include "utils_sanitizers.h"

#include <numa.h>
#include <numaif.h>
Expand Down
1 change: 0 additions & 1 deletion test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def _create_match_list(self) -> List[str]:
lib.append(f"lib/{lib_prefix}umf.{lib_ext}")
if is_umf_proxy:
lib.append(f"lib/{lib_prefix}umf_proxy.{lib_ext_shared}")
lib.append(f"lib/{lib_prefix}umf_utils.{lib_ext_static}")

share = []
share = [
Expand Down