]> mj.ucw.cz Git - libucw.git/blob - ucw/sorter/debug/radix-tune-thresh.sh
Conf: Decoupled cf_stack_done() from committing
[libucw.git] / ucw / sorter / debug / radix-tune-thresh.sh
1 #!/bin/bash
2 # An utility for tuning the Sherlock's radix sorter threshold
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/ucw/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 # 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"
23
24 # Maximum size of the test -- should be slightly less than a half of SortBuffer
25 SIZE=$(($SORTBUF/2 - 8192))
26
27 # Which sort-test test we try
28 TEST="2"
29
30 # Which thresholds we try
31 THRS="16"
32 T=$SIZE
33 while [ $T -gt 100 ] ; do
34         THRS="$THRS $T"
35         T=$(($T/2))
36 done
37
38 if true ; then
39
40 rm -f tmp/radix-*
41 echo "sizes" >tmp/radix-sizes
42 while [ $SIZE -gt 262144 ] ; do
43         echo $SIZE >>tmp/radix-sizes
44         for T in $THRS ; do
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
47         done
48         SIZE=$(($SIZE/2))
49 done
50
51 fi
52
53 FILES=tmp/radix-sizes
54 for T in $THRS ; do
55         a=tmp/radix-$T
56         echo >$a.out $T
57         sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
58         FILES="$FILES $a.out"
59 done
60
61 log "These are the results:"
62 paste $FILES