Skip to content

Build openBLAS with oneTBB parallelism support #4066

Closed

Description

@vineel96

Hello,
I have following doubts:

  1. how to build openBLAS with oneTBB parallelism support instead of openmp?
  2. which combination is better to build openBLAS with? openBLAS +openMP or openBLAS +oneTBB or openBLAS+pthreads?

Activity

  1. changed the title [-]Build openblas with oneTBB parallelism support[/-] [+]Build openBLAS with oneTBB parallelism support[/+] on May 28, 2023
  2. martin-frbg commented on May 28, 2023

    @martin-frbg
    Collaborator

    There is currently no support for TBB in OpenBLAS, what people appear to be doing (with varying success if you search for earlier issues mentioning TBB) is use a single-threaded build of OpenBLAS with their TBB-parallelized program.
    The choice of pthreads or OpenMP depends largely on what your main program uses. At least in theory, OpenMP would offer better thread safety and easier thread affinity handling, but may incur some overhead. On many/most platforms, OpenMP is implemented on top of pthreads anyway, and if your main
    program uses OpenMP you will want OpenBLAS to be either built with OpenMP, or built-single threaded, to avoid having to sets of threads that do not know of each other and compete for resources.

  3. vineel96 commented on May 29, 2023

    @vineel96
    Author

    Hi @martin-frbg ,
    Thanks for the reply.

    1. is there a way to modify makefile to build openBLAS with oneTBB similar to how openmp is given as option while building openBLAS? or only way is manually write oneTBB based code and use single threaded openBLAS?
    2. I am trying to build openBLAS with oneTBB so that it is algorithm/code independent. which means whatever algorithm that runs on top of openBLAS should make use of oneTBB without actually modifying the algorithm. is this right way to try? and can we see any performance gain by doing this?
  4. martin-frbg commented on May 29, 2023

    @martin-frbg
    Collaborator

    there is currently no support for this - only an unfinished concept from four years ago in PR #2255

  5. brada4 commented on May 30, 2023

    @brada4
    Contributor

    1/ TBB equivalents of OMP PARALLEL pragmas
    2/ TBB mutexes
    3/ TBB malloc in place of current sbrk/mmap allocator

  6. vineel96 commented on Aug 4, 2023

    @vineel96
    Author

    Hi @martin-frbg and @brada4,
    Thanks for the comments. I have some questions:

    1. The file changes that are proposed in WIP: allow threading backend to be replaced by caller #2255 pull request isnt enough to merge it to openblas? Why its not merged or further taken to implement if any if it boosts performance?
    2. Also, can you suggest any room for improvement in openblas in threading part which helps improve parallelism and improve speed? Like any Gsoc project on this or i want to know if there is any scope in improving the threading part?
    3. Im intended to improve the threading performance w.r.t scikit learn library which uses openblas. So any ideas/leads regarding improving threading and parallelism part of scikit learn library?
  7. martin-frbg commented on Aug 4, 2023

    @martin-frbg
    Collaborator
    1. The PR has a list of unfinished tasks at the top, I'd like to see at least the pthreads backend changes implemented (and some testing, of course). Some people expressed interest in the changes, but nobody got around to actually doing anything, not even during the time when it could trivially be merged into a local checkout for testing. (And even now I expect the merge conflicts that are currently flagged by git can easily be resolved again - it is just that I did not get around to that yet).
    2. No Gsoc project, and probably nobody with the time to provide the associated mentoring, just plans and ongoing wkr to identify any remaining bottlenecks e.g. from excessive locking or use of too many threads for a given task. OpenBLAS does not have a big team of developers behind it, and never had.
    3. I'm not familiar with scikit learn, but I suspect it is using BLAS functions through NumPy. It would probably help to know which BLAS functions are involved, the "typical" matrix sizes in what people use scikit-learn for, and to get some
      fair comparison figures for OpenBLAS vs some other library on the same kind of hardware. So far there has only been Sklearn Performance on ARM NeoverseN1 #3925 which is basically "MKL on high-performance hardware is faster than OpenBLAS on low-performance hardware" with no data that would allow reproducing the reported problem.
  8. vineel96 commented on Aug 29, 2023

    @vineel96
    Author

    Hello @martin-frbg,
    Very much thanks for the replies and suggestions.
    3. As of now scikit-learn is using gemm() function from scipy.linalg.cython_blas , mainly for matrix multiplication(eg kmeans). According to you, by knowing the sizes of mostly used matrices, this info will be usefull in optimizing algorithm further?
    4. Another doubt: Is this PR (#2255) is equivalent to building openBLAS with no threading support at all? Like building openBLAS without pthreads and openmp?
    5. Also is it possible to build openBLAS no threaded version i.e build openBLAS from source without pthreads and without openmp? if yes what is the instructions/methods to build it?

  9. brada4 commented on Aug 29, 2023

    @brada4
    Contributor

    Open a new issue since it is not related to TBB.
    Documentation is in Makefile.rule - USE_THREAD=0 USE_LOCKING=1

  10. vineel96 commented on Sep 4, 2023

    @vineel96
    Author

    Hi @brada4,
    Thank you for the reply.

  11. martin-frbg commented on Apr 22, 2024

    @martin-frbg
    Collaborator

    now fixed by #4577

  12. ogrisel commented on Oct 17, 2025

    @ogrisel
    Contributor

    @vineel96 @martin-frbg @brada4 do you know of any attempt to leverage #4577 to leverage TBB for OpenBLAS parallelism?

  13. martin-frbg commented on Oct 17, 2025

    @martin-frbg
    Collaborator

    Sadly I never got around to doing more than the bare minimum of testing that this would not break anything. My understanding is that it would tie into the thread setup of an existing TBB-using application and effectively redirect
    from OpenBLAS' central exec_blas() call to an equivalent TBB handler.
    I'm also not aware of anyone actually using this in third-party projects yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions