Status of TBB
I'm planing to use TBB for thread parallelism in a ISTL based project. I'm willing to prepare a MR in dune-istl when I introduced all the TBB calls. But I'm wondering what is the actual status of TBB in dune? The build infrastructure is there but it is not used in the core modules. On the 2017 developer meeting was a discussion about that: https://dune-project.org/community/meetings/2017-03-devmeeting/threading-infrastructure/
That is what was agreed on:
We could introduce an abstraction layer. But that only makes sense if we have at least a rough idea regarding the possible variability of the interface. We do not know about any other possible interface. And wrapping will in some cases be quite expensive (support wise)
and
We standardise on TBB without abstraction/wrappers. TBB remains optional: if not available there will be not automatic threading in the core modules. Infrastructure that only makes sense in connection with TBB may be missing then. - We do not allow OpenMP in core modules. Users may use OpenMP in their own modules. - We generally disallow threads not managed by the thread pool. In special cases you may start threads outside (e.g. for communicating in the background), but you need to ensure that there are no adverse effects, e.g. performace loss due to oversubscription. - When there is equivalent functionality in TBB and the C++ standard, prefer the standard functionality.
Does that mean, that whenever I want to use TBB in the core modules if have to provide a fallback like
#if HAVE_TBB
tbb::parallel_for(..., [](...){
...
}):
#else
for(...){
...
}
#endif
I think that would lead to very ugly code. Should we provide at least convenient functions for the most used cases like parallel_for
?