mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
ICV2017u3 package update;
- Optimizations set change. Now IPP integrations will provide code for SSE42, AVX2 and AVX512 (SKX) CPUs only. For HW below SSE42 IPP code is disabled. - Performance regressions fixes for IPP code paths; - cv::boxFilter integration improvement; - cv::filter2D integration improvement;
This commit is contained in:
+164
-24
@@ -1909,55 +1909,146 @@ struct IPPInitSingleton
|
||||
public:
|
||||
IPPInitSingleton()
|
||||
{
|
||||
useIPP = true;
|
||||
ippStatus = 0;
|
||||
funcname = NULL;
|
||||
filename = NULL;
|
||||
linen = 0;
|
||||
ippFeatures = 0;
|
||||
useIPP = true;
|
||||
useIPP_NE = false;
|
||||
ippStatus = 0;
|
||||
funcname = NULL;
|
||||
filename = NULL;
|
||||
linen = 0;
|
||||
cpuFeatures = 0;
|
||||
ippFeatures = 0;
|
||||
ippTopFeatures = 0;
|
||||
pIppLibInfo = NULL;
|
||||
|
||||
ippStatus = ippGetCpuFeatures(&cpuFeatures, NULL);
|
||||
if(ippStatus < 0)
|
||||
{
|
||||
std::cerr << "ERROR: IPP cannot detect CPU features, IPP was disabled " << std::endl;
|
||||
useIPP = false;
|
||||
return;
|
||||
}
|
||||
ippFeatures = cpuFeatures;
|
||||
|
||||
bool unsupported = false;
|
||||
const char* pIppEnv = getenv("OPENCV_IPP");
|
||||
cv::String env = pIppEnv;
|
||||
if(env.size())
|
||||
{
|
||||
env = env.toLowerCase();
|
||||
if(env.substr(0, 2) == "ne")
|
||||
{
|
||||
useIPP_NE = true;
|
||||
env = env.substr(3, env.size());
|
||||
}
|
||||
|
||||
if(env == "disabled")
|
||||
{
|
||||
std::cerr << "WARNING: IPP was disabled by OPENCV_IPP environment variable" << std::endl;
|
||||
useIPP = false;
|
||||
}
|
||||
#if IPP_VERSION_X100 >= 900
|
||||
else if(env == "sse")
|
||||
ippFeatures = ippCPUID_SSE;
|
||||
else if(env == "sse2")
|
||||
ippFeatures = ippCPUID_SSE2;
|
||||
else if(env == "sse3")
|
||||
ippFeatures = ippCPUID_SSE3;
|
||||
else if(env == "ssse3")
|
||||
ippFeatures = ippCPUID_SSSE3;
|
||||
else if(env == "sse41")
|
||||
ippFeatures = ippCPUID_SSE41;
|
||||
else if(env == "sse42")
|
||||
ippFeatures = ippCPUID_SSE42;
|
||||
else if(env == "avx")
|
||||
ippFeatures = ippCPUID_AVX;
|
||||
{
|
||||
if(!(cpuFeatures&ippCPUID_SSE42))
|
||||
unsupported = true;
|
||||
ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42;
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AES);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_SHA);
|
||||
}
|
||||
else if(env == "avx2")
|
||||
ippFeatures = ippCPUID_AVX2;
|
||||
{
|
||||
if(!(cpuFeatures&ippCPUID_AVX2))
|
||||
unsupported = true;
|
||||
ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2;
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AES);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_F16C);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_ADCOX);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_RDSEED);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_PREFETCHW);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_MPX);
|
||||
}
|
||||
#if defined (_M_AMD64) || defined (__x86_64__)
|
||||
else if(env == "avx512")
|
||||
{
|
||||
if(!(cpuFeatures&ippCPUID_AVX512F))
|
||||
unsupported = true;
|
||||
|
||||
ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2|ippCPUID_AVX512F;
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AES);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_F16C);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_ADCOX);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_RDSEED);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_PREFETCHW);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_MPX);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512CD);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512VL);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512BW);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512DQ);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512ER);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512PF);
|
||||
ippFeatures |= (cpuFeatures&ippCPUID_AVX512VBMI);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
std::cerr << "ERROR: Improper value of OPENCV_IPP: " << env.c_str() << std::endl;
|
||||
std::cerr << "ERROR: Improper value of OPENCV_IPP: " << env.c_str() << ". Correct values are: disabled, sse42, avx2, avx512 (Intel64 only)" << std::endl;
|
||||
}
|
||||
|
||||
if(unsupported)
|
||||
{
|
||||
std::cerr << "WARNING: selected IPP features are not supported by CPU. IPP was initialized with default features" << std::endl;
|
||||
ippFeatures = cpuFeatures;
|
||||
}
|
||||
|
||||
// Disable AVX1 since we don't track regressions for it. SSE42 will be used instead
|
||||
if(cpuFeatures&ippCPUID_AVX && !(cpuFeatures&ippCPUID_AVX2))
|
||||
ippFeatures &= ~ippCPUID_AVX;
|
||||
|
||||
// IPP integrations in OpenCV support only SSE4.2, AVX2 and AVX-512 optimizations.
|
||||
if(!(
|
||||
cpuFeatures&ippCPUID_AVX512F ||
|
||||
cpuFeatures&ippCPUID_AVX2 ||
|
||||
cpuFeatures&ippCPUID_SSE42
|
||||
))
|
||||
{
|
||||
useIPP = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IPP_INITIALIZER(ippFeatures)
|
||||
ippFeatures = ippGetEnabledCpuFeatures();
|
||||
|
||||
// Detect top level optimizations to make comparison easier for optimizations dependent conditions
|
||||
if(ippFeatures&ippCPUID_AVX512F)
|
||||
{
|
||||
if((ippFeatures&ippCPUID_AVX512_SKX) == ippCPUID_AVX512_SKX)
|
||||
ippTopFeatures = ippCPUID_AVX512_SKX;
|
||||
else if((ippFeatures&ippCPUID_AVX512_KNL) == ippCPUID_AVX512_KNL)
|
||||
ippTopFeatures = ippCPUID_AVX512_KNL;
|
||||
else
|
||||
ippTopFeatures = ippCPUID_AVX512F; // Unknown AVX512 configuration
|
||||
}
|
||||
else if(ippFeatures&ippCPUID_AVX2)
|
||||
ippTopFeatures = ippCPUID_AVX2;
|
||||
else if(ippFeatures&ippCPUID_SSE42)
|
||||
ippTopFeatures = ippCPUID_SSE42;
|
||||
|
||||
pIppLibInfo = ippiGetLibVersion();
|
||||
}
|
||||
|
||||
bool useIPP;
|
||||
public:
|
||||
bool useIPP;
|
||||
bool useIPP_NE;
|
||||
|
||||
int ippStatus; // 0 - all is ok, -1 - IPP functions failed
|
||||
int ippStatus; // 0 - all is ok, -1 - IPP functions failed
|
||||
const char *funcname;
|
||||
const char *filename;
|
||||
int linen;
|
||||
Ipp64u ippFeatures;
|
||||
Ipp64u cpuFeatures;
|
||||
Ipp64u ippTopFeatures;
|
||||
const IppLibraryVersion *pIppLibInfo;
|
||||
};
|
||||
|
||||
static IPPInitSingleton& getIPPSingleton()
|
||||
@@ -1983,6 +2074,17 @@ int getIppFeatures()
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long long getIppTopFeatures();
|
||||
|
||||
unsigned long long getIppTopFeatures()
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
return getIPPSingleton().ippTopFeatures;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line)
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
@@ -2013,6 +2115,19 @@ String getIppErrorLocation()
|
||||
#endif
|
||||
}
|
||||
|
||||
String getIppVersion()
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
const IppLibraryVersion *pInfo = getIPPSingleton().pIppLibInfo;
|
||||
if(pInfo)
|
||||
return format("%s %s %s", pInfo->Name, pInfo->Version, pInfo->BuildDate);
|
||||
else
|
||||
return String("error");
|
||||
#else
|
||||
return String("disabled");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool useIPP()
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
@@ -2038,6 +2153,31 @@ void setUseIPP(bool flag)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool useIPP_NE()
|
||||
{
|
||||
#ifdef HAVE_IPP
|
||||
CoreTLSData* data = getCoreTlsData().get();
|
||||
if(data->useIPP_NE < 0)
|
||||
{
|
||||
data->useIPP_NE = getIPPSingleton().useIPP_NE;
|
||||
}
|
||||
return (data->useIPP_NE > 0);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setUseIPP_NE(bool flag)
|
||||
{
|
||||
CoreTLSData* data = getCoreTlsData().get();
|
||||
#ifdef HAVE_IPP
|
||||
data->useIPP_NE = (getIPPSingleton().useIPP_NE)?flag:false;
|
||||
#else
|
||||
(void)flag;
|
||||
data->useIPP_NE = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace ipp
|
||||
|
||||
} // namespace cv
|
||||
|
||||
Reference in New Issue
Block a user