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

IPP 2018 Update 1 - ippInit issue

Wieszok__Zygfryd
Beginner
1,732 Views

Hello,

Recently we have updated IPP library to 2018 update 1 and we encounter a series of application crush. We have noticed that the reason for failure is the ippInit function which returns non zero status. We have encountered this error for processor Intel I7-7700k. The ippInit function returns code 49 (ippStsFeatureNotSupported) for this processor even though the value is not specified in the documentation. Apart from the erroneous status the AVX and AVX2 features are disabled. Our investigation showed that the ippInit function is written as 

Ipp64u featureMask;
ippGetCpuFeatures(&featureMask)
return ownSetCpuFeaturesAndIdx(featureMask, ?)

The featureMask returned by ippGetCpuFeatures for I7-7700k is 0x1007efff. When we edit the value and pass 0x0007efff to ownSetCpuFeaturesAndIdx, the status 0 is returned and AVX features are enabled. The following picture shows the difference between initialized features :

We have checked the older versions of the library (2017 and 2018.0.0) and the ippInit function worked correctly (status 0) and initialized all available features. Hence the bug is introduced in 2018 update 1.

Do you plan to fix it or do you know any workaround?

0 Kudos
19 Replies
Alice_H_Intel
Employee
1,732 Views

Hello,

I'll investigate this and get back to you soon.

Thanks,

Alice

0 Kudos
Igor_A_Intel
Employee
1,732 Views

Hi Zygfryd,

non-zero status means "error" only in case if it's negative, all status values above zero are just warnings. In your case "StsFeatureNotSupported" status is related to MPX cpu feature and it is just a warning that doesn't affect IPP libraries behavior. You should detect error only if status is negative. MPX feature differentiates SKL (desktop) cpu from other AVX2 cpus (HSW, BDW). Anyway AVX2 code will be dispatched (by default) on your system. We'll remove this warning in the next IPP update/release.

regards, Igor

 

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Hi Igor,

Thank you very much for your response. I would like to make sure about that the AVX2 instructions will be used, because the function ippGetEnabledCpuFeatures reports AVX, AVX2 and MPX instructions as disabled. Do IPP functions use other instructions than those reported by ippGetEnabledCpuFeatures?

Regards
Zygfryd

0 Kudos
Igor_A_Intel
Employee
1,732 Views

Zygfryd,

it's not clear for me why do you call non-public internal function which starts with prefix "own"?

could you compile and execute the very simple code and provide me an output? (Init is not required anymore - library performs auto-initialization):

#include <stdio.h>
#include "ipp.h"

int main (){
    const IppLibraryVersion *lib;

    lib = ippsGetLibVersion();
    printf( "CPU       : %s\n", lib->targetCpu );
    printf( "Name      : %s\n", lib->Name );
    printf( "Version   : %s\n", lib->Version );
    printf( "Build date: %s\n", lib->BuildDate );
    return 0;
}

- just in order to be sure that normal path works correctly

regards, Igor

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Igor, 

I do not use the internal function. I use the standard ippInit function. The code I showed you is the internal implementation of ippInit where I think might be the issue.

I have modified your code a little:

#include <stdio.h>
#include "ipp.h"

int main() {
	const IppLibraryVersion *lib;

	lib = ippsGetLibVersion();
	printf("CPU       : %s\n", lib->targetCpu);
	printf("Name      : %s\n", lib->Name);
	printf("Version   : %s\n", lib->Version);
	printf("Build date: %s\n", lib->BuildDate);

	Ipp64u mask;
	IppStatus status = ippGetCpuFeatures(&mask, nullptr);
	printf("CPU features: %llu\n", mask);
	Ipp64u emask = ippGetEnabledCpuFeatures();
	printf("Supported features: %llu\n", emask);

	return 0;
}

And here is the result:

 testIpp_2.png

As you can see the CPU features and IPP supported features differs. The number shows that following instructions are disabled AVX, AVX2, MPX although they are supported by CPU. 

regards, Zygfryd

0 Kudos
Igor_A_Intel
Employee
1,732 Views

Hi Zyggfryd,

sorry for delay, there is a real bug in default IPP dispatcher in 2018 upd#1, that is related to MPX bit in CPUID (it differentiates SKL desktop from other AVX2 cpus). The workaround is to get cpu features, remove/mask MPX from them, and then call SetCpuFeatures() - correct AVX2 path will be used. We'll provide a fix with the next update very soon.

small test (based on your one):

#include <stdio.h>
#include "ipp.h"

int main() {
    const IppLibraryVersion *lib;

    lib = ippsGetLibVersion();
    printf("CPU       : %s\n", lib->targetCpu);
    printf("Name      : %s\n", lib->Name);
    printf("Version   : %s\n", lib->Version);
    printf("Build date: %s\n", lib->BuildDate);
    Ipp64u mask;
    IppStatus status = ippGetCpuFeatures(&mask, NULL);
    printf("CPU features: %llx\n", mask);
    Ipp64u emask = ippGetEnabledCpuFeatures();
    printf("Supported features: %llx\n", emask);

    status = ippSetCpuFeatures(mask & (IPP_MAX_64U^ippCPUID_MPX));
    emask = ippGetEnabledCpuFeatures();
    printf("Supported features: %llx\n", emask);
    lib = ippsGetLibVersion();
    printf("CPU       : %s\n", lib->targetCpu);
    printf("Name      : %s\n", lib->Name);
    printf("Version   : %s\n", lib->Version);
    printf("Build date: %s\n", lib->BuildDate);

    return 0;
}

