sxs-collaboration / spectre

SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics.
https://spectre-code.org
Other
158 stars 189 forks source link

Improve Blaze-interoperability of our matrix types #3377

Open nilsvu opened 3 years ago

nilsvu commented 3 years ago

Feature request:

It would be nice to consolidate our matrix types and improve their interoperability with Blaze. Currently we have:

The types are subclasses (instead of aliases) so they can be forward-declared. Here are the problems with this setup:

Similar issues apply to our vector types: We use our own custom DataVector a lot, but don't currently make use of Blaze features like grouping/tagging.

Does anyone have ideas how to improve interoperability with Blaze in our code? I've been thinking we could work more directly with Blaze types, but writing the blaze:: namespace all over the codebase seems like a bad idea since it couples us too tightly to Blaze. Perhaps we could do something like our tmpl namespace that's just an alias for brigand, e.g. linalg = blaze? I can't think of a great way how to organize includes and forward-decls in that case though.

nilsdeppe commented 3 years ago
  1. I'm not sure it would be good to set it to max size. 12x12 is okay, but if someone increases that for testing they'll blow the stack pretty quickly. That seems like an bug. We also don't create matrices that often, they're usually cached and passed by reference. I regularly used 50+ basis functions for testing subcell, for example.
  2. it uses dgemm_ calling into LIBXSMM. This is quite a bit faster than what Blaze does. If I remember correctly someone requested Blaze add LIBXSMM support a year or two back in an issue on the Blaze repo.

We do use grouping/tagging, just we used it before Blaze had official support for it. We could reasonably switch to using that in the backend, but this seems like it could be a lot of work with no benefit. I'm not sure what advantage Blaze's official grouping/tagging has over the under-the-hood stuff we use.

From this issue it's not clear to me what interoperability you are looking for. This seems like a question about why we don't use HybridMatrix, Blaze's operator* (or whatever the call to matrix multiplication is), and Blaze's grouping/tagging. What operation(s) are you trying to do that don't work?