From c57f8780e96cd7093d039f767dab246eabe60dfa Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Fri, 29 Jul 2016 07:00:10 +0900 Subject: [PATCH] show CPU feature correctly when FP16 is available * make sure that CV_FP16 has the correct meaning * check FP16 feature correctly --- modules/core/include/opencv2/core/cvdef.h | 11 ----------- modules/core/include/opencv2/core/private.hpp | 11 +++++++++++ modules/core/src/convert.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h index 5ff8ec421..e3ad5cf90 100644 --- a/modules/core/include/opencv2/core/cvdef.h +++ b/modules/core/include/opencv2/core/cvdef.h @@ -193,10 +193,6 @@ enum CpuFeatures { # endif # define CV_POPCNT 1 # endif -# if defined HAVE_FP16 && (defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700)) -# include -# define CV_FP16 1 -# endif # if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600 && 0) // MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX // See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32 @@ -231,10 +227,6 @@ enum CpuFeatures { # include #endif -#if defined HAVE_FP16 && defined __GNUC__ -# define CV_FP16 1 -#endif - #if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ # define CV_VFP 1 #endif @@ -265,9 +257,6 @@ enum CpuFeatures { #ifndef CV_SSE4_2 # define CV_SSE4_2 0 #endif -#ifndef CV_FP16 -# define CV_FP16 0 -#endif #ifndef CV_AVX # define CV_AVX 0 #endif diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index 4d0bd2653..656394bd3 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -71,6 +71,17 @@ # endif #endif +#if defined HAVE_FP16 && (defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700)) +# include +# define CV_FP16 1 +#elif defined HAVE_FP16 && defined __GNUC__ +# define CV_FP16 1 +#endif + +#ifndef CV_FP16 +# define CV_FP16 0 +#endif + //! @cond IGNORED namespace cv diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index dff0f9bc6..f6178d2bc 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -4568,7 +4568,7 @@ cvtScaleHalf_( const float* src, size_t sstep, short* dst, size_t sstep /= sizeof(src[0]); dstep /= sizeof(dst[0]); - if( checkHardwareSupport(CV_FP16) ) + if( checkHardwareSupport(CV_CPU_FP16) ) { for( ; size.height--; src += sstep, dst += dstep ) { @@ -4622,7 +4622,7 @@ cvtScaleHalf_( const short* src, size_t sstep, float* dst, size_t sstep /= sizeof(src[0]); dstep /= sizeof(dst[0]); - if( checkHardwareSupport(CV_FP16) ) + if( checkHardwareSupport(CV_CPU_FP16) ) { for( ; size.height--; src += sstep, dst += dstep ) {