pghysels / STRUMPACK

Structured Matrix Package (LBNL)
http://portal.nersc.gov/project/sparse/strumpack/
Other
167 stars 40 forks source link

Butterfly matrix compress with blocks of elements? #121

Open mdschroer opened 3 months ago

mdschroer commented 3 months ago

Is building a butterfly matrix from blocks of elements supported? It looks like it is supported by ButterflyPACK, but as best as I can tell it hasn't yet been implemented in the STRUMPACK wrapper.

I can save a little bit of calculations with my kernel by computing a block at a time, as opposed to element by element. Do you expect the butterfly construct_from_elements to support block-by-block construction in the future?

Thanks!

liuyangzhuan commented 3 months ago

@pghysels any thought on this? I thought we already have it in strumpack sparse matrix interface, but maybe not yet for the dense interface?

pghysels commented 3 months ago

Apologies for the delay, yes it is supported: https://github.com/pghysels/STRUMPACK/blob/d64fa989fc5c70922ae7944e9515034f86890b61/src/HODLR/ButterflyMatrix.hpp#L124

elem_blocks_t is defined here: https://github.com/pghysels/STRUMPACK/blob/d64fa989fc5c70922ae7944e9515034f86890b61/src/HODLR/HODLRMatrix.hpp#L97 you can ignore the ExtractionMeta argument.

mdschroer commented 3 months ago

Ah gotcha! I guess that it isn't implemented in the structured interface (that I had been using), but is in the ButterflyMatrix class directly? I'll switch to using the ButterflyMatrix class.

Thanks guys!

pghysels commented 3 months ago

I think this one: https://portal.nersc.gov/project/sparse/strumpack/v7.2.0/namespacestrumpack_1_1structured.html#a93b718a88093b1cb9769a28eb04c6b9a

mdschroer commented 3 months ago

Hmm. When I try to build a butterfly matrix using the structured interface and block extraction, I get a std::logic_error "Not implemented yet". The same code works fine with element-by-element extraction.

For reference, my matrix is a complex, with non-square shape.

If the situation isn't immediately apparent, I can put together some reproducer code.

Thanks!

liuyangzhuan commented 3 months ago

Yes, please post some example code for the ease of diagnosis.

On Wed, Jul 3, 2024 at 8:53 AM mdschroer @.***> wrote:

Hmm. When I try to build a butterfly matrix using the structured interface and block extraction, I get a std::logic_error "Not implemented yet".

For reference, my matrix is a complex, with non-square shape.

If the situation isn't immediately apparent, I can put together some reproducer code.

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/pghysels/STRUMPACK/issues/121#issuecomment-2206654468, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT6SCRWJPC5RXGWZTDURO3ZKQM7JAVCNFSM6AAAAABJ2RPKRSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBWGY2TINBWHA . You are receiving this because you commented.Message ID: @.***>

-- Yang Liu Research Scientist Lawrence Berkeley National Laboratory

pghysels commented 3 months ago

It looks like that exception is coming from https://github.com/pghysels/STRUMPACK/blob/d64fa989fc5c70922ae7944e9515034f86890b61/src/structured/StructuredMatrix.cpp#L951 The functionality should be there for ButterflyMatrix (including complex and non-square), but just not added to the StructuredMatrix interface. I don't have time to do that this week. I'll try next week. You could try the class ButterflyMatrix directly: https://github.com/pghysels/STRUMPACK/blob/d64fa989fc5c70922ae7944e9515034f86890b61/src/HODLR/ButterflyMatrix.hpp#L123