]> mj.ucw.cz Git - libucw.git/blob - debug/sorter/radix-tune-bits.sh
Added a simple utility for tuning the radix-sorter width.
[libucw.git] / debug / sorter / radix-tune-bits.sh
1 #!/bin/bash
2 # An utility for tuning the Sherlock's radix sorter
3 # (c) 2007 Martin Mares <mj@ucw.cz>
4 set -e
5 UCW_PROGNAME="$0"
6 . lib/libucw.sh
7
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"
11
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"
17
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"
21
22 # Which bit widths we try
23 WIDTHS="6 7 8 9 10 11 12 13 14"
24
25 # Which sort-test tests we try
26 TESTS="2,5,8,15"
27
28 # Check various bit widths of the radix sorter
29 rm -f tmp/radix-*
30 for W in $WIDTHS ; do
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
36 done
37
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
40
41 FILES=""
42 for W in 0 $WIDTHS ; do
43         a=tmp/radix-$W
44         echo >$a.out "$W bits"
45         sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
46         FILES="$FILES $a.out"
47 done
48
49 log "These are the results:"
50 echo "test#,$TESTS" | tr , '\n' >tmp/radix-tests
51 paste tmp/radix-tests $FILES