Is armadillo solve() thread safe?

前端 未结 2 721
清歌不尽
清歌不尽 2021-02-06 20:04

In my code I have loop in which I construct and over determined linear system and try to solve it:

#pragma omp parallel for
for (int i = 0; i < n[0]+1; i++) {         


        
相关标签:
2条回答
  • 2021-02-06 20:29

    The thread safety of Armadillo's solve() function depends (only) on the BLAS library that you use. The LAPACK implementations are thread safe when BLAS is. The Armadillo solve() function is not thread safe when linking to the reference BLAS library. However, it is thread safe when using OpenBLAS. Additionally, ATLAS provides a BLAS implementation that also mentions it is thread safe, and the Intel MKL is thread safe as well, but I have no experience with Armadillo linked to those libraries.

    Of course, this only applies when you run solve() from multiple threads with different data.

    0 讨论(0)
  • 2021-02-06 20:34

    Are you sure your systems are over determined? solve_ud in your stack trace says otherwise. Though you have solve_od too, and probably that's nothing to do with the issue. But it doesn't hurt to find why that's happening and fix it if you think the systems should be od.

    Is armadillo solve() thread safe?

    That I think depends on your lapack version, also see this. Looking at the code of solve_od all the variables accessed seem to be local. Note the warning in the code:

    NOTE: the dgels() function in the lapack library supplied by ATLAS 3.6 seems to have problems

    Thus it seems only lapack::gels can cause trouble for you. If fixing lapack is not possible, a workaround is to stack your systems and solve a single large system. That probably would be even more efficient if your individual systems are small.

    0 讨论(0)
提交回复
热议问题