Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6701 Discussions

CPU feature recognition not always working


Hey there,

I am facing a problem with the ippInit() auto recognition of the available and enabled features. This only seems to happen on a WinXP SP3 32-bit on a notebook running an Intel i3-2348M. Some times our software was crashing with an illegal instruction error. We were able to identify an AVX instruction that was being executed. Since WinXP is not able to handle AVX at all it should not be enabled. This is in about 90-95% of the cases true but in these 5-10% IPP selects the g9 arch which would be AVX capable. Most of the time the p8 arch is selected which is totally fine for WinXP and the given CPU.

Now I am not sure how the initialization of the enabled instructionssets is working. Though I suspect that it needs to be enabled by the OS kernel, I am not quite sure about that.

My suspicion is based on this little code example i used for my tests:

#include "stdafx.h"

#include "immintrin.h"
#include <iostream>

#include "ippi.h"
#include "ippcore.h"
#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])
 	__m256* a;
 	__m256 b;

	int i = 0;

	Ipp64u features;
	ippGetCpuFeatures(&features, 0);
 	IppStatus status = ippInit();
 	std::cout << ippGetLibVersion()->Version << " " << ippiGetLibVersion()->targetCpu << "; hasAVX: " << (features & ippCPUID_AVX) << "; hasOSAVX: " << (features & ippAVX_ENABLEDBYOS) << std::endl;

 	while (i<100)
 		a = new __m256;
 		std::cout << "*a = " << ((float*)a)[0] << " " << ((float*)a)[1] << " " << ((float*)a)[2] << " " << ((float*)a)[3] << std::endl;
 		std::cout << "a = " << a << std::endl;
 		b = _mm256_loadu_ps((float*)a);
 		std::cout << "b = " << ((float*)&b)[0] << ((float*)&b)[1] << ((float*)&b)[2] << ((float*)&b)[3] << std::endl;

	return 0;

This usually gives us a p8 arch on WinXP but sometimes we get the mentioned g9. This behavior can sometimes be seen more often after a reboot. The latter codepart (the while loop) should mess with the AVX instruction. This works on some Win8.1 but crashes on WinXP though it sometimes does get through one iteration. I know that this could result from (un)lucky timing with the windows scheduler. For testing the selected arch I commented out the loop and executed the program 100 times using some batch for loop.

Still my colleagues and I have no clue why IPP is selecting the wrong arch. Right now we catch that case and initialize with the p8 arch manually. Does anyone have a clue? Thanks in advance.

0 Kudos
1 Reply

Hi Marcel,

please check - IPP uses the same official mechanizm. If you are able to reproduce this issue with the code from this page, than  most probably something is wrong with your WinXP installation. If not - then let's try to find the root of this issue using joint debugging session.

regards, Igor

0 Kudos