Skip to content

Commit c834c04

Browse files
committed
🎨 Generate lookup benchmark data
1 parent 3059995 commit c834c04

File tree

4 files changed

+148
-50305
lines changed

4 files changed

+148
-50305
lines changed

benchmark/lookup/CMakeLists.txt

Lines changed: 81 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
add_versioned_package("gh:boost-ext/mph#v1.0.8")
22
add_versioned_package("gh:serge-sans-paille/frozen#292a811")
33

4-
# Define the variable values
5-
set(BENCH_ALG_NAMES
4+
function(gen_lookup_data)
5+
set(oneValueArgs TARGET TYPE SIZE OUTPUT)
6+
cmake_parse_arguments(GEN "" "${oneValueArgs}" "" ${ARGN})
7+
8+
set(script "${CMAKE_SOURCE_DIR}/tools/benchmark/gen_map_data.py")
9+
get_filename_component(DIR "${GEN_OUTPUT}" DIRECTORY)
10+
11+
add_custom_command(
12+
OUTPUT ${GEN_OUTPUT}
13+
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIR}"
14+
COMMAND ${Python3_EXECUTABLE} ${script} --type ${GEN_TYPE} --size
15+
${GEN_SIZE} --output ${GEN_OUTPUT}
16+
DEPENDS ${script}
17+
COMMAND_EXPAND_LISTS)
18+
add_custom_target(${GEN_TARGET} DEPENDS ${GEN_OUTPUT})
19+
endfunction()
20+
21+
set(ALG_NAMES
622
std_map
723
std_unordered_map
824
frozen_map
@@ -15,54 +31,57 @@ set(BENCH_ALG_NAMES
1531
pseudo_pext_indirect_5
1632
pseudo_pext_indirect_6)
1733

18-
foreach(type IN ITEMS uint16 uint32)
19-
foreach(i RANGE 1 10)
20-
list(APPEND BENCH_DATASETS exp_${i}_${type})
21-
endforeach()
22-
foreach(i RANGE 20 100 10)
23-
list(APPEND BENCH_DATASETS exp_${i}_${type})
24-
endforeach()
25-
foreach(i RANGE 200 1000 100)
26-
list(APPEND BENCH_DATASETS exp_${i}_${type})
27-
endforeach()
28-
endforeach()
29-
3034
set(EXCLUDED_COMBINATIONS
31-
mph_pext_exp_70_uint32
32-
mph_pext_exp_80_uint32
33-
mph_pext_exp_90_uint32
34-
mph_pext_exp_100_uint32
35-
mph_pext_exp_200_uint32
36-
mph_pext_exp_300_uint32
37-
mph_pext_exp_400_uint32
38-
mph_pext_exp_500_uint32
39-
mph_pext_exp_600_uint32
40-
mph_pext_exp_700_uint32
41-
mph_pext_exp_800_uint32
42-
mph_pext_exp_900_uint32
43-
mph_pext_exp_1000_uint32
44-
mph_pext_exp_70_uint16
45-
mph_pext_exp_80_uint16
46-
mph_pext_exp_90_uint16
47-
mph_pext_exp_100_uint16
48-
mph_pext_exp_200_uint16
49-
mph_pext_exp_300_uint16
50-
mph_pext_exp_400_uint16
51-
mph_pext_exp_500_uint16
52-
mph_pext_exp_600_uint16
53-
mph_pext_exp_700_uint16
54-
mph_pext_exp_800_uint16
55-
mph_pext_exp_900_uint16
56-
mph_pext_exp_1000_uint16)
35+
mph_pext_exp_uint32_70
36+
mph_pext_exp_uint32_80
37+
mph_pext_exp_uint32_90
38+
mph_pext_exp_uint32_100
39+
mph_pext_exp_uint32_200
40+
mph_pext_exp_uint32_300
41+
mph_pext_exp_uint32_400
42+
mph_pext_exp_uint32_500
43+
mph_pext_exp_uint32_600
44+
mph_pext_exp_uint32_700
45+
mph_pext_exp_uint32_800
46+
mph_pext_exp_uint32_900
47+
mph_pext_exp_uint32_1000
48+
mph_pext_exp_uint16_70
49+
mph_pext_exp_uint16_80
50+
mph_pext_exp_uint16_90
51+
mph_pext_exp_uint16_100
52+
mph_pext_exp_uint16_200
53+
mph_pext_exp_uint16_300
54+
mph_pext_exp_uint16_400
55+
mph_pext_exp_uint16_500
56+
mph_pext_exp_uint16_600
57+
mph_pext_exp_uint16_700
58+
mph_pext_exp_uint16_800
59+
mph_pext_exp_uint16_900
60+
mph_pext_exp_uint16_1000)
5761

58-
# Generate all possible combinations of the variables
59-
foreach(BENCH_ALG_NAME ${BENCH_ALG_NAMES})
60-
foreach(BENCH_DATASET ${BENCH_DATASETS})
61-
if("${BENCH_ALG_NAME}_${BENCH_DATASET}" IN_LIST EXCLUDED_COMBINATIONS)
62+
function(gen_pp_benchmarks)
63+
set(oneValueArgs TYPE SIZE)
64+
cmake_parse_arguments(BM "" "${oneValueArgs}" "" ${ARGN})
65+
66+
set(DATASET exp_${BM_TYPE}_${BM_SIZE})
67+
set(HEADER "${CMAKE_BINARY_DIR}/benchmark/generated/${DATASET}.hpp")
68+
set(DATA_TARGET "bm_lookup_data_${DATASET}")
69+
gen_lookup_data(
70+
TARGET
71+
${DATA_TARGET}
72+
TYPE
73+
${BM_TYPE}
74+
SIZE
75+
${BM_SIZE}
76+
OUTPUT
77+
${HEADER})
78+
79+
foreach(ALG_NAME ${ALG_NAMES})
80+
if("${ALG_NAME}_${DATASET}" IN_LIST EXCLUDED_COMBINATIONS)
6281
continue()
6382
endif()
64-
set(name "${BENCH_ALG_NAME}_${BENCH_DATASET}_bench")
6583

84+
set(name "${ALG_NAME}_${DATASET}_bench")
6685
add_benchmark(
6786
${name}
6887
NANO
@@ -72,10 +91,23 @@ foreach(BENCH_ALG_NAME ${BENCH_ALG_NAMES})
7291
cib_lookup
7392
mph
7493
frozen-headers)
75-
target_compile_options(${name} PRIVATE -fconstexpr-steps=4000000000)
94+
target_compile_options(${name} PRIVATE -fconstexpr-steps=4000000000
95+
--include=${HEADER})
7696
target_compile_definitions(
77-
${name}
78-
PRIVATE ALG_NAME=bench_${BENCH_ALG_NAME}
79-
BENCH_DATASET=${BENCH_DATASET} ANKERL_NANOBENCH_IMPLEMENT)
97+
${name} PRIVATE ALG_NAME=bench_${ALG_NAME} DATASET=${DATASET}
98+
ANKERL_NANOBENCH_IMPLEMENT)
99+
add_dependencies(${name} ${DATA_TARGET})
100+
endforeach()
101+
endfunction()
102+
103+
foreach(type IN ITEMS uint16 uint32)
104+
foreach(i RANGE 1 10)
105+
gen_pp_benchmarks(TYPE ${type} SIZE ${i})
106+
endforeach()
107+
foreach(i RANGE 20 100 10)
108+
gen_pp_benchmarks(TYPE ${type} SIZE ${i})
109+
endforeach()
110+
foreach(i RANGE 200 1000 100)
111+
gen_pp_benchmarks(TYPE ${type} SIZE ${i})
80112
endforeach()
81113
endforeach()

0 commit comments

Comments
 (0)