Upgrading hardware for LinearAlgebra in Julia

Hello, I typically work on solving eigenvalue problems with non-Hermitian matrices using LinearAlgebra.jl. Recently, I’ve been considering upgrading my laptop to improve the operating time for matrix diagonalization and eigenvalue/eigenstate plotting.

Could you recommend a better laptop for these tasks? My current setup is a 2019 Apple MacBook Pro 13 with an Intel Core i7 2.8GHz processor, 16GB of RAM, and a 512GB SSD. My budget is up to 3000 USD, and I require 24GB or more of RAM for dealing with larger matrices.

For example, the eigvals() function takes around 4800 seconds to run with the following code:

using LinearAlgebra
N = 24000
A = rand(Complex{Float64}, N, N)

Are there laptops that can achieve significantly faster computation times? I’ve heard that having sufficient memory bandwidth might help. Additionally, are there any differences in Julia’s performance between macOS and Windows?

1 Like

I have a Framework | Choose Framework Laptop 13 DIY Edition (AMD Ryzen™ 7040 laptop with 32 GB RAM (about 1873 EUR incl 2 TB SSD), and executing your code needed 2444 seconds:

julia> @time include("bench.jl")
2443.947729 seconds (649.32 k allocations: 17.223 GiB, 0.00% gc time, 0.02% compilation time)
24000-element Vector{ComplexF64}:
  -63.28884672452826 + 1.5069795003392608im
  -63.12570688280942 + 1.4679802358275418im
 -63.015408649892365 - 0.42639858375064493im
 -62.946303089959684 + 0.23500221839911026im
  -62.88981327039282 - 5.183074187040009im
  -62.88776881868133 + 5.592425894654174im
  -62.86713334920773 + 5.009766111939222im
 -62.815652194879405 + 7.609916770085996im
  -62.76227359987212 - 2.595894052465677im
  -62.73574157082742 - 1.3667994538987132im
  62.889907901907776 + 1.33551586908236im
   62.90583407685033 - 3.5874513673751816im
   62.92909375107443 + 3.3003355030709787im
   62.96355871197654 + 6.116995895976287im
   63.02210103845973 - 2.6238456440881786im
  63.072462256601426 + 0.5801813099236778im
  63.173794099395465 - 5.058255854848188im
  63.209142310557354 + 0.26971206309029594im
   11999.39418054727 + 12000.131475334652im

If you use an AMD Ryzen™ 7040HS CPU as in the 16 inch version of this laptop you will gain another 10-20% of speed.

If you want the best performance, I would suggest Linux or Mac over Windows.


Thank you for your recommendation. That’s cool! but the Framework PC is not sold in Japan😢.

I’d like to know which Intel and Mac CPUs are equivalent to the AMD Ryzen™ 7040HS CPU in terms of diagonalization performance. Also, I want to know how hot your laptop got while executing bench.jl.

From what perspective?

Between 80 and 100 °C CPU temperature. Which is fine, you hear the fan, but it is not loud. The laptop casing was not hot, only the CPU.

Other laptops with this CPU: AMD Ryzen 7040 series Laptop List - Google Sheets


You may want to check this recent topic Help wanted: benchmarking multi-threaded CPU performance.

One question: Must it be a laptop? What about a desktop at home as a server, and your laptop as a thin client? In a desktop you get more capacity/$, and they are expandable. Set up a VPN on your router if you need an access from outside.

As for Windows vs. Mac: They are difficult to compare, as Windows doesn’t run on Apple’s “M” processors. On Macs, the M processors are supposed to be much faster than their previous generation using Intel. In any case on my relatively low end Mac Mini M1, 8GB (2020) Julia was about twice as fast as on a medium range i5 Windows Notebook a year older.

In the benchmarking topic, those in possession of a powerful computer were asked to share benchmarking results. My Mac Mini was certainly not in in the category, but here are my results - you may want to compare with your Mac:

[7.7, 7.6, 7.5, 7.5, 7.6, 7.7, 7.7, 7.6, 7.6]  threads=4
[9.3, 9.8, 8.8, 9.8, 9.4, 9.3, 9.8, 9.5, 9.8]  threads=8

Yes, my priority is portability. Since I can access a supercomputer at my university (if I follow the procedure), I’m looking for a “thin client” with better performance than my current one, though it doesn’t need to be the best.

Here is my result:

[2.0, 2.6, 2.5, 2.5, 2.4, 2.6, 2.8, 2.5, 2.4]  threads=1
[7.4, 7.9, 7.8, 8.1, 8.4, 7.2, 7.3, 7.6, 7.2]  threads=4

and my colleague’s one with M1 Max MacBook Pro:

[1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7]  threads=1

It seems that this benchmark doesn’t reflect the diagonalization performance on Mac. Indeed, with the M1 Max, eigvals(rand(Complex{Float64}, 6000, 6000)) took around 60 seconds, which suggests that for N = 24000, the computation would take approximately 60 * 64 = 3840 seconds based on the O(n^3) scaling law. This calculation shows the M1 Max is 1.25 times faster than my current setup. This result also implies that the AMD Ryzen™ 7 7840U is much better than the M1 Max for my purposes. (assuming I didn’t make any calculation errors)

Could someone run this on an M3 Mac or an Intel Core i9 (or Ultra 9) with N=6000?

If you are already inside the Apple ecosystem, you need to be real with yourself about whether you want to leave it or not. If not: Apple has a trade-in program. See how much you can trade-in or sell your current macbook for. Use the proceeds to get the most expensive macbook that fits within your budget (and 3000 goes quite a ways).

You could of course get more performance per dollar by leaving the ecosystem, but that may not be the only criteria you care about.

I’m not fixated on Apple products. While I find features like battery life and usability attractive, I’m aware of drawbacks such as not being suitable for gaming and cost. My main concern in this topic is just to know which laptop or CPU can perform diagonalization most comfortably and quickly. After knowing that, I will consider my other criteria and chose my next laptop.

FWIW, I did N=6000 in 75 seconds with my desktop.

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × AMD Ryzen 9 5950X 16-Core Processor
  LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 32 default, 0 interactive, 16 GC (on 32 virtual cores)
1 Like