Преглед изворни кода

Move dpfreq computation into SubproblemProgress constructor

This is in preparation for refactoring the computation of the number of
needed dpnodes, workers, and dpfreq into a callback into the driver
program.
Ian Goldberg пре 14 година
родитељ
комит
99445b0133
1 измењених фајлова са 16 додато и 16 уклоњено
  1. 16 16
      controller.cc

+ 16 - 16
controller.cc

@@ -191,8 +191,8 @@ struct SubproblemProgress : Subproblem {
     ZZ solution;
 
     SubproblemProgress(unsigned short id, const ZZ &b, const ZZ &t,
-	    const ZZ &m, const ZZ &o, unsigned int dpf) :
-	    Subproblem(id, b, t, m, o, dpf), solved(false) {
+	    const ZZ &m, const ZZ &o) :
+	    Subproblem(id, b, t, m, o, 4294967), solved(false) {
 	// How many DPnodes should we use for a problem of this size?
 	desired_dpnodes = 2;
 	// How many workers would we like to use?
@@ -203,6 +203,19 @@ struct SubproblemProgress : Subproblem {
 	} else {
 	    max_workers = trunc_long(sorder,31) + 1;
 	}
+
+	// By default, 1 in 1000 points are distinguihed points.  The
+	// number in the next line is 2^32/1000
+	dpfreq = 4294967;
+	if (order < 1000) {
+	    // Just make every point a DP
+	    dpfreq = 4294967295U;
+	} else if (NumBits(order) < 27) {
+	    // The frequency of DPs should be 10/sqrt(order) to avoid
+	    // a DP-free cycle, so dpfreq = (10*2^32)/sqrt(order)
+	    ZZ f = (to_ZZ(10) << 32) / SqrRoot(order);
+	    dpfreq = trunc_long(f, 31);
+	}
     }
 
     // Stop all dpnodes and workers
@@ -451,22 +464,9 @@ static vector<SubproblemProgress> decomp(const ZZ_p &base, const ZZ_p &target,
 	    }
 	}
 
-	// By default, 1 in 1000 points are distinguihed points.  The
-	// number in the next line is 2^32/1000
-	unsigned int dpfreq = 4294967;
-	if (order < 1000) {
-	    // Just make every point a DP
-	    dpfreq = 4294967295U;
-	} else if (NumBits(order) < 27) {
-	    // The frequency of DPs should be 10/sqrt(order) to avoid
-	    // a DP-free cycle, so dpfreq = (10*2^32)/sqrt(order)
-	    ZZ f = (to_ZZ(10) << 32) / SqrRoot(order);
-	    dpfreq = trunc_long(f, 31);
-	}
 	++curproblemid;
 	ret.push_back(SubproblemProgress(curproblemid, rep(subgroup_base),
-				    rep(subgroup_target),
-				    f.factor, order, dpfreq));
+				    rep(subgroup_target), f.factor, order));
     }
 
     return ret;