Re: [petsc-users] Kronecker Product

2023-01-30 Thread Jose E. Roman
The matrix can be a shell matrix, only the matrix-vector product operation is 
required.

Jose


> El 30 ene 2023, a las 22:23, Guglielmo, Tyler Hardy via petsc-users 
>  escribió:
> 
> I have an implementation of the slepc MFN matrix exponential which is 
> implicitly using ExpoKit.  You have to supply a matrix into the Slepc MFN 
> operator to set the problem up as far as I know.
>  
> Tyler
>  
> From: Matthew Knepley 
> Date: Monday, January 30, 2023 at 12:24 PM
> To: Guglielmo, Tyler Hardy 
> Cc: Barry Smith , petsc-users@mcs.anl.gov 
> 
> Subject: Re: [petsc-users] Kronecker Product
> 
> On Mon, Jan 30, 2023 at 3:08 PM Guglielmo, Tyler Hardy via petsc-users 
>  wrote:
> I would need the Kronecker product to be explicitly available to perform 
> matrix exponentials.  A and B are of order 5000, so not too large.  I will 
> give storing them on all ranks a shot.  Thanks for the tips!
>  
> Were you going to do exponentials by explicit factorization? For large 
> matrices, I thought it was common to
> use matrix-free methods 
> (https://slepc.upv.es/documentation/current/docs/manualpages/MFN/index.html)
>  
>   Thanks,
>  
> Matt
>  
>  
> Best,
> Tyler
>  
> From: Barry Smith 
> Date: Monday, January 30, 2023 at 12:01 PM
> To: Guglielmo, Tyler Hardy 
> Cc: petsc-users@mcs.anl.gov 
> Subject: Re: [petsc-users] Kronecker Product
> 
>  
>   What is large? If A and B have dimensions of 1000, then the Kronecker 
> product is of size 1,000,000. Do you want the Kronecker product to be 
> explicitly formed or just available as matrix vector products?  If just 
> explicitly available then I think you can just store sparse A (for example) 
> completely on all ranks, 10,000 by 10,000 sparse matrix is small for 
> sequential) while B is distributed.
>  
> Barry
>  
>  
> 
> On Jan 30, 2023, at 2:48 PM, Guglielmo, Tyler Hardy  
> wrote:
>  
> Both matrices (A and B) would be approximately the same size and large.  The 
> use case (for me at least) is to create several large sparse matrices which 
> will be combined in various ways through Kronecker products.  The combination 
> happens at every time step in an evolution, so it really needs to be fast as 
> well.  I’m thinking mpi/petsc is probably not the most optimal way for 
> dealing with this, and might just have to work with single node 
> multi-threading.
>  
> Best,
> Tyler
>  
> From: Matthew Knepley 
> Date: Monday, January 30, 2023 at 11:31 AM
> To: Guglielmo, Tyler Hardy 
> Cc: Barry Smith , petsc-users@mcs.anl.gov 
> 
> Subject: Re: [petsc-users] Kronecker Product
> 
> On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users 
>  wrote:
> Thanks Barry,
>  
> I saw that function, but wasn’t sure how to apply it since the documentation 
> says that S and T are dense matrices, but in my case all matrices involved 
> are sparse.  Is there a way to work around the dense requirement?
>  
> We don't have parallel sparse-sparse. It would not be too hard to write, but 
> it would be some work.
>  
> It is hard to understand the use case. Is one matrix much smaller? If not, 
> and you inherit the distribution from A, it seems
> like it might be very suboptimal, and otherwise you would have to 
> redistribute on the fly and it would get very complicated.
>  
>   Thanks,
>  
>  Matt
>  
> Best,
> Tyler
>  
> From: Barry Smith 
> Date: Monday, January 30, 2023 at 11:12 AM
> To: Guglielmo, Tyler Hardy 
> Cc: petsc-users@mcs.anl.gov 
> Subject: Re: [petsc-users] Kronecker Product
> 
>  
>Do you need the explicit sparse representation of the Kronecker product? 
> Or do you want to apply it as an operator or solve systems with it? If the 
> latter you can use 
> https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij
>  
>   Barry
>  
>  
> 
>  
> 
> On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
>  wrote:
>  
> Hi all,
>  
> I am wondering if there is any functionality for taking Kronecker products of 
> large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
> found, but it seems like this does not work for parallel matrices.  Any ideas 
> here? 
>  
> An option could be to make A and B sequential, compute the Kronecker product, 
> C, then scatter C into a parallel matrix?  This seems like a horribly 
> inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
> :)!
>  
> Best,
> Tyler 
>  
> +
> Tyler Guglielmo
> Postdoctoral Researcher
> Lawrence Livermore National Lab
> Office: 925-423-6186
> Cell: 210-480-8000

