@@ -330,6 +330,14 @@ void Factorise::processSupernodes(Int start, Int end) {
330330 }
331331}
332332
333+ void Factorise::processSmallSubtrees (Int i, Int j) {
334+ for (Int tree = i; tree < j; ++tree) {
335+ Int start = S_ .smallSubtreeInfo (tree).start ;
336+ Int end = S_ .smallSubtreeInfo (tree).end ;
337+ processSupernodes (start, end);
338+ }
339+ }
340+
333341bool Factorise::run (Numeric& num) {
334342#if HIPO_TIMING_LEVEL >= 1
335343 Clock clock;
@@ -354,16 +362,36 @@ bool Factorise::run(Numeric& num) {
354362 highs::parallel::spawn ([=]() { processSupernodes (start, end); });
355363 }
356364
357- // wait for subtrees in the layer to complete
358- for (Int i = 0 ; i < S_ .layerIndex ().size (); ++i) {
359- highs::parallel::sync ();
360- }
361-
362365 // process small subtrees
366+ // They are grouped together and spawned when a group has more than 5% of
367+ // total operations
368+ Int small_start{};
369+ double small_ops_current{};
370+ Int small_spawned{};
363371 for (Int i = 0 ; i < S_ .smallSubtrees ().size (); ++i) {
364- Int start = S_ .smallSubtreeInfo (i).start ;
365- Int end = S_ .smallSubtreeInfo (i).end ;
366- processSupernodes (start, end);
372+ small_ops_current += S_ .smallSubtreeInfo (i).ops_fraction ;
373+
374+ if (small_ops_current > 0.05 ) {
375+ // spawn start to current
376+ highs::parallel::spawn (
377+ [=]() { processSmallSubtrees (small_start, i + 1 ); });
378+
379+ small_start = i + 1 ;
380+ small_ops_current = 0.0 ;
381+ ++small_spawned;
382+ }
383+ }
384+ if (small_ops_current > 0 ) {
385+ // spawn start to end
386+ ++small_spawned;
387+ highs::parallel::spawn ([=]() {
388+ processSmallSubtrees (small_start, S_ .smallSubtrees ().size ());
389+ });
390+ }
391+
392+ // wait for subtrees to complete
393+ for (Int i = 0 ; i < S_ .layerIndex ().size () + small_spawned; ++i) {
394+ highs::parallel::sync ();
367395 }
368396
369397 // process nodes above layer
0 commit comments