Add preprocessor macro DUNE_FORCE_INLINE
Summary
Some recursive algorithms can only be optimized properly if the function calls are inlined. It has been observed that the compiler heuristics are not always enough to trigger this inlining, e.g., in !1447 for the tensor index contraction algorithm. This MR provides a unified way to force inlining of functions if possible, or trigger an error if not. It uses the attribute always_inline
and for MSVC uses [[msvc::forceinline]]
. It has been tested in !1447 (and in https://gitlab.dune-project.org/simon.praetorius/dune-tensor) and leads to better optimized code.
Discussion
The code is put into the directory dune/common/std
since actually it should be available via the standard attribute [[always_inline]]
. Unfortunately, not all compilers (and version) interpret this attribute correctly. Thus a convenience fallback implementation using the compiler-specific attributes is provided.
ToDo
-
Add changelog entry