-rwxr-xr-x 3668 sortbench-20240116/do raw
#!/bin/sh -e
top=`pwd`
rm -rf $top/stdsort
rm -rf $top/djbsort
rm -rf $top/fast-and-robust
rm -rf $top/vxsort-cpp
rm -rf $top/highway
rm -rf $top/x86-simd-sort
rm -rf $top/plot.pdf
echo '[1;34m===== stdsort (std::sort) [0m'
mkdir $top/stdsort
cd $top/stdsort
cp $top/bench-stdsort.cc .
clang -O3 -march=native -o bench-stdsort bench-stdsort.cc
./bench-stdsort > bench-stdsort.out
echo '[1;34m===== djbsort (https://sorting.cr.yp.to) [0m'
mkdir $top/djbsort
cd $top/djbsort
wget -m https://sorting.cr.yp.to/djbsort-latest-version.txt
version=$(cat sorting.cr.yp.to/djbsort-latest-version.txt)
wget -m https://sorting.cr.yp.to/djbsort-$version.tar.gz
tar -xzf sorting.cr.yp.to/djbsort-$version.tar.gz
cd djbsort-$version
ln -s $top/djbsort link-build
ln -s $top/djbsort link-install
./do
cd $top/djbsort
cp $top/bench-djbsort.c .
clang -O3 -march=native -o bench-djbsort bench-djbsort.c \
-I $top/djbsort/include -L $top/djbsort/lib \
-ldjbsort
env LD_LIBRARY_PATH=$top/djbsort/lib \
./bench-djbsort > bench-djbsort.out
echo '[1;34m===== far (https://github.com/simd-sorting/fast-and-robust) [0m'
cd $top
git clone https://github.com/simd-sorting/fast-and-robust
cd fast-and-robust
cp $top/bench-far.cc .
clang++ \
-no-pie -O3 -march=native \
-o bench-far bench-far.cc \
-I avx2_sort_demo
./bench-far > bench-far.out
echo '[1;34m===== vxsort (https://github.com/damageboy/vxsort-cpp) [0m'
cd $top
git clone https://github.com/damageboy/vxsort-cpp
cd vxsort-cpp
sed -i 's/^cmake_minimum_required(.*)$/cmake_minimum_required(VERSION 3.15)/' CMakeLists.txt
sed -i 's/include(ConfigGBench)/# include(ConfigGBench)/' CMakeLists.txt
sed -i 's/include(ConfigGTest)/# include(ConfigGTest)/' CMakeLists.txt
sed -i 's!add_subdirectory(${PROJECT_SOURCE_DIR}/bench/)!# add_subdirectory(${PROJECT_SOURCE_DIR}/bench/)!' CMakeLists.txt
sed -i 's!add_subdirectory(${PROJECT_SOURCE_DIR}/tests/)!# add_subdirectory(${PROJECT_SOURCE_DIR}/tests/)!' CMakeLists.txt
mkdir build-release
cd build-release
export CC=clang
export CXX=clang++
cmake ..
make -j 4
cd $top/vxsort-cpp
cp $top/bench-vxsort.cc .
clang++ -std=c++17 \
-no-pie -O3 -march=native \
-o bench-vxsort bench-vxsort.cc \
-I vxsort \
-I vxsort/vector_machine \
-I build-release/_deps/cpu_features-src/include \
-L build-release/vxsort \
-L build-release/_deps/cpu_features-build \
-lvxsort \
-lcpu_features
./bench-vxsort > bench-vxsort.out
echo '[1;34m===== vqsort (https://github.com/google/highway) [0m'
cd $top
git clone https://github.com/google/highway
cd highway
mkdir -p build && cd build
cmake ..
make -j 4
cd $top/highway
cp $top/bench-vqsort.cc .
clang++ -O3 -march=native -o bench-vqsort bench-vqsort.cc \
-I . -I build/googletest-src/googletest/include -L build -L build/lib \
-lhwy_contrib -lhwy -lgtest -pthread
./bench-vqsort > bench-vqsort.out
echo '[1;34m===== x86simdsort (https://github.com/intel/x86-simd-sort.git) [0m'
cd $top
git clone https://github.com/intel/x86-simd-sort.git
cd x86-simd-sort
meson setup --buildtype release builddir && cd builddir
meson compile
cd $top/x86-simd-sort
cp $top/bench-x86simdsort.cc .
clang++ -std=c++20 -O3 -march=native -o bench-x86simdsort bench-x86simdsort.cc \
-I lib -L builddir -L builddir/lib \
-lx86simdsortcpp
LD_LIBRARY_PATH=$top/x86-simd-sort/builddir ./bench-x86simdsort > bench-x86simdsort.out
echo '[1;34m===== create plot.pdf [0m'
cd $top
./plot \
stdsort black stdsort/bench-stdsort.out \
djbsort blue djbsort/bench-djbsort.out \
far magenta fast-and-robust/bench-far.out \
vxsort red vxsort-cpp/bench-vxsort.out \
vqsort green highway/bench-vqsort.out \
x86simdsort orange x86-simd-sort/bench-x86simdsort.out