]> mj.ucw.cz Git - libucw.git/commitdiff
Added a simple utility for tuning the radix-sorter width.
authorMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 15:18:02 +0000 (17:18 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 15:18:02 +0000 (17:18 +0200)
debug/sorter/Makefile
debug/sorter/radix-tune-bits.sh [new file with mode: 0644]

index 93fa99cc417bad609fdc8c67d923cfe43b86ed9c..6a871c64da9c6c4376f8be90d06ce6f7bf720288 100644 (file)
@@ -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 (file)
index 0000000..baab6df
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+# An utility for tuning the Sherlock's radix sorter
+# (c) 2007 Martin Mares <mj@ucw.cz>
+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