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.1 by dl, Fri Oct 23 19:57:06 2009 UTC vs.
Revision 1.4 by jsr166, Tue Nov 3 01:04:02 2009 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? new ForkJoinPool() :
38 >            ForkJoinPool g = (procs == 0) ?
39 >                new ForkJoinPool() :
40                  new ForkJoinPool(procs);
41              lastStealCount = g.getStealCount();
42              for (int i = FIRST_SIZE; i <= LAST_SIZE; i++)
43                  test(g, i);
44              System.out.println(g);
45 <            g.shutdown();    
45 >            g.shutdown();
46          }
47      }
48  
# Line 53 | Line 54 | public final class NQueensCS extends Rec
54          g.invoke(task);
55          int solutions = task.solutions;
56          long time = System.nanoTime() - start;
57 <        double secs = ((double)time) / NPS;
57 >        double secs = (double) time / NPS;
58          if (solutions != expectedSolutions[i])
59              throw new Error();
60          System.out.printf("NQueensCS %3d", i);
# Line 63 | Line 64 | public final class NQueensCS extends Rec
64          lastStealCount = sc;
65          System.out.printf(" Steals/t: %5d", ns/ps);
66          System.out.println();
67 <    }            
67 >    }
68  
69 <    // Boards are represented as arrays where each cell
69 >    // Boards are represented as arrays where each cell
70      // holds the column number of the queen in that row
71  
72      final int[] sofar;
73      NQueensCS nextSubtask; // to link subtasks
74      int solutions;
75 <    NQueensCS(int[] a) {
76 <        this.sofar = a;  
75 >    NQueensCS(int[] a) {
76 >        this.sofar = a;
77      }
78  
79      public final void compute() {
# Line 108 | Line 109 | public final class NQueensCS extends Rec
109  
110      private static int processSubtasks(NQueensCS s) {
111          // Always run first the task held instead of forked
112 <        s.compute();
112 >        s.compute();
113          int ns = s.solutions;
114          s = s.nextSubtask;
115          // Then the unstolen ones

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines