11add_versioned_package("gh:boost-ext/mph#v1.0.8" )
22add_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,56 @@ 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-
3034set (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+ gen_lookup_data(
69+ TARGET
70+ bm_lookup_data_${DATASET}
71+ TYPE
72+ ${BM_TYPE}
73+ SIZE
74+ ${BM_SIZE}
75+ OUTPUT
76+ ${HEADER} )
77+
78+ foreach (ALG_NAME ${ALG_NAMES} )
79+ if ("${ALG_NAME} _${DATASET} " IN_LIST EXCLUDED_COMBINATIONS)
6280 continue ()
6381 endif ()
64- set (name "${BENCH_ALG_NAME} _${BENCH_DATASET} _bench" )
6582
83+ set (name "${ALG_NAME} _${DATASET} _bench" )
6684 add_benchmark(
6785 ${name}
6886 NANO
@@ -72,10 +90,23 @@ foreach(BENCH_ALG_NAME ${BENCH_ALG_NAMES})
7290 cib_lookup
7391 mph
7492 frozen-headers)
75- target_compile_options (${name} PRIVATE -fconstexpr-steps=4000000000)
93+ target_compile_options (${name} PRIVATE -fconstexpr-steps=4000000000
94+ --include =${HEADER} )
7695 target_compile_definitions (
77- ${name}
78- PRIVATE ALG_NAME=bench_${BENCH_ALG_NAME}
79- BENCH_DATASET=${BENCH_DATASET} ANKERL_NANOBENCH_IMPLEMENT)
96+ ${name} PRIVATE ALG_NAME=bench_${ALG_NAME} DATASET=${DATASET}
97+ ANKERL_NANOBENCH_IMPLEMENT)
98+ add_dependencies (${name} bm_lookup_data_${DATASET} )
99+ endforeach ()
100+ endfunction ()
101+
102+ foreach (type IN ITEMS uint16 uint32)
103+ foreach (i RANGE 1 10)
104+ gen_pp_benchmarks(TYPE ${type} SIZE ${i} )
105+ endforeach ()
106+ foreach (i RANGE 20 100 10)
107+ gen_pp_benchmarks(TYPE ${type} SIZE ${i} )
108+ endforeach ()
109+ foreach (i RANGE 200 1000 100)
110+ gen_pp_benchmarks(TYPE ${type} SIZE ${i} )
80111 endforeach ()
81112endforeach ()
0 commit comments