[Dune-devel] Explicit template instantiation
Carsten Gräser
graeser at mi.fu-berlin.de
Tue Feb 16 20:46:13 CET 2021
Dear Simon,
Am 16.02.21 um 16:34 schrieb Simon Praetorius:
> Recently, I have experimented with explicit template instantiation of
> some grid types leading to a reasonable speedup of compile processes.
> In a few applications I have compile times for a single target > 5min
> on a decent machine and was wondering how to to reduce that time.
>
> In summary: explicit template instantiation is a way to enforce an
> instantiation of a template in a translation unit and to prevent from
> implicit instantiations of that same template.
this sounds like a good idea. While link time optimization
may help to do inlineing, unrolling, ... across translation
until boundaries, this potential runtime penalty could be
a valid reason against this.
Maybe this could be done in an opt-in fashion:
* Do not use `extern template` in the header.
* Do some documented explicit instantiation in the library.
* Users may (but don't have to) prohibit implicit instantiation
by using `extern template ...` in their application after
including the header. For sure this can only be done for
those well-documented instantiations contained in the lib.
* If the user does not use `extern template ...` she will
get implicit instantiation as usual.
Best,
Carsten
More information about the Dune-devel
mailing list