# OpenBLAS much slower on Windows than Linux

**URL:** <https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562>\
**Category:** Performance\
**Tags:** windows, blas, linearalgebra, openblas\
**Created:** [July 20, 2022, 11:40pm UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562 "2022-07-20T23:40:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [July 20, 2022, 11:40pm UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562/1 "2022-07-20T23:40:27Z")

</div>

This is a continuation of a discussion in issues [159](https://github.com/SciML/LinearSolve.jl/issues/159) and [166](https://github.com/SciML/LinearSolve.jl/issues/166) of [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl).

I have two computers with similar, 8-core i7-9700 CPUs, one of which runs Windows and the other Manjaro Linux. I ran the [benchmark script](https://github.com/JuliaLinearAlgebra/RecursiveFactorization.jl/blob/master/perf/lu.jl) (after implementing [this](https://github.com/JuliaLinearAlgebra/RecursiveFactorization.jl/pull/53) PR), which measures the speed of LU factorizations on a `Float64` square matrix of order in the range `4:8:500` using 8 threads. The results for OpenBLAS under Windows are abysmally worse than under Linux. Plots are shown below, where the blue trace is the OpenBLAS result. First the Linux result:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/b/eb2b786eb8e0310aeb397415d9e892cfc9bb2f3f.png)  
and now the Windows result:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/a/facfa0447e8e5fba3ff3d09213015ebf6842c792.png)

On Linux OpenBLAS computes the factorization for a matrix of order 500 at a rate of about 110 GFLOPS, but on Windows, it tops out at less than 40.

My questions: Is this an expected result? Why is the performance of OpenBLAS, the default library used for Julia BLAS, so much worse on Windows than on Linux?

Note, you can find more plots, for MKL, and for using only a single thread, on the above-linked issues.

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [July 22, 2022, 10:06pm UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562/2 "2022-07-22T22:06:33Z")

</div>

> [@PeterSimon](#):
>
> The results for OpenBLAS under Windows are abysmally worse than under Linux.

based on another thread as I see you are using Julia 1.7.3

> julia\> versioninfo(verbose=true)  
> Julia Version 1.7.3

As [I see Julia 1.7.3](https://github.com/JuliaLang/julia/blob/v1.7.3/deps/openblas.version) - has `OPENBLAS_BRANCH=v0.3.13`

And check the OpenBlas Changelog.txt:

- Latest release: `Version 0.3.20` date=`20-Feb-2022`  
[https://github.com/xianyi/OpenBLAS/blob/develop/Changelog.txt](https://github.com/xianyi/OpenBLAS/blob/develop/Changelog.txt)

Version 0.3.19: 19-Dec-2021

- x86\_64:
  - fixed missing thread initialization for static builds on Windows/MSVC

Version 0.3.14: 17-Mar-2021

- x86\_64:
  - Fixed compilation for DYNAMIC\_ARCH with clang on Windows
  - Added support for running the BLAS/CBLAS tests on Windows
  - Fixed signatures of the tls callback functions for Windows x64

IMHO:  
This is just a theory, but I think the first thing to do is to upgrade the ~ old OpenBlas … and see the result again. Maybe the results are better with the new version.

IMHO: interesting … windows OpenBlas has some limitations with AVX-512  
( `julia-buildbot/master/inventory.py` )

```julia
       # OpenBLAS can't deal with avx512 on windows for some reason.
        flags += "OPENBLAS_NO_AVX512=1 "

```

( [source](https://github.com/JuliaCI/julia-buildbot/blob/16890ab559a27c15d133d36f5f9ac294dee7b811/master/inventory.py#L74_L75) )  
( But probably this is not related to your config )

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [July 22, 2022, 11:13pm UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562/3 "2022-07-22T23:13:51Z")

</div>

Thanks for looking into this. Following your suggestion, I installed Julia 1.8.0-rc3, which [has](https://github.com/JuliaLang/julia/blob/v1.8.0-rc3/deps/openblas.version) OPENBLAS\_BRANCH=v0.3.20 . I then reran the script with 8 threads enabled under Windows with the following result:

 ![windows_lu_float64_1.8.0-rc3_skylake_8cores_OpenBLAS](https://global.discourse-cdn.com/julialang/original/3X/2/c/2c417e7df7609e2334aa7e0daa07c0effdb8ec76.png)  
The OpenBLAS result is still very poor.

When I started Julia with only a single thread (which causes the script to set `BLAS.set_num_threads(1)`), OpenBLAS performed somewhat better:

 ![windows_lu_float64_1.8.0-rc3_skylake_1cores_OpenBLAS](https://global.discourse-cdn.com/julialang/original/3X/d/4/d4c219be0755688d2b08cecaa7a9dde37ac4d06a.png)

Still, both results with Julia 1.8-rc3 on Windows are significantly worse than Julia 1.7.3 on Linux.

---

<div class="post-metadata">

**Author:** ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)\
**Post date:** [July 22, 2022, 11:39pm UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562/4 "2022-07-22T23:39:17Z")

</div>

As I see OpenBlas has an Internal benchmark  
[https://github.com/xianyi/OpenBLAS/tree/develop/benchmark/scripts](https://github.com/xianyi/OpenBLAS/tree/develop/benchmark/scripts)

And if one of the internal benchmarks could replicate the similar Linux-vs-Windows mismatch, it would clearly show that it is purely an OpenBlas problem ( and then it could be reported )

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [July 23, 2022, 1:09am UTC](https://discourse.julialang.org/t/openblas-much-slower-on-windows-than-linux/84562/5 "2022-07-23T01:09:21Z")

</div>

Here is the result of running the Octave benchmark for Octave version 7.1.0 on Windows and Linux with `From 4 To 500 Step=8 Loops=100`:  
 ![benchmark_plot](https://global.discourse-cdn.com/julialang/original/3X/3/1/3155be6f3ace1884de8b2433130140ee423d8681.png)
