Thomas Schwinge wrote:
The idea of transitioning libgomp from C to C++ implementation has come
up a number of times, where the clunkiness that comes with C++ is
believed to be favorable compared to the clunkiness of the C
implementation.
...
most recently in context of an upcoming OpenMP OMPT
implementation […], to be able to use "boolean templates" as a compilation
toggle, to get certain functions compiled for both of with vs. without
OMPT support, and dynamically at run time, if OMPT isn't actually
enabled
Two notes:
* First, OMPT implementation work is currently being under way; hence,
it makes sense that the C++ is available once the changes are ready
to land. – The Boolean templates are supposed to get resolved at
compile time at call side. Such that the non-OMPT implementation is
inlined - while the OMPT callback version is a non-inlined static
function, invoked if the tool of the user registered a callback for
that feature.
Benchmarking an OMPT implementation showing that while for most
functions, just having an 'if' around the callback handling, for
some code, there is a measurable slow down; thus, for for those
the inlining + function call makes sense - and templates make it
easy to avoid code duplications in a readable way.
* Second, the idea is that for now neither exceptions nor RTTY are
used/enabled and that no additionally library dependency like to
libstdc++ is added, i.e. the idea is to enable only some C++ features
without adding any runtime overhead or runtime dependency.
For OMPT, the idea is also to be able to disable all OMPT completely
('#ifndef') - for all targets that don't support it (or the user
compiling GCC does not want to have it).
In terms of compatibility: This changes requires that all systems that
want to use (thread-based) OpenMP - and, hence, libgomp have support
the C++ compiler - but in terms of target capabilities, this shouldn't
require and additional features than C.
Tobias