Skip to content

OpenBLAS test num threads update - #3402

Merged
galabovaa merged 5 commits into
latestfrom
openblas-test-threads
Oct 27, 2026
Merged

galabovaa merged 5 commits into
latestfrom
openblas-test-threads

Conversation

@galabovaa

Copy link
Copy Markdown
Contributor

Description

Follow-up to #3293, incorporating the review discussion there.

What the code here introduces, largely following the previous PR:

  • Check that OpenBLAS actually runs in serial

Before solving, HiPO sets the number of OpenBLAS threads to 1. Previously this was a silent no-op if the build was misconfigured: if HiGHS was linked against OpenBLAS but HIPO_USES_OPENBLAS was not defined, the call did nothing and OpenBLAS ran multi-threaded, which slows HiPO down considerably.

Now highs_openblas_set_num_threads returns the number of threads OpenBLAS reports after the call (-1 if HiGHS was built without OpenBLAS support). Before solving, HiPO checks this against the BLAS provider reported in the build metadata: if the provider is OpenBLAS but the thread count is not 1, HiPO logs an error and returns kSolveError instead of running slowly without warning. Calling it with 0 or less just returns the current number of threads without changing it (used by the tests).

This check is skipped when hipo_serial_blas is false (see below).

  • Detect OpenBLAS from BLAS_LIBRARIES

If the library name contains "openblas", the BLAS metadata is set to OpenBLAS, so HIPO_USES_OPENBLAS is defined.

  • Opt-out

New option hipo_serial_blas (default true). The number of OpenBLAS threads is process-wide, so users running other OpenBLAS work in the same process can set it to false. HiPO then neither changes the number of OpenBLAS threads nor checks it.

  • Thread safety

Calls are serialised with a mutex, and openblas_set_num_threads is only called when the thread count actually needs to change, so concurrent HiGHS instances don't reconfigure OpenBLAS while another is running BLAS routines.

  • Provider checks

Added a portable, case-insensitive is_substring_case to stringutil.h, used for the OpenBLAS and Apple Accelerate checks.

  • Docs

New "BLAS threads" section in [parallel.md](http://parallel.md/), the option definition, and notes in the installation, Python and Julia pages.

  • libblastrampoline

HiGHS.jl uses libblastrampoline, so HiPO does not change the number of BLAS threads there. We should probably document on the JuMP side that users should call BLAS.set_num_threads(1) to get the best performance out of HiPO, noting that this applies to the whole Julia session, so it may slow down other code that relies on parallel BLAS. cc @odow

  • Tests

Unit tests for is_substring_case and the OpenBLAS thread wrapper, and a HiPO test checking that OpenBLAS runs in serial by default and is left alone when hipo_serial_blas is false.

Checklist

  • I have read the contributing guidelines
  • This PR targets the latest branch
  • Tests are passing
  • Documentation was updated where relevant
  • This PR is not primarily AI-generated (per the AI contributions policy in CONTRIBUTING.md)

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.06122% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.19%. Comparing base (b0f37ed) to head (d76287b).
⚠️ Report is 1 commits behind head on latest.

Files with missing lines Patch % Lines
highs/ipm/IpxWrapper.cpp 0.00% 10 Missing ⚠️
check/TestHighsExternalDeps.cpp 59.09% 9 Missing ⚠️
extern/HighsExtrasExternalDeps.h 0.00% 2 Missing ⚠️
highs/ipm/hipo/ipm/FactorHighsSolver.cpp 0.00% 1 Missing ⚠️
highs/lp_data/HighsOptions.h 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           latest    #3402      +/-   ##
==========================================
- Coverage   75.19%   75.19%   -0.01%     
==========================================
  Files         460      460              
  Lines      112421   112464      +43     
  Branches    17826    17828       +2     
==========================================
+ Hits        84540    84569      +29     
- Misses      27599    27613      +14     
  Partials      282      282              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@galabovaa
galabovaa marked this pull request as draft October 12, 2026 17:03
@galabovaa
galabovaa force-pushed the openblas-test-threads branch from e8e508b to 601a87c Compare October 12, 2026 17:14
@filikat

filikat commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks Ivet, this looks great.
The only thing I would notice is that we are claiming multiple times in the documentation that HiPO runs better when BLAS is serial. This is definitely true for OpenBLAS, but I don't know if it's true for other BLAS libraries, like MKL.

@galabovaa
galabovaa marked this pull request as ready for review October 22, 2026 13:06
@galabovaa

Copy link
Copy Markdown
Contributor Author

@filikat I updates the sections to specify OpenBLAS. Would you please have another look? Thank you!

@galabovaa
galabovaa merged commit 399f1c0 into latest Oct 27, 2026
569 of 572 checks passed
@galabovaa
galabovaa deleted the openblas-test-threads branch October 28, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants