Intel® C++ Compiler 16.0 User and Reference Guide
Tells the compiler that the code region may be targeted for processors with the specified features. The compiler may then generate optimized code for the specified features.
extern void _allow_cpu_features(unsigned __int64); |
unsigned __int64 |
an unsigned __int64 bitset representing one or more cpuid features: _FEATURE_GENERIC_IA32 _FEATURE_FPU _FEATURE_CMOV _FEATURE_MMX _FEATURE_FXSAVE _FEATURE_SSE _FEATURE_SSE2 _FEATURE_SSE3 _FEATURE_SSSE3 _FEATURE_SSE4_1 _FEATURE_SSE4_2 _FEATURE_MOVBE _FEATURE_POPCNT _FEATURE_PCLMULQDQ _FEATURE_AES _FEATURE_F16C _FEATURE_AVX _FEATURE_RDRND _FEATURE_FMA _FEATURE_BMI _FEATURE_LZCNT _FEATURE_HLE _FEATURE_RTM _FEATURE_AVX2 _FEATURE_KNCNI _FEATURE_ADX _FEATURE_RDSEED |
Use this intrinsic function to use the specified processor feature at a code block level. The function only affects the scope of the code following the function call. Ensure that the code block will run only on processors with the specified features. If the code runs on a processor without the specified feature, the program may fail with an illegal instruction exception.
To use specified processor features at a function level, use the cpu_dispatch or the cpu_specific attribute or the optimization_parameter pragma.
To use specified processor features at the file level, use the -[Q]x compiler option.
The following example demonstrates how to use this intrinsic function to allow the compiler to generate the necessary code to use the Advanced Vector Extensions (AVX) and Streaming SIMD Extensions 2 (SSE2) features in the processor.
#include <string.h> #include <immintrin.h> #define MAXIMGS 20 #define MAXNAME 512 typedef struct { int x; /* image X axis size */ int y; /* image Y axis size */ int bpp; /* image bits */ char name[MAXNAME]; /* image full filename */ unsigned char * data; /* pointer to raw byte image data */ } rawimage; extern rawimage * imagelist[MAXIMGS]; extern int numimages; rawimage* CreateImage(char * filename) { rawimage* newimage = NULL; int i, len, intable; intable=0; if (numimages!=0) { _allow_cpu_featured(_FEATURE_SSE2,_FEATURE_AVX); for (i=0; i<numimages; i++) { if (!strcmp(filename, imagelist[i]->name)) { newimage=imagelist[i]; intable=1; } } } if (!intable) { newimage=(rawimage *)malloc(sizeof(rawimage)); if (newimage != NULL) { strcpy(newimage->name, filename); imagelist[numimages]=newimage; /* add new one to the table */ numimages++; /* increment the number of images */ } } return newimage; }
Returns nothing.