# Show off Julia performance on your PC!

**URL:** <https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606>\
**Category:** Performance\
**Created:** [January 21, 2020, 1:59am UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606 "2020-01-21T01:59:32Z")\
**Posts on this page:** 14\
**Page:** 3

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [April 17, 2020, 1:23pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/41 "2020-04-17T13:23:01Z")

</div>

Here’s mine:

```julia
julia> @time peakflops(16_000)
 27.067492 seconds (16 allocations: 3.815 GiB, 1.28% gc time)
3.140591528004417e11

```

I also checked out AcuteBenchmarks which is awesome. I ran the first example and got this:

 ![bench-dims-set1](https://global.discourse-cdn.com/julialang/original/3X/2/1/21fe1600261090bc32e99f3f59e183a3b2b8714f.png)

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [April 17, 2020, 1:32pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/42 "2020-04-17T13:32:04Z")

</div>

> [@mthelm85](#):
>
> I was wanting to run Linux on this machine but it wasn’t until after I purchased the motherboard that I realized that Asus doesn’t support Linux for this partcular mobo yet (based on their [Linux status report for desktop mobos](https://dlcdnimgs.asus.com/websites/global/aboutASUS/OS/Linux-Status-report-201810.pdf)).

I’ll second what semeonschaub says. My motherboard isn’t on that list either.  
The ethernet port on the motherboard doesn’t work, so I have my ethernet cable plugged into a dongle, plugged into a usb slot.

I’d have tried installing Linux first, I’d be a little surprised if you run into problems.

> [@martincornejo](#):
>
> Interesting! How can software from the repositories enhance the performance?

[This blog post](https://clearlinux.org/news-blogs/boosting-python-profile-guided-platform-specific-optimizations) discusses how they optimized python libraries like `sci-kit-learn` using profile-guided optimization and also compiling multiple versions for different architectures.

The Julia system image already does function multi-versioning, as do the most important/sensitive libraries like BLAS or FFTW.  
Maybe some of the other libraries that Julia depends on, like GMP and MPFR, would [benefit from supporting more recent instruction sets](https://github.com/JuliaLang/julia/issues/35215#issuecomment-602261291).

For the most part, it probably doesn’t make that big a difference because the libraries where the authors put a lot of effort into making sure the code takes advantage of SIMD (like OpenBLAS/MKL and FFTW) will already use multi-versioning by default.

But in some cases, like Clear Linux’s python, [it does make a big difference](https://www.phoronix.com/scan.php?page=news_item&px=Clear-Linux-2019-Python-Perf).

> [@Modatu](#):
>
> Do you use the NVIDIA drivers and if yes what was your experience of getting them to work?

It’s an AMD GPU (Vega 64). You can make out the “R” and “EON” parts of of “RADEON”.

I’d heard Clear Linux recently made it easier to install proprietary software like Chrome. I haven’t looked into that yet. They have documentation [describing how to install NVIDEA’s drivers](https://docs.01.org/clearlinux/latest/tutorials/nvidia.html).

> [@mthelm85](#):
>
> Beauty is in the eye of the beholder. I appreciate this kind of build as it reminds me of my cryptocurrency mining rig that I built and ran for a couple of years.

> [@Modatu](#):
>
> BTW, your machine looks like a proper Workstation

Ha, thanks! Moving it is impractical.

> [@martincornejo](#):
>
> Does MKL make such a difference? I would have expected less! I tried to check it out but failed the build, I have an ivybridge i7 mobile processor.

I’m a little surprised. This is with OpenBLAS 0.3.9, which seems to finally have good AVX-512 support.  
It actually beat MKL in my single-threaded benchmarks (above roughly 200x200), and looked like it was getting close in multi-threaded by 10,000 x 10,000.

You could try something like this in both MATLAB and Julia

```julia
M = K = N = 16_000
A = rand(M, K); B = rand(K, N); # perhaps precompile with smaller sizes, like `M = K = N = 500` first.
t = @elapsed A * B;
flops = 2M * K * N / t

```

I’ll leave the MATLAB version to you.  
You could file an issue with MKL.jl.

> [@BLI](#):
>
> Should I be a little disappointed? Or is this what I could expect?

Probably what you can expect.

> [@carstenbauer](#):
>
> (I wouldn’t be worthy of a monster computer like @Elrod’s anyways)

I confess most of what it’s done is just run lots of benchmarks in parallel (I’ve set single and all-core clock speeds to be equal / disabled all boosting, so speed on a given core should be mostly independent of what any of the other cores are doing [barring things like contention over L3 cache]).

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [April 17, 2020, 2:35pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/43 "2020-04-17T14:35:37Z")

</div>

> [@Elrod](#):
>
> If you do try it, and do try building from source, it requires adding `F_COMPILER=GFORTRAN` to open blas’s flags in `deps/blas.mk` , due to open blas’s build system mistaking Clear Linux’s gfortran for ifort, and thus passing the wrong compiler flags.

Is it necessary to build from source or is it possible to simply install the generic Linux binary? This is uncharted territory for a long-time Windows user 😬

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel/32/6480_2.png) [@daniel](https://discourse.julialang.org/u/daniel)\
**Post date:** [April 17, 2020, 2:59pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/44 "2020-04-17T14:59:36Z")

</div>

For what it’s worth, here are my numbers for a 3950x slightly overclocked to 4.2GHz allcore and running with 3600MHz CL14 memory.

```julia
using LinearAlgebra #openblas
BLAS.set_num_threads(1)
peakflops(16_000)

4.7525320641043976e10

BLAS.set_num_threads(32)
peakflops(16_000)

7.247416073580671e11

```

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [April 17, 2020, 3:33pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/45 "2020-04-17T15:33:18Z")

</div>

[Official Linux binaries](https://julialang.org/downloads/) are fine.  
Are you familiar with the command line?

@daniel  
The 3950X can’t achieve 369 GFLOPS single threaded.  
Can you double check that number / that it really corresponds to a single thread?  
If the number is correct, that’d imply something like strassen.

I’m not sure why, but on my computer

```julia
julia> ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
8

```

The default is to start with 8 threads. Maybe your first run was with 8 threads?  
Your second run was probably with 16, since OpenBLAS builds with Julia allow up to 16 threads by default.

I edited my `blas.mk` when building Julia to increase the limit to 18 (the number of physical cores on this machine):

```julia
julia> using LinearAlgebra

julia> BLAS.set_num_threads(18)

julia> ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
18

julia> BLAS.set_num_threads(36)

julia> ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
18

julia> Sys.CPU_THREADS
36

julia> BLAS.set_num_threads(1)

julia> BLAS.vendor()
:openblas64

julia> @time peakflops(16_000)
 68.089648 seconds (12 allocations: 3.815 GiB, 0.09% gc time)
1.208110293882327e11

```

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [April 17, 2020, 3:37pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/46 "2020-04-17T15:37:08Z")

</div>

> Are familiar with the command line?

I have very limited experience with Linux commands (limited to fooling around with a Raspberry Pi and then Ubuntu years ago on an old laptop).

I’m pretty sure I have an unused external hard drive laying around somewhere so this weekend I think I’ll try to get a dual-boot setup going to see if I can get everything set up/installed the way that I like it.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel/32/6480_2.png) [@daniel](https://discourse.julialang.org/u/daniel)\
**Post date:** [April 17, 2020, 4:13pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/47 "2020-04-17T16:13:02Z")

</div>

Oops, you’re totally right. Already wondered about the poor scaling. Edited the post above.  
The second run seems to be with 32 threads, at least

```julia
ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())

```

shows 32, even with the precompiled Julia binary.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [April 17, 2020, 4:23pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/48 "2020-04-17T16:23:08Z")

</div>

You better set the number of Threads to the number of Physical cores and not the number of threads with SMT enabled.  
This is what we saw in the past (Though most information came form Intel CPU’s, so it might be different here).

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [April 17, 2020, 4:41pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/49 "2020-04-17T16:41:48Z")

</div>

> [@daniel](#):
>
> The second run seems to be with 32 threads, at least

[blas.mk](https://github.com/JuliaLang/julia/blob/master/deps/blas.mk) sets at most 16 as the upper limit, as does [OpenBLASBuilder](https://github.com/JuliaLinearAlgebra/OpenBLASBuilder/blob/master/build_tarballs.jl#L43). I don’t know how the Julia binaries get built, nor where their linked OpenBLAS’s build script is, but it seems it’s neither of those.

I also thought the same as Royi, which is why I set the maximum possible number of threads to 18 instead of 36.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel/32/6480_2.png) [@daniel](https://discourse.julialang.org/u/daniel)\
**Post date:** [April 17, 2020, 5:05pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/50 "2020-04-17T17:05:49Z")

</div>

Yeah I was surprised by this as well. There seems to be a slight speedup going from 16 to 32 threads which is consist between runs, atleast when calling peaksflops.

```julia
julia> BLAS.set_num_threads(16)

julia> peakflops(16_000)
7.12436321023842e11

julia> BLAS.set_num_threads(32)

julia> peakflops(16_000)
7.285140776841587e11

```

and htop shows 32 running threads.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [April 17, 2020, 6:00pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/51 "2020-04-17T18:00:02Z")

</div>

This is interesting.  
It is known that AMD’s SMT implementation is more efficient than Intel.  
So your results could be example of that.

Another option might be the kernel doesn’t squeeze all resources available in a single thread on a physical CPU, hence you get some more performance. It might suggest that OpenBLAS can have more optimized kernels for Ryzen (Based on Zen 2 Core). Just a guess…

---

<div class="post-metadata">

**Author:** ![Modatu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Modatu](https://discourse.julialang.org/u/Modatu)\
**Post date:** [April 18, 2020, 6:38am UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/52 "2020-04-18T06:38:14Z")

</div>

I do not want to hijack this thread, but does one of you know of a guide to squeeze all the performance out of julia during install/compilation?  
For example do you compile your own OpenBLAS or do you let Julia handle this?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [April 18, 2020, 10:54am UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/53 "2020-04-18T10:54:59Z")

</div>

> [@Modatu](#):
>
> For example do you compile your own OpenBLAS or do you let Julia handle this?

OpenBLAS dynamically picks specialized kernels for the runtime architecture so there isn’t an advantage to compile it locally.

---

<div class="post-metadata">

**Author:** ![peterj](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@peterj](https://discourse.julialang.org/u/peterj)\
**Post date:** [April 26, 2020, 9:21pm UTC](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606/54 "2020-04-26T21:21:39Z")

</div>

This thread got a bit off-topic, but I figured I would try the tests in this comment. I have an MSI laptop that is a few years old now:

```julia
julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)    
  CPU: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = "C:\Users\peter\AppData\Local\Programs\Microsoft VS Code\Code.exe"
  JULIA_NUM_THREADS = 6

```

with `N = 10^8`

```julia
julia> @btime sequential_add!($y, $x)
  13.872 s (0 allocations: 0 bytes)

julia> @btime parallel_add!($y, $x)   
  4.312 s (33 allocations: 4.98 KiB)

```

with `N = 2^27`

```julia
julia> @btime sequential_add!($y, $x)
  21.121 s (0 allocations: 0 bytes)   

julia> @btime parallel_add!($y, $x)   
  6.310 s (34 allocations: 5.00 KiB)

```

[Previous page](https://discourse.julialang.org/t/show-off-julia-performance-on-your-pc/33606.md?page=2)
