Does the underlying CPU have Nehalem microarchitecture? Does the CPU support Intel Advanced Vector Extensions, also known as AVX? Does the CPU support Streaming SIMD Extensions 4.2, also known as SSE 4.2? When you have to write optimized code that tries to take full advantage of the underlying hardware, you definitely require accurate answers to those questions. If you use Intel Integrated Performance Primitives, also known as IPP, simple calls to one or two of its software functions can provide you with all the answers.
As a disclaimer, I must say there are other ways of retrieving detailed information about your Intel multicore CPU features. However, after I discovered two functions in IPP that provide most of the information I usually need, I started to use both the ippGetCpuType and ippGetCpuFeatures functions by calling them in any programming language in which I needed detailed information about the CPU. Just as an example, because IPP includes C# wrappers, it is really easy to call ippGetCpuType in C#.
One of the key advantages of both the ippGetCpuType and ippGetCpuFeatures functions is that they are always updated with the latest Intel microarchitectures and SIMD instruction sets. Whenever there is a new version of IPP, you will usually find that there these functions return new values to identify the newest Intel CPU features available at that moment. This way, you don't need to worry about low-level calls to detect specific CPU features. Instead, you just have to worry about creating optimized code to take full advantage of the new features.
The ippGetCpuType function, declared in ippcore.h, returns an appropriate IppCpuType value according to the detected CPU. This function returns just one type of processor and doesn't return the sum of many features. For example, if the computer or device has a CPU with Intel AVX support, it will return IppCpuType.ippCpuAVX. However, Intel CPUs that include support for Intel AVX also support both Intel SSE 4.2 and SSE 4.1, among other SIMD instruction sets. If the computer or device has an old Clarksfield mobile Intel Core i7 CPU with support for SSE 4.2, ippGetCpuType will return IppCpuType.ippCpuSSE42.
When you need more information about the CPU features, you usually think of the CPUID instruction for the x86 family. You can spend a few weeks reading the detailed Intel Processor Identification and the CPUID instruction. However, it is easier to take advantage of the ippGetCpuFeatures function that makes it simple to retrieve the most important CPU features returned by the CPUID instruction without adding unnecessary complexity or assembly code to your application. With a simple call to ippGetCpuFeatures, you can apply bitwise and operators to the features mask and detect which specific features the CPU provides. This way, you can easily determine whether the CPU provides support to many instruction sets, such as SSE 4.1, SSE 4.2, AES, and AVX, and you can determine the individual support for each of these instruction sets.
In addition, it is possible to detect operating system support for AVX. The mask value ippCUPID_AVX (256) determines AVX support at the CPU level and the mask value ippAVX_ENABLEDBYOS (512) specifies that the operating system supports Intel AVX. If the returned features mask includes ippCUPID_AVX but doesn't include ippAVX_ENABLEDBYOS, you won't be able to take advantage of Intel AVX because the operating system doesn't have the necessary support, even when the CPU is ready to work with the instruction set. You can read about operating system support for AVX in "Windows 7 and Windows Server 2008 R2 Service Pack 1 Bring AVX Support."
Intel IPP is a commercial product, but you can download a free trial version from http://software.intel.com/en-us/intel-ipp/.
If you want to dive deeper into both the ippGetCpuType and ippGetCpuFeatures functions, you can read the detailed documentation for their related enums, masks, parameters, and return values.


