From 9fce06bcb110d9fab60e1491342bd3ed7f191c50 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 10 Sep 2007 17:18:02 +0200 Subject: [PATCH] Added a simple utility for tuning the radix-sorter width. --- debug/sorter/Makefile | 3 +- debug/sorter/radix-tune-bits.sh | 51 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 debug/sorter/radix-tune-bits.sh diff --git a/debug/sorter/Makefile b/debug/sorter/Makefile index 93fa99cc..6a871c64 100644 --- a/debug/sorter/Makefile +++ b/debug/sorter/Makefile @@ -1,8 +1,9 @@ # Tests related to the new sorter DIRS+=debug/sorter -PROGS+=$(addprefix $(o)/debug/sorter/,retros radix-file-test radix-asio-test) +PROGS+=$(addprefix $(o)/debug/sorter/,retros radix-file-test radix-asio-test radix-tune-bits) $(o)/debug/sorter/retros: $(o)/debug/sorter/retros.o $(LIBSH) $(o)/debug/sorter/radix-file-test: $(o)/debug/sorter/radix-file-test.o $(LIBSH) $(o)/debug/sorter/radix-asio-test: $(o)/debug/sorter/radix-asio-test.o $(LIBSH) +$(o)/debug/sorter/radix-tune-bits: $(s)/debug/sorter/radix-tune-bits.sh diff --git a/debug/sorter/radix-tune-bits.sh b/debug/sorter/radix-tune-bits.sh new file mode 100644 index 00000000..baab6df8 --- /dev/null +++ b/debug/sorter/radix-tune-bits.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# An utility for tuning the Sherlock's radix sorter +# (c) 2007 Martin Mares +set -e +UCW_PROGNAME="$0" +. lib/libucw.sh + +# Path to Sherlock build directory +[ -n "$BUILD" ] || BUILD=.. +[ -f "$BUILD/lib/sorter/sorter.h" ] || die "BUILD does not point to Sherlock build directory" + +# Find out sort buffer size +parse-config 'Sorter{##SortBuffer}' +SORTBUF=$CF_Sorter_SortBuffer +[ "$SORTBUF" -gt 0 ] || die "Unable to determine SortBuffer" +log "Detected sort buffer size $SORTBUF" + +# Size of the test -- should be slightly less than a half of SortBuffer +SIZE=$(($SORTBUF/2 - 8192)) +log "Decided to benchmark sorting of $SIZE byte data" + +# Which bit widths we try +WIDTHS="6 7 8 9 10 11 12 13 14" + +# Which sort-test tests we try +TESTS="2,5,8,15" + +# Check various bit widths of the radix sorter +rm -f tmp/radix-* +for W in $WIDTHS ; do + log "Compiling with $W-bit radix splits" + rm -f $BUILD/obj/lib/sorter/sort-test{,.o} + ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test ) + log "Running the tests" + $BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v 2>&1 | tee tmp/radix-$W +done + +log "Trying with radix-sort switched off" +$BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v -d32 2>&1 | tee tmp/radix-0 + +FILES="" +for W in 0 $WIDTHS ; do + a=tmp/radix-$W + echo >$a.out "$W bits" + sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out + FILES="$FILES $a.out" +done + +log "These are the results:" +echo "test#,$TESTS" | tr , '\n' >tmp/radix-tests +paste tmp/radix-tests $FILES -- 2.39.2