gcc-6 has a robust feature that can compile and dispatch different functions according to hardware supported.
(One example: https://lwn.net/Articles/691932/)
However, when compile with Eigen
gcc-6 -msse2 -I$EIGEN_DIR
/* codes start
*/ codes end
From the assembly view, Eigen compiled with only SSE2 support. The func1 do have avx512, avx2, and sse variants, but the contents are almost the same.
I know Eigen decides the feature supported in the compile time (template), determined by the compile flags pass in.
Is it possible to hot switch while target_clones gives different compile flags in his variant function?
I don't see how this would even theoretically solvable.
Maybe it is possible to clutter all Eigen functions with __attribute__((target_clones( ... ))) and hope that inlining makes this magically work.
The alternative is to compile multiple versions of the function with different flags and link them together.