Commits

Hans-Nikolai Viessmann committed 4a07b17

Added some more comments

  • Participants
  • Parent commits fcaeae4

Comments (0)

Files changed (1)

File cw2/TotientRange.sac

 #pragma linksign [0,1]
 
 // Function exists already in form of `fmod', but seems slower... 
-inline double[] dmod(double[] a, double[] b)
+double[] dmod(double[] a, double[] b)
 {
     k = toi(a / b);
     s = a - tod(k) * b;
     return(s);
 }
 
-inline double[] hcf(double[] x, double[] y)
+double[] hcf(double[] x, double[] y)
 {
     while (y != 0d) {
         t = dmod(x, y);
     return(vec);
 }
 
-inline double[] sumTotient(int[] lower, int[] upper)
+double[] sumTotient(int[] lower, int[] upper)
 {
     count = 2;
     tmp = with {
-        // Seems to make little difference...
-        //#pragma wlcomp Ubv([5,5], [5,5], ConstSeg([0,0], [50,100], [50,0], [100,100], Default))
-        //#pragma wlcomp Scheduling(Affinity(), TaskSel(Even(0,5), ConstSeg([0,0], [50,100], [50,0], [100,100], Default)))
+        // Seems to make little difference...it is likely that these pragmas
+        // do not work currently...
+        //#pragma wlcomp Ubv([5,5],
+        //                   [5,5],
+        //                   ConstSeg([0,0], [50,100],
+        //                            [50,0], [100,100], Default))
+        //#pragma wlcomp Scheduling(Affinity(),
+        //                          TaskSel(Even(0,5), ConstSeg([0,0],
+        //                                  [50,100], [50,0], [100,100],
+        //                                  Default)))
         
         // This is the original solution that simply goes from the first
         // index to the last index.
         // This is the optimized version that uses pair-based computation,
         // which reduces the number of threads created and helps to more
         // evenly balance the computational load.
-        //([0] <= [i] <= [(upper - lower) / 2]) : euler(tod(i + lower)) + euler(tod(upper - i));
+        ([0] <= [i] <= [(upper - lower) / 2]) : euler(tod(i + lower))
+                                              + euler(tod(upper - i));
        
-        // Seems to provide about the same amount of speedup as the one above
-        ([0] <= [i] <= [(upper - lower) / 4]) : euler(tod(i + lower)) + euler(tod(upper - i)) + euler(tod(i + lower + 250)) + euler(tod(upper - 250 - i));
+        // Seems to provide about the same amount of speedup as the one above.
+        // However this is more experiemental, being that we have fixed the
+        // fourths to a range of 1 to 1000. This could be resolved by deviding
+        // (upper - lower) / 4, but we feel that the added effort isn't going
+        // to provide a particular speed up over pairing above.
+        //([0] <= [i] <= [(upper - lower) / 4]) : euler(tod(i + lower))
+        //                                      + euler(tod(upper - i))
+        //                                      + euler(tod(i + lower + 250))
+        //                                      + euler(tod(upper - 250 - i));
     } : fold(+, 0d);
     return(tmp);
 }