Enable automatic function multiversioning #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some time, we have disabled the use of AVX instructions when compiling in order to prevent issues (SIGILL) for users who compile on an AVX-capable machione, but then run their programs on a machine which predates those instructions. This makes little difference for single-precision evaluation, but hurts significantly for double-precision evaulation.
GCC's function multiversioning feature offers a way to have our cake and eat it too, in the sense of enabling these instructions at runtime only on machines which can use them. Direct us of that feature is annoying, however, as it requires an entire separate function definition for each version. That would makes sense when using vector intrinsics explicitly, but we don't and duplicating code would be ugly. However, the related target_clones attribute offers a way to get this done more automatically.
Testing seems to indicate that this can substantially mitigate the slow-down involved in switching to double-precision evaluation:
'multiple'/full gradient evaluation rate with
photospline-bench-templated
:(d=double precision evaluation)
Mesaured on an AMD 3950X @ 3.5GHz (boost disabled), compiled with GCC 8.5.
Known concerns:
-fPIC
on the library/-fPIE
on users of it.