Community
cancel
Showing results for 
Search instead for 
Did you mean: 
bp
Beginner
257 Views

intrinsic for CPUID like informations

I just found that the Intel C++ Compiler XE 13.1 offers this intrinsic

Now I'm under Linux with g++ and I would like to know if there is a similar intrinsic.

Thanks.

0 Kudos
12 Replies
SergeyKostrov
Valued Contributor II
257 Views

The _may_i_use_cpu_feature intrinsic function is declared in immintrin.h header file and I'm no sure if you could use the instruction if CPU doesn't support AVX or AVX2 instruction sets.
SergeyKostrov
Valued Contributor II
257 Views

>>...I'm no sure if you could use the instruction if CPU doesn't support AVX or AVX2 instruction sets... It is working and it means the function uses a generic IA32 set of Intel instructions. Here are runtime outputs for two different systems: [ TestApp Executed on Ivy Bridge ] _FEATURE_SSE = 1 _FEATURE_SSE2 = 1 _FEATURE_F16C = 1 _FEATURE_AVX = 1 _FEATURE_AVX2 = 0 [ TestApp Executed on Pentium 4 ] _FEATURE_SSE = 1 _FEATURE_SSE2 = 1 _FEATURE_F16C = 0 _FEATURE_AVX = 0 _FEATURE_AVX2 = 0 Note: A test program TestApp was built on Ivy Bridge with VS 2008.
maratyszcza
Beginner
257 Views

gcc 4.8 provides similar feature via __builtin_cpu_supports intrinsic. See GCC 4.8 release notes for details: http://gcc.gnu.org/gcc-4.8/changes.html

SergeyKostrov
Valued Contributor II
257 Views

I'd like to add that the name of the intrinsic function: _may_i_use_cpu_feature looks very strange and it violates already defined naming conventions, that is, using _mm_ prefix for 99% of all intrinsic functions. I think Intel needs to rename the function to: __cpufeature ( similar to __cpuid ) or _mm_cpufeature and please consider it as a Feature Request. Thanks.
andysem
New Contributor III
257 Views

While I agree that _may_i_use_cpu_feature is a very odd name, I don't think that _mm_ prefix is appropriate because cpuid is not a SIMD (or "multimedia", in the early Intel terms; remember MMX) instruction.

Just for the sake of reference, MSVC supports __cpuid intrinsic: http://msdn.microsoft.com/es-es/library/vstudio/hskdteyh%28v=vs.100%29.aspx. I think, Intel on Windows should support it as well.

Bernard
Black Belt
257 Views

Sergey Kostrov wrote:

I'd like to add that the name of the intrinsic function:

_may_i_use_cpu_feature

looks very strange and it violates already defined naming conventions, that is, using _mm_ prefix for 99% of all intrinsic functions. I think Intel needs to rename the function to:

__cpufeature ( similar to __cpuid )

or

_mm_cpufeature

and please consider it as a Feature Request. Thanks.

Completely agree with you

SergeyKostrov
Valued Contributor II
257 Views

[ SergeyK suggested ] >>...I think Intel needs to rename the function to: >> >>__cpufeature ( similar to __cpuid ) [ Andysem wrote ] >>...I don't think that _mm_ prefix is appropriate because cpuid is not a SIMD... Here is a question: Why wouldn't we vote for __cpufeature name?
SergeyKostrov
Valued Contributor II
257 Views

A test case is very simple and here it is: #include "immintrin.h" #define __cpufeature _may_i_use_cpu_feature int _tmain( void ) { int iSse = __cpufeature( _FEATURE_SSE ); int iSse2 = __cpufeature( _FEATURE_SSE2 ); int iF16c = __cpufeature( _FEATURE_F16C ); int iAvx = __cpufeature( _FEATURE_AVX ); int iAvx2 = __cpufeature( _FEATURE_AVX2 ); _tprintf( _T("_FEATURE_SSE = %d\n") _T("_FEATURE_SSE2 = %d\n") _T("_FEATURE_F16C = %d\n") _T("_FEATURE_AVX = %d\n") _T("_FEATURE_AVX2 = %d\n"), iSse, iSse2, iF16c, iAvx, iAvx2 ); return ( int )0; }
andysem
New Contributor III
257 Views

Sergey Kostrov wrote:

Here is a question: Why wouldn't we vote for __cpufeature name?

Yes, that naming is my preference. +1 for renaming.

Bernard
Black Belt
257 Views

>>>Here is a question: Why wouldn't we vote for __cpufeature name?>>>

Proper for name for cpuid intrinsic function.

andysem
New Contributor III
257 Views

> Proper for name for cpuid intrinsic function.

cpuid intrinsic is more useful when you want to test for multiple features. Which, by the way, is often the case when testing for different versions of SSE/AVX.

SergeyKostrov
Valued Contributor II
257 Views

I like that new intrinsic function and I used it already a couple of times. However, I vote for a change to __cpufeature name and the list of supported features needs to be extended. Thanks in advance.
Reply