From 0367669a1e58cac0555f274f5325f975f6f1d6f7 Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Wed, 31 Aug 2016 18:10:54 +0100 Subject: [PATCH] Stop integer overflow in do_sub test and make sure no particles are considered as a no-op not a trigger. Fix a trivial scaling bug in the task weights (could also overflow) --- src/scheduler.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index f121f21d57..0d50a4e7af 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -152,8 +152,9 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { if (ci->split) { /* Make a sub? */ - if (scheduler_dosub && (ci->count * ci->count < space_subsize || - ci->gcount * ci->gcount < space_subsize)) { + if (scheduler_dosub && + ((ci->count > 0 && ci->count < space_subsize / ci->count) || + (ci->gcount > 0 && ci->gcount < space_subsize / ci->gcount))) { /* convert to a self-subtask. */ t->type = task_type_sub_self; @@ -917,7 +918,7 @@ void scheduler_reweight(struct scheduler *s) { (sizeof(int) * 8 - intrinsics_clz(t->ci->count)); break; case task_type_self: - t->weight += 1 * t->ci->count * t->ci->count; + t->weight += 1 * wscale * t->ci->count * t->ci->count; break; case task_type_pair: if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) @@ -962,7 +963,7 @@ void scheduler_reweight(struct scheduler *s) { // clocks_from_ticks( getticks() - tic ), clocks_getunit()); /* int min = tasks[0].weight, max = tasks[0].weight; - for ( k = 1 ; k < nr_tasks ; k++ ) + for ( int k = 1 ; k < nr_tasks ; k++ ) if ( tasks[k].weight < min ) min = tasks[k].weight; else if ( tasks[k].weight > max ) -- GitLab