Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matrix-dense-vector multiplication faster for symmetric/hermitian matrices using adjoint #28

Open
jamblejoe opened this issue Dec 15, 2021 · 1 comment

Comments

@jamblejoe
Copy link

As Julia is for now exclusively using CSC storage format, the matrix-dense-vector multiplication is faster for symmetric/hermitian matrix A if one computes A' * v instead of A * v. A simple example script hinting this is the following:

julia> let
       for D in [10^3, 10^4, 10^5, 10^6]
           A = sprand(D,D,1/D)
           A = A+A'
           v = rand(D)
           w = similar(v)
           @btime mul!($w, $A, $v)
           @btime mul!($w,$A',$v)
       end
       end
  3.500 μs (0 allocations: 0 bytes)
  1.540 μs (0 allocations: 0 bytes)
  23.100 μs (0 allocations: 0 bytes)
  14.100 μs (0 allocations: 0 bytes)
  305.400 μs (0 allocations: 0 bytes)
  206.300 μs (0 allocations: 0 bytes)
  13.283 ms (0 allocations: 0 bytes)
  4.167 ms (0 allocations: 0 bytes)

On

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

and MKLSparse v1.1.0.

Should MKLSparse detect this with ishermitian ?

@amontoison
Copy link
Member

We should add a better dispatch if the sparse matrix is wrapped in Symmetric or Hermitian.
I remember that they have a dedicated routine for symmetric matrices (sparse_symv).
It should be even faster than A' * v.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants