I typically use a static inlining approach to specialization. I have an old branch somewhere with experiments along these lines for BAIJ, but this is the strategy in real code (for small tensor contractions).
https://github.com/CEED/libCEED/blob/main/backends/avx/ceed-avx-tensor.c#L240-L246 The SF case is unique in that most of the genericness is to cover different types, not just array lengths to specialize on. Junchao used C++ templates to do the same things in the Kokkos SF backend and I think it's fair to say the C++ version is at least as good provided you're willing to use C++. Mark Adams <[email protected]> writes: > That sounds like a good idea. > We can do this incrementally: add some (Jed's) preprocessor into configure, > let Frank use that and we can replace old flexible ones as desired. > > On Tue, Dec 29, 2020 at 6:41 PM Matthew Knepley <[email protected]> wrote: > >> I do not mind accepting Frank's MR. However, if this is a 2x improvement >> for something that is often done, should we think about having >> a nicer way to add block sizes? Jed has code for different blocks using >> the preprocessor (I think) in sfbasic, and we have top-level switches >> in PBJACOBI and (I think) MatInvertDiagonal. Should we agree on a good >> strategy and use it everywhere? >> >> Matt >> >> On Tue, Dec 29, 2020 at 10:32 AM Mark Adams <[email protected]> wrote: >> >>> Yes, this is a useful thing to have. AIJ assembly is always a problem and >>> this seems like a good optimization to have in there. >>> Thanks, >>> Mark >>> >>> On Tue, Dec 29, 2020 at 9:47 AM Frank Bramkamp <[email protected]> >>> wrote: >>> >>>> >>>> Dear Mark, >>>> >>>> then I can do this. >>>> I will add it to the sequential and parallel part. >>>> Probably useful for everyone. >>>> >>>> Greetings, Frank >>>> >>>> >>>> >>>> >> >> -- >> 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/> >>
