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 #include <Eigen/Dense> __attribute__((target_clones("avx512f","avx2","default"))) int func1(){ ...Eigen releated... } */ 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? Thank you.
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.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1542.