diff --git a/client/coproc_sched.h b/client/coproc_sched.h index 6f3ae8852d0..d15a7ca54a3 100644 --- a/client/coproc_sched.h +++ b/client/coproc_sched.h @@ -33,19 +33,21 @@ extern void assign_coprocs(std::vector& jobs); struct SPORADIC_RESOURCES { double ncpus_used, ncpus_max; double mem_used, mem_max; - COPROCS sp_coprocs; + COPROCS sr_coprocs; // clear reservations; called on each poll void init_poll() { ncpus_used= 0; mem_used = 0; - sp_coprocs.clear_usage(); + sr_coprocs.clear_usage(); } + // called once at start void init() { - sp_coprocs.clone(coprocs, false); + sr_coprocs.clone(coprocs, false); init_poll(); } + // are there enough free resources to run the task? bool enough(ACTIVE_TASK *atp) { if (mem_used + atp->procinfo.working_set_size_smoothed > mem_max) { @@ -60,7 +62,7 @@ struct SPORADIC_RESOURCES { bool found = false; if (rt) { double u = avp->gpu_usage.usage; - COPROC& cp = sp_coprocs.coprocs[rt]; + COPROC& cp = sr_coprocs.coprocs[rt]; for (int i=0; iapp, cp, i)) continue; if (u + cp.usage[i] <= 1) { @@ -72,6 +74,7 @@ struct SPORADIC_RESOURCES { } return true; } + // reserve resources for the task void reserve(ACTIVE_TASK *atp) { RESULT *rp = atp->result; @@ -81,7 +84,7 @@ struct SPORADIC_RESOURCES { int rt = avp->gpu_usage.rsc_type; if (rt) { double u = avp->gpu_usage.usage; - COPROC& cp = sp_coprocs.coprocs[rt]; + COPROC& cp = sr_coprocs.coprocs[rt]; for (int i=0; iapp, cp, i)) continue; if (u + cp.usage[i] <= 1) { @@ -91,6 +94,8 @@ struct SPORADIC_RESOURCES { } } } + + void print(); }; extern SPORADIC_RESOURCES sporadic_resources; diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index 5a57a8cf291..d844cda29ef 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -889,7 +889,7 @@ void CLIENT_STATE::make_run_list(vector& run_list) { proc_rsc.ncpus -= sporadic_resources.ncpus_used; for (int rt=1; rt 0) { + msg_printf(NULL, MSG_INFO, " GPU %s instance %d: %f\n", + cp.type, j, cp.usage[j] + ); + } + } + } +} + // is computing suspended for this job? // static bool computing_suspended(ACTIVE_TASK *atp) { @@ -218,6 +234,10 @@ void CLIENT_STATE::sporadic_poll() { if (changed_active) { request_schedule_cpus("sporadic apps changed state"); } + + if (log_flags.sporadic_debug) { + sporadic_resources.print(); + } } void CLIENT_STATE::sporadic_init() { diff --git a/samples/sporadic/sporadic.cpp b/samples/sporadic/sporadic.cpp index 9f2b952af21..294fc22a0e3 100644 --- a/samples/sporadic/sporadic.cpp +++ b/samples/sporadic/sporadic.cpp @@ -20,9 +20,6 @@ void boinc_sporadic_set_ac_state(SPORADIC_AC_STATE); SPORADIC_CA_STATE boinc_sporadic_get_ca_state(); -void print_state() { -} - void compute_one_sec() { double start = dtime(); while (1) {