Skip to content

Commit

Permalink
add debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpanderson committed Oct 3, 2023
1 parent c5226bc commit b7eee0c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
15 changes: 10 additions & 5 deletions client/coproc_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ extern void assign_coprocs(std::vector<RESULT*>& 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) {
Expand All @@ -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; i<cp.count; i++) {
if (gpu_excluded(rp->app, cp, i)) continue;
if (u + cp.usage[i] <= 1) {
Expand All @@ -72,6 +74,7 @@ struct SPORADIC_RESOURCES {
}
return true;
}

// reserve resources for the task
void reserve(ACTIVE_TASK *atp) {
RESULT *rp = atp->result;
Expand All @@ -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; i<cp.count; i++) {
if (gpu_excluded(rp->app, cp, i)) continue;
if (u + cp.usage[i] <= 1) {
Expand All @@ -91,6 +94,8 @@ struct SPORADIC_RESOURCES {
}
}
}

void print();
};

extern SPORADIC_RESOURCES sporadic_resources;
2 changes: 1 addition & 1 deletion client/cpu_sched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ void CLIENT_STATE::make_run_list(vector<RESULT*>& run_list) {
proc_rsc.ncpus -= sporadic_resources.ncpus_used;
for (int rt=1; rt<proc_rsc.pr_coprocs.n_rsc; rt++) {
COPROC& cp = proc_rsc.pr_coprocs.coprocs[rt];
COPROC& cp2 = sporadic_resources.sp_coprocs.coprocs[rt];
COPROC& cp2 = sporadic_resources.sr_coprocs.coprocs[rt];
for (int j=0; j<cp.count; j++) {
cp.usage[j] = cp2.usage[j];
}
Expand Down
20 changes: 20 additions & 0 deletions client/cs_sporadic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@

SPORADIC_RESOURCES sporadic_resources;

void SPORADIC_RESOURCES::print() {
msg_printf(NULL, MSG_INFO, "Sporadic resources:");
msg_printf(NULL, MSG_INFO, " %f CPUs", ncpus_used);
msg_printf(NULL, MSG_INFO, " %f MB RAM", mem_used/MEGA);
for (int i=1; i<sr_coprocs.n_rsc; i++) {
COPROC& cp = sr_coprocs.coprocs[i];
for (int j=0; j<cp.count; j++) {
if (cp.usage[j] > 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) {
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 0 additions & 3 deletions samples/sporadic/sporadic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b7eee0c

Please sign in to comment.