Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgemv is not thread safe #477

Closed
susilehtola opened this issue Dec 18, 2014 · 8 comments
Closed

dgemv is not thread safe #477

susilehtola opened this issue Dec 18, 2014 · 8 comments

Comments

@susilehtola
Copy link
Contributor

I found out to my surprise that OpenBLAS is not thread safe.

Running in parallel with OpenMP, each thread running an eigenvalue decomposition of the same matrix yields a different result than running the decomposition in sequential mode.

@susilehtola
Copy link
Contributor Author

A test program is available at http://theory.physics.helsinki.fi/~jzlehtol/lapack_test.tar.gz

Compile with
$ g++ lapack_test.cpp -fopenmp $OPENBLAS_LIBRARY

@wernsaar
Copy link
Contributor

Hi,

How did you cpmpiled OpenBLAS?
I you use threads in the calling program, you should use a sinbled threaded
OpenBLAS library. You also shoud use the Gfortran flag -frecursive for
lapack and you should
increase your stack size limit.

Best regards
Werner

On 12/18/2014 08:39 AM, Susi Lehtola wrote:

I found out to my surprise that OpenBLAS is not thread safe.

Running in parallel with OpenMP, each thread running an eigenvalue
decomposition of the same matrix yields a different result than
running the decomposition in sequential mode.


Reply to this email directly or view it on GitHub
#477.

@susilehtola
Copy link
Contributor Author

Thanks for the hint! The problem was in LAPACK.

@Fulguritus
Copy link

@susilehtola Could you elaborate on that? How did you solve the problem?

@susilehtola
Copy link
Contributor Author

Fulguritus: by adding -frecursive to the LAPACK compilation flags.

Pushing fixed Fedora packages soon.

@IvanUkhov
Copy link
Contributor

IvanUkhov commented May 29, 2016

@susilehtola, may I ask if what you did was only uncommenting this line. Was there anything else? What puzzles me a mite is that you experienced this problem when calling dgemv, but this routine belongs to BLAS, not LAPACK. Probably that flag affects both then as LAPACK relies on BLAS internally.

@susilehtola
Copy link
Contributor Author

@IvanUkhov IIRC the only change I did was adding the -frecursive flag to the Fedora netlib BLAS/LAPACK package, after which OpenBLAS worked as its supposed to.

But this was 1.5 years ago, and the Fedora package has changed since then due to changed guidelines. Now the packages are always built with -frecursive enabled.

BTW the comment "enable this flag only on 64bit Linux and if you need a thread safe lapack library" is rather misguiding: the -frecursive flag isn't exclusive to 64-bit, it's necessary on all architectures to make the library thread safe.

@IvanUkhov
Copy link
Contributor

@susilehtola, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants