11#include " FactorHiGHSSolver.h"
22
3+ #include < cstring>
34#include < limits>
45
56#include " HighsExternalApi.h"
@@ -572,6 +573,10 @@ Int FactorHiGHSSolver::setNla() {
572573 return kStatusOk ;
573574}
574575
576+ static bool usingAppleBlas () {
577+ return strstr (HighsExtras::blas::getInfo ()->provider , " Apple" ) != nullptr ;
578+ }
579+
575580void FactorHiGHSSolver::setParallel () {
576581 // Set parallel options
577582 bool parallel_tree = false ;
@@ -597,35 +602,35 @@ void FactorHiGHSSolver::setParallel() {
597602 assert (1 == 0 );
598603
599604 } else if (options_.parallel == kHighsChooseString ) {
600- #ifdef HIPO_USES_APPLE_BLAS
601- // Blas on Apple do not work well with parallel_node, but parallel_tree
602- // seems to always be beneficial.
603- parallel_node = false ;
604- parallel_tree = true ;
605- #else
606- // Otherwise, parallel_node is active because it is triggered only if the
607- // frontal matrix is large enough anyway.
608- parallel_node = true ;
609-
610- // parallel_tree instead is chosen with a heuristic
611-
612- double tree_speedup = S_ .flops () / S_ .critops ();
613- double sn_size = (double )S_ .size () / S_ .sn ();
614-
615- bool enough_sn = S_ .sn () > kMinNumberSn ;
616- bool enough_flops = S_ .flops () > kLargeFlopsThresh ;
617- bool speedup_is_large = tree_speedup > kLargeSpeedupThresh ;
618- bool sn_are_large = sn_size > kLargeSnThresh ;
619- bool sn_are_not_small = sn_size > kSmallSnThresh ;
620-
621- // parallel_tree is active if the supernodes are large, or if there is a
622- // large expected speedup and the supernodes are not too small, provided
623- // that the number of flops and supernodes is not too small.
624- if (enough_sn && enough_flops &&
625- (sn_are_large || (speedup_is_large && sn_are_not_small))) {
605+ if (usingAppleBlas ()) {
606+ // Blas on Apple do not work well with parallel_node, but parallel_tree
607+ // seems to always be beneficial.
608+ parallel_node = false ;
626609 parallel_tree = true ;
610+ } else {
611+ // Otherwise, parallel_node is active because it is triggered only if the
612+ // frontal matrix is large enough anyway.
613+ parallel_node = true ;
614+
615+ // parallel_tree instead is chosen with a heuristic
616+
617+ double tree_speedup = S_ .flops () / S_ .critops ();
618+ double sn_size = (double )S_ .size () / S_ .sn ();
619+
620+ bool enough_sn = S_ .sn () > kMinNumberSn ;
621+ bool enough_flops = S_ .flops () > kLargeFlopsThresh ;
622+ bool speedup_is_large = tree_speedup > kLargeSpeedupThresh ;
623+ bool sn_are_large = sn_size > kLargeSnThresh ;
624+ bool sn_are_not_small = sn_size > kSmallSnThresh ;
625+
626+ // parallel_tree is active if the supernodes are large, or if there is a
627+ // large expected speedup and the supernodes are not too small, provided
628+ // that the number of flops and supernodes is not too small.
629+ if (enough_sn && enough_flops &&
630+ (sn_are_large || (speedup_is_large && sn_are_not_small))) {
631+ parallel_tree = true ;
632+ }
627633 }
628- #endif
629634
630635 // If serial memory is too large, switch off tree parallelism to avoid
631636 // running out of memory
0 commit comments