Re: [petsc-users] Kronecker Product

2023-01-30 Thread Guglielmo, Tyler Hardy via petsc-users
I have an implementation of the slepc MFN matrix exponential which is 
implicitly using ExpoKit.  You have to supply a matrix into the Slepc MFN 
operator to set the problem up as far as I know.

Tyler

From: Matthew Knepley 
Date: Monday, January 30, 2023 at 12:24 PM
To: Guglielmo, Tyler Hardy 
Cc: Barry Smith , petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] Kronecker Product
On Mon, Jan 30, 2023 at 3:08 PM Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
I would need the Kronecker product to be explicitly available to perform matrix 
exponentials.  A and B are of order 5000, so not too large.  I will give 
storing them on all ranks a shot.  Thanks for the tips!

Were you going to do exponentials by explicit factorization? For large 
matrices, I thought it was common to
use matrix-free methods 
(https://slepc.upv.es/documentation/current/docs/manualpages/MFN/index.html<https://urldefense.us/v3/__https:/slepc.upv.es/documentation/current/docs/manualpages/MFN/index.html__;!!G2kpM7uM-TzIFchu!nSXMSWur4Lrpt0oF_bjtBae92VccTBcCHUQJRYWByuB4bZ5HHzFHhGtLjs7NrgHZUCE$>)

  Thanks,

Matt


Best,
Tyler

From: Barry Smith mailto:bsm...@petsc.dev>>
Date: Monday, January 30, 2023 at 12:01 PM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product

  What is large? If A and B have dimensions of 1000, then the Kronecker product 
is of size 1,000,000. Do you want the Kronecker product to be explicitly formed 
or just available as matrix vector products?  If just explicitly available then 
I think you can just store sparse A (for example) completely on all ranks, 
10,000 by 10,000 sparse matrix is small for sequential) while B is distributed.

Barry


On Jan 30, 2023, at 2:48 PM, Guglielmo, Tyler Hardy 
mailto:gugliel...@llnl.gov>> wrote:

Both matrices (A and B) would be approximately the same size and large.  The 
use case (for me at least) is to create several large sparse matrices which 
will be combined in various ways through Kronecker products.  The combination 
happens at every time step in an evolution, so it really needs to be fast as 
well.  I’m thinking mpi/petsc is probably not the most optimal way for dealing 
with this, and might just have to work with single node multi-threading.

Best,
Tyler

From: Matthew Knepley mailto:knep...@gmail.com>>
Date: Monday, January 30, 2023 at 11:31 AM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: Barry Smith mailto:bsm...@petsc.dev>>, 
petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product
On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Thanks Barry,

I saw that function, but wasn’t sure how to apply it since the documentation 
says that S and T are dense matrices, but in my case all matrices involved are 
sparse.  Is there a way to work around the dense requirement?

We don't have parallel sparse-sparse. It would not be too hard to write, but it 
would be some work.

It is hard to understand the use case. Is one matrix much smaller? If not, and 
you inherit the distribution from A, it seems
like it might be very suboptimal, and otherwise you would have to redistribute 
on the fly and it would get very complicated.

  Thanks,

 Matt

Best,
Tyler

From: Barry Smith mailto:bsm...@petsc.dev>>
Date: Monday, January 30, 2023 at 11:12 AM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product

   Do you need the explicit sparse representation of the Kronecker product? Or 
do you want to apply it as an operator or solve systems with it? If the latter 
you can use 
https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij<https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>

  Barry



On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:

Hi all,

I am wondering if there is any functionality for taking Kronecker products of 
large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
found, but it seems like this does not work for parallel matrices.  Any ideas 
here?

