<commit_before>include(BenchmarkMacros)

set(NO_AUTOVEC "-fno-tree-vectorize")
check_cxx_compiler_flag(${NO_AUTOVEC} check_compiler_flag_no_autovect_gcc)
if(NOT check_compiler_flag_no_autovect_gcc)
   set(NO_AUTOVEC "-no-vec")
   check_cxx_compiler_flag(${NO_AUTOVEC} check_compiler_flag_no_autovect_icc)
   if(NOT check_compiler_flag_no_autovect_icc)
      message(STATUS "Missing flag to disable autovectorization in the compiler")
      SET(NO_AUTOVEC)
   endif(NOT check_compiler_flag_no_autovect_icc)
endif(NOT check_compiler_flag_no_autovect_gcc)

find_file(HAVE_SYS_MMAN sys/mman.h)
if(HAVE_SYS_MMAN)
   set(USE_MLOCK_IN_BENCHMARKS TRUE CACHE BOOL "Use memlock to get more reliable results in the benchmarks.")
   if(NOT USE_MLOCK_IN_BENCHMARKS)
      add_definitions(-DVC_BENCHMARK_NO_MLOCK)
   endif(NOT USE_MLOCK_IN_BENCHMARKS)
else(HAVE_SYS_MMAN)
   add_definitions(-DVC_BENCHMARK_NO_MLOCK)
endif(HAVE_SYS_MMAN)
mark_as_advanced(HAVE_SYS_MMAN)

set(FAST_MATH_BENCHMARK FALSE CACHE BOOL "Use floating point math shortcuts. Might not be IEEE compliant!")
if(FAST_MATH_BENCHMARK)
   if(COMPILER_IS_GCC OR COMPILER_IS_OPEN64)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
   elseif(COMPILER_IS_INTEL)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model fast=2")
   elseif(COMPILER_IS_MSVC)
      message(WARNING "Missing flag for MSVC to implement fast-math")
   endif()
endif(FAST_MATH_BENCHMARK)

add_library(cpuset STATIC cpuset.c)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
   set(REALTIME_BENCHMARKS FALSE CACHE BOOL "Use SCHED_FIFO priority to give benchmarks highest priority, achieving less jitter in the results.")
   if(REALTIME_BENCHMARKS)
      add_executable(rtwrapper rtwrapper.cpp)
      add_definitions(-DSCHED_FIFO_BENCHMARKS)
      add_custom_command(TARGET rtwrapper POST_BUILD
         COMMAND sudo chown root rtwrapper
         COMMAND sudo chmod +s rtwrapper
         WORKING_DIRECTORY "${CMAKE_CURRENT_BUILD_DIR}"
         COMMENT "Making the rtwrapper suid root"
         )
   endif(REALTIME_BENCHMARKS)
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

vc_add_benchmark(arithmetics)
vc_add_benchmark(flops)
vc_add_benchmark(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS VC_SLOWDOWN_GATHER)
vc_add_benchmark(mask)
vc_add_benchmark(compare VC_DISABLE_PTEST)
vc_add_benchmark(math)
vc_add_benchmark(memio)
add_target_property(memio_scalar_benchmark COMPILE_FLAGS ${NO_AUTOVEC})
vc_add_benchmark(dhryrock)
vc_add_benchmark(whetrock)

add_executable(flops_autovect autoflops.cpp benchmark.cpp)
target_link_libraries(flops_autovect Vc ${LIBS} CpuId)
add_executable(flops_noautovect autoflops.cpp benchmark.cpp)
check_cxx_compiler_flag("-fno-tree-vectorize" check_compiler_flag_no_autovect_gcc)
add_target_property(flops_noautovect COMPILE_FLAGS ${NO_AUTOVEC})
target_link_libraries(flops_noautovect Vc ${LIBS} CpuId)

add_executable(sort_benchmark sort.cpp benchmark.cpp)
target_link_libraries(sort_benchmark Vc ${LIBS} CpuId)
add_target_property(sort_benchmark OUTPUT_NAME sort)
add_custom_target("run_sort_benchmark" sort_benchmark DEPENDS sort_benchmark COMMENT "Running sort")
add_target_property("run_sort_benchmark" EXCLUDE_FROM_DEFAULT_BUILD 1)
add_dependencies(benchmarks "run_sort_benchmark")

vc_generate_plots(arithmetics)
vc_generate_plots(flops)
vc_generate_plots(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS)
vc_generate_plots(mask)
vc_generate_plots(compare VC_DISABLE_PTEST)
vc_generate_plots(math)
vc_generate_plots(memio)

add_executable(constants constants.cpp benchmark.cpp)
target_link_libraries(constants Vc ${LIBS} CpuId)

if(QT4_FOUND)<commit_msg>the idea was to not use prefetching in the memio benchmark, so the compiler should not second guess our code<commit_after>include(BenchmarkMacros)

set(NO_AUTOVEC "-fno-tree-vectorize")
check_cxx_compiler_flag(${NO_AUTOVEC} check_compiler_flag_no_autovect_gcc)
if(NOT check_compiler_flag_no_autovect_gcc)
   set(NO_AUTOVEC "-no-vec")
   check_cxx_compiler_flag(${NO_AUTOVEC} check_compiler_flag_no_autovect_icc)
   if(NOT check_compiler_flag_no_autovect_icc)
      message(STATUS "Missing flag to disable autovectorization in the compiler")
      SET(NO_AUTOVEC)
   endif(NOT check_compiler_flag_no_autovect_icc)
endif(NOT check_compiler_flag_no_autovect_gcc)

set(NO_PREFETCH "-fno-prefetch-loop-arrays")
check_cxx_compiler_flag(${NO_PREFETCH} check_compiler_flag_no_prefetch_gcc)
if(NOT check_compiler_flag_no_prefetch_gcc)
   message(WARNING "Missing flag to disable prefetching")
   set(NO_PREFETCH "")
endif()

find_file(HAVE_SYS_MMAN sys/mman.h)
if(HAVE_SYS_MMAN)
   set(USE_MLOCK_IN_BENCHMARKS TRUE CACHE BOOL "Use memlock to get more reliable results in the benchmarks.")
   if(NOT USE_MLOCK_IN_BENCHMARKS)
      add_definitions(-DVC_BENCHMARK_NO_MLOCK)
   endif(NOT USE_MLOCK_IN_BENCHMARKS)
else(HAVE_SYS_MMAN)
   add_definitions(-DVC_BENCHMARK_NO_MLOCK)
endif(HAVE_SYS_MMAN)
mark_as_advanced(HAVE_SYS_MMAN)

set(FAST_MATH_BENCHMARK FALSE CACHE BOOL "Use floating point math shortcuts. Might not be IEEE compliant!")
if(FAST_MATH_BENCHMARK)
   if(COMPILER_IS_GCC OR COMPILER_IS_OPEN64)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
   elseif(COMPILER_IS_INTEL)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model fast=2")
   elseif(COMPILER_IS_MSVC)
      message(WARNING "Missing flag for MSVC to implement fast-math")
   endif()
endif(FAST_MATH_BENCHMARK)

add_library(cpuset STATIC cpuset.c)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
   set(REALTIME_BENCHMARKS FALSE CACHE BOOL "Use SCHED_FIFO priority to give benchmarks highest priority, achieving less jitter in the results.")
   if(REALTIME_BENCHMARKS)
      add_executable(rtwrapper rtwrapper.cpp)
      add_definitions(-DSCHED_FIFO_BENCHMARKS)
      add_custom_command(TARGET rtwrapper POST_BUILD
         COMMAND sudo chown root rtwrapper
         COMMAND sudo chmod +s rtwrapper
         WORKING_DIRECTORY "${CMAKE_CURRENT_BUILD_DIR}"
         COMMENT "Making the rtwrapper suid root"
         )
   endif(REALTIME_BENCHMARKS)
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

vc_add_benchmark(arithmetics)
vc_add_benchmark(flops)
vc_add_benchmark(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS VC_SLOWDOWN_GATHER)
vc_add_benchmark(mask)
vc_add_benchmark(compare VC_DISABLE_PTEST)
vc_add_benchmark(math)
vc_add_benchmark(memio)
add_target_property(memio_scalar_benchmark COMPILE_FLAGS "${NO_AUTOVEC} ${NO_PREFETCH}")
if(USE_SSE2)
   add_target_property(memio_sse_benchmark COMPILE_FLAGS ${NO_PREFETCH})
endif()
if(USE_AVX)
   add_target_property(memio_avx_benchmark COMPILE_FLAGS ${NO_PREFETCH})
endif()
vc_add_benchmark(dhryrock)
vc_add_benchmark(whetrock)

add_executable(flops_autovect autoflops.cpp benchmark.cpp)
target_link_libraries(flops_autovect Vc ${LIBS} CpuId)
add_executable(flops_noautovect autoflops.cpp benchmark.cpp)
check_cxx_compiler_flag("-fno-tree-vectorize" check_compiler_flag_no_autovect_gcc)
add_target_property(flops_noautovect COMPILE_FLAGS ${NO_AUTOVEC})
target_link_libraries(flops_noautovect Vc ${LIBS} CpuId)

add_executable(sort_benchmark sort.cpp benchmark.cpp)
target_link_libraries(sort_benchmark Vc ${LIBS} CpuId)
add_target_property(sort_benchmark OUTPUT_NAME sort)
add_custom_target("run_sort_benchmark" sort_benchmark DEPENDS sort_benchmark COMMENT "Running sort")
add_target_property("run_sort_benchmark" EXCLUDE_FROM_DEFAULT_BUILD 1)
add_dependencies(benchmarks "run_sort_benchmark")

vc_generate_plots(arithmetics)
vc_generate_plots(flops)
vc_generate_plots(gather VC_NO_BSF_LOOPS VC_NO_GATHER_TRICKS)
vc_generate_plots(mask)
vc_generate_plots(compare VC_DISABLE_PTEST)
vc_generate_plots(math)
vc_generate_plots(memio)

add_executable(constants constants.cpp benchmark.cpp)
target_link_libraries(constants Vc ${LIBS} CpuId)

if(QT4_FOUND)
{'fraction_non_alphanumeric': 0.07106009801392829, 'fraction_numerical': 0.001418622646376064, 'mean_word_length': 7.903559127439724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5597459', 'n_tokens_mistral': 3072, 'n_tokens_neox': 2953, 'n_words': 479}