2 # An utility for tuning the Sherlock's radix sorter threshold
3 # (c) 2007 Martin Mares <mj@ucw.cz>
8 # Path to Sherlock build directory
9 [ -n "$BUILD" ] || BUILD=..
10 [ -f "$BUILD/ucw/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 # Find out radix-sorter width
19 [ -f "$BUILD/obj/config.mk" ] || die "Sherlock source not configured"
20 WIDTH=`sed <$BUILD/obj/config.mk 's/^CONFIG_UCW_RADIX_SORTER_BITS=\(.*\)/\1/;t;d'`
21 [ -n "$WIDTH" ] || die "CONFIG_UCW_RADIX_SORTER_BITS not set (!?)"
22 log "Detected radix-sorter width $WIDTH"
24 # Maximum size of the test -- should be slightly less than a half of SortBuffer
25 SIZE=$(($SORTBUF/2 - 8192))
27 # Which sort-test test we try
30 # Which thresholds we try
33 while [ $T -gt 100 ] ; do
41 echo "sizes" >tmp/radix-sizes
42 while [ $SIZE -gt 262144 ] ; do
43 echo $SIZE >>tmp/radix-sizes
45 log "Trying size $SIZE with threshold $T"
46 $BUILD/obj/ucw/sorter/sort-test -SSorter.RadixThreshold=$T -s$SIZE -t$TEST -v 2>&1 | tee -a tmp/radix-$T
57 sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
61 log "These are the results:"