Skip to content

Commit 2f19836

Browse files
committed
add script to compare perf. of different x86 level
1 parent 90e0420 commit 2f19836

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
build
2-
build_debug
3-
build_script
1+
build*
42
.gdb_history
53
outputs
64
tags
75
compile_commands.json
86
.cache
7+
perf.data*
98
*.log
109
**/__pycache__

CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,21 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
1111
endif()
1212

1313
include(CheckCXXCompilerFlag)
14-
unset(SIMPLE_FAST_FLOAT_BENCHMARK_COMPILER_SUPPORTS_MARCH_NATIVE CACHE)
15-
CHECK_CXX_COMPILER_FLAG(-march=native SIMPLE_FAST_FLOAT_BENCHMARK_COMPILER_SUPPORTS_MARCH_NATIVE)
16-
if(SIMPLE_FAST_FLOAT_BENCHMARK_COMPILER_SUPPORTS_MARCH_NATIVE)
17-
add_compile_options(-march=native)
14+
set(SIMPLE_FAST_FLOAT_BENCHMARK_MARCH "" CACHE STRING
15+
"Set -march value for benchmarks (e.g. native, x86-64-v4, etc)")
16+
17+
if(NOT SIMPLE_FAST_FLOAT_BENCHMARK_MARCH)
18+
set(_SFF_MARCH_FLAG "-march=native")
19+
else()
20+
set(_SFF_MARCH_FLAG "-march=${SIMPLE_FAST_FLOAT_BENCHMARK_MARCH}")
21+
endif()
22+
23+
CHECK_CXX_COMPILER_FLAG(${_SFF_MARCH_FLAG} _SFF_MARCH_SUPPORTED)
24+
if(_SFF_MARCH_SUPPORTED)
25+
add_compile_options(${_SFF_MARCH_FLAG})
26+
message(STATUS "Compiling with ${_SFF_MARCH_FLAG}")
1827
else()
19-
message(STATUS "native target not supported")
28+
message(STATUS "${_SFF_MARCH_FLAG} not supported, proceeding without -march flag.")
2029
endif()
2130

2231
if (NOT CMAKE_BUILD_TYPE AND NOT SANITIZE)

scripts/test_x86_levels.bash

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
CPU=$1
4+
OutputDir="outputs/${CPU}"
5+
Algorithms="schubfach,dragonbox"
6+
7+
if [ -z "$1" ]; then
8+
echo "Usage: $0 <CPU>"
9+
exit 1
10+
fi
11+
12+
mkdir -p ${OutputDir}
13+
for v in x86-64 x86-64-v2 x86-64-v3 x86-64-v4 native; do
14+
cmake -B build-${v} -DSIMPLE_FAST_FLOAT_BENCHMARK_MARCH=${v}
15+
cmake --build build-${v}
16+
17+
echo "Running benchmarks for ${v} on ${CPU}..."
18+
./build-${v}/benchmarks/benchmark -f data/canada.txt -a ${Algorithms} > ${OutputDir}/${CPU}_g++_canada_none_${v}.raw
19+
./build-${v}/benchmarks/benchmark -f data/mesh.txt -a ${Algorithms} > ${OutputDir}/${CPU}_g++_mesh_none_${v}.raw
20+
./build-${v}/benchmarks/benchmark -a ${Algorithms} > ${OutputDir}/${CPU}_g++_uniform_01_none_${v}.raw
21+
done
22+
23+
for f in ${OutputDir}/*.raw; do
24+
python3 scripts/latex_table.py "$f" > "${f%.raw}.tex"
25+
echo "Converted $f to ${f%.raw}.tex"
26+
done

0 commit comments

Comments
 (0)