New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 1542 - gcc-6 function multiple version didn't work with Eigen (target_clones)
Summary: gcc-6 function multiple version didn't work with Eigen (target_clones)
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - AVX Linux
: Normal Feature Request
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-12 00:22 UTC by Zhili Zheng
Modified: 2018-04-14 18:40 UTC (History)
3 users (show)



Attachments

Description Zhili Zheng 2018-04-12 00:22:36 UTC
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.
Comment 1 Christoph Hertzberg 2018-04-14 18:40:26 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.