1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

cmake: fix fp16 support

This commit is contained in:
Alexander Alekhin
2017-04-04 20:34:58 +03:00
parent d15d9f558d
commit e5d9b608c4
8 changed files with 17 additions and 53 deletions
@@ -70,6 +70,10 @@
# include <immintrin.h>
# define CV_AVX 1
#endif
#ifdef CV_CPU_COMPILE_FP16
# include <immintrin.h>
# define CV_FP16 1
#endif
#ifdef CV_CPU_COMPILE_AVX2
# include <immintrin.h>
# define CV_AVX2 1
@@ -154,6 +158,9 @@ struct VZeroUpperGuard {
#ifndef CV_AVX
# define CV_AVX 0
#endif
#ifndef CV_FP16
# define CV_FP16 0
#endif
#ifndef CV_AVX2
# define CV_AVX2 0
#endif
@@ -721,7 +721,7 @@ inline v_reg<typename V_TypeTraits<_Tp>::abs_type, n> v_absdiff(const v_reg<_Tp,
{
typedef typename V_TypeTraits<_Tp>::abs_type rtype;
v_reg<rtype, n> c;
const rtype mask = std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0;
const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0);
for( int i = 0; i < n; i++ )
{
rtype ua = a.s[i] ^ mask;
@@ -278,7 +278,7 @@ struct v_float64x2
};
#endif
#if defined (HAVE_FP16)
#if CV_FP16
// Workaround for old comiplers
template <typename T> static inline int16x4_t vreinterpret_s16_f16(T a)
{ return (int16x4_t)a; }
@@ -775,7 +775,7 @@ OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32)
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
#endif
#if defined (HAVE_FP16)
#if CV_FP16
// Workaround for old comiplers
inline v_float16x4 v_load_f16(const short* ptr)
{ return v_float16x4(vld1_f16(ptr)); }
@@ -1223,7 +1223,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
}
#endif
#if defined (HAVE_FP16)
#if CV_FP16
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
{
return v_float32x4(vcvt_f32_f16(a.val));
@@ -255,7 +255,7 @@ struct v_float64x2
__m128d val;
};
#if defined(HAVE_FP16)
#if CV_FP16
struct v_float16x4
{
typedef short lane_type;
@@ -1056,7 +1056,7 @@ inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps)
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd)
#if defined(HAVE_FP16)
#if CV_FP16
inline v_float16x4 v_load_f16(const short* ptr)
{ return v_float16x4(_mm_loadl_epi64((const __m128i*)ptr)); }
inline void v_store_f16(short* ptr, v_float16x4& a)
@@ -1776,7 +1776,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
return v_float64x2(_mm_cvtps_pd(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(a.val),8))));
}
#if defined(HAVE_FP16)
#if CV_FP16
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
{
return v_float32x4(_mm_cvtph_ps(a.val));
@@ -66,17 +66,6 @@
# undef max
#endif
#if defined HAVE_FP16 && (defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700))
# include <immintrin.h>
# 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
+3 -3
View File
@@ -743,7 +743,7 @@ template<typename R> struct TheTest
TheTest & test_loadstore_fp16()
{
#if CV_FP16
#if CV_FP16 && CV_SIMD128
AlignedData<R> data;
AlignedData<R> out;
@@ -775,7 +775,7 @@ template<typename R> struct TheTest
TheTest & test_float_cvt_fp16()
{
#if CV_FP16
#if CV_FP16 && CV_SIMD128
AlignedData<v_float32x4> data;
if(checkHardwareSupport(CV_CPU_FP16))
@@ -1008,7 +1008,7 @@ TEST(hal_intrin, float64x2) {
}
#endif
#if CV_FP16
#if CV_FP16 && CV_SIMD128
TEST(hal_intrin, float16x4) {
TheTest<v_float16x4>()
.test_loadstore_fp16()