# OpenBLAS: Julia slower than R

**URL:** <https://discourse.julialang.org/t/openblas-julia-slower-than-r/21594>\
**Category:** Performance\
**Tags:** linearalgebra\
**Created:** [March 7, 2019, 7:18pm UTC](https://discourse.julialang.org/t/openblas-julia-slower-than-r/21594 "2019-03-07T19:18:17Z")\
**Posts on this page:** 1\
**Showing post:** 31

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 15, 2019, 12:06pm UTC](https://discourse.julialang.org/t/openblas-julia-slower-than-r/21594/31 "2019-03-15T12:06:50Z")

</div>

> [@Elrod](#):
>
> Also, I thought R uses 32 bit BLAS while Julia uses 64. Does swapping sym links really work?

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](https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/include/R_ext/BLAS.h) 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](https://rdrr.io/cran/bigalgebra/man/bigalgebra-package.html) 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](https://github.com/JuliaLang/julia/issues/4923). (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.

---

_[View the full topic](https://discourse.julialang.org/t/openblas-julia-slower-than-r/21594)._
