Skip to content

Commit 66d38de

Browse files
committed
Enable ubench benchmark with OS memory provider on Windows
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent 9963011 commit 66d38de

File tree

4 files changed

+77
-8
lines changed

4 files changed

+77
-8
lines changed

.github/workflows/benchmarks.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
-DUMF_BUILD_TESTS=OFF
4040
-DUMF_FORMAT_CODE_STYLE=OFF
4141
-DUMF_DEVELOPER_MODE=OFF
42+
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
4243
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
4344
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4445
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
@@ -67,3 +68,63 @@ jobs:
6768
- name: Run MT benchmarks
6869
working-directory: ${{github.workspace}}/build
6970
run: ./benchmark/multithread_bench
71+
72+
benchmarks-windows:
73+
name: Windows
74+
env:
75+
BUILD_DIR : "${{github.workspace}}/build/"
76+
HWLOC_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows"
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
build_type: [Release]
81+
compiler: [{c: cl, cxx: cl}]
82+
shared_library: ['ON', 'OFF']
83+
runs-on: 'windows-2022'
84+
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
88+
89+
- name: Initialize vcpkg
90+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
91+
with:
92+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
93+
vcpkgDirectory: ${{github.workspace}}/build/vcpkg
94+
vcpkgJsonGlob: '**/vcpkg.json'
95+
96+
- name: Install dependencies
97+
run: vcpkg install
98+
shell: pwsh # Specifies PowerShell as the shell for running the script.
99+
100+
- name: Configure build
101+
run: >
102+
cmake
103+
-B ${{env.BUILD_DIR}}
104+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
105+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
106+
-DCMAKE_PREFIX_PATH=${{env.HWLOC_PATH}}
107+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
108+
-DUMF_BUILD_BENCHMARKS=ON
109+
-DUMF_BUILD_BENCHMARKS_MT=OFF
110+
-DUMF_BUILD_TESTS=OFF
111+
-DUMF_FORMAT_CODE_STYLE=OFF
112+
-DUMF_DEVELOPER_MODE=OFF
113+
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
114+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
115+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
116+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
117+
-DUMF_ENABLE_POOL_TRACKING=OFF
118+
119+
- name: Build UMF
120+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
121+
122+
- name: Run benchmarks
123+
working-directory: ${{env.BUILD_DIR}}
124+
shell: pwsh # Specifies PowerShell as the shell for running the script.
125+
run: |
126+
# add path to umf.dll
127+
$env:PATH += ";${{env.BUILD_DIR}}\bin\${{matrix.build_type}}"
128+
# add path to hwloc-15.dll
129+
$env:PATH += ";${{env.HWLOC_PATH}}\bin"
130+
.\benchmark\${{matrix.build_type}}\ubench.exe

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ if(UMF_BUILD_TESTS)
123123
endif()
124124

125125
if(UMF_BUILD_BENCHMARKS)
126-
if(LINUX)
126+
if(LINUX OR WINDOWS)
127127
add_subdirectory(benchmark)
128128
else()
129-
message(FATAL_ERROR "benchmarks are supported on Linux only")
129+
message(FATAL_ERROR "benchmarks are supported on Linux and Windows only")
130130
endif()
131131
endif()
132132

benchmark/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,29 @@ endif()
2222

2323
add_executable(ubench ubench.c)
2424

25+
if(LINUX)
26+
set(LIBS_LINUX m)
27+
endif()
28+
2529
add_dependencies(ubench
2630
umf
2731
${LIBS_OPTIONAL})
2832

29-
target_include_directories(ubench PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include/)
33+
target_include_directories(ubench PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include/ ${UMF_CMAKE_SOURCE_DIR}/src/utils/)
3034

3135
target_link_libraries(ubench
3236
umf
3337
${LIBS_OPTIONAL}
3438
${CMAKE_THREAD_LIBS_INIT}
35-
m)
39+
${LIBS_LINUX})
3640

3741
if (UMF_BUILD_BENCHMARKS_MT)
3842
add_executable(multithread_bench multithread.cpp)
3943
target_link_libraries(multithread_bench
4044
umf
4145
${LIBS_OPTIONAL}
4246
pthread
43-
m)
47+
${LIBS_LINUX})
4448
target_include_directories(multithread_bench PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include/)
4549
endif()
4650

benchmark/ubench.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@
2424
#endif
2525

2626
#include <stdbool.h>
27+
28+
#ifndef _WIN32
2729
#include <unistd.h>
30+
#endif
2831

2932
#include "ubench.h"
33+
#include "utils_common.h"
3034

3135
// BENCHMARK CONFIG
3236
#define N_ITERATIONS 1000
33-
#define ALLOC_SIZE (getpagesize())
37+
#define ALLOC_SIZE (util_get_page_size())
3438

3539
// OS MEMORY PROVIDER CONFIG
3640
#define OS_MEMORY_PROVIDER_TRACE (0)
@@ -65,7 +69,7 @@ static void do_benchmark(alloc_t *array, size_t iters, malloc_t malloc_f,
6569
}
6670

6771
static alloc_t *alloc_array(size_t iters) {
68-
Alloc_size = ALLOC_SIZE;
72+
Alloc_size = (int)ALLOC_SIZE;
6973
alloc_t *array = malloc(iters * sizeof(alloc_t));
7074
if (array == NULL) {
7175
perror("malloc() failed");
@@ -223,7 +227,7 @@ UBENCH_EX(simple, disjoint_pool_with_os_memory_provider) {
223227
exit(-1);
224228
}
225229

226-
umf_disjoint_pool_params_t disjoint_memory_pool_params = {};
230+
umf_disjoint_pool_params_t disjoint_memory_pool_params = {0};
227231
disjoint_memory_pool_params.SlabMinSize = DISJOINT_POOL_SLAB_MIN_SIZE;
228232
disjoint_memory_pool_params.MaxPoolableSize =
229233
DISJOINT_POOL_MAX_POOLABLE_SIZE;

0 commit comments

Comments
 (0)