Skip to content

Commit 746cb7d

Browse files
committed
Fix running benchmark without disjoint pool
Turning off disjoint pool (using UMF_BUILD_LIBUMF_POOL_DISJOINT) should not turn off benchmark (as it is now). Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 8853ffd commit 746cb7d

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ install(
7575
EXPORT ${PROJECT_NAME}-targets)
7676

7777
add_subdirectory(src)
78+
7879
if(UMF_BUILD_TESTS)
7980
add_subdirectory(test)
8081
endif()
81-
if(UMF_BUILD_BENCHMARKS AND UMF_BUILD_LIBUMF_POOL_DISJOINT)
82+
83+
if(UMF_BUILD_BENCHMARKS)
8284
if(LINUX)
8385
add_subdirectory(benchmark)
8486
else()

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ For development and contributions:
5353

5454
### Benchmark
5555

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`.
56+
A simple micro benchmark based on [ubench](https://github.com/sheredom/ubench.h).
57+
In order to build the benchmark, the `UMF_BUILD_BENCHMARKS` CMake configuration flag has to be turned `ON`.
5858

5959
### Windows
6060

benchmark/CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
66
message(WARNING "The ubench SHOULD NOT be run in the Debug build type!")
77
endif()
88

9+
if(UMF_BUILD_LIBUMF_POOL_DISJOINT)
10+
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} disjoint_pool)
11+
endif()
12+
913
add_executable(ubench ubench.c)
14+
1015
add_dependencies(ubench
1116
umf
12-
disjoint_pool)
17+
${LIBS_OPTIONAL})
18+
1319
target_include_directories(ubench PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include/)
20+
1421
target_link_libraries(ubench
1522
umf
16-
disjoint_pool
23+
${LIBS_OPTIONAL}
1724
pthread
1825
m)
26+
27+
if (UMF_BUILD_LIBUMF_POOL_DISJOINT)
28+
target_compile_definitions(ubench PRIVATE UMF_BUILD_LIBUMF_POOL_DISJOINT=1)
29+
endif()

benchmark/ubench.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
*
88
*/
99

10-
#include <umf/pools/pool_disjoint.h>
1110
#include <umf/providers/provider_os_memory.h>
1211

12+
#ifdef UMF_BUILD_LIBUMF_POOL_DISJOINT
13+
#include <umf/pools/pool_disjoint.h>
14+
#endif
15+
1316
#include <stdbool.h>
1417
#include <unistd.h>
1518

@@ -145,6 +148,7 @@ UBENCH_EX(simple, os_memory_provider) {
145148
free(array);
146149
}
147150

151+
#ifdef UMF_BUILD_LIBUMF_POOL_DISJOINT
148152
////////////////// DISJOINT POOL WITH OS MEMORY PROVIDER
149153

150154
static void *w_umfPoolMalloc(void *provider, size_t size, size_t alignment) {
@@ -200,5 +204,6 @@ UBENCH_EX(simple, disjoint_pool_with_os_memory_provider) {
200204
umfMemoryProviderDestroy(os_memory_provider);
201205
free(array);
202206
}
207+
#endif /* UMF_BUILD_LIBUMF_POOL_DISJOINT */
203208

204209
UBENCH_MAIN();

0 commit comments

Comments
 (0)