@@ -164,6 +164,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
164164 double desiredParallelism = static_cast <double >(p);
165165
166166 VertexType totalAssigned = 0 ;
167+ unsigned totalAttempts = 1U ;
167168 supstep = 0 ;
168169
169170 while (totalAssigned < n) {
@@ -177,6 +178,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
177178 bool continueSuperstepAttempts = true ;
178179
179180 while (continueSuperstepAttempts) {
181+ assert (totalAttempts < (UINT_MAX / (p + 1U )));
180182 for (unsigned proc = 0 ; proc < p; proc++) {
181183 newAssignments[proc].clear ();
182184 }
@@ -228,10 +230,12 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
228230 }
229231 }
230232
231- if (schedule.AssignedProcessor (succ) == UINT_MAX) {
232- schedule.SetAssignedProcessor (succ, 0 );
233- } else if (schedule.AssignedProcessor (succ) != 0 ) {
234- schedule.SetAssignedProcessor (succ, p);
233+ 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);
236+ } else {
237+ schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + 0U );
238+ canScheduleSameProc = true ;
235239 }
236240
237241 VertexType succIndex;
@@ -243,7 +247,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
243247
244248 --predec[succIndex];
245249 if (predec[succIndex] == 0 ) {
246- if (schedule. AssignedProcessor (succ) == 0 ) {
250+ if (canScheduleSameProc ) {
247251 procReady[0 ].emplace_back (succ);
248252 std::push_heap (procReady[0 ].begin (), procReady[0 ].end (), std::greater<>{});
249253 } else {
@@ -293,10 +297,12 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
293297 }
294298 }
295299
296- if (schedule.AssignedProcessor (succ) == UINT_MAX) {
297- schedule.SetAssignedProcessor (succ, proc);
298- } else if (schedule.AssignedProcessor (succ) != proc) {
299- schedule.SetAssignedProcessor (succ, p);
300+ 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);
303+ } else {
304+ schedule.SetAssignedProcessor (succ, totalAttempts * (p + 1U ) + proc);
305+ canScheduleSameProc = true ;
300306 }
301307
302308 VertexType succIndex;
@@ -308,7 +314,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
308314
309315 --predec[succIndex];
310316 if (predec[succIndex] == 0 ) {
311- if (schedule. AssignedProcessor (succ) == proc ) {
317+ if (canScheduleSameProc ) {
312318 procReady[proc].emplace_back (succ);
313319 std::push_heap (procReady[proc].begin (), procReady[proc].end (), std::greater<>{});
314320 } else {
@@ -362,31 +368,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
362368 continueSuperstepAttempts = false ;
363369 }
364370
365- // undo proc assingments and predec increases in any case
366- for (unsigned proc = 0 ; proc < p; ++proc) {
367- for (const VertexType &node : newAssignments[proc]) {
368- for (const VertexType &succ : graph.Children (node)) {
369- if constexpr (hasVerticesInTopOrderV<GraphT>) {
370- if constexpr (hasChildrenInVertexOrderV<GraphT>) {
371- if (succ >= endNode) {
372- break ;
373- }
374- } else {
375- if (succ >= endNode) {
376- continue ;
377- }
378- }
379- } else {
380- if (posInTopOrder[succ] >= endNode) {
381- continue ;
382- }
383- }
384-
385- schedule.SetAssignedProcessor (succ, UINT_MAX);
386- }
387- }
388- }
389-
371+ // undo predec increases in any case
390372 for (unsigned proc = 0 ; proc < p; ++proc) {
391373 for (const VertexType &node : newAssignments[proc]) {
392374 for (const VertexType &succ : graph.Children (node)) {
@@ -427,6 +409,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
427409
428410 limit++;
429411 limit += (limit / 2 );
412+ ++totalAttempts;
430413 }
431414
432415 // apply best iteration
@@ -519,9 +502,7 @@ class GrowLocalAutoCoresParallel : public Scheduler<GraphT> {
519502
520503 const VertexType n = instance.NumberOfVertices ();
521504
522- for (VertexType vert = 0 ; vert < n; ++vert) {
523- schedule.SetAssignedProcessor (vert, UINT_MAX);
524- }
505+ schedule.SetAssignedProcessors (std::vector<unsigned >(n, 0U ));
525506
526507 VertexType numNodesPerThread = n / numThreads;
527508 std::vector<VertexType> startNodes;
0 commit comments