# Parallel computing for eigs() function

**URL:** <https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926>\
**Category:** Julia at Scale\
**Created:** [April 8, 2019, 3:48pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926 "2019-04-08T15:48:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeed](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@saeed](https://discourse.julialang.org/u/saeed)\
**Post date:** [April 8, 2019, 3:48pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/1 "2019-04-08T15:48:51Z")

</div>

Hello, I am new to julia and parallel computing. I want to use parallel computing capability in julia in doing shift-invert calculations. My problem is that I have a couple of sparse matrices, and want to find specific eigenvalue of these matrices. depending on the size of my matrices, I want to use 4-24 of cores available on each computing node. The usual sparse matrices, shift-invert, Arpack function I use is as follows:

Val, Vec = eigs(A, nev=10, sigma=-5, ritzvec=true, tol=0.0);

My question is how can I run this single function on multiple cores. There is no ‘for loop’ in my code, just this line.

Thank you,

---

<div class="post-metadata">

**Author:** ![jonas-kr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonas-kr/32/1810_2.png) [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Post date:** [April 8, 2019, 7:59pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/2 "2019-04-08T19:59:49Z")

</div>

> [@saeed](#):
>
> ow can I run this single function on multiple cores. There is no ‘for loop’ in my code, just this line.

To the best of my knowledge there is no way to run the Arpack eigensolver in parallel. Since the process is iterative, the previous result is needed in every step of the iteration in order to obtain a new approximation to a subspace. However, it might be possible to parallelize the application of the operator (i.e. the shift-and-invert operation in your case) to the vectors of the krylov subspace.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 8, 2019, 9:05pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/3 "2019-04-08T21:05:40Z")

</div>

It looks like there is a [P\_ARPACK](https://www.caam.rice.edu/software/ARPACK/download.html#P_ARPACK) library that uses MPI to to do ARPACK algorithms in parallel. This doesn’t appear to have a counterpart in julia, but you can make a [ccall](https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/index.html) wrapper to use it from julia.

If you do succeed in getting that working, it may be a valuable contribution to the julia community as a package.

---

<div class="post-metadata">

**Author:** ![saeed](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@saeed](https://discourse.julialang.org/u/saeed)\
**Post date:** [April 9, 2019, 1:45am UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/4 "2019-04-09T01:45:39Z")

</div>

Thank you for your reply. Strange thing is that on my personal computer, I see that all my core are 100% working when I use:

> > > eigs(sparse(rand(n,n)), nev=10, sigma=5, ritzvec=true, tol=0.0)

But whenever I load my desire matrix from a .txt file, only one CPU get to work.

For the case that all my core start to work, I don’t do anything regarding parallel computing, even when I start julia by:

> > > julia -p 2

still, there are 8 workers.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [April 9, 2019, 1:53am UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/5 "2019-04-09T01:53:17Z")

</div>

I believe Arpack calls into blas. Then multiple threads might be engaged.

---

<div class="post-metadata">

**Author:** ![jonas-kr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonas-kr/32/1810_2.png) [@jonas-kr](https://discourse.julialang.org/u/jonas-kr)\
**Post date:** [April 12, 2019, 1:57pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/6 "2019-04-12T13:57:37Z")

</div>

According to my observations, it seems like only the initial factorization of the matrix is performed using multiple threads and afterwards only a single one is used. But honestly, I do not know whether it makes sense to perform the subsequent calculations in parallel…

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 12, 2019, 6:31pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/7 "2019-04-12T18:31:46Z")

</div>

I just came across this library: [https://pardiso-project.org](https://pardiso-project.org) which _does_ have a julia wrapper already: [https://github.com/JuliaSparse/Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl)

---

<div class="post-metadata">

**Author:** ![Carol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carol/32/8140_2.png) [@Carol](https://discourse.julialang.org/u/Carol)\
**Post date:** [May 29, 2019, 5:55pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/8 "2019-05-29T17:55:29Z")

</div>

Hi, could you please tell me how you can use `eigs()` in Julia 1.0 version?  
I cannot find this function.

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [May 29, 2019, 6:25pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/9 "2019-05-29T18:25:06Z")

</div>

`eigs` is now in [Arpack.jl](https://julialinearalgebra.github.io/Arpack.jl/stable/)

---

<div class="post-metadata">

**Author:** ![bmxam](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@bmxam](https://discourse.julialang.org/u/bmxam)\
**Post date:** [February 9, 2021, 9:11am UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/10 "2021-02-09T09:11:36Z")

</div>

You can take a look at a project I’ve just started : [SlepcWrap.jl](https://github.com/bmxam/SlepcWrap.jl). It is a julia wrapper for the [SLEPc](https://slepc.upv.es/) library, aimed to solve large eigenvalue problems on (parallel) distributed architectures. Check out the README or the documentation for an example.

---

<div class="post-metadata">

**Author:** ![carlomontec](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlomontec/32/2011_2.png) [@carlomontec](https://discourse.julialang.org/u/carlomontec)\
**Post date:** [April 14, 2021, 12:45pm UTC](https://discourse.julialang.org/t/parallel-computing-for-eigs-function/22926/11 "2021-04-14T12:45:46Z")

</div>

This looks awesome! Thanks
