OpenMathLib / OpenMathLib/OpenBLAS

The performance of the OpenBlas library decreases when running in multi-threaded environments

Open
#5,469 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
7.6k
Forks
1.7k
Avg merge
1d 3h
Merged PRs (30d)
42

Description

hello,
C++programs run on Ubuntu 24.04 using the OpenBlas library. The function execution time is less than 1ms on a single thread, but it increases several times on multiple threads, and the system call time also increases.
The openblas library is installed using the apt tool, and the default settings are as follows:
OpenBLAS 0.3.26 NO_LAPACKE DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64

The single thread time is less than 1ms, and opening 8 threads can achieve a maximum of 10ms and a minimum of about 1ms.
The thread function contains a loop traversal operation. Delete the following line of code, and the multi-threaded performance is similar to that of a single thread.
arma::cx_mat pmusic = ss * nnn_md * ss.ht();
Among them, nnn_md is a complex matrix of 15 * 15,ss is a complex matrix 1*15
then,how to solve the problem of multi-threaded performance degradation?
int main()
{
openblas_set_num_threads(1);
int current_threads = openblas_get_num_threads();
printf("current thread num is %d\n", current_threads);
for (int i = 0; i < 1;++i)
{
std::thread t1(processfunction);
t1.detach();
}
while (1)
{
}
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied C++ example on Ubuntu 24.04 with OpenBLAS 0.3.26, including the complex matrix expression and the reported thread settings. Compare single-thread and multi-thread timings and system-call time; done means identifying the cause of the degradation or documenting the conditions and configuration needed to avoid it.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.