Skip to content

Commit e4d2cfe

Browse files
committed
Extract Disjoint Pool into static lib
Also add the unified_memory_framework target to installed files, as this is a dependency of Disjoint Pool. Installed files example locations: /usr/local/include/umf.h /usr/local/include/umf/pools/pool_disjoint.h /usr/local/include/umf/pools/pool_jemalloc.h /usr/local/include/umf/providers/provider_os_memory.h /usr/local/include/umf/memory_pool.h /usr/local/include/umf/memory_provider.h /usr/local/include/umf/memory_provider_ops.h /usr/local/include/umf/base.h /usr/local/include/umf/memory_pool_ops.h /usr/local/lib/libunified_memory_framework.a /usr/local/lib/libdisjoint_pool.a
1 parent 6c79b70 commit e4d2cfe

File tree

11 files changed

+100
-29
lines changed

11 files changed

+100
-29
lines changed

.github/workflows/basic.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
-DUMF_FORMAT_CODE_STYLE=OFF
4747
-DUMF_DEVELOPER_MODE=ON
4848
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
49+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4950
5051
- name: Build UMF
5152
run: |

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
-DUMF_FORMAT_CODE_STYLE=OFF
3535
-DUMF_DEVELOPER_MODE=OFF
3636
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
37+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
3738
-DUMF_ENABLE_POOL_TRACKING=OFF
3839
3940
- name: Build UMF

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
1010

1111
include(CTest)
1212
include(CMakePackageConfigHelpers)
13+
include(GNUInstallDirs)
1314

1415
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1516
include(helpers)
1617

1718
# Build Options
1819
option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
20+
option(UMF_BUILD_LIBUMF_POOL_DISJOINT "Build the libumf_pool_disjoint static library" OFF)
1921
option(UMF_BUILD_LIBUMF_POOL_JEMALLOC "Build the libumf_pool_jemalloc static library" OFF)
2022
option(UMF_BUILD_TESTS "Build UMF tests" ON)
2123
option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
@@ -76,7 +78,7 @@ add_subdirectory(src)
7678
if(UMF_BUILD_TESTS)
7779
add_subdirectory(test)
7880
endif()
79-
if(UMF_BUILD_BENCHMARKS)
81+
if(UMF_BUILD_BENCHMARKS AND UMF_BUILD_LIBUMF_POOL_DISJOINT)
8082
if(LINUX)
8183
add_subdirectory(benchmark)
8284
else()

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ A memory provider that provides memory from an operating system.
2020

2121
## Memory pool managers
2222

23+
### libumf_pool_disjoint
24+
25+
TODO: Add a description
26+
27+
#### Requirements
28+
29+
To enable this feature, the `UMF_BUILD_LIBUMF_POOL_DISJOINT` option needs to be turned `ON`.
30+
2331
### libumf_pool_jemalloc (Linux-only)
2432

2533
libumf_pool_jemalloc is a [jemalloc](https://github.com/jemalloc/jemalloc)-based memory pool manager built as a separate static library.
@@ -43,6 +51,11 @@ Required packages:
4351
For development and contributions:
4452
- clang-format-15.0 (can be installed with `python -m pip install clang-format==15.0.7`)
4553

54+
### Benchmark
55+
56+
Disjoint Pool is a required dependency of the micro benchmark.
57+
In order to build the benchmark, the `UMF_BUILD_LIBUMF_POOL_DISJOINT` CMake configuration flag has to be turned `ON`.
58+
4659
### Windows
4760

4861
Generating Visual Studio Project. EXE and binaries will be in **build/bin/{build_config}**
@@ -87,6 +100,7 @@ List of options provided by CMake:
87100
| Name | Description | Values | Default |
88101
| - | - | - | - |
89102
| UMF_BUILD_SHARED_LIBRARY | Build UMF as shared library | ON/OFF | OFF |
103+
| UMF_BUILD_LIBUMF_POOL_DISJOINT | Build the libumf_pool_disjoint static library | ON/OFF | OFF |
90104
| UMF_BUILD_LIBUMF_POOL_JEMALLOC | Build the libumf_pool_jemalloc static library | ON/OFF | OFF |
91105
| UMF_BUILD_TESTS | Build UMF tests | ON/OFF | ON |
92106
| UMF_BUILD_BENCHMARKS | Build UMF benchmarks | ON/OFF | OFF |

benchmark/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
77
endif()
88

99
add_executable(ubench ubench.c)
10-
add_dependencies(ubench unified_memory_framework)
10+
add_dependencies(ubench
11+
unified_memory_framework
12+
disjoint_pool)
1113
target_include_directories(ubench PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include/)
1214
target_link_libraries(ubench
1315
unified_memory_framework
16+
disjoint_pool
1417
numa
1518
pthread)

src/CMakeLists.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ set(UMF_SOURCES
88
memory_pool.c
99
memory_provider.c
1010
memory_provider_get_last_failed.c
11-
pool/pool_disjoint.cpp
1211
provider/provider_os_memory.c
1312
provider/provider_tracking.c
1413
critnib/critnib.c
@@ -54,18 +53,20 @@ endif()
5453

5554
add_library(${PROJECT_NAME}::unified_memory_framework ALIAS unified_memory_framework)
5655

57-
target_include_directories(unified_memory_framework PUBLIC
58-
${UMF_CMAKE_SOURCE_DIR}/include
59-
./common
60-
./critnib
61-
./provider
62-
./utils)
56+
target_include_directories(unified_memory_framework PUBLIC
57+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
58+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common>
59+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/critnib>
60+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/provider>
61+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils>
62+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
63+
)
6364

64-
# libumf_pool_jemalloc
65-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
66-
if(LINUX)
67-
add_umf_library(pool_jemalloc STATIC pool/pool_jemalloc.c)
68-
else()
69-
message(FATAL_ERROR "libumf_pool_jemalloc is supported on Linux only")
70-
endif()
71-
endif()
65+
install(TARGETS unified_memory_framework
66+
EXPORT ${PROJECT_NAME}-targets
67+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
68+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
69+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
70+
)
71+
72+
add_subdirectory(pool)

src/pool/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (C) 2023 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+
# libumf_pool_disjoint
6+
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
7+
add_umf_library(disjoint_pool STATIC
8+
pool_disjoint.cpp)
9+
10+
add_library(${PROJECT_NAME}::disjoint_pool ALIAS disjoint_pool)
11+
12+
add_dependencies(disjoint_pool
13+
unified_memory_framework)
14+
15+
target_link_libraries(disjoint_pool PRIVATE
16+
unified_memory_framework)
17+
18+
target_include_directories(disjoint_pool PUBLIC
19+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/umf/pools>
20+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
21+
)
22+
23+
install(TARGETS disjoint_pool
24+
EXPORT ${PROJECT_NAME}-targets
25+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
26+
)
27+
endif()
28+
29+
# libumf_pool_jemalloc
30+
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
31+
if(LINUX)
32+
add_umf_library(pool_jemalloc STATIC
33+
pool_jemalloc.c)
34+
else()
35+
message(FATAL_ERROR "libumf_pool_jemalloc is supported on Linux only")
36+
endif()
37+
endif()

src/pool/pool_disjoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
// TODO: replace with logger?
2323
#include <iostream>
2424

25+
#include "pool_disjoint.h"
2526
#include "umf.h"
26-
#include "umf/pools/pool_disjoint.h"
2727
#include "umf_helpers.hpp"
2828
#include "utils_math.h"
2929

test/CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ function(add_umf_test)
3838
${ARG_LIBS})
3939

4040
target_include_directories(${TEST_TARGET_NAME} PRIVATE
41-
${UMF_TEST_DIR}/common
4241
${UMF_CMAKE_SOURCE_DIR}/src
43-
${UMF_CMAKE_SOURCE_DIR}/src/pool/disjoint)
42+
${UMF_TEST_DIR}/common)
4443

