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="0 6 7 8 9 10 11 12 13 14"
25 # Which RadixThresholds we try
26 THRS="2000 4000 10000 20000 50000"
28 # Which sort-test tests we try
31 # Check various bit widths of the radix sorter
34 rm -f $BUILD/obj/lib/sorter/sort-test{,.o}
36 log "Compiling with no radix splits"
37 ( cd $BUILD && make obj/lib/sorter/sort-test )
40 log "Compiling with $W-bit radix splits"
41 ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
45 log "Testing with RadixThreshold=$THR"
46 $BUILD/obj/lib/sorter/sort-test -SThreads.DefaultStackSize=2M -SSorter.RadixThreshold=$THR -s$SIZE -t$TESTS $OPT -v 2>&1 | tee -a tmp/radix-$W
50 echo "thresh" >tmp/radix-thrs
51 echo "test#" >tmp/radix-tests
53 for TEST in `echo $TESTS | tr ',' ' '` ; do
54 echo $THR >>tmp/radix-thrs
55 echo $TEST >>tmp/radix-tests
59 FILES="tmp/radix-thrs tmp/radix-tests"
62 echo >$a.out "$W bits"
63 sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
67 log "These are the results:"