23 |
|
|
24 |
|
/** for time conversion */ |
25 |
|
static final long NPS = (1000L * 1000 * 1000); |
26 |
< |
|
26 |
> |
|
27 |
|
public static void main(String[] args) throws Exception { |
28 |
|
int procs = 0; |
29 |
|
try { |
35 |
|
return; |
36 |
|
} |
37 |
|
for (int reps = 0; reps < 2; ++reps) { |
38 |
< |
ForkJoinPool g = procs == 0? new ForkJoinPool() : |
38 |
> |
ForkJoinPool g = procs == 0? new ForkJoinPool() : |
39 |
|
new ForkJoinPool(procs); |
40 |
|
lastStealCount = g.getStealCount(); |
41 |
|
for (int i = FIRST_SIZE; i <= LAST_SIZE; i++) |
42 |
|
test(g, i); |
43 |
|
System.out.println(g); |
44 |
< |
g.shutdown(); |
44 |
> |
g.shutdown(); |
45 |
|
} |
46 |
|
} |
47 |
|
|
63 |
|
lastStealCount = sc; |
64 |
|
System.out.printf(" Steals/t: %5d", ns/ps); |
65 |
|
System.out.println(); |
66 |
< |
} |
66 |
> |
} |
67 |
|
|
68 |
< |
// Boards are represented as arrays where each cell |
68 |
> |
// Boards are represented as arrays where each cell |
69 |
|
// holds the column number of the queen in that row |
70 |
|
|
71 |
|
final int[] sofar; |
72 |
|
NQueensCS nextSubtask; // to link subtasks |
73 |
|
int solutions; |
74 |
< |
NQueensCS(int[] a) { |
75 |
< |
this.sofar = a; |
74 |
> |
NQueensCS(int[] a) { |
75 |
> |
this.sofar = a; |
76 |
|
} |
77 |
|
|
78 |
|
public final void compute() { |
108 |
|
|
109 |
|
private static int processSubtasks(NQueensCS s) { |
110 |
|
// Always run first the task held instead of forked |
111 |
< |
s.compute(); |
111 |
> |
s.compute(); |
112 |
|
int ns = s.solutions; |
113 |
|
s = s.nextSubtask; |
114 |
|
// Then the unstolen ones |