|
| 1 | +add_versioned_package("gh:boost-ext/mph#v1.0.8") |
| 2 | +add_versioned_package("gh:serge-sans-paille/frozen#292a811") |
| 3 | + |
| 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 |
| 22 | + std_map |
| 23 | + std_unordered_map |
| 24 | + frozen_map |
| 25 | + frozen_unordered_map |
| 26 | + pseudo_pext_direct |
| 27 | + pseudo_pext_indirect_1 |
| 28 | + pseudo_pext_indirect_2 |
| 29 | + pseudo_pext_indirect_3 |
| 30 | + pseudo_pext_indirect_4 |
| 31 | + pseudo_pext_indirect_5 |
| 32 | + pseudo_pext_indirect_6) |
| 33 | + |
| 34 | +set(EXCLUDED_COMBINATIONS |
| 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) |
| 61 | + |
| 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) |
| 81 | + continue() |
| 82 | + endif() |
| 83 | + |
| 84 | + set(name "${ALG_NAME}_${DATASET}_bench") |
| 85 | + add_benchmark( |
| 86 | + ${name} |
| 87 | + NANO |
| 88 | + FILES |
| 89 | + pseudo_pext.cpp |
| 90 | + SYSTEM_LIBRARIES |
| 91 | + cib_lookup |
| 92 | + mph |
| 93 | + frozen-headers) |
| 94 | + target_compile_options(${name} PRIVATE -fconstexpr-steps=4000000000 |
| 95 | + --include=${HEADER}) |
| 96 | + target_compile_definitions( |
| 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}) |
| 112 | + endforeach() |
| 113 | +endforeach() |
0 commit comments