Giter Club home page Giter Club logo

Comments (7)

BacAmorim avatar BacAmorim commented on June 13, 2024 1

Soon you won't have to :-) : JuliaSparse/MKLSparse.jl#22
(The magic of BinaryBuilder and Artifacts!)

That is pretty sweet!

from quantica.jl.

pablosanjose avatar pablosanjose commented on June 13, 2024

Hey @BacAmorim, thanks for the pointer! Yes, we had that package in our radar. @fernandopenaranda has been looking hard into paralellizing KPM, and has found an excellent approach using MKLSparse.jl. The multithreaded mul! calls to MKL are incredibly efficient, and scale nicely with number of threads. He's able to gain almost a 10x performance boost over a naive Base.Threads approach, and even over a custom KPM-specific mul! that computes moments at the same time as does the matrix-vector multiply. I actually wonder now if any hand-tuned matrix-free approach as in KITE could actually be as performant as the MKL libraries, so the interest of #66 for me is currently lower than it was. Note that matrix-free approaches have a disadvantage in that they need to apply any non-periodic element of the system on the fly for each multiplication, unlike when you first build your sparse matrix in memory. The key issue that determines the ideal strategy is whether you are really memory limited or not.

from quantica.jl.

pablosanjose avatar pablosanjose commented on June 13, 2024

Regarding this, with #72 plus the recently merged JuliaSparse/MKLSparse.jl#20 you should automatically get multithreaded KPM just by doing using MKLSparse

from quantica.jl.

pablosanjose avatar pablosanjose commented on June 13, 2024

In any case, let me also say that ThreadedSparseArrays.jl is very impressive. It shows how to use Base.Threads efficiently to get pretty close to what MKL does using pure Julia. Some comparisons using Julia 1.6 with four threads

julia> sp = sprand(ComplexF64, 10^6,10^6, 10^-5); v = rand(ComplexF64, 10^6); spt = ThreadedSparseMatrixCSC(sp);

OpenBLAS (default)

julia> @btime sp'v;
  99.862 ms (3 allocations: 15.26 MiB)

ThreadedSparseArrays.jl

julia> @btime spt'v;
  29.970 ms (39 allocations: 15.26 MiB)

MKLSparse.jl

julia> @btime sp'v;
  22.143 ms (3 allocations: 15.26 MiB)

from quantica.jl.

BacAmorim avatar BacAmorim commented on June 13, 2024

Note that matrix-free approaches have a disadvantage in that they need to apply any non-periodic element of the system on the fly for each multiplication, unlike when you first build your sparse matrix in memory. The key issue that determines the ideal stratefy is whether you are really memory limited or not.

I agree: memory being the limiting factor or not seems to be the key here. I am of the opinion that if memory is the limiting factor, you might be investing your time in the wrong problem :p

Those comparison's between ThreadedSparseArrays.jl and MKLSparse.jl seems pretty cool! But MKLSparse still seems the best option when it comes to performance. I only see two reasons why a pure Julia version could be desirable:

  1. Not having to install and configure MKL
  2. ThreadedSparseArrays.jl uses @spawn which enables the new smart composable parallelism of Julia: otherwise one might have competition between julia and mkl threads (but that can also happen with blas threads...)

from quantica.jl.

pablosanjose avatar pablosanjose commented on June 13, 2024

Not having to install and configure MKL

Soon you won't have to :-) : JuliaSparse/MKLSparse.jl#22
(The magic of BinaryBuilder and Artifacts!)

new smart composable parallelism

Yes, this one is a big deal. Perhaps enough to add a dependency to ThreadedSparseArrays.jl in Quantica. Of course the ideal would be to have it in Base: JuliaLang/julia#29525

from quantica.jl.

pablosanjose avatar pablosanjose commented on June 13, 2024

JuliaSparse/MKLSparse.jl#22 has been merged. I'll be closing this for now, as it is arguably solved by MKLSparse.

from quantica.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.