From fef94315af7eba4340c8922e32d54403be7e3b58 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 6 Dec 2016 16:25:10 +0300 Subject: [PATCH] core: exp/log workaround for MSVS --- modules/core/src/mathfuncs_core.cpp | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/modules/core/src/mathfuncs_core.cpp b/modules/core/src/mathfuncs_core.cpp index c021812247..e0cc5b58dd 100644 --- a/modules/core/src/mathfuncs_core.cpp +++ b/modules/core/src/mathfuncs_core.cpp @@ -373,6 +373,62 @@ void sqrt64f(const double* src, double* dst, int len) dst[i] = std::sqrt(src[i]); } +// Workaround for ICE in MSVS 2015 update 3 (issue #7795) +// CV_AVX is not used here, because generated code is faster in non-AVX mode. +// (tested with disabled IPP on i5-6300U) +#if (defined _MSC_VER && _MSC_VER >= 1900) +void exp32f(const float *src, float *dst, int n) +{ + CV_INSTRUMENT_REGION() + + CALL_HAL(exp32f, cv_hal_exp32f, src, dst, n); + CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_32f_A21, src, dst, n) >= 0); + + for (int i = 0; i < n; i++) + { + dst[i] = std::exp(src[i]); + } +} + +void exp64f(const double *src, double *dst, int n) +{ + CV_INSTRUMENT_REGION() + + CALL_HAL(exp64f, cv_hal_exp64f, src, dst, n); + CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_64f_A50, src, dst, n) >= 0); + + for (int i = 0; i < n; i++) + { + dst[i] = std::exp(src[i]); + } +} + +void log32f(const float *src, float *dst, int n) +{ + CV_INSTRUMENT_REGION() + + CALL_HAL(log32f, cv_hal_log32f, src, dst, n); + CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_32f_A21, src, dst, n) >= 0); + + for (int i = 0; i < n; i++) + { + dst[i] = std::log(src[i]); + } +} +void log64f(const double *src, double *dst, int n) +{ + CV_INSTRUMENT_REGION() + + CALL_HAL(log64f, cv_hal_log64f, src, dst, n); + CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_64f_A50, src, dst, n) >= 0); + + for (int i = 0; i < n; i++) + { + dst[i] = std::log(src[i]); + } +} +#else + ////////////////////////////////////// EXP ///////////////////////////////////// typedef union @@ -1466,6 +1522,8 @@ void log64f( const double *x, double *y, int n ) } } +#endif // issue 7795 + //============================================================================= // for compatibility with 3.0