Skip to content

Commit 614c4b5

Browse files
committed
Incorporate jemalloc_pool into libumf
Remove the separate static `jemalloc_pool` library. Make the `UMF_BUILD_LIBUMF_POOL_JEMALLOC` option turned ON by default. Incorporate jemalloc_pool into libumf. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent e95d92e commit 614c4b5

16 files changed

+101
-64
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ jobs:
209209
--install-dir ${{env.INSTL_DIR}}
210210
--build-type ${{matrix.build_type}}
211211
--disjoint-pool
212-
--jemalloc-pool
213212
${{ matrix.install_tbb == 'ON' && matrix.disable_hwloc != 'ON' && matrix.shared_library == 'ON' && '--proxy' || '' }}
214213
--umf-version ${{env.UMF_VERSION}}
215214
${{ matrix.shared_library == 'ON' && '--shared-library' || '' }}
@@ -300,7 +299,6 @@ jobs:
300299
--install-dir ${{env.INSTL_DIR}}
301300
--build-type ${{matrix.build_type}}
302301
--disjoint-pool
303-
--jemalloc-pool
304302
${{matrix.shared_library == 'ON' && '--proxy' || '' }}
305303
--umf-version ${{env.UMF_VERSION}}
306304
${{ matrix.shared_library == 'ON' && '--shared-library' || ''}}
@@ -495,7 +493,6 @@ jobs:
495493
--install-dir ${{env.INSTL_DIR}}
496494
--build-type ${{env.BUILD_TYPE}}
497495
--disjoint-pool
498-
--jemalloc-pool
499496
--proxy
500497
--umf-version ${{env.UMF_VERSION}}
501498
--shared-library

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ endif()
113113

114114
if(NOT UMF_BUILD_LIBUMF_POOL_JEMALLOC)
115115
set(UMF_POOL_JEMALLOC_ENABLED FALSE)
116+
set(JEMALLOC_FOUND FALSE)
117+
set(JEMALLOC_LIBRARIES FALSE)
116118
elseif(WINDOWS)
117119
pkg_check_modules(JEMALLOC jemalloc)
118120
if(NOT JEMALLOC_FOUND)
@@ -190,6 +192,12 @@ if(JEMALLOC_FOUND OR JEMALLOC_LIBRARIES)
190192
message(STATUS " JEMALLOC_LIBRARIES = ${JEMALLOC_LIBRARIES}")
191193
message(STATUS " JEMALLOC_INCLUDE_DIRS = ${JEMALLOC_INCLUDE_DIRS}")
192194
message(STATUS " JEMALLOC_LIBRARY_DIRS = ${JEMALLOC_LIBRARY_DIRS}")
195+
else()
196+
set(UMF_POOL_JEMALLOC_ENABLED FALSE)
197+
message(
198+
STATUS
199+
"Disabling the Jemalloc Pool and tests and benchmarks that use it because jemalloc was not built/found."
200+
)
193201
endif()
194202

195203
if(UMF_DISABLE_HWLOC)
@@ -523,14 +531,14 @@ elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
523531
)
524532
endif()
525533
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL JEMALLOC)
526-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
534+
if(UMF_POOL_JEMALLOC_ENABLED)
527535
set(UMF_PROXY_LIB_ENABLED ON)
528536
set(PROXY_LIB_USES_JEMALLOC_POOL ON)
529-
set(PROXY_LIBS jemalloc_pool umf)
537+
set(PROXY_LIBS umf)
530538
else()
531539
message(
532540
STATUS
533-
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but UMF_BUILD_LIBUMF_POOL_JEMALLOC is OFF"
541+
"Disabling the proxy library, because UMF_PROXY_LIB_BASED_ON_POOL==JEMALLOC but the jemalloc pool is disabled"
534542
)
535543
endif()
536544
else()

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,9 @@ The default jemalloc package is required on Windows.
298298
##### Requirements
299299

300300
1) The `UMF_BUILD_LIBUMF_POOL_JEMALLOC` option turned `ON`
301-
2) Required packages:
302-
- jemalloc (Windows only)
301+
2) jemalloc is required:
302+
- on Linux and MacOS: jemalloc is fetched and built from sources (a custom build),
303+
- on Windows: the default jemalloc package is required
303304

304305
#### Scalable Pool (part of libumf)
305306

benchmark/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function(add_umf_benchmark)
5151

5252
set(BENCH_NAME umf-${ARG_NAME})
5353

54-
set(BENCH_LIBS ${ARG_LIBS} umf)
54+
set(BENCH_LIBS ${ARG_LIBS} umf umf_utils)
5555

5656
add_umf_executable(
5757
NAME ${BENCH_NAME}
@@ -121,8 +121,7 @@ set(LIB_DIRS ${LIBHWLOC_LIBRARY_DIRS})
121121
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
122122
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} disjoint_pool)
123123
endif()
124-
if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
125-
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} jemalloc_pool ${JEMALLOC_LIBRARIES})
124+
if(UMF_POOL_JEMALLOC_ENABLED)
126125
set(LIB_DIRS ${LIB_DIRS} ${JEMALLOC_LIBRARY_DIRS})
127126
endif()
128127
if(LINUX)

benchmark/multithread.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ int main() {
139139
// ctest looks for "PASSED" in the output
140140
std::cout << "PASSED" << std::endl;
141141

142+
#if defined(UMF_POOL_DISJOINT_ENABLED)
142143
ret = umfDisjointPoolParamsDestroy(hDisjointParams);
143144
if (ret != UMF_RESULT_SUCCESS) {
144145
std::cerr << "disjoint pool params destroy failed" << std::endl;
145146
return -1;
146147
}
148+
#endif
147149

148150
return 0;
149151
}

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ if(LINUX)
282282
add_umf_executable(
283283
NAME ${EXAMPLE_NAME}
284284
SRCS dram_and_fsdax/dram_and_fsdax.c
285-
LIBS umf jemalloc_pool)
285+
LIBS umf)
286286

