2 # An utility for tuning the Sherlock's radix sorter
3 # (c) 2007 Martin Mares <mj@ucw.cz>
8 # Path to Sherlock build directory
9 [ -n "$BUILD" ] || BUILD=..
10 [ -f "$BUILD/lib/sorter/sorter.h" ] || die "BUILD does not point to Sherlock build directory"
12 # Find out sort buffer size
13 parse-config 'Sorter{##SortBuffer}'
14 SORTBUF=$CF_Sorter_SortBuffer
15 [ "$SORTBUF" -gt 0 ] || die "Unable to determine SortBuffer"
16 log "Detected sort buffer size $SORTBUF"
18 # Size of the test -- should be slightly less than a half of SortBuffer
19 SIZE=$(($SORTBUF/2 - 8192))
20 log "Decided to benchmark sorting of $SIZE byte data"
22 # Which bit widths we try
23 WIDTHS="6 7 8 9 10 11 12 13 14"
25 # Which sort-test tests we try
28 # Check various bit widths of the radix sorter
31 log "Compiling with $W-bit radix splits"
32 rm -f $BUILD/obj/lib/sorter/sort-test{,.o}
33 ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
34 log "Running the tests"
35 $BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v 2>&1 | tee tmp/radix-$W
38 log "Trying with radix-sort switched off"
39 $BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v -d32 2>&1 | tee tmp/radix-0
42 for W in 0 $WIDTHS ; do
44 echo >$a.out "$W bits"
45 sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
49 log "These are the results:"
50 echo "test#,$TESTS" | tr , '\n' >tmp/radix-tests
51 paste tmp/radix-tests $FILES