]> mj.ucw.cz Git - libucw.git/blob - debug/sorter/radix-tune-bits.sh
d0f02cc56b98e20a3f47f91de0ae4c94db00a644
[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="0 6 7 8 9 10 11 12 13 14"
24
25 # Which RadixThresholds we try
26 THRS="2000 4000 10000 20000 50000"
27
28 # Which sort-test tests we try
29 TESTS="2,5,8,15"
30
31 # Check various bit widths of the radix sorter
32 rm -f tmp/radix-*
33 for W in $WIDTHS ; do
34         rm -f $BUILD/obj/lib/sorter/sort-test{,.o}
35         if [ $W = 0 ] ; then
36                 log "Compiling with no radix splits"
37                 ( cd $BUILD && make obj/lib/sorter/sort-test )
38                 OPT="-d32"
39         else
40                 log "Compiling with $W-bit radix splits"
41                 ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
42                 OPT=
43         fi
44         for THR in $THRS ; do
45                 log "Testing with RadixThreshold=$THR"
46                 $BUILD/obj/lib/sorter/sort-test -SSorter.RadixThreshold=$THR -s$SIZE -t$TESTS $OPT -v 2>&1 | tee -a tmp/radix-$W
47         done
48 done
49
50 echo "thresh" >tmp/radix-thrs
51 echo "test#" >tmp/radix-tests
52 for THR in $THRS ; do
53         for TEST in `echo $TESTS | tr ',' ' '` ; do
54                 echo $THR >>tmp/radix-thrs
55                 echo $TEST >>tmp/radix-tests
56         done
57 done
58
59 FILES="tmp/radix-thrs tmp/radix-tests"
60 for W in $WIDTHS ; do
61         a=tmp/radix-$W
62         echo >$a.out "$W bits"
63         sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
64         FILES="$FILES $a.out"
65 done
66
67 log "These are the results:"
68 paste $FILES