[Dune-devel] Explicit template instantiation

Dedner, Andreas A.S.Dedner at warwick.ac.uk
Wed Feb 17 13:14:34 CET 2021


Hi,
I'm probably missing what this proposal is about - but wouldn't this increase build time for everyone even if I don't use this instantiation? So if I'm not interested in YaspGrid then I pay the instatiation cost while building dune-grid?

Why is this actually needed in the core modules? If someone wants speedup for yaspgrid for the executables in their own 'dune-foo' module. they can instantiate in a 'libdunefoo' and will also have it downstream from dune-foo? They could even have a `dune-yaspgrid` module with only this library in it and have `dune-foo` depend on or suggest `dune-yaspgrid` with exactly the same effect but without changing anything in dune-grid and requiring opt-in/opt-out in the configuration.

Best
Andreas
________________________________
From: Dune-devel <dune-devel-bounces at lists.dune-project.org> on behalf of Carsten Gräser <graeser at mi.fu-berlin.de>
Sent: 17 February 2021 12:04
To: dune-devel at lists.dune-project.org <dune-devel at lists.dune-project.org>
Subject: Re: [Dune-devel] Explicit template instantiation

Am 16.02.21 um 23:53 schrieb Simon Praetorius:
>> 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.
>
> I don't know what is the best way to go. But I'm afraid that not
> writing the "extern termplate" in the headers would be more
> irritating than helping. We would just gain longer compile times for
> the libraries - not the opposite. And then the explicit instantiation
I don't understand this argument:

* If the template was implicitly instantiated in the library before,
   doing it explicitly now should not increase library build time.
* If the template was not implicitly instantiated in the library before,
   you must instantiate it explicitly now, which increases library build
   time. Otherwise you can't use it downstream. At some place you have
   to do the instantiation. The whole purpose of the proposal seems to
   be, to move this cost upward in the build hierarchy in order to prevent
   paying it multiple times downstream.

> (with prevented implicit instantiation) would mostly not be used. But
> it is something very positive for the user. I think just "well
> documentation" is not enough.
If there is some performance penalty, introducing this silently
is IMO a no-go. Hence I would prefer an opt-in approach.
An alternative to the fully manual approach I proposed before,
would be to provide a single header (per module) with all the
`extern template...` declarations for the instances contained
in the library. Then the user can opt-in by including this header.

Best,
Carsten

_______________________________________________
Dune-devel mailing list
Dune-devel at lists.dune-project.org
https://lists.dune-project.org/mailman/listinfo/dune-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20210217/2568d496/attachment.htm>


More information about the Dune-devel mailing list