Skip to content

Commit 950aebb

Browse files
authored
Merge pull request #6800 from BOINC/dpa_resource_usage2
client: fill in resource usage if not specified
2 parents 42f244e + 143c141 commit 950aebb

File tree

8 files changed

+90
-47
lines changed

8 files changed

+90
-47
lines changed

client/client_state.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -706,19 +706,7 @@ int CLIENT_STATE::init() {
706706
// (typically anonymous platform)
707707
//
708708
for (APP_VERSION* avp: app_versions) {
709-
if (!avp->resource_usage.avg_ncpus) {
710-
avp->resource_usage.avg_ncpus = 1;
711-
}
712-
if (!avp->resource_usage.flops) {
713-
avp->resource_usage.flops = avp->resource_usage.avg_ncpus * host_info.p_fpops;
714-
715-
// for GPU apps, use conservative estimate:
716-
// assume GPU runs at 10X peak CPU speed
717-
//
718-
if (avp->resource_usage.rsc_type) {
719-
avp->resource_usage.flops += avp->resource_usage.coproc_usage * 10 * host_info.p_fpops;
720-
}
721-
}
709+
avp->fill_in_resource_usage();
722710
}
723711

724712
// must go after check_app_config() and parse_state_file()

client/client_types.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,61 @@ void APP_VERSION::init() {
883883
#endif
884884
}
885885

886+
// see if app version is disallowed by config
887+
//
888+
bool APP_VERSION::disallowed_by_config(PROJECT *p) {
889+
if (cc_config.dont_use_vbox && strstr(plan_class, "vbox")) {
890+
msg_printf(p, MSG_INFO,
891+
"Skipping VirtualBox app version: disabled in cc_config.xml"
892+
);
893+
return true;
894+
}
895+
if (cc_config.dont_use_wsl && strstr(plan_class, "wsl")) {
896+
msg_printf(p, MSG_INFO,
897+
"skipping WSL app version: disabled in cc_config.xml"
898+
);
899+
return true;
900+
}
901+
if (cc_config.dont_use_docker && strstr(plan_class, "docker")) {
902+
msg_printf(p, MSG_INFO,
903+
"skipping Docker app: disabled in cc_config.xml"
904+
);
905+
return true;
906+
}
907+
return false;
908+
}
909+
910+
// fill in resource usage if not already present
911+
//
912+
void APP_VERSION::fill_in_resource_usage() {
913+
if (resource_usage.avg_ncpus == 0) {
914+
resource_usage.avg_ncpus = 1;
915+
}
916+
if (resource_usage.flops == 0) {
917+
resource_usage.flops = resource_usage.avg_ncpus * gstate.host_info.p_fpops;
918+
919+
// for GPU apps, use conservative estimate:
920+
// assume GPU runs at 10X peak CPU speed
921+
//
922+
if (resource_usage.rsc_type) {
923+
resource_usage.flops += resource_usage.coproc_usage * 10 * gstate.host_info.p_fpops;
924+
}
925+
}
926+
}
927+
928+
// Parse an <app_version> element; called from
929+
// 1) parse scheduler reply: scheduler_op.cpp
930+
// 2) parse client state file: cs_statefile.cpp
931+
// 3) parse app_info.xml for anonymous platform: cs_statefile.cpp
932+
//
933+
// After this you need to:
934+
// - check if disallowed by config
935+
// do this right away; config.xml has already been parsed
936+
// - fill in resource usage if not specified
937+
// In cases 2 and 3 we don't have CPU FLOPS yet,
938+
// so we have to do this a bit later.
939+
// In case 1 we do it right away.
940+
//
886941
int APP_VERSION::parse(XML_PARSER& xp) {
887942
FILE_REF file_ref;
888943
double dtemp;

client/client_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ struct APP_VERSION {
390390
~APP_VERSION(){}
391391
void init();
392392
int parse(XML_PARSER&);
393+
bool disallowed_by_config(PROJECT*);
394+
void fill_in_resource_usage();
393395
int write(MIOFILE&, bool write_file_info = true);
394396
bool had_download_failure(int& failnum);
395397
void get_file_errors(std::string&);

client/cpu_sched.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,13 @@ double total_peak_flops() {
676676
// Initialize project "priorities" based on REC:
677677
// compute resource share and REC fractions
678678
// among compute-intensive, non-suspended projects
679+
// Also compute rec_sum
679680
//
680681
void project_priority_init(bool for_work_fetch) {
681682
double rs_sum = 0;
683+
// sum of resource share of runnable (or fetchable) projects
682684
rec_sum = 0;
685+
// sum of recent work of runnable (or fetchable) projects
683686
for (unsigned int i=0; i<gstate.projects.size(); i++) {
684687
PROJECT* p = gstate.projects[i];
685688
if (p->non_cpu_intensive) continue;
@@ -722,7 +725,11 @@ void PROJECT::compute_sched_priority() {
722725
if (resource_share == 0) {
723726
sched_priority = -1e3 - rec_frac;
724727
} else {
725-
sched_priority = - rec_frac/resource_share_frac;
728+
if (resource_share_frac > 0) {
729+
sched_priority = - rec_frac/resource_share_frac;
730+
} else {
731+
sched_priority = - rec_frac;
732+
}
726733
}
727734
}
728735

client/cs_statefile.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,16 @@ int CLIENT_STATE::parse_state_file_aux(const char* fname) {
262262
continue;
263263
}
264264
if (retval) {
265-
msg_printf(NULL, MSG_INTERNAL_ERROR,
265+
msg_printf(project, MSG_INTERNAL_ERROR,
266266
"Can't parse application version in state file"
267267
);
268268
delete avp;
269269
continue;
270270
}
271+
if (avp->disallowed_by_config(project)) {
272+
delete avp;
273+
continue;
274+
}
271275
if (strlen(avp->platform) == 0) {
272276
safe_strcpy(avp->platform, get_primary_platform());
273277
} else {
@@ -957,24 +961,7 @@ int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
957961
delete avp;
958962
continue;
959963
}
960-
if (cc_config.dont_use_vbox && strstr(avp->plan_class, "vbox")) {
961-
msg_printf(p, MSG_INFO,
962-
"skipping vbox app in app_info.xml; vbox disabled in cc_config.xml"
963-
);
964-
delete avp;
965-
continue;
966-
}
967-
if (cc_config.dont_use_wsl && strstr(avp->plan_class, "wsl")) {
968-
msg_printf(p, MSG_INFO,
969-
"skipping wsl app in app_info.xml; wsl disabled in cc_config.xml"
970-
);
971-
delete avp;
972-
continue;
973-
}
974-
if (cc_config.dont_use_docker && strstr(avp->plan_class, "docker")) {
975-
msg_printf(p, MSG_INFO,
976-
"skipping docker app in app_info.xml; docker disabled in cc_config.xml"
977-
);
964+
if (avp->disallowed_by_config(p)) {
978965
delete avp;
979966
continue;
980967
}

client/scheduler_op.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
774774
"Can't parse application version in scheduler reply: %s",
775775
boincerror(retval)
776776
);
777-
} else {
777+
} else if (!av.disallowed_by_config(project)) {
778+
av.fill_in_resource_usage();
778779
app_versions.push_back(av);
779780
}
780781
} else if (xp.match_tag("workunit")) {

client/sim.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ void make_job(
225225
) {
226226
APP* app = choose_app(app_list);
227227
APP_VERSION* avp = choose_app_version(app);
228-
rp->clear();
229-
rp->avp = avp;
230-
rp->app = app;
231-
if (!rp->avp) {
228+
if (!avp) {
232229
fprintf(stderr, "ERROR - NO APP VERSION\n");
233230
exit(1);
234231
}
232+
rp->clear();
233+
rp->avp = avp;
234+
rp->app = app;
235235
rp->project = p;
236236
rp->wup = wup;
237+
rp->resource_usage = avp->resource_usage;
237238
sprintf(rp->name, "%s_%d", p->project_name, p->result_index++);
238239
wup->project = p;
239240
wup->rsc_fpops_est = app->fpops_est;

client/work_fetch.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ PROJECT* WORK_FETCH::non_cpu_intensive_project_needing_work() {
657657
return 0;
658658
}
659659

660-
static bool higher_priority(PROJECT *p1, PROJECT *p2) {
660+
static bool higher_priority(const PROJECT *p1, const PROJECT *p2) {
661661
return (p1->sched_priority > p2->sched_priority);
662662
}
663663

@@ -712,15 +712,15 @@ void WORK_FETCH::setup() {
712712
// and from project/resource pairs.
713713
// Must do this after rr_simulation() and compute_nuploading_results()
714714
//
715-
for (unsigned int i=0; i<gstate.projects.size(); i++) {
715+
for (unsigned int i = 0; i < gstate.projects.size(); i++) {
716716
PROJECT* p = gstate.projects[i];
717717
p->pwf.project_reason = compute_project_reason(p);
718-
for (int j=0; j<coprocs.n_rsc; j++) {
718+
for (int j = 0; j < coprocs.n_rsc; j++) {
719719
RSC_PROJECT_WORK_FETCH& rpwf = p->rsc_pwf[j];
720720
rpwf.rsc_project_reason = rpwf.compute_rsc_project_reason(p);
721721
}
722722
}
723-
for (int j=0; j<coprocs.n_rsc; j++) {
723+
for (int j = 0; j < coprocs.n_rsc; j++) {
724724
rsc_work_fetch[j].dont_fetch_reason = RSC_REASON_NONE;
725725
}
726726

@@ -734,11 +734,13 @@ void WORK_FETCH::setup() {
734734
// which will generally be between 0 and 1.
735735
// This is a little arbitrary but I can't think of anything better.
736736
//
737-
double max_queued_flops = gstate.work_buf_total()*total_peak_flops();
738-
for (unsigned int i=0; i<gstate.results.size(); i++) {
739-
RESULT* rp = gstate.results[i];
740-
PROJECT* p = rp->project;
741-
p->sched_priority -= rp->estimated_flops_remaining()/max_queued_flops;
737+
double max_queued_flops = gstate.work_buf_total() * total_peak_flops();
738+
if (max_queued_flops) {
739+
for (unsigned int i = 0; i < gstate.results.size(); i++) {
740+
RESULT* rp = gstate.results[i];
741+
PROJECT* p = rp->project;
742+
p->sched_priority -= rp->estimated_flops_remaining() / max_queued_flops;
743+
}
742744
}
743745

744746
projects_sorted = gstate.projects;

0 commit comments

Comments
 (0)