p_fpops*$fpw + $x->p_iops*(1-$fpw); $cps /= 1e9; $cps /= 864; $cc = $x->cpu_time * $cps; return $cc; } // $x is an array of result/host objects; // return the variance among claimed credits given an FP weight // function fpw_var($results, $fpw) { $cc = array(); foreach ($results as $r) { $cc[] = cc($r, $fpw); } return normalized_variance($cc); } // scan WUs for which credit has been granted, // and for which there at least 2 valid results. // For each of these, compute the variance among claimed credits // given various FP weights (0, .1, ... 1). // Maintain the sum of these in an array // function get_data() { $nwus = 4000; $sum = array(); for ($i=0; $i<=10; $i++) { $sum[] = 0; } $r1 = mysql_query( "select id from workunit where canonical_resultid>0 limit $nwus" ); $n = 0; while ($wu = mysql_fetch_object($r1)) { $results = array(); $r2 = mysql_query("select * from result where workunitid=$wu->id"); $found_zero = false; while ($result = mysql_fetch_object($r2)) { if ($result->granted_credit==0) continue; // skip invalid $host = lookup_host($result->hostid); $r = null; $r->cpu_time = $result->cpu_time; $r->p_fpops = $host->p_fpops; $r->p_iops = $host->p_iops; $results[] = $r; } //echo "Wu $wu->id -------------\n"; if (count($results)<2) continue; for ($i=0; $i<=10; $i++) { $fpw = $i/10.; $sum[$i] += fpw_var($results, $fpw); } $n++; } echo "This script recommends value for in config.xml. It does this by finding the value that minimizes the variance among claimed credit for workunits currently in your database. It examines at most $nwus WUs (edit the script to change this). Number of workunits analyzed: $n "; for ($i=0; $i<=10; $i++) { $fpw = $i/10.; $r = $sum[$i]/$n; echo "FP weight $fpw: variance is $r\n"; if ($i == 0) { $best = $r; $fbest = $fpw; } else { if ($r < $best) { $best = $r; $fbest = $fpw; } } } echo " Recommended value: $fbest "; } get_data(); ?>