4544
add_test(NAME ${TEST_NAME}
4645
COMMAND ${TEST_TARGET_NAME}
@@ -62,13 +61,26 @@ if (UMF_BUILD_LIBUMF_POOL_JEMALLOC)
6261
set(LIBS_JEMALLOC pool_jemalloc jemalloc numa)
6362
endif()
6463

65-
add_umf_test(NAME base SRCS base.cpp)
66-
add_umf_test(NAME memoryPool SRCS memoryPoolAPI.cpp malloc_compliance_tests.cpp LIBS ${LIBS_JEMALLOC})
67-
add_umf_test(NAME memoryProvider SRCS memoryProviderAPI.cpp)
68-
add_umf_test(NAME disjointPool SRCS disjoint_pool.cpp malloc_compliance_tests.cpp)
69-
add_umf_test(NAME c_api_disjoint_pool SRCS c_api/disjoint_pool.c)
70-
add_umf_test(NAME memory_pool_internal SRCS memory_pool_internal.cpp)
64+
add_umf_test(NAME base
65+
SRCS base.cpp)
66+
add_umf_test(NAME memoryPool
67+
SRCS memoryPoolAPI.cpp malloc_compliance_tests.cpp
68+
LIBS ${LIBS_JEMALLOC})
69+
add_umf_test(NAME memoryProvider
70+
SRCS memoryProviderAPI.cpp)
71+
add_umf_test(NAME memory_pool_internal
72+
SRCS memory_pool_internal.cpp)
73+
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
74+
add_umf_test(NAME disjointPool
75+
SRCS disjoint_pool.cpp malloc_compliance_tests.cpp
76+
LIBS ${PROJECT_NAME}::disjoint_pool)
77+
add_umf_test(NAME c_api_disjoint_pool
78+
SRCS c_api/disjoint_pool.c
79+
LIBS ${PROJECT_NAME}::disjoint_pool)
80+
endif()
7181

7282
if(LINUX) # OS-specific functions are implemented only for Linux now
73-
add_umf_test(NAME provider_os_memory SRCS provider_os_memory.cpp LIBS numa)
83+
add_umf_test(NAME provider_os_memory
84+
SRCS provider_os_memory.cpp
85+
LIBS numa)
7486
endif()

test/c_api/disjoint_pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include <stdlib.h>
66

7+
#include "pool_disjoint.h"
78
#include "provider_null.h"
89
#include "test_helpers.h"
9-
#include "umf/pools/pool_disjoint.h"
1010

1111
void test_disjoint_pool_default_params(void) {
1212
umf_memory_provider_handle_t provider = nullProviderCreate();

test/disjoint_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#include "memoryPool.hpp"
66
#include "pool.hpp"
7+
#include "pool_disjoint.h"
78
#include "provider.hpp"
89
#include "provider_null.h"
910
#include "provider_trace.h"
10-
#include "umf/pools/pool_disjoint.h"
1111

1212
umf_disjoint_pool_params_t poolConfig() {
1313
umf_disjoint_pool_params_t config{};

0 commit comments

Comments
 (0)