. // generate a page of the best-performing GPU models. // // "best-performing" is defined as minimizing the average of // // elapsed_time(J)/rsc_fpops_est(J) // over completed jobs J currently in the DB require_once("../inc/util.inc"); function get_gpu_model($x, $vendor) { $descs = explode("]", $x); array_pop($descs); foreach ($descs as $desc) { $desc = trim($desc, "["); $d = explode("|", $desc); if ($d[0] == "BOINC") continue; if ($d[0] != $vendor) continue; return $d[1]; } return null; } function add_model($model, $r, &$models) { if (array_key_exists($model, $models)) { $models[$model]->count++; $models[$model]->time += $r->elapsed_time; } else { $x = null; $x->count = 1; $x->time = $r->elapsed_time; $models[$model] = $x; } } // return a data structure containing GPU usage info for a vendor // $x->total: combined list // $x->windows // $x->linux // $x->mac // function get_gpu_list($vendor) { $avs = BoincAppVersion::enum("plan_class like '%$vendor%'"); $av_ids = ""; foreach($avs as $av) { $av_ids .= "$av->id, "; } $av_ids .= "0"; $t = time() - 30*86400; $results = BoincResult::enum("app_version_id in ($av_ids) and create_time > $t and elapsed_time>100 limit 5000"); $total = array(); $win = array(); $linux = array(); $mac = array(); foreach ($results as $r) { $h = BoincHost::lookup_id($r->hostid); if (!$h) continue; $v = $vendor=="cuda"?"CUDA":"ATI"; $model = get_gpu_model($h->serialnum, $v); if (!$model) continue; add_model($model, $r, $total); if (strstr($h->os_name, "Windows")) { add_model($model, $r, $win); } if (strstr($h->os_name, "Linux")) { add_model($model, $r, $linux); } if (strstr($h->os_name, "Darwin")) { add_model($model, $r, $mac); } } $x = null; $x->total = $total; $x->win = $win; $x->linux = $linux; $x->mac = $mac; return $x; } function get_gpu_lists() { $x = null; $x->cuda = get_gpu_list("cuda"); $x->ati = get_gpu_list("ati"); return $x; } function gpucmp($x1, $x2) { $y1 = $x1->time/$x1->count; $y2 = $x2->time/$x2->count; return $y1 > $y2; } function show_list($models, $name) { echo "