@@ -297,9 +297,6 @@ private static void parallelRadixSortImpl(
297297 }
298298 }
299299
300- int sourceStartIndex = sourceFromIndex ;
301- int targetStartIndex = targetFromIndex ;
302-
303300 BucketInserterThread [] bucketInserterThreads =
304301 new BucketInserterThread [spawnDegree ];
305302
@@ -310,16 +307,13 @@ private static void parallelRadixSortImpl(
310307 new BucketInserterThread (
311308 source ,
312309 target ,
313- sourceStartIndex ,
314- targetStartIndex ,
310+ sourceFromIndex ,
311+ targetFromIndex ,
315312 startIndexMap ,
316313 processedMaps [i ],
317314 subrangeLength ,
318315 recursionDepth );
319316
320- sourceStartIndex += subrangeLength ;
321- targetStartIndex += subrangeLength ;
322-
323317 bucketInserterThread .start ();
324318 bucketInserterThreads [i ] = bucketInserterThread ;
325319 }
@@ -328,8 +322,8 @@ private static void parallelRadixSortImpl(
328322 new BucketInserterThread (
329323 source ,
330324 target ,
331- sourceStartIndex ,
332- targetStartIndex ,
325+ sourceFromIndex ,
326+ targetFromIndex ,
333327 startIndexMap ,
334328 processedMaps [spawnDegree - 1 ],
335329 rangeLength - (spawnDegree - 1 ) * subrangeLength ,
@@ -444,7 +438,7 @@ private static void parallelRadixSortImpl(
444438 target ,
445439 source ,
446440 targetFromIndex + startIndexMap [bucketKey ],
447- sourceStartIndex + startIndexMap [bucketKey ],
441+ sourceFromIndex + startIndexMap [bucketKey ],
448442 globalBucketSizeMap [bucketKey ],
449443 recursionDepth + 1 ,
450444 threadCountMap [i ]);
@@ -458,7 +452,7 @@ private static void parallelRadixSortImpl(
458452 SorterThread [] sorterThreads = new SorterThread [spawnDegree - 1 ];
459453
460454 // Recur into deeper depth via multithreading:
461- for (int i = 0 ; i != sorterThreads . length ; i ++) {
455+ for (int i = 0 ; i != spawnDegree - 1 ; i ++) {
462456 SorterThread sorterThread =
463457 new SorterThread (
464458 arrayOfTaskArrays .get (i ));
@@ -824,9 +818,11 @@ public void run() {
824818 for (int i = sourceFromIndex ; i != sourceToIndex ; i ++) {
825819 int datum = source [i ];
826820 int bucketKey = getBucketIndex (datum , recursionDepth );
821+ int startIndex = startIndexMap [bucketKey ];
822+ int processedCount = processedMap [bucketKey ]++;
823+ int targetIndex = targetFromIndex + startIndex + processedCount ;
827824
828- target [targetFromIndex + startIndexMap [bucketKey ] +
829- processedMap [bucketKey ]++] = datum ;
825+ target [targetIndex ] = datum ;
830826 }
831827 }
832828 }
0 commit comments