10 |
|
class ScalarLongSort { |
11 |
|
static final long NPS = (1000L * 1000 * 1000); |
12 |
|
|
13 |
< |
static int THRESHOLD; |
13 |
> |
static int THRESHOLD = -1; |
14 |
|
static final boolean warmup = true; |
15 |
|
|
16 |
|
public static void main (String[] args) throws Exception { |
18 |
|
int n = 1 << 22; |
19 |
|
int reps = 20; |
20 |
|
int sreps = 2; |
21 |
+ |
int st = -1; |
22 |
|
try { |
23 |
|
if (args.length > 0) |
24 |
|
procs = Integer.parseInt(args[0]); |
25 |
|
if (args.length > 1) |
26 |
|
n = Integer.parseInt(args[1]); |
27 |
|
if (args.length > 2) |
28 |
< |
reps = Integer.parseInt(args[1]); |
28 |
> |
reps = Integer.parseInt(args[2]); |
29 |
> |
if (args.length > 3) |
30 |
> |
st = Integer.parseInt(args[3]); |
31 |
|
} |
32 |
|
catch (Exception e) { |
33 |
< |
System.out.println("Usage: java ScalarLongSort threads n reps"); |
33 |
> |
System.out.println("Usage: java ScalarLongSort threads n reps sequential-threshold"); |
34 |
|
return; |
35 |
|
} |
36 |
|
ForkJoinPool pool = (procs == 0) ? new ForkJoinPool() : |
49 |
|
checkSorted(a); |
50 |
|
} |
51 |
|
|
52 |
< |
// for now hardwire 8 * #CPUs leaf tasks |
53 |
< |
THRESHOLD = 1 + ((n + 7) >>> 3) / pool.getParallelism(); |
54 |
< |
// THRESHOLD = 1 + ((n + 15) >>> 4) / pool.getParallelism(); |
55 |
< |
// THRESHOLD = 1 + ((n + 31) >>> 5) / pool.getParallelism(); |
52 |
> |
if (st <= 0) // for now hardwire 8 * #CPUs leaf tasks |
53 |
> |
THRESHOLD = 1 + ((n + 7) >>> 3) / pool.getParallelism(); |
54 |
> |
else |
55 |
> |
THRESHOLD = st; |
56 |
|
|
57 |
|
System.out.printf("Sorting %d longs, %d replications\n", n, reps); |
58 |
|
for (int i = 0; i < reps; ++i) { |