OpenBLAS: Julia slower than R

This — the default Julia OpenBLAS build is ABI-incompatible with R, so it is impossible to simply move files around to make R use Julia’s BLAS or vice versa.

In particular, even on a 64-bit build, R uses the standard BLAS interface, which uses the 32-bit int type for sizes, which limits you to linear algebra on vectors/matrices with no more than 2³¹–1 elements per dimension. (There is a bigalgebra package for R to work around this limitation.)

In contrast, the OpenBLAS that Julia links to is specially built so that it uses 64-bit integers on 64-bit machines. To avoid accidentally linking this 64-bit BLAS to other libraries that expect a 32-bit interface, Julia’s OpenBLAS renames the symbols in the BLAS and LAPACK libraries. (You can double-check your Julia build by looking at LinearAlgebra.BlasInt, which is Int64 if Julia was built with the 64-bit BLAS interface.)

Because of this, it is impossible for R and the default Julia to share a BLAS. You may think that this is what you did by moving links around, but you are wrong.

The only way to link Julia and R to the same BLAS is to recompile Julia to use a 32-bit BLAS interface (pass USE_BLAS64=0 to make IIRC), and then possibly you need to recompile R as well to make sure it points to the new library.

12 Likes