@@ -1929,11 +1929,22 @@ struct IPPInitSingleton
1929
1929
}
1930
1930
ippFeatures = cpuFeatures;
1931
1931
1932
- bool unsupported = false ;
1933
1932
const char * pIppEnv = getenv (" OPENCV_IPP" );
1934
1933
cv::String env = pIppEnv;
1935
1934
if (env.size ())
1936
1935
{
1936
+ #if IPP_VERSION_X100 >= 201703
1937
+ const Ipp64u minorFeatures = ippCPUID_MOVBE|ippCPUID_AES|ippCPUID_CLMUL|ippCPUID_ABR|ippCPUID_RDRAND|ippCPUID_F16C|
1938
+ ippCPUID_ADCOX|ippCPUID_RDSEED|ippCPUID_PREFETCHW|ippCPUID_SHA|ippCPUID_MPX|ippCPUID_AVX512CD|ippCPUID_AVX512ER|
1939
+ ippCPUID_AVX512PF|ippCPUID_AVX512BW|ippCPUID_AVX512DQ|ippCPUID_AVX512VL|ippCPUID_AVX512VBMI;
1940
+ #elif IPP_VERSION_X100 >= 201700
1941
+ const Ipp64u minorFeatures = ippCPUID_MOVBE|ippCPUID_AES|ippCPUID_CLMUL|ippCPUID_ABR|ippCPUID_RDRAND|ippCPUID_F16C|
1942
+ ippCPUID_ADCOX|ippCPUID_RDSEED|ippCPUID_PREFETCHW|ippCPUID_SHA|ippCPUID_AVX512CD|ippCPUID_AVX512ER|
1943
+ ippCPUID_AVX512PF|ippCPUID_AVX512BW|ippCPUID_AVX512DQ|ippCPUID_AVX512VL|ippCPUID_AVX512VBMI;
1944
+ #else
1945
+ const Ipp64u minorFeatures = 0 ;
1946
+ #endif
1947
+
1937
1948
env = env.toLowerCase ();
1938
1949
if (env.substr (0 , 2 ) == " ne" )
1939
1950
{
@@ -1947,58 +1958,20 @@ struct IPPInitSingleton
1947
1958
useIPP = false ;
1948
1959
}
1949
1960
else if (env == " sse42" )
1950
- {
1951
- if (!(cpuFeatures&ippCPUID_SSE42))
1952
- unsupported = true ;
1953
- ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42;
1954
- ippFeatures |= (cpuFeatures&ippCPUID_AES);
1955
- ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
1956
- ippFeatures |= (cpuFeatures&ippCPUID_SHA);
1957
- }
1961
+ ippFeatures = minorFeatures|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42;
1958
1962
else if (env == " avx2" )
1959
- {
1960
- if (!(cpuFeatures&ippCPUID_AVX2))
1961
- unsupported = true ;
1962
- ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2;
1963
- ippFeatures |= (cpuFeatures&ippCPUID_AES);
1964
- ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
1965
- ippFeatures |= (cpuFeatures&ippCPUID_F16C);
1966
- ippFeatures |= (cpuFeatures&ippCPUID_ADCOX);
1967
- ippFeatures |= (cpuFeatures&ippCPUID_RDSEED);
1968
- ippFeatures |= (cpuFeatures&ippCPUID_PREFETCHW);
1969
- ippFeatures |= (cpuFeatures&ippCPUID_MPX);
1970
- }
1963
+ ippFeatures = minorFeatures|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2;
1964
+ #if IPP_VERSION_X100 >= 201700
1971
1965
#if defined (_M_AMD64) || defined (__x86_64__)
1972
1966
else if (env == " avx512" )
1973
- {
1974
- if (!(cpuFeatures&ippCPUID_AVX512F))
1975
- unsupported = true ;
1976
-
1977
- ippFeatures = ippCPUID_MMX|ippCPUID_SSE|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2|ippCPUID_AVX512F;
1978
- ippFeatures |= (cpuFeatures&ippCPUID_AES);
1979
- ippFeatures |= (cpuFeatures&ippCPUID_CLMUL);
1980
- ippFeatures |= (cpuFeatures&ippCPUID_F16C);
1981
- ippFeatures |= (cpuFeatures&ippCPUID_ADCOX);
1982
- ippFeatures |= (cpuFeatures&ippCPUID_RDSEED);
1983
- ippFeatures |= (cpuFeatures&ippCPUID_PREFETCHW);
1984
- ippFeatures |= (cpuFeatures&ippCPUID_MPX);
1985
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512CD);
1986
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512VL);
1987
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512BW);
1988
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512DQ);
1989
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512ER);
1990
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512PF);
1991
- ippFeatures |= (cpuFeatures&ippCPUID_AVX512VBMI);
1992
- }
1967
+ ippFeatures = minorFeatures|ippCPUID_SSE2|ippCPUID_SSE3|ippCPUID_SSSE3|ippCPUID_SSE41|ippCPUID_SSE42|ippCPUID_AVX|ippCPUID_AVX2|ippCPUID_AVX512F;
1968
+ #endif
1993
1969
#endif
1994
1970
else
1995
1971
std::cerr << " ERROR: Improper value of OPENCV_IPP: " << env.c_str () << " . Correct values are: disabled, sse42, avx2, avx512 (Intel64 only)" << std::endl;
1996
- }
1997
1972
1998
- if (unsupported)
1999
- {
2000
- std::cerr << " WARNING: selected IPP features are not supported by CPU. IPP was initialized with default features" << std::endl;
2001
- ippFeatures = cpuFeatures;
1973
+ // Trim unsupported features
1974
+ ippFeatures &= cpuFeatures;
2002
1975
}
2003
1976
2004
1977
// Disable AVX1 since we don't track regressions for it. SSE42 will be used instead
@@ -2007,7 +1980,9 @@ struct IPPInitSingleton
2007
1980
2008
1981
// IPP integrations in OpenCV support only SSE4.2, AVX2 and AVX-512 optimizations.
2009
1982
if (!(
1983
+ #if IPP_VERSION_X100 >= 201700
2010
1984
cpuFeatures&ippCPUID_AVX512F ||
1985
+ #endif
2011
1986
cpuFeatures&ippCPUID_AVX2 ||
2012
1987
cpuFeatures&ippCPUID_SSE42
2013
1988
))
@@ -2016,10 +1991,14 @@ struct IPPInitSingleton
2016
1991
return ;
2017
1992
}
2018
1993
2019
- IPP_INITIALIZER (ippFeatures)
1994
+ if (ippFeatures == cpuFeatures)
1995
+ IPP_INITIALIZER (0 )
1996
+ else
1997
+ IPP_INITIALIZER (ippFeatures)
2020
1998
ippFeatures = ippGetEnabledCpuFeatures ();
2021
1999
2022
2000
// Detect top level optimizations to make comparison easier for optimizations dependent conditions
2001
+ #if IPP_VERSION_X100 >= 201700
2023
2002
if (ippFeatures&ippCPUID_AVX512F)
2024
2003
{
2025
2004
if ((ippFeatures&ippCPUID_AVX512_SKX) == ippCPUID_AVX512_SKX)
@@ -2029,7 +2008,9 @@ struct IPPInitSingleton
2029
2008
else
2030
2009
ippTopFeatures = ippCPUID_AVX512F; // Unknown AVX512 configuration
2031
2010
}
2032
- else if (ippFeatures&ippCPUID_AVX2)
2011
+ else
2012
+ #endif
2013
+ if (ippFeatures&ippCPUID_AVX2)
2033
2014
ippTopFeatures = ippCPUID_AVX2;
2034
2015
else if (ippFeatures&ippCPUID_SSE42)
2035
2016
ippTopFeatures = ippCPUID_SSE42;
0 commit comments