]> mj.ucw.cz Git - libucw.git/commitdiff
Redefined RadixThreshold to bound the array size instead of the number
authorMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 18:55:23 +0000 (20:55 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 10 Sep 2007 18:55:23 +0000 (20:55 +0200)
of elements -- the switching point seems to be related more to cache
effects than decision performance.

debug/sorter/radix-tune-bits.sh
lib/sorter/array.c

index 65098382f34e742682540810634989ec05e21860..d0f02cc56b98e20a3f47f91de0ae4c94db00a644 100644 (file)
@@ -23,7 +23,7 @@ log "Decided to benchmark sorting of $SIZE byte data"
 WIDTHS="0 6 7 8 9 10 11 12 13 14"
 
 # Which RadixThresholds we try
-THRS="100 500 1000 2500 5000"
+THRS="2000 4000 10000 20000 50000"
 
 # Which sort-test tests we try
 TESTS="2,5,8,15"
index efa314a8702c1fd01339c9467cc473b5c70d96f3..5bc60276d5046fc8fca71dd29dbd6f40f4e21258 100644 (file)
@@ -48,7 +48,7 @@ asort_radix(struct asort_context *ctx, void *array, void *buffer, uns num_elts,
   for (uns i=0; i<buckets; i++)
     {
       uns n = cnt[i] - pos;
-      if (n < sorter_radix_threshold || shift < ASORT_MIN_SHIFT)
+      if (n * cts->elt_size < sorter_radix_threshold || shift < ASORT_MIN_SHIFT)
        {
          ctx->quicksort(buffer, n);
          if (!swapped_output)
@@ -216,7 +216,7 @@ rs_finish(struct worker_thread *thr UNUSED, struct work *ww)
 
   if (thr)
     DBG("Thread %d: Finishing %d items, shift=%d", thr->id, w->num_elts, w->shift);
-  if (w->shift < ASORT_MIN_SHIFT || w->num_elts < sorter_radix_threshold)
+  if (w->shift < ASORT_MIN_SHIFT || w->num_elts * ctx->elt_size < sorter_radix_threshold)
     {
       w->ctx->quicksort(w->in, w->num_elts);
       if (w->swap_output)
@@ -396,7 +396,7 @@ asort_run(struct asort_context *ctx)
                              ctx->num_elts * ctx->elt_size >= sorter_thread_threshold &&
                              !(sorter_debug & SORT_DEBUG_ASORT_NO_THREADS));
 
-  if (ctx->num_elts < sorter_radix_threshold ||
+  if (ctx->num_elts * ctx->elt_size < sorter_radix_threshold ||
       ctx->hash_bits <= ASORT_MIN_SHIFT ||
       !ctx->radix_split ||
       (sorter_debug & SORT_DEBUG_ASORT_NO_RADIX))