287287
target_link_options(${EXAMPLE_NAME} PRIVATE "-Wl,--no-as-needed,-ldl")
288288

examples/dram_and_fsdax/CMakeLists.txt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,15 @@ if(NOT LIBHWLOC_FOUND)
2121
find_package(LIBHWLOC 2.3.0 REQUIRED hwloc)
2222
endif()
2323

24-
# find the custom jemalloc pointed by CMAKE_PREFIX_PATH
25-
find_package(JEMALLOC REQUIRED jemalloc)
26-
2724
# build the example
2825
set(EXAMPLE_NAME umf_example_dram_and_fsdax)
2926
add_executable(${EXAMPLE_NAME} dram_and_fsdax.c)
3027
target_include_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_INCLUDE_DIRS})
3128

32-
target_link_directories(
33-
${EXAMPLE_NAME}
34-
PRIVATE
35-
${LIBUMF_LIBRARY_DIRS}
36-
${LIBHWLOC_LIBRARY_DIRS}
37-
${JEMALLOC_LIBRARY_DIRS})
29+
target_link_directories(${EXAMPLE_NAME} PRIVATE ${LIBUMF_LIBRARY_DIRS}
30+
${LIBHWLOC_LIBRARY_DIRS})
3831

39-
target_link_libraries(
40-
${EXAMPLE_NAME} PRIVATE hwloc jemalloc_pool ${JEMALLOC_LIBRARIES}
41-
${LIBUMF_LIBRARIES})
32+
target_link_libraries(${EXAMPLE_NAME} PRIVATE hwloc ${LIBUMF_LIBRARIES})
4233

4334
# an optional part - adds a test of this example
4435
add_test(
@@ -54,6 +45,6 @@ if(LINUX)
5445
TEST ${EXAMPLE_NAME}
5546
PROPERTY
5647
ENVIRONMENT_MODIFICATION
57-
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${JEMALLOC_LIBRARY_DIRS}"
48+
"LD_LIBRARY_PATH=path_list_append:${LIBUMF_LIBRARY_DIRS};LD_LIBRARY_PATH=path_list_append:${LIBHWLOC_LIBRARY_DIRS}"
5849
)
5950
endif()

src/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,19 @@ set(UMF_SOURCES
6969
critnib/critnib.c
7070
ravl/ravl.c
7171
pool/pool_proxy.c
72+
pool/pool_jemalloc.c
7273
pool/pool_scalable.c)
7374

75+
if(UMF_POOL_JEMALLOC_ENABLED)
76+
set(UMF_LIBS ${UMF_LIBS} ${JEMALLOC_LIBRARIES})
77+
set(UMF_PRIVATE_LIBRARY_DIRS ${UMF_PRIVATE_LIBRARY_DIRS}
78+
${JEMALLOC_LIBRARY_DIRS})
79+
set(UMF_PRIVATE_INCLUDE_DIRS ${UMF_PRIVATE_INCLUDE_DIRS}
80+
${JEMALLOC_INCLUDE_DIRS})
81+
set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}
82+
"UMF_POOL_JEMALLOC_ENABLED=1")
83+
endif()
84+
7485
if(NOT UMF_DISABLE_HWLOC)
7586
set(UMF_SOURCES ${UMF_SOURCES} ${HWLOC_DEPENDENT_SOURCES}
7687
memtargets/memtarget_numa.c)
@@ -146,15 +157,19 @@ else()
146157
LIBS ${UMF_LIBS})
147158
endif()
148159

160+
target_include_directories(umf PRIVATE ${UMF_PRIVATE_INCLUDE_DIRS})
161+
target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})
162+
target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
163+
149164
add_dependencies(umf coarse)
150165

151166
if(UMF_LINK_HWLOC_STATICALLY)
152167
add_dependencies(umf ${UMF_HWLOC_NAME})
153168
endif()
154169

155-
target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS})
156-
157-
target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS})
170+
if(NOT WINDOWS AND UMF_POOL_JEMALLOC_ENABLED)
171+
add_dependencies(umf jemalloc)
172+
endif()
158173

159174
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
160175
if(LINUX)

src/libumf.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ EXPORTS
3636
umfFileMemoryProviderParamsSetVisibility
3737
umfGetIPCHandle
3838
umfGetLastFailedMemoryProvider
39+
umfJemallocPoolOps
40+
umfJemallocPoolParamsCreate
41+
umfJemallocPoolParamsDestroy
42+
umfJemallocPoolParamsSetKeepAllMemory
3943
umfLevelZeroMemoryProviderOps
4044
umfLevelZeroMemoryProviderParamsCreate
4145
umfLevelZeroMemoryProviderParamsDestroy

src/libumf.map

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ UMF_1.0 {
3030
umfFileMemoryProviderParamsSetVisibility;
3131
umfGetIPCHandle;
3232
umfGetLastFailedMemoryProvider;
33+
umfJemallocPoolOps;
34+
umfJemallocPoolParamsCreate;
35+
umfJemallocPoolParamsDestroy;
36+
umfJemallocPoolParamsSetKeepAllMemory;
3337
umfLevelZeroMemoryProviderOps;
3438
umfLevelZeroMemoryProviderParamsCreate;
3539
umfLevelZeroMemoryProviderParamsDestroy;

0 commit comments

Comments
 (0)