ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/NQueensCS.java
(Generate patch)

Comparing jsr166/src/test/loops/NQueensCS.java (file contents):
Revision 1.4 by jsr166, Tue Nov 3 01:04:02 2009 UTC vs.
Revision 1.5 by dl, Sun Sep 19 12:55:37 2010 UTC

# Line 23 | Line 23 | public final class NQueensCS extends Rec
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 {
# Line 35 | Line 35 | public final class NQueensCS extends Rec
35              return;
36          }
37          for (int reps = 0; reps < 2; ++reps) {
38 <            ForkJoinPool g = (procs == 0) ?
39 <                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  
# Line 54 | Line 53 | public final class NQueensCS extends Rec
53          g.invoke(task);
54          int solutions = task.solutions;
55          long time = System.nanoTime() - start;
56 <        double secs = (double) time / NPS;
56 >        double secs = ((double)time) / NPS;
57          if (solutions != expectedSolutions[i])
58              throw new Error();
59          System.out.printf("NQueensCS %3d", i);
# Line 64 | Line 63 | public final class NQueensCS extends Rec
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() {
# Line 109 | Line 108 | public final class NQueensCS extends Rec
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines