@@ -231,10 +231,13 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
231231 }
232232
233233 bool canScheduleSameProc = false ;
234- if ((schedule.AssignedProcessor (succ) / (p + 1U ) == totalAttempts) & ((schedule.AssignedProcessor (succ) % (p + 1U )) != 0U )) {
235- schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + p);
234+ const unsigned pp1 = p + 1U ;
235+ const unsigned base = pp1 * totalAttempts;
236+ const unsigned remainder = schedule.AssignedProcessor (succ) - base;
237+ if ((remainder < pp1) & (remainder != 0U )) {
238+ schedule.SetAssignedProcessor (succ, base + p);
236239 } else {
237- schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + 0U );
240+ schedule.SetAssignedProcessor (succ, base + 0U );
238241 canScheduleSameProc = true ;
239242 }
240243
@@ -298,10 +301,13 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
298301 }
299302
300303 bool canScheduleSameProc = false ;
301- if ((schedule.AssignedProcessor (succ) / (p + 1U ) == totalAttempts) & ((schedule.AssignedProcessor (succ) % (p + 1U )) != proc)) {
302- schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + p);
304+ const unsigned pp1 = p + 1U ;
305+ const unsigned base = pp1 * totalAttempts;
306+ const unsigned remainder = schedule.AssignedProcessor (succ) - base;
307+ if ((remainder < pp1) & (remainder != proc)) {
308+ schedule.SetAssignedProcessor (succ, base + p);
303309 } else {
304- schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + proc);
310+ schedule.SetAssignedProcessor (succ, base + proc);
305311 canScheduleSameProc = true ;
306312 }
307313
0 commit comments