help find the optimum.
log "Decided to benchmark sorting of $SIZE byte data"
# Which bit widths we try
-WIDTHS="6 7 8 9 10 11 12 13 14"
+WIDTHS="0 6 7 8 9 10 11 12 13 14"
+
+# Which RadixThresholds we try
+THRS="100 500 1000 2500 5000"
# Which sort-test tests we try
TESTS="2,5,8,15"
# Check various bit widths of the radix sorter
rm -f tmp/radix-*
for W in $WIDTHS ; do
- log "Compiling with $W-bit radix splits"
rm -f $BUILD/obj/lib/sorter/sort-test{,.o}
- ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
- log "Running the tests"
- $BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v 2>&1 | tee tmp/radix-$W
+ if [ $W = 0 ] ; then
+ log "Compiling with no radix splits"
+ ( cd $BUILD && make obj/lib/sorter/sort-test )
+ OPT="-d32"
+ else
+ log "Compiling with $W-bit radix splits"
+ ( cd $BUILD && make CEXTRA="-DFORCE_RADIX_BITS=$W" obj/lib/sorter/sort-test )
+ OPT=
+ fi
+ for THR in $THRS ; do
+ log "Testing with RadixThreshold=$THR"
+ $BUILD/obj/lib/sorter/sort-test -SSorter.RadixThreshold=$THR -s$SIZE -t$TESTS $OPT -v 2>&1 | tee -a tmp/radix-$W
+ done
done
-log "Trying with radix-sort switched off"
-$BUILD/obj/lib/sorter/sort-test -s$SIZE -t$TESTS -v -d32 2>&1 | tee tmp/radix-0
+echo "thresh" >tmp/radix-thrs
+echo "test#" >tmp/radix-tests
+for THR in $THRS ; do
+ for TEST in `echo $TESTS | tr ',' ' '` ; do
+ echo $THR >>tmp/radix-thrs
+ echo $TEST >>tmp/radix-tests
+ done
+done
-FILES=""
-for W in 0 $WIDTHS ; do
+FILES="tmp/radix-thrs tmp/radix-tests"
+for W in $WIDTHS ; do
a=tmp/radix-$W
echo >$a.out "$W bits"
sed 's/.* \([0-9.]\+\)s internal sorting.*/\1/;t;d' <$a >>$a.out
done
log "These are the results:"
-echo "test#,$TESTS" | tr , '\n' >tmp/radix-tests
-paste tmp/radix-tests $FILES
+paste $FILES
#include <string.h>
#include <alloca.h>
-#define ASORT_MIN_RADIX 5000 // FIXME: var?
#define ASORT_MIN_SHIFT 2
static void
for (uns i=0; i<buckets; i++)
{
uns n = cnt[i] - pos;
- if (n < ASORT_MIN_RADIX || shift < ASORT_MIN_SHIFT)
+ if (n < sorter_radix_threshold || shift < ASORT_MIN_SHIFT)
{
ctx->quicksort(buffer, n);
if (!swapped_output)
struct rs_work *w = (struct rs_work *) ww;
DBG("Thread %d: Finishing %d items, shift=%d", thr->id, w->num_elts, w->shift);
- if (w->shift < ASORT_MIN_SHIFT || w->num_elts < ASORT_MIN_RADIX)
+ if (w->shift < ASORT_MIN_SHIFT || w->num_elts < sorter_radix_threshold)
{
w->ctx->quicksort(w->in, w->num_elts);
if (w->swap_output)
ctx->num_elts * ctx->elt_size >= sorter_thread_threshold &&
!(sorter_debug & SORT_DEBUG_ASORT_NO_THREADS));
- if (ctx->num_elts < ASORT_MIN_RADIX ||
+ if (ctx->num_elts < sorter_radix_threshold ||
ctx->hash_bits <= ASORT_MIN_SHIFT ||
!ctx->radix_split ||
(sorter_debug & SORT_DEBUG_ASORT_NO_RADIX))
extern uns sorter_trace, sorter_stream_bufsize;
extern uns sorter_debug, sorter_min_radix_bits, sorter_max_radix_bits;
extern uns sorter_min_multiway_bits, sorter_max_multiway_bits;
-extern uns sorter_threads, sorter_thread_threshold;
+extern uns sorter_threads, sorter_thread_threshold, sorter_radix_threshold;
extern u64 sorter_bufsize;
extern struct fb_params sorter_fb_params;
uns sorter_max_multiway_bits;
uns sorter_threads;
uns sorter_thread_threshold;
+uns sorter_radix_threshold = 4096;
struct fb_params sorter_fb_params;
static struct cf_section sorter_config = {
CF_UNS("MaxMultiwayBits", &sorter_max_multiway_bits),
CF_UNS("Threads", &sorter_threads),
CF_UNS("ThreadThreshold", &sorter_thread_threshold),
+ CF_UNS("RadixThreshold", &sorter_radix_threshold),
CF_END
}
};