output:

bash-4.2$ cc c.c libippvm.a libipps.a libippcore.a
bash-4.2$ ./a.out
CPU       : y8
Name      : ippSP SSE4.2 (y8)
Version   : 2018.0.1 (r56998)
Build date: Oct 11 2017
CPU features: 1007efff
Supported features: 10076eff
Supported features: 7efff
CPU       : l9
Name      : ippSP AVX2 (l9)
Version   : 2018.0.1 (r56998)
Build date: Oct 11 2017
bash-4.2$
 

regards, Igor

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Hi Igor

Thank you for your help. I am looking forward to the update, until then I will use your workaround.

0 Kudos
BMart1
New Contributor II
1,732 Views

Is the fix for this out?

0 Kudos
Chao_Y_Intel
Moderator
1,732 Views

HI Bruno, 
We have the latest IPP 2018.1.1 posted in our registration center.  This was fix in this release.

Thanks,
Chao

0 Kudos
BMart1
New Contributor II
1,732 Views

The latest version https://registrationcenter.intel.com/en/forms/?productid=2558&licensetype=2​ lets me download is 2018.1.156. A newer version is listed for an expired trial of parallel studio and it won't let me download it.

0 Kudos
Chao_Y_Intel
Moderator
1,732 Views

Hi,

The latest one is l_ipp_2018.1.176.tgz.  If you have a valid license for parallel studio XE. In the registration center, it can find it   at "Intel® Parallel Studio XE Cluster Edition for Linux*">> "Intel® Integrated Performance Primitives for Linux*".

Thanks,
Chao

0 Kudos
BMart1
New Contributor II
1,732 Views

I only have the free license for ipp and I use Windows.

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

We have released our application with IPP 2018.0.2 some time ago. Unfortunately, recently one of our clients has come to us with a problem of crashing application on his computer. We have figured out that the application crash is caused by invalid IPP initialization. The client computer is equipped with Intel Xeon Gold 6140 2.30Ghz and Windows Server 2012 R2. As advised by Igor Astakhov we have used the following workaround for IPP initialization:

status = ippInit();
if(status == 0)
{
	return TRUE;
} else if(status < 0)
{
	throw std::exception();
}
else if(status == ippStsNotSupportedCpu || status == ippStsNonIntelCpu)
{
	return TRUE;
} else
{
	Ipp64u mask;
	status = ippGetCpuFeatures(&mask, nullptr);
	if(status != 0)
	{
		throw std::exception();
	}
	status = ippSetCpuFeatures(mask & (IPP_MAX_64U^ippCPUID_MPX));
	if(status != 0)
	{
		throw std::exception();
	}
}
The return code for ippInit function was 49 ( ippStsFeatureNotSupported), therefore the workaround code was executed. However, the function ippSetCpuFeatures also returned status 49. 
 
 According to other, Igor advise that positive status is only a working, we have removed assertion for positive status and used only ippInit function ignoring status 49 (without the workaround code). Unfortunately, this code, end up with illegal instruction exception in the first call to image processing function (ippiTranspose_8u_C1R).
 
Igor Astakhov (Intel) wrote:
non-zero status means "error" only in case if it's negative, all status values above zero are just warnings. In your case "StsFeatureNotSupported" status is related to MPX cpu feature and it is just a warning that doesn't affect IPP libraries behavior. You should detect error only if status is negative. 
 
We do not have access to this computer any longer and we do not have a station with Intel Xeon Gold 6140 2.30Ghz in our office. Therefore we kindly ask you if you can confirm that this error is fixed in IPP 2019? Can you also confirm that this error does not occur on any other Intel processor?
 
I kindly ask for priority support in this issue as this error is critical for us.
 
Best regards
Zygfryd Wieszok
0 Kudos
Pavel_B_Intel1
Employee
1,732 Views

Hello Zygfryd,

please double check version of IPP you used for the application. I see the problem with dispatcher shall be fixed in IPP 2018 update2. Could you, please, print IPP library version using ippGetLibraryVersion() function?

In any case we just double-check this case with IPP 2018 update2 and IPP 2019 releases.

Pavel

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Hello Pavel,

Thank you for checking the issue for me. I have checked the IPP version on our build server and it appeared to be 2018.1.156. 

When I was writing the report, I checked the IPP version on my developer PC where IPP 2018.2.185 was installed. Sorry for misleading you with incorrect IPP version.

We have found a computer in our office on which we are able to reproduce the issue and soon we will evaluate IPP 2019 and let you know if this solved the issue for us.

