Skip to content

Commit 866d57c

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

File tree

4 files changed

+83
-8
lines changed

4 files changed

+83
-8
lines changed

.github/workflows/benchmarks.yml

Lines changed: 67 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,69 @@ 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+
os: ['windows-2022']
81+
build_type: [Release]
82+
compiler: [{c: cl, cxx: cl}]
83+
shared_library: ['ON', 'OFF']
84+
runs-on: ${{matrix.os}}
85+
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
89+
90+
- uses: lukka/get-cmake@latest
91+
with:
92+
cmakeVersion: 3.22.6
93+
94+
- name: Initialize vcpkg
95+
uses: lukka/[email protected]
96+
with:
97+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
98+
vcpkgDirectory: ${{ github.workspace }}/build/vcpkg
99+
vcpkgConfigurationJsonGlob: '**/vcpkg-configuration.json'
100+
101+
- name: Install dependencies
102+
run: vcpkg install
103+
shell: pwsh # Specifies PowerShell as the shell for running the script.
104+
105+
- name: Configure build
106+
run: >
107+
cmake
108+
-B ${{env.BUILD_DIR}}
109+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
110+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
111+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
112+
-DCMAKE_PREFIX_PATH=${{env.HWLOC_PATH}}
113+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
114+
-DUMF_BUILD_BENCHMARKS=ON
115+
-DUMF_BUILD_BENCHMARKS_MT=OFF
116+
-DUMF_BUILD_TESTS=OFF
117+
-DUMF_FORMAT_CODE_STYLE=OFF
118+
-DUMF_DEVELOPER_MODE=OFF
119+
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON
120+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
121+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
122+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
123+
-DUMF_ENABLE_POOL_TRACKING=OFF
124+
125+
- name: Build UMF
126+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $Env:NUMBER_OF_PROCESSORS
127+
128+
- name: Run benchmarks
129+
working-directory: ${{env.BUILD_DIR}}
130+
shell: pwsh # Specifies PowerShell as the shell for running the script.
131+
run: |
132+
# add path to umf.dll
133+
$env:PATH += ";${{env.BUILD_DIR}}\bin\${{matrix.build_type}}"
134+
# add path to hwloc-15.dll
135+
$env:PATH += ";${{env.HWLOC_PATH}}\bin"
136+
.\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)