An option could be to make A and B sequential, compute the Kronecker product, 
C, then scatter C into a parallel matrix?  This seems like a horribly 
inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
:)!

Best,
Tyler

+++

Re: [petsc-users] Kronecker Product

2023-01-30 Thread Matthew Knepley
On Mon, Jan 30, 2023 at 3:08 PM Guglielmo, Tyler Hardy via petsc-users <
petsc-users@mcs.anl.gov> wrote:

> I would need the Kronecker product to be explicitly available to perform
> matrix exponentials.  A and B are of order 5000, so not too large.  I will
> give storing them on all ranks a shot.  Thanks for the tips!
>

Were you going to do exponentials by explicit factorization? For large
matrices, I thought it was common to
use matrix-free methods (
https://slepc.upv.es/documentation/current/docs/manualpages/MFN/index.html)

  Thanks,

Matt


>
>
> Best,
>
> Tyler
>
>
>
> *From: *Barry Smith 
> *Date: *Monday, January 30, 2023 at 12:01 PM
> *To: *Guglielmo, Tyler Hardy 
> *Cc: *petsc-users@mcs.anl.gov 
> *Subject: *Re: [petsc-users] Kronecker Product
>
>
>
>   What is large? If A and B have dimensions of 1000, then the Kronecker
> product is of size 1,000,000. Do you want the Kronecker product to be
> explicitly formed or just available as matrix vector products?  If just
> explicitly available then I think you can just store sparse A (for example)
> completely on all ranks, 10,000 by 10,000 sparse matrix is small for
> sequential) while B is distributed.
>
>
>
> Barry
>
>
>
>
>
> On Jan 30, 2023, at 2:48 PM, Guglielmo, Tyler Hardy 
> wrote:
>
>
>
> Both matrices (A and B) would be approximately the same size and large.
> The use case (for me at least) is to create several large sparse matrices
> which will be combined in various ways through Kronecker products.  The
> combination happens at every time step in an evolution, so it really needs
> to be fast as well.  I’m thinking mpi/petsc is probably not the most
> optimal way for dealing with this, and might just have to work with single
> node multi-threading.
>
>
>
> Best,
>
> Tyler
>
>
>
> *From: *Matthew Knepley 
> *Date: *Monday, January 30, 2023 at 11:31 AM
> *To: *Guglielmo, Tyler Hardy 
> *Cc: *Barry Smith , petsc-users@mcs.anl.gov <
> petsc-users@mcs.anl.gov>
> *Subject: *Re: [petsc-users] Kronecker Product
>
> On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users <
> petsc-users@mcs.anl.gov> wrote:
>
> Thanks Barry,
>
>
>
> I saw that function, but wasn’t sure how to apply it since the
> documentation says that S and T are dense matrices, but in my case all
> matrices involved are sparse.  Is there a way to work around the dense
> requirement?
>
>
>
> We don't have parallel sparse-sparse. It would not be too hard to write,
> but it would be some work.
>
>
>
> It is hard to understand the use case. Is one matrix much smaller? If not,
> and you inherit the distribution from A, it seems
>
> like it might be very suboptimal, and otherwise you would have to
> redistribute on the fly and it would get very complicated.
>
>
>
>   Thanks,
>
>
>
>  Matt
>
>
>
> Best,
>
> Tyler
>
>
>
> *From: *Barry Smith 
> *Date: *Monday, January 30, 2023 at 11:12 AM
> *To: *Guglielmo, Tyler Hardy 
> *Cc: *petsc-users@mcs.anl.gov 
> *Subject: *Re: [petsc-users] Kronecker Product
>
>
>
>Do you need the explicit sparse representation of the Kronecker
> product? Or do you want to apply it as an operator or solve systems with
> it? If the latter you can use
> https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij
> <https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>
>
>
>
>   Barry
>
>
>
>
>
>
>
> On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users <
> petsc-users@mcs.anl.gov> wrote:
>
>
>
> Hi all,
>
>
>
> I am wondering if there is any functionality for taking Kronecker products
> of large sparse matrices that are parallel?  MatSeqAIJKron is as close as I
> have found, but it seems like this does not work for parallel matrices.
> Any ideas here?
>
>
>
> An option could be to make A and B sequential, compute the Kronecker
> product, C, then scatter C into a parallel matrix?  This seems like a
> horribly inefficient procedure.  I’m still fairly new to petsc, so thanks
> for patience :)!
>
>
>
> Best,
>
> Tyler
>
>
>
> +
>
> Tyler Guglielmo
>
> Postdoctoral Researcher
>
> Lawrence Livermore National Lab
>
> Office: 925-423-6186
>
> Cell: 210-480-8000
>
> +
>
>
>
>
>
>
> --
>
> What most experimenters take for granted before they begin their
> expe

Re: [petsc-users] Kronecker Product

2023-01-30 Thread Guglielmo, Tyler Hardy via petsc-users
I would need the Kronecker product to be explicitly available to perform matrix 
exponentials.  A and B are of order 5000, so not too large.  I will give 
storing them on all ranks a shot.  Thanks for the tips!

Best,
Tyler

From: Barry Smith 
Date: Monday, January 30, 2023 at 12:01 PM
To: Guglielmo, Tyler Hardy 
Cc: petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] Kronecker Product

  What is large? If A and B have dimensions of 1000, then the Kronecker product 
is of size 1,000,000. Do you want the Kronecker product to be explicitly formed 
or just available as matrix vector products?  If just explicitly available then 
I think you can just store sparse A (for example) completely on all ranks, 
10,000 by 10,000 sparse matrix is small for sequential) while B is distributed.

Barry



On Jan 30, 2023, at 2:48 PM, Guglielmo, Tyler Hardy  wrote:

Both matrices (A and B) would be approximately the same size and large.  The 
use case (for me at least) is to create several large sparse matrices which 
will be combined in various ways through Kronecker products.  The combination 
happens at every time step in an evolution, so it really needs to be fast as 
well.  I’m thinking mpi/petsc is probably not the most optimal way for dealing 
with this, and might just have to work with single node multi-threading.

Best,
Tyler

From: Matthew Knepley mailto:knep...@gmail.com>>
Date: Monday, January 30, 2023 at 11:31 AM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: Barry Smith mailto:bsm...@petsc.dev>>, 
petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product
On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Thanks Barry,

I saw that function, but wasn’t sure how to apply it since the documentation 
says that S and T are dense matrices, but in my case all matrices involved are 
sparse.  Is there a way to work around the dense requirement?

We don't have parallel sparse-sparse. It would not be too hard to write, but it 
would be some work.

It is hard to understand the use case. Is one matrix much smaller? If not, and 
you inherit the distribution from A, it seems
like it might be very suboptimal, and otherwise you would have to redistribute 
on the fly and it would get very complicated.

  Thanks,

 Matt

Best,
Tyler

From: Barry Smith mailto:bsm...@petsc.dev>>
Date: Monday, January 30, 2023 at 11:12 AM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product

   Do you need the explicit sparse representation of the Kronecker product? Or 
do you want to apply it as an operator or solve systems with it? If the latter 
you can use 
https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij<https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>

  Barry



On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:

Hi all,

I am wondering if there is any functionality for taking Kronecker products of 
large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
found, but it seems like this does not work for parallel matrices.  Any ideas 
here?

An option could be to make A and B sequential, compute the Kronecker product, 
C, then scatter C into a parallel matrix?  This seems like a horribly 
inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
:)!

Best,
Tyler

+
Tyler Guglielmo
Postdoctoral Researcher
Lawrence Livermore National Lab
Office: 925-423-6186
Cell: 210-480-8000
+



--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<https://urldefense.us/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!G2kpM7uM-TzIFchu!nK03nUENfNtHoOs8RWmJWJQYJH2IlC_lYQPNn7kV9FsBv2CQKR_VSqbLGRLFShVpKmY$>



Re: [petsc-users] Kronecker Product

2023-01-30 Thread Barry Smith

  What is large? If A and B have dimensions of 1000, then the Kronecker product 
is of size 1,000,000. Do you want the Kronecker product to be explicitly formed 
or just available as matrix vector products?  If just explicitly available then 
I think you can just store sparse A (for example) completely on all ranks, 
10,000 by 10,000 sparse matrix is small for sequential) while B is distributed.

Barry