Zygfryd

 

0 Kudos
Pavel_B_Intel1
Employee
1,732 Views

Zygfryd,

please note there was one more issue in IPP dispatcher, we fixed in IPP 2018 update3. So IPP 2018 update3 and IPP 2019 gold shall work well with simple ippInit(). You do not need to implement the workaround provided by Igor.

Also please note: base on the documents I have the only Windows Server 2016 supports AVX-512 instruction set. On Windows Server 2012 R2 we expect to run AVX2 optimization level (but I can be wrong here).

Pavel

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Pavel

I am sorry to inform you but there is still an issue with IPP 2019 gold initialization.

I am getting status code 49 on IPP 2019 initialization using a computer with Intel Xeon W-2133 3.6Ghz and Windows 8.1 Pro 64-bit. 

On the computer, I have run following code compiled with Visual Studio 2015:

#include <stdio.h>
#include <iostream>
#include "ipp.h"

int main() {
	const IppLibraryVersion *lib;

	lib = ippsGetLibVersion();
	printf("CPU       : %s\n", lib->targetCpu);
	printf("Name      : %s\n", lib->Name);
	printf("Version   : %s\n", lib->Version);
	printf("Build date: %s\n", lib->BuildDate);


	auto initStatus = ippInit();
	std::cout << "Ipp init: " << initStatus << "\n";

	Ipp64u mask;
	IppStatus status = ippGetCpuFeatures(&mask, nullptr);
	printf("CPU features: %llu\n", mask);
	Ipp64u emask = ippGetEnabledCpuFeatures();
	printf("Enabled features: %llu\n", emask);

	return 0;
}

The result was:

CPU       : l9
Name      : ippSP AVX2 (l9)
Version   : 2019.0.0 Gold (r59881)
Build date: Jul 11 2018
Ipp init: 49
CPU features: 389541887
Enabled features: 268955647

I have also tested if I am able to execute IPP functions on the computer despite the initialization issueI have executed the following code:

int main() {
	std::cout << "Ipp init: " << ippInit() << "\n";

	const int size = 256;
	auto ptr = ippsMalloc_32f(size);
	std::cout << "Ipp set: " << ippsSet_32f(1.75f, ptr, size) << "\n";
	std::cout << "Ipp add: " << ippsAddC_32f_I(0.5f, ptr, size) << "\n";

	float expected = 2.25f;
	for (size_t i = 0; i < size; i++)
	{
		if(abs(ptr - expected) > 0.000001)
		{
			std::cout << "Results invalid. Expected " << std::setprecision(10) << expected << " Actual: " << ptr;
			break;
		}
	}
	ippsFree(ptr);
	std::cout << "End\n";

	return 0;

The results were:

Ipp init: 49
Ipp set: 0
Ipp add: 0
End

However, based on that quick test I cannot confirm that Illegal instruction will not occur later in the application in other IPP function.

Can you confirm that it is safe to use the library when initialization status was 49 or can you advise us any workaround to keep thing moving until the issue is fixed? 

Zygfryd

0 Kudos
Igor_A_Intel
Employee
1,732 Views

Hi Zygfryd,

the status "ippStsFeatureNotSupported" in your case means that your CPU supports AVX-512 instruction set, but operating system doesn't support AVX-512 state/registers storing/restoring (ippAVX512_ENABLEDBYOS feature in IPP terminology). Therefore IPP dispatches the highest possible optimization for this case - AVX2. For this case IPP dispatcher checks that OS supports "ippAVX_ENABLEDBYOS" (AVX, 256-bit registers/state storing/restoring), AVX2 instruction set is supported by CPU (there are no CPUs that support AVX-512 but don't support AVX2 - AVX2 support is inherited automatically as well as SSE, SSE2, SSE42, AVX). Therefore everything must be OK with your application, linked with IPP 2018 upd#2 or higher.

regards, Igor

0 Kudos
Wieszok__Zygfryd
Beginner
1,732 Views

Hi Igor

Thank you for your support. 

I understand that in the new version of IPP, the status 49 is just a warning that OS does not support some CPU features and the library can be safely executed. My precaution about the status code comes from the previous version when it forerun troubles. 

We will update the IPP library in a new version of our product, however, it will take us a few weeks to deliver it to our clients. Until then, we cannot withdraw the product with IPP 2018.1.156. Can you advise us which CPU / OS configurations are prone to the issue so we can inform our customers?

Reading the document https://software.intel.com/en-us/articles/issue-fix-illegal-instructions-error-in-intel-ipp-functions/ I understand that the problem will occur on processors equipped with AVX512 and Windows earlier than Windows Server 2016. Are there any other configurations which may be problematic (we support only Windows platforms)?

One of our colleges from another site found a workaround for the problem that worked for him. He turned on Hyper-V and problem did not occur. I do not know his configuration but I assume that he used CPU with AVX512 and Windows Server 2012. I will confirm it later. Can you confirm that this is a workaround for the issue or just a coincidence?

Best regards
Zygfryd

0 Kudos
Reply