2016-06-24 22:42:11 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2016 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
// credit_test
|
2009-11-10 21:00:29 +00:00
|
|
|
//
|
|
|
|
// Simulate the new credit system for the N most recent jobs
|
|
|
|
// in project's database, and give a comparison of new and old systems.
|
|
|
|
// Doesn't modify anything.
|
|
|
|
//
|
2010-03-11 04:19:07 +00:00
|
|
|
// You must first run html/ops/credit_test.php to create a data file
|
|
|
|
//
|
2009-11-10 21:00:29 +00:00
|
|
|
|
2009-11-04 21:23:56 +00:00
|
|
|
#include <stdio.h>
|
2009-11-04 23:04:07 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2009-11-04 21:23:56 +00:00
|
|
|
#include "sched_config.h"
|
2010-03-09 04:15:10 +00:00
|
|
|
#include "sched_customize.h"
|
2009-11-04 21:23:56 +00:00
|
|
|
#include "boinc_db.h"
|
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
#define MAX_JOBS 100000
|
2009-11-12 00:22:33 +00:00
|
|
|
#define PRINT_AV_PERIOD 100
|
|
|
|
#define SCALE_AV_PERIOD 20
|
2010-03-11 04:19:07 +00:00
|
|
|
|
|
|
|
#define MIN_HOST_SAMPLES 10
|
2009-11-12 00:22:33 +00:00
|
|
|
// don't use host scaling unless have this many samples for host
|
2010-03-11 04:19:07 +00:00
|
|
|
#define MIN_VERSION_SAMPLES 100
|
2009-11-15 18:15:35 +00:00
|
|
|
// don't update a version's scale unless it has this many samples,
|
|
|
|
// and don't accumulate stats until this occurs
|
2009-11-10 21:00:29 +00:00
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
#define HAV_AVG_THRESH 20
|
|
|
|
#define HAV_AVG_WEIGHT .01
|
|
|
|
#define HAV_AVG_LIMIT 10
|
|
|
|
|
|
|
|
#define AV_AVG_THRESH 50000
|
|
|
|
#define AV_AVG_WEIGHT .005
|
|
|
|
#define AV_AVG_LIMIT 10
|
2009-11-04 21:23:56 +00:00
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
double min_credit = 0;
|
2009-11-04 21:23:56 +00:00
|
|
|
vector<APP_VERSION> app_versions;
|
|
|
|
vector<APP> apps;
|
|
|
|
vector<HOST_APP_VERSION> host_app_versions;
|
2009-11-10 21:00:29 +00:00
|
|
|
vector<PLATFORM> platforms;
|
|
|
|
bool accumulate_stats = false;
|
2010-03-11 04:19:07 +00:00
|
|
|
// set to true when we have PFC averages for
|
|
|
|
// both a GPU and a CPU version
|
2009-11-04 21:23:56 +00:00
|
|
|
|
|
|
|
void read_db() {
|
|
|
|
DB_APP app;
|
|
|
|
DB_APP_VERSION av;
|
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
while (!app.enumerate("")) {
|
2009-11-04 21:23:56 +00:00
|
|
|
apps.push_back(app);
|
|
|
|
}
|
2009-11-10 21:00:29 +00:00
|
|
|
while (!av.enumerate("where deprecated=0 order by id desc")) {
|
2010-03-29 22:28:20 +00:00
|
|
|
av.pfc_scale= 1;
|
2009-11-04 21:23:56 +00:00
|
|
|
app_versions.push_back(av);
|
|
|
|
}
|
2009-11-10 21:00:29 +00:00
|
|
|
DB_PLATFORM platform;
|
|
|
|
while (!platform.enumerate("")) {
|
|
|
|
platforms.push_back(platform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PLATFORM* lookup_platform(int id) {
|
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<platforms.size(); i++) {
|
|
|
|
PLATFORM& p = platforms[i];
|
|
|
|
if (p.id == id) return &p;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
APP_VERSION* lookup_av(int id) {
|
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
APP_VERSION& av = app_versions[i];
|
|
|
|
if (av.id == id) return &av;
|
|
|
|
}
|
|
|
|
printf(" missing app version %d\n", id);
|
|
|
|
exit(1);
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
APP& lookup_app(int id) {
|
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
APP& app = apps[i];
|
|
|
|
if (app.id == id) return app;
|
|
|
|
}
|
2010-03-10 00:33:31 +00:00
|
|
|
printf("missing app: %d\n", id);
|
2010-06-25 18:54:37 +00:00
|
|
|
exit(1);
|
|
|
|
return apps[0];
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 00:22:33 +00:00
|
|
|
HOST_APP_VERSION& lookup_host_app_version(int hostid, int avid) {
|
2009-11-04 21:23:56 +00:00
|
|
|
unsigned int i;
|
2009-11-12 00:22:33 +00:00
|
|
|
for (i=0; i<host_app_versions.size(); i++) {
|
|
|
|
HOST_APP_VERSION& hav = host_app_versions[i];
|
|
|
|
if (hav.host_id != hostid) continue;
|
|
|
|
if (hav.app_version_id != avid) continue;
|
|
|
|
return hav;
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|
2009-11-12 00:22:33 +00:00
|
|
|
HOST_APP_VERSION h;
|
2009-11-04 21:23:56 +00:00
|
|
|
h.host_id = hostid;
|
2009-11-12 00:22:33 +00:00
|
|
|
h.app_version_id = avid;
|
|
|
|
host_app_versions.push_back(h);
|
|
|
|
return host_app_versions.back();
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 23:04:07 +00:00
|
|
|
void print_average(AVERAGE& a) {
|
2010-03-11 04:19:07 +00:00
|
|
|
printf("n %f avg %f\n", a.n, a.get_avg()
|
2009-11-10 21:00:29 +00:00
|
|
|
);
|
2009-11-04 23:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void print_avs() {
|
|
|
|
unsigned int i;
|
2009-11-10 21:00:29 +00:00
|
|
|
printf("----- scales --------\n");
|
2009-11-04 23:04:07 +00:00
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
APP_VERSION& av = app_versions[i];
|
|
|
|
if (!av.pfc.n) continue;
|
2009-11-10 21:00:29 +00:00
|
|
|
PLATFORM* p = lookup_platform(av.platformid);
|
2015-07-23 17:11:08 +00:00
|
|
|
printf("app %lu vers %lu (%s %s)\n scale %f ",
|
2010-03-29 22:28:20 +00:00
|
|
|
av.appid, av.id, p->name, av.plan_class, av.pfc_scale
|
2009-11-04 23:04:07 +00:00
|
|
|
);
|
|
|
|
print_average(av.pfc);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2009-11-10 21:00:29 +00:00
|
|
|
printf("-------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void lookup_host(DB_HOST& h, int id) {
|
|
|
|
int retval = h.lookup_id(id);
|
|
|
|
if (retval) {
|
|
|
|
printf("can't find host %d\n", id);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
// used in the computation of AV scale factors
|
|
|
|
//
|
2010-03-11 04:19:07 +00:00
|
|
|
struct RSC_INFO {
|
|
|
|
double pfc_sum;
|
|
|
|
double pfc_n;
|
|
|
|
int nvers_thresh; // # app versions w/ lots of samples
|
|
|
|
int nvers_total;
|
|
|
|
|
|
|
|
RSC_INFO() {
|
|
|
|
pfc_sum = 0;
|
|
|
|
pfc_n = 0;
|
|
|
|
nvers_thresh = 0;
|
|
|
|
nvers_total = 0;
|
|
|
|
}
|
|
|
|
void update(APP_VERSION& av) {
|
|
|
|
nvers_total++;
|
|
|
|
if (av.pfc.n > MIN_VERSION_SAMPLES) {
|
|
|
|
nvers_thresh++;
|
|
|
|
pfc_sum += av.pfc.get_avg() * av.pfc.n;
|
|
|
|
pfc_n += av.pfc.n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
double avg() {
|
|
|
|
return pfc_sum/pfc_n;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void scale_versions(APP& app, double avg) {
|
|
|
|
for (unsigned int j=0; j<app_versions.size(); j++) {
|
|
|
|
APP_VERSION& av = app_versions[j];
|
|
|
|
if (av.appid != app.id) continue;
|
|
|
|
if (av.pfc.n < MIN_VERSION_SAMPLES) continue;
|
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
av.pfc_scale= avg/av.pfc.get_avg();
|
2010-03-11 04:19:07 +00:00
|
|
|
PLATFORM* p = lookup_platform(av.platformid);
|
|
|
|
printf("updating scale factor for (%s %s)\n",
|
|
|
|
p->name, av.plan_class
|
|
|
|
);
|
|
|
|
printf(" n: %f avg PFC: %f new scale: %f\n",
|
2010-03-29 22:28:20 +00:00
|
|
|
av.pfc.n, av.pfc.get_avg(), av.pfc_scale
|
2010-03-11 04:19:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
app.min_avg_pfc = avg;
|
|
|
|
}
|
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
// update app version scale factors,
|
|
|
|
// and find the min average PFC for each app
|
2009-11-10 21:00:29 +00:00
|
|
|
//
|
|
|
|
void update_av_scales() {
|
|
|
|
unsigned int i, j;
|
|
|
|
printf("----- updating scales --------\n");
|
|
|
|
for (i=0; i<apps.size(); i++) {
|
|
|
|
APP& app = apps[i];
|
2015-07-23 17:11:08 +00:00
|
|
|
printf("app %lu\n", app.id);
|
2010-03-11 04:19:07 +00:00
|
|
|
RSC_INFO cpu_info, gpu_info;
|
2010-03-10 00:33:31 +00:00
|
|
|
|
2010-03-09 04:15:10 +00:00
|
|
|
// find the average PFC of CPU and GPU versions
|
2009-11-10 21:00:29 +00:00
|
|
|
|
|
|
|
for (j=0; j<app_versions.size(); j++) {
|
|
|
|
APP_VERSION& av = app_versions[j];
|
|
|
|
if (av.appid != app.id) continue;
|
2010-03-09 04:15:10 +00:00
|
|
|
if (strstr(av.plan_class, "cuda") || strstr(av.plan_class, "ati")) {
|
2015-07-23 17:11:08 +00:00
|
|
|
printf("gpu update: %lu %s %f\n", av.id, av.plan_class, av.pfc.get_avg());
|
2010-03-11 04:19:07 +00:00
|
|
|
gpu_info.update(av);
|
2010-03-09 04:15:10 +00:00
|
|
|
} else {
|
2015-07-23 17:11:08 +00:00
|
|
|
printf("cpu update: %lu %s %f\n", av.id, av.plan_class, av.pfc.get_avg());
|
2010-03-11 04:19:07 +00:00
|
|
|
cpu_info.update(av);
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-11 04:19:07 +00:00
|
|
|
|
|
|
|
// If there are only CPU or only GPU versions,
|
|
|
|
// and 2 are above threshold, normalize to the average
|
|
|
|
//
|
|
|
|
// If there are both, and at least 1 of each is above threshold,
|
|
|
|
// normalize to the min of the averages
|
|
|
|
//
|
|
|
|
if (cpu_info.nvers_total) {
|
|
|
|
if (gpu_info.nvers_total) {
|
|
|
|
if (cpu_info.nvers_thresh && gpu_info.nvers_thresh) {
|
|
|
|
printf("CPU avg: %f\n", cpu_info.avg());
|
|
|
|
printf("GPU avg: %f\n", gpu_info.avg());
|
|
|
|
scale_versions(app,
|
|
|
|
cpu_info.avg()<gpu_info.avg()?cpu_info.avg():gpu_info.avg()
|
|
|
|
);
|
|
|
|
accumulate_stats = true;
|
|
|
|
}
|
2010-03-09 04:15:10 +00:00
|
|
|
} else {
|
2010-03-11 04:19:07 +00:00
|
|
|
if (cpu_info.nvers_thresh > 1) {
|
|
|
|
scale_versions(app, cpu_info.avg());
|
|
|
|
accumulate_stats = true;
|
|
|
|
}
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-03-11 04:19:07 +00:00
|
|
|
if (gpu_info.nvers_thresh > 1) {
|
|
|
|
scale_versions(app, gpu_info.avg());
|
|
|
|
accumulate_stats = true;
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
2009-11-10 21:00:29 +00:00
|
|
|
}
|
|
|
|
|
2010-03-09 04:15:10 +00:00
|
|
|
|
2009-11-10 21:00:29 +00:00
|
|
|
}
|
|
|
|
printf("-------------\n");
|
2009-11-04 23:04:07 +00:00
|
|
|
}
|
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
// Compute or estimate normalized peak FLOP count (PFC),
|
|
|
|
// and update data structures.
|
2010-03-11 04:19:07 +00:00
|
|
|
// Return true if the PFC was computed in the "normal" way,
|
|
|
|
// i.e. not anon platform, and reflects version scaling
|
2010-03-09 04:15:10 +00:00
|
|
|
//
|
2010-03-10 06:00:37 +00:00
|
|
|
bool get_pfc(RESULT& r, WORKUNIT& wu, double& pfc) {
|
2010-03-09 04:15:10 +00:00
|
|
|
APP_VERSION* avp = NULL;
|
|
|
|
DB_HOST host;
|
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
APP& app = lookup_app(r.appid);
|
|
|
|
HOST_APP_VERSION& hav = lookup_host_app_version(
|
|
|
|
r.hostid, r.app_version_id
|
|
|
|
);
|
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
if (r.elapsed_time) {
|
2010-03-09 04:15:10 +00:00
|
|
|
// new client
|
2010-03-29 22:28:20 +00:00
|
|
|
hav.et.update(
|
|
|
|
r.elapsed_time/wu.rsc_fpops_est,
|
|
|
|
HAV_AVG_THRESH, HAV_AVG_WEIGHT, HAV_AVG_LIMIT
|
|
|
|
);
|
2010-03-09 04:15:10 +00:00
|
|
|
if (r.app_version_id < 0) {
|
2010-03-10 00:33:31 +00:00
|
|
|
// anon platform
|
2010-03-09 04:15:10 +00:00
|
|
|
//
|
2010-03-10 00:33:31 +00:00
|
|
|
pfc = app.min_avg_pfc;
|
2010-03-11 04:19:07 +00:00
|
|
|
if (hav.et.n > MIN_HOST_SAMPLES) {
|
|
|
|
pfc *= (r.elapsed_time/wu.rsc_fpops_est)/hav.et.get_avg();
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
2010-03-10 00:33:31 +00:00
|
|
|
printf(" skipping: anon platform\n");
|
|
|
|
return false;
|
2010-03-09 04:15:10 +00:00
|
|
|
} else {
|
2010-03-11 04:19:07 +00:00
|
|
|
pfc = (r.elapsed_time * r.flops_estimate);
|
2010-03-09 04:15:10 +00:00
|
|
|
avp = lookup_av(r.app_version_id);
|
|
|
|
printf(" sec: %.0f GFLOPS: %.0f PFC: %.0fG raw credit: %.2f\n",
|
|
|
|
r.elapsed_time, r.flops_estimate/1e9, pfc/1e9, pfc*COBBLESTONE_SCALE
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// old client
|
2010-03-10 00:33:31 +00:00
|
|
|
//
|
2010-03-29 22:28:20 +00:00
|
|
|
hav.et.update(
|
|
|
|
r.cpu_time/wu.rsc_fpops_est,
|
|
|
|
HAV_AVG_THRESH, HAV_AVG_WEIGHT, HAV_AVG_LIMIT
|
|
|
|
);
|
2010-03-11 04:19:07 +00:00
|
|
|
pfc = app.min_avg_pfc*wu.rsc_fpops_est;
|
|
|
|
if (hav.et.n > MIN_HOST_SAMPLES) {
|
|
|
|
double s = r.elapsed_time/hav.et.get_avg();
|
|
|
|
pfc *= s;
|
|
|
|
printf(" old client: scaling by %f (%f/%f)\n",
|
|
|
|
s, r.elapsed_time, hav.et.get_avg()
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
printf(" old client: not scaling\n");
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
2010-03-10 00:33:31 +00:00
|
|
|
return false;
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
avp->pfc.update(
|
|
|
|
pfc/wu.rsc_fpops_est,
|
|
|
|
AV_AVG_THRESH, AV_AVG_WEIGHT, AV_AVG_LIMIT
|
|
|
|
);
|
2010-03-09 04:15:10 +00:00
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
// version normalization
|
2010-03-09 04:15:10 +00:00
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
double vnpfc = pfc * avp->pfc_scale;
|
2010-03-10 00:33:31 +00:00
|
|
|
|
|
|
|
PLATFORM* p = lookup_platform(avp->platformid);
|
2010-03-11 04:19:07 +00:00
|
|
|
printf(" updated version PFC: %f\n", pfc/wu.rsc_fpops_est);
|
2010-03-10 00:33:31 +00:00
|
|
|
printf(" version scale (%s %s): %f\n",
|
2010-03-29 22:28:20 +00:00
|
|
|
p->name, avp->plan_class, avp->pfc_scale
|
2010-03-10 00:33:31 +00:00
|
|
|
);
|
2010-03-09 04:15:10 +00:00
|
|
|
|
|
|
|
// host normalization
|
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
hav.pfc.update(
|
|
|
|
pfc/wu.rsc_fpops_est,
|
|
|
|
HAV_AVG_THRESH, HAV_AVG_WEIGHT, HAV_AVG_LIMIT
|
|
|
|
);
|
2010-03-10 00:33:31 +00:00
|
|
|
|
2010-03-09 04:15:10 +00:00
|
|
|
double host_scale = 1;
|
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
if (hav.pfc.n > MIN_HOST_SAMPLES && avp->pfc.n > MIN_VERSION_SAMPLES) {
|
2010-03-09 04:15:10 +00:00
|
|
|
host_scale = avp->pfc.get_avg()/hav.pfc.get_avg();
|
2010-03-11 04:19:07 +00:00
|
|
|
if (host_scale > 1) host_scale = 1;
|
|
|
|
printf(" host scale: %f (%f/%f)\n",
|
|
|
|
host_scale, avp->pfc.get_avg(), hav.pfc.get_avg()
|
|
|
|
);
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
2010-03-10 00:33:31 +00:00
|
|
|
pfc = vnpfc * host_scale;
|
2010-03-09 04:15:10 +00:00
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
return avp->pfc.n > MIN_VERSION_SAMPLES;
|
2010-03-09 04:15:10 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 21:00:29 +00:00
|
|
|
int main(int argc, char** argv) {
|
2010-03-11 04:19:07 +00:00
|
|
|
RESULT r;
|
|
|
|
WORKUNIT wu;
|
2009-11-04 21:23:56 +00:00
|
|
|
int retval;
|
2009-11-15 18:15:35 +00:00
|
|
|
FILE* f = fopen("credit_test_unsorted", "w");
|
2009-11-10 21:00:29 +00:00
|
|
|
|
2010-03-11 04:19:07 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
min_credit = atof(argv[1]);
|
2009-11-10 21:00:29 +00:00
|
|
|
}
|
2009-11-04 21:23:56 +00:00
|
|
|
|
|
|
|
retval = config.parse_file();
|
|
|
|
if (retval) {printf("no config: %d\n", retval); exit(1);}
|
|
|
|
retval = boinc_db.open(
|
|
|
|
config.db_name, config.db_host, config.db_user, config.db_passwd
|
|
|
|
);
|
2020-05-06 20:01:21 +00:00
|
|
|
if (retval) {
|
|
|
|
fprintf(stderr, "can't open db: %s\n",
|
|
|
|
boinc_db.error_string()
|
|
|
|
);
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-11-04 21:23:56 +00:00
|
|
|
|
|
|
|
read_db();
|
|
|
|
|
2010-03-09 04:15:10 +00:00
|
|
|
int n=0, nstats=0;
|
2009-11-10 21:00:29 +00:00
|
|
|
double total_old_credit = 0;
|
|
|
|
double total_new_credit = 0;
|
2010-03-11 04:19:07 +00:00
|
|
|
FILE* in = fopen("credit_test_data", "r");
|
2012-06-10 05:38:34 +00:00
|
|
|
if (!in) {
|
|
|
|
printf("can't open credit_test_data\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-03-11 04:19:07 +00:00
|
|
|
printf("min credit: %f\n", min_credit);
|
|
|
|
while (!feof(in)) {
|
2015-07-23 17:11:08 +00:00
|
|
|
int c = fscanf(in, "%lu %lu %lu %lu %lf %lu %lf %lf %lf %lf",
|
2010-03-11 04:19:07 +00:00
|
|
|
&r.id, &r.workunitid, &r.appid, &r.hostid,
|
|
|
|
&r.claimed_credit, &r.app_version_id, &r.elapsed_time,
|
|
|
|
&r.flops_estimate, &r.cpu_time, &wu.rsc_fpops_est
|
|
|
|
);
|
|
|
|
if (c != 10) break;
|
2015-07-23 17:11:08 +00:00
|
|
|
printf("%d) result %lu WU %lu host %lu old credit %f\n",
|
2010-03-11 04:19:07 +00:00
|
|
|
n, r.id, r.workunitid, r.hostid, r.claimed_credit
|
2009-11-12 00:22:33 +00:00
|
|
|
);
|
2010-03-11 04:19:07 +00:00
|
|
|
n++;
|
|
|
|
if (r.claimed_credit < min_credit) {
|
|
|
|
printf(" skipping: small credit\n");
|
2010-03-10 06:00:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-11-12 00:22:33 +00:00
|
|
|
|
2010-03-10 00:33:31 +00:00
|
|
|
double pfc;
|
2010-03-11 04:19:07 +00:00
|
|
|
bool normal = get_pfc(r, wu, pfc);
|
2010-03-10 00:33:31 +00:00
|
|
|
double new_claimed_credit = pfc * COBBLESTONE_SCALE;
|
2010-03-11 04:19:07 +00:00
|
|
|
if (normal) {
|
|
|
|
printf(" new credit %.2f old credit %.2f\n",
|
|
|
|
new_claimed_credit, r.claimed_credit
|
2010-03-09 04:15:10 +00:00
|
|
|
);
|
2010-03-11 04:19:07 +00:00
|
|
|
if (accumulate_stats) {
|
|
|
|
total_old_credit += r.claimed_credit;
|
|
|
|
total_new_credit += new_claimed_credit;
|
|
|
|
nstats++;
|
2015-07-23 17:11:08 +00:00
|
|
|
fprintf(f, "%lu %lu %.2f %.2f\n",
|
2010-03-11 17:49:19 +00:00
|
|
|
r.workunitid, r.id, new_claimed_credit, r.claimed_credit
|
|
|
|
);
|
2010-03-11 04:19:07 +00:00
|
|
|
} else {
|
|
|
|
printf(" not accumulated\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf(" new credit (average): %f\n", new_claimed_credit);
|
2009-11-10 21:00:29 +00:00
|
|
|
}
|
2009-11-04 21:23:56 +00:00
|
|
|
|
2009-11-12 00:22:33 +00:00
|
|
|
if (n%SCALE_AV_PERIOD ==0) {
|
2009-11-04 21:23:56 +00:00
|
|
|
update_av_scales();
|
|
|
|
}
|
2009-11-12 00:22:33 +00:00
|
|
|
if (n%PRINT_AV_PERIOD ==0) {
|
2009-11-10 21:00:29 +00:00
|
|
|
print_avs();
|
|
|
|
}
|
2009-11-15 18:15:35 +00:00
|
|
|
if (n%1000 == 0) {
|
|
|
|
fprintf(stderr, "%d\n", n);
|
|
|
|
}
|
2010-03-11 04:19:07 +00:00
|
|
|
if (n >= MAX_JOBS) break;
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|
2012-06-10 05:38:34 +00:00
|
|
|
fclose(in);
|
2009-11-15 18:15:35 +00:00
|
|
|
fclose(f);
|
2009-11-10 23:39:51 +00:00
|
|
|
if (nstats == 0) {
|
|
|
|
printf("Insufficient jobs were read from DB\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2009-11-04 23:04:07 +00:00
|
|
|
print_avs();
|
2009-11-10 21:00:29 +00:00
|
|
|
|
2009-11-12 00:40:30 +00:00
|
|
|
printf("Average credit: old %.2f new %.2f (ratio %.2f)\n",
|
|
|
|
total_old_credit/nstats, total_new_credit/nstats,
|
|
|
|
total_new_credit/total_old_credit
|
|
|
|
);
|
2009-11-12 00:22:33 +00:00
|
|
|
//printf("Variance claimed to grant old credit: %f\n", sqrt(variance_old/nstats));
|
|
|
|
//printf("Variance claimed to grant old credit: %f\n", sqrt(variance_old/nstats));
|
2009-11-04 21:23:56 +00:00
|
|
|
}
|