> On Jan 30, 2023, at 2:48 PM, Guglielmo, Tyler Hardy  
> wrote:
> 
> Both matrices (A and B) would be approximately the same size and large.  The 
> use case (for me at least) is to create several large sparse matrices which 
> will be combined in various ways through Kronecker products.  The combination 
> happens at every time step in an evolution, so it really needs to be fast as 
> well.  I’m thinking mpi/petsc is probably not the most optimal way for 
> dealing with this, and might just have to work with single node 
> multi-threading.
>  
> Best,
> Tyler
>  
> From: Matthew Knepley mailto:knep...@gmail.com>>
> Date: Monday, January 30, 2023 at 11:31 AM
> To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
> Cc: Barry Smith mailto:bsm...@petsc.dev>>, 
> petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> 
> mailto:petsc-users@mcs.anl.gov>>
> Subject: Re: [petsc-users] Kronecker Product
> 
> On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users 
> mailto:petsc-users@mcs.anl.gov>> wrote:
> Thanks Barry,
>  
> I saw that function, but wasn’t sure how to apply it since the documentation 
> says that S and T are dense matrices, but in my case all matrices involved 
> are sparse.  Is there a way to work around the dense requirement?
>  
> We don't have parallel sparse-sparse. It would not be too hard to write, but 
> it would be some work.
>  
> It is hard to understand the use case. Is one matrix much smaller? If not, 
> and you inherit the distribution from A, it seems
> like it might be very suboptimal, and otherwise you would have to 
> redistribute on the fly and it would get very complicated.
>  
>   Thanks,
>  
>  Matt
>  
> Best,
> Tyler
>  
> From: Barry Smith mailto:bsm...@petsc.dev>>
> Date: Monday, January 30, 2023 at 11:12 AM
> To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
> Cc: petsc-users@mcs.anl.gov <mailto:petsc-users@mcs.anl.gov> 
> mailto:petsc-users@mcs.anl.gov>>
> Subject: Re: [petsc-users] Kronecker Product
> 
>  
>Do you need the explicit sparse representation of the Kronecker product? 
> Or do you want to apply it as an operator or solve systems with it? If the 
> latter you can use 
> https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij 
> <https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>
>  
>   Barry
>  
>  
> 
>  
> 
> On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
> mailto:petsc-users@mcs.anl.gov>> wrote:
>  
> Hi all,
>  
> I am wondering if there is any functionality for taking Kronecker products of 
> large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
> found, but it seems like this does not work for parallel matrices.  Any ideas 
> here? 
>  
> An option could be to make A and B sequential, compute the Kronecker product, 
> C, then scatter C into a parallel matrix?  This seems like a horribly 
> inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
> :)!
>  
> Best,
> Tyler 
>  
> +
> Tyler Guglielmo
> Postdoctoral Researcher
> Lawrence Livermore National Lab
> Office: 925-423-6186
> Cell: 210-480-8000
> +
>  
> 
>  
> -- 
> What most experimenters take for granted before they begin their experiments 
> is infinitely more interesting than any results to which their experiments 
> lead.
> -- Norbert Wiener
>  
> https://www.cse.buffalo.edu/~knepley/ 
> <https://urldefense.us/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!G2kpM7uM-TzIFchu!nK03nUENfNtHoOs8RWmJWJQYJH2IlC_lYQPNn7kV9FsBv2CQKR_VSqbLGRLFShVpKmY$>


Re: [petsc-users] Kronecker Product

2023-01-30 Thread Guglielmo, Tyler Hardy via petsc-users
Both matrices (A and B) would be approximately the same size and large.  The 
use case (for me at least) is to create several large sparse matrices which 
will be combined in various ways through Kronecker products.  The combination 
happens at every time step in an evolution, so it really needs to be fast as 
well.  I’m thinking mpi/petsc is probably not the most optimal way for dealing 
with this, and might just have to work with single node multi-threading.

Best,
Tyler

From: Matthew Knepley 
Date: Monday, January 30, 2023 at 11:31 AM
To: Guglielmo, Tyler Hardy 
Cc: Barry Smith , petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] Kronecker Product
On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:
Thanks Barry,

I saw that function, but wasn’t sure how to apply it since the documentation 
says that S and T are dense matrices, but in my case all matrices involved are 
sparse.  Is there a way to work around the dense requirement?

