Quantcast

Sparse matrices

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Sparse matrices

Clinton Winant-2
I would like to optimize the performance of octave on a machine that has multiple processors.  I have optimized LAPACK and BLAS to use parallel threads, and where LAPACK is used, that helps a lot.  I was initially surprised that the enhanced LAPACK did not speed up the execution of, for instance, u=K\F, if K is sparse, but now I realize that sparse matrix calculations are done with a special set of tools (see http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_113.html)

Does anyone know if it is possible to tune the sparse matrix package to take advantage of multiple processors?

Clint

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sparse matrices

Carlo de Falco-2

> On 5 Mar 2017, at 18:10, Clinton Winant <[hidden email]> wrote:
>
> I would like to optimize the performance of octave on a machine that has multiple processors.  I have optimized LAPACK and BLAS to use parallel threads, and where LAPACK is used, that helps a lot.  I was initially surprised that the enhanced LAPACK did not speed up the execution of, for instance, u=K\F, if K is sparse, but now I realize that sparse matrix calculations are done with a special set of tools (see http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_113.html)

that page is about ten years old! you should be looking here for more recent Octave docs:
https://www.gnu.org/software/octave/doc/interpreter/

> Does anyone know if it is possible to tune the sparse matrix package to take advantage of multiple processors?

Octave relies entirely on suitesparse [1] for the implementation of mldivide operator ("\") for sparse matrices [2],
if you can optimize suitesparse that will most likely also affect Octave.

If you want to use iterative solvers like gmres [3] instead of mldivide, using the sparsersb [4] package will greatly
improve the performance.

> Clint

c.

[1] http://faculty.cse.tamu.edu/davis/suitesparse.html
[2] https://www.gnu.org/software/octave/doc/interpreter/Techniques-Used-for-Linear-Algebra.html#Techniques-Used-for-Linear-Algebra
    https://www.gnu.org/software/octave/doc/interpreter/Sparse-Linear-Algebra.html#Sparse-Linear-Algebra
[3] https://www.gnu.org/software/octave/doc/interpreter/Specialized-Solvers.html#XREFgmres
[4] https://octave.sourceforge.io/sparsersb/


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sparse matrices

Carlo de Falco-2
Please keep the list in CC and use bottom posting [1] when replying to messages.

> On 5 Mar 2017, at 19:09, Clinton Winant <[hidden email]> wrote:
>
> Thanks  I want to try sparsersb.  To do this I suppose I ned to rebuild octave with a flag such as --with-sparsersb??

No, what made you think such flag exists?

>  Should I also remove sparsesuite from my system??

No.

Here is the instructions for installing packages:
https://www.gnu.org/software/octave/doc/interpreter/Installing-and-Removing-Packages.html#Installing-and-Removing-Packages

Be aware that sparsersb WILL NOT transparently improve performance of exixsting Octave code,
your code will have to be explicitely written to use sparserb and an appropriate iterative solver.

Actually, what sparsersb really does is just provide a special class of matrices for which matrix vector product
can be computed very fast.

Also be aware that for small size matrices (i.e. whose full LU factorization would fit in memory)
the direct solvers from suitesparse will most likely always perform better than an iterative solver,
especially if you don't have a good preconditioner.

On the other hand iterative solvers are able to solve systems of very large size that would lead to memory overflow
with a direct method.

c.

[1] https://en.wikipedia.org/wiki/Posting_style#Bottom-posting




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sparse matrices

Sebastian Schöps
Carlo de Falco-2 wrote
On the other hand iterative solvers are able to solve systems of very large size that would lead to memory overflow with a direct method.
talking about linear solvers.... is anyone aware of a nice way (or a package) for interfacing petsc? There is a Matlab interface which might work with Octave but I did not try it yet. I was recently interested in using the multigrid solvers of petsc from within Octave.

Sebastian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Sparse matrices

tmacchant
In reply to this post by Carlo de Falco-2
----- Original Message -----

> From: Carlo De Falco 
> To: Clinton Winant 
> Cc: Octave Help 
> Date: 2017/3/6, Mon 02:46
> Subject: Re: Sparse matrices
>
>
>>  On 5 Mar 2017, at 18:10, Clinton Winant <[hidden email]>
> wrote:
>>
>>  I would like to optimize the performance of octave on a machine that has
> multiple processors.  I have optimized LAPACK and BLAS to use parallel threads,
> and where LAPACK is used, that helps a lot.  I was initially surprised that the
> enhanced LAPACK did not speed up the execution of, for instance, u=K\F, if K
> is sparse, but now I realize that sparse matrix calculations are done with a
> special set of tools (see
> http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_113.html)
>
> that page is about ten years old! you should be looking here for more recent
> Octave docs:
> https://www.gnu.org/software/octave/doc/interpreter/
>
>>  Does anyone know if it is possible to tune the sparse matrix package to
> take advantage of multiple processors?
>
> Octave relies entirely on suitesparse [1] for the implementation of mldivide
> operator ("\") for sparse matrices [2],
> if you can optimize suitesparse that will most likely also affect Octave.
>
> If you want to use iterative solvers like gmres [3] instead of mldivide, using
> the sparsersb [4] package will greatly
> improve the performance.
>
>>  Clint
>
> c.
>
> [1] http://faculty.cse.tamu.edu/davis/suitesparse.html
> [2]
> https://www.gnu.org/software/octave/doc/interpreter/Techniques-Used-for-Linear-Algebra.html#Techniques-Used-for-Linear-Algebra
>    
> https://www.gnu.org/software/octave/doc/interpreter/Sparse-Linear-Algebra.html#Sparse-Linear-Algebra
> [3]
> https://www.gnu.org/software/octave/doc/interpreter/Specialized-Solvers.html#XREFgmres
> [4] https://octave.sourceforge.io/sparsersb/
>


This is mere my guess.


*********************
If I remember correctly, suitesparse also depends on blas. 
However, you change blas routine only for octave but not for suitesparse.
The blas library used for matrix calculation for sparse matrices do not change from before.
Thus sparse matrix calculation might not be changed.
****************

As ​Dmitri wrote in your previous thread,
http://octave.1599824.n4.nabble.com/making-octave-with-lapack-pt-td4682148.html#a4682152


 
Dynamic library seems to be changed at run-time.  

Also, as Dmitri wrote in the above, I recommend to use openblas instead of atlas.

I am not expert so that I hope that someone else who know much about on this matter make replies.

Tatsuro 


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...