We don't have parallel sparse-sparse. It would not be too hard to write, but it 
would be some work.

It is hard to understand the use case. Is one matrix much smaller? If not, and 
you inherit the distribution from A, it seems
like it might be very suboptimal, and otherwise you would have to redistribute 
on the fly and it would get very complicated.

  Thanks,

 Matt

Best,
Tyler

From: Barry Smith mailto:bsm...@petsc.dev>>
Date: Monday, January 30, 2023 at 11:12 AM
To: Guglielmo, Tyler Hardy mailto:gugliel...@llnl.gov>>
Cc: petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov> 
mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Kronecker Product

   Do you need the explicit sparse representation of the Kronecker product? Or 
do you want to apply it as an operator or solve systems with it? If the latter 
you can use 
https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij<https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>

  Barry



On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
mailto:petsc-users@mcs.anl.gov>> wrote:

Hi all,

I am wondering if there is any functionality for taking Kronecker products of 
large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
found, but it seems like this does not work for parallel matrices.  Any ideas 
here?

An option could be to make A and B sequential, compute the Kronecker product, 
C, then scatter C into a parallel matrix?  This seems like a horribly 
inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
:)!

Best,
Tyler

+
Tyler Guglielmo
Postdoctoral Researcher
Lawrence Livermore National Lab
Office: 925-423-6186
Cell: 210-480-8000
+



--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<https://urldefense.us/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!G2kpM7uM-TzIFchu!nK03nUENfNtHoOs8RWmJWJQYJH2IlC_lYQPNn7kV9FsBv2CQKR_VSqbLGRLFShVpKmY$>


Re: [petsc-users] Kronecker Product

2023-01-30 Thread Matthew Knepley
On Mon, Jan 30, 2023 at 2:24 PM Guglielmo, Tyler Hardy via petsc-users <
petsc-users@mcs.anl.gov> wrote:

> Thanks Barry,
>
>
>
> I saw that function, but wasn’t sure how to apply it since the
> documentation says that S and T are dense matrices, but in my case all
> matrices involved are sparse.  Is there a way to work around the dense
> requirement?
>

We don't have parallel sparse-sparse. It would not be too hard to write,
but it would be some work.

It is hard to understand the use case. Is one matrix much smaller? If not,
and you inherit the distribution from A, it seems
like it might be very suboptimal, and otherwise you would have to
redistribute on the fly and it would get very complicated.

  Thanks,

 Matt


> Best,
>
> Tyler
>
>
>
> *From: *Barry Smith 
> *Date: *Monday, January 30, 2023 at 11:12 AM
> *To: *Guglielmo, Tyler Hardy 
> *Cc: *petsc-users@mcs.anl.gov 
> *Subject: *Re: [petsc-users] Kronecker Product
>
>
>
>Do you need the explicit sparse representation of the Kronecker
> product? Or do you want to apply it as an operator or solve systems with
> it? If the latter you can use
> https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij
> <https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>
>
>
>
>   Barry
>
>
>
>
>
>
>
> On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users <
> petsc-users@mcs.anl.gov> wrote:
>
>
>
> Hi all,
>
>
>
> I am wondering if there is any functionality for taking Kronecker products
> of large sparse matrices that are parallel?  MatSeqAIJKron is as close as I
> have found, but it seems like this does not work for parallel matrices.
> Any ideas here?
>
>
>
> An option could be to make A and B sequential, compute the Kronecker
> product, C, then scatter C into a parallel matrix?  This seems like a
> horribly inefficient procedure.  I’m still fairly new to petsc, so thanks
> for patience :)!
>
>
>
> Best,
>
> Tyler
>
>
>
> +
>
> Tyler Guglielmo
>
> Postdoctoral Researcher
>
> Lawrence Livermore National Lab
>
> Office: 925-423-6186
>
> Cell: 210-480-8000
>
> +
>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>


Re: [petsc-users] Kronecker Product

2023-01-30 Thread Guglielmo, Tyler Hardy via petsc-users
Thanks Barry,

I saw that function, but wasn’t sure how to apply it since the documentation 
says that S and T are dense matrices, but in my case all matrices involved are 
sparse.  Is there a way to work around the dense requirement?

Best,
Tyler

From: Barry Smith 
Date: Monday, January 30, 2023 at 11:12 AM
To: Guglielmo, Tyler Hardy 
Cc: petsc-users@mcs.anl.gov 
Subject: Re: [petsc-users] Kronecker Product

   Do you need the explicit sparse representation of the Kronecker product? Or 
do you want to apply it as an operator or solve systems with it? If the latter 
you can use 
https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij<https://urldefense.us/v3/__https:/petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/*matcreatekaij__;Iw!!G2kpM7uM-TzIFchu!lSQ9WFlYi6PMdfs3WAfEq4ydgCLZtfDgyFy9PjdLNTisCsHtwmVuukcpIv1J0i1EtiQ$>

  Barry





On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
 wrote:

Hi all,

I am wondering if there is any functionality for taking Kronecker products of 
large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
found, but it seems like this does not work for parallel matrices.  Any ideas 
here?

An option could be to make A and B sequential, compute the Kronecker product, 
C, then scatter C into a parallel matrix?  This seems like a horribly 
inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
:)!

Best,
Tyler

+
Tyler Guglielmo
Postdoctoral Researcher
Lawrence Livermore National Lab
Office: 925-423-6186
Cell: 210-480-8000
+



Re: [petsc-users] Kronecker Product

2023-01-30 Thread Barry Smith

   Do you need the explicit sparse representation of the Kronecker product? Or 
do you want to apply it as an operator or solve systems with it? If the latter 
you can use 
https://petsc.org/release/docs/manualpages/Mat/MatCreateKAIJ/#matcreatekaij

  Barry



> On Jan 30, 2023, at 12:53 PM, Guglielmo, Tyler Hardy via petsc-users 
>  wrote:
> 
> Hi all,
>  
> I am wondering if there is any functionality for taking Kronecker products of 
> large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
> found, but it seems like this does not work for parallel matrices.  Any ideas 
> here? 
>  
> An option could be to make A and B sequential, compute the Kronecker product, 
> C, then scatter C into a parallel matrix?  This seems like a horribly 
> inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
> :)!
>  
> Best,
> Tyler 
>  
> +
> Tyler Guglielmo
> Postdoctoral Researcher
> Lawrence Livermore National Lab
> Office: 925-423-6186
> Cell: 210-480-8000
> +



[petsc-users] Kronecker Product

2023-01-30 Thread Guglielmo, Tyler Hardy via petsc-users
Hi all,

I am wondering if there is any functionality for taking Kronecker products of 
large sparse matrices that are parallel?  MatSeqAIJKron is as close as I have 
found, but it seems like this does not work for parallel matrices.  Any ideas 
here?

An option could be to make A and B sequential, compute the Kronecker product, 
C, then scatter C into a parallel matrix?  This seems like a horribly 
inefficient procedure.  I’m still fairly new to petsc, so thanks for patience 
:)!

Best,
Tyler

+
Tyler Guglielmo
Postdoctoral Researcher
Lawrence Livermore National Lab
Office: 925-423-6186
Cell: 210-480-8000
+


[petsc-users] Kronecker product

2019-02-25 Thread Yuyun Yang via petsc-users
Hello team,

I'd like to ask whether PETSc has a function to compute the Kronecker product 
of a sparse matrix with an identity matrix? A Google search didn't lead me to a 
manual page (like most of the other PETSc functions), so I'm wondering if this 
has been implemented yet.

Thanks very much!

Best,
Yuyun


Re: [petsc-users] Kronecker product

2019-02-25 Thread Jed Brown via petsc-users
MatCreateMAIJ does that (implicitly).

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateMAIJ.html

If you want a Kronecker product with a non-identity matrix, this PR may
be of interest.

https://bitbucket.org/petsc/petsc/pull-requests/1334/rmills-mat-kaij/diff

Yuyun Yang via petsc-users  writes:

> Hello team,
>
> I'd like to ask whether PETSc has a function to compute the Kronecker product 
> of a sparse matrix with an identity matrix? A Google search didn't lead me to 
> a manual page (like most of the other PETSc functions), so I'm wondering if 
> this has been implemented yet.
>
> Thanks very much!
>
> Best,
> Yuyun