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

core(intrin): drop hasSIMD128 checks

- use compile-time checks instead (`#if CV_SIMD128`)
- runtime checks are useless
This commit is contained in:
Alexander Alekhin
2019-06-08 19:14:35 +00:00
parent 254f88f805
commit 1e9ad5476d
14 changed files with 27 additions and 166 deletions
+5 -19
View File
@@ -318,8 +318,7 @@ public:
low(_low), high(_high), aperture_size(_aperture_size), L2gradient(_L2gradient)
{
#if CV_SIMD128
haveSIMD = hasSIMD128();
if(haveSIMD)
if (true)
_map.create(src.rows + 2, (int)alignSize((size_t)(src.cols + CV_MALLOC_SIMD128 + 1), CV_MALLOC_SIMD128), CV_8UC1);
else
#endif
@@ -338,8 +337,7 @@ public:
low(_low), high(_high), aperture_size(0), L2gradient(_L2gradient)
{
#if CV_SIMD128
haveSIMD = hasSIMD128();
if(haveSIMD)
if (true)
_map.create(src.rows + 2, (int)alignSize((size_t)(src.cols + CV_MALLOC_SIMD128 + 1), CV_MALLOC_SIMD128), CV_8UC1);
else
#endif
@@ -440,7 +438,6 @@ public:
{
int j = 0, width = src.cols * cn;
#if CV_SIMD128
if (haveSIMD)
{
for ( ; j <= width - 8; j += 8)
{
@@ -464,7 +461,6 @@ public:
{
int j = 0, width = src.cols * cn;
#if CV_SIMD128
if (haveSIMD)
{
for(; j <= width - 8; j += 8)
{
@@ -525,7 +521,7 @@ public:
// From here actual src row is (i - 1)
// Set left and right border to 1
#if CV_SIMD128
if(haveSIMD)
if (true)
_pmap = map.ptr<uchar>(i) + CV_MALLOC_SIMD128;
else
#endif
@@ -547,7 +543,6 @@ public:
const int TG22 = 13573;
int j = 0;
#if CV_SIMD128
if (haveSIMD)
{
const v_int32x4 v_low = v_setall_s32(low);
const v_int8x16 v_one = v_setall_s8(1);
@@ -806,9 +801,6 @@ private:
bool L2gradient, needGradient;
ptrdiff_t mapstep;
int cn;
#if CV_SIMD128
bool haveSIMD;
#endif
mutable Mutex mutex;
};
@@ -820,9 +812,6 @@ public:
map(_map), dst(_dst)
{
dst = _dst;
#if CV_SIMD128
haveSIMD = hasSIMD128();
#endif
}
~finalPass() {}
@@ -836,13 +825,13 @@ public:
uchar *pdst = dst.ptr<uchar>(i);
const uchar *pmap = map.ptr<uchar>(i + 1);
#if CV_SIMD128
if(haveSIMD)
if (true)
pmap += CV_MALLOC_SIMD128;
else
#endif
pmap += 1;
#if CV_SIMD128
if(haveSIMD) {
{
const v_uint8x16 v_zero = v_setzero_u8();
const v_uint8x16 v_ff = ~v_zero;
const v_uint8x16 v_two(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
@@ -873,9 +862,6 @@ public:
private:
const Mat &map;
Mat &dst;
#if CV_SIMD128
bool haveSIMD;
#endif
finalPass(const finalPass&); // = delete
finalPass& operator=(const finalPass&); // = delete
-14
View File
@@ -56,9 +56,6 @@ static void calcMinEigenVal( const Mat& _cov, Mat& _dst )
#if CV_TRY_AVX
bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
#endif
#if CV_SIMD128
bool haveSimd = hasSIMD128();
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
{
@@ -78,7 +75,6 @@ static void calcMinEigenVal( const Mat& _cov, Mat& _dst )
j = 0;
#if CV_SIMD128
if( haveSimd )
{
v_float32x4 half = v_setall_f32(0.5f);
for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
@@ -112,9 +108,6 @@ static void calcHarris( const Mat& _cov, Mat& _dst, double k )
#if CV_TRY_AVX
bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
#endif
#if CV_SIMD128
bool haveSimd = hasSIMD128();
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
{
@@ -135,7 +128,6 @@ static void calcHarris( const Mat& _cov, Mat& _dst, double k )
j = 0;
#if CV_SIMD128
if( haveSimd )
{
v_float32x4 v_k = v_setall_f32((float)k);
@@ -254,9 +246,6 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
#if CV_TRY_AVX
bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
#endif
#if CV_SIMD128
bool haveSimd = hasSIMD128();
#endif
int depth = src.depth();
double scale = (double)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size;
@@ -298,7 +287,6 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
j = 0;
#if CV_SIMD128
if( haveSimd )
{
for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
@@ -711,7 +699,6 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
factor = 1./(factor * factor * factor);
#if CV_SIMD128
float factor_f = (float)factor;
bool haveSimd = hasSIMD128();
v_float32x4 v_factor = v_setall_f32(factor_f), v_m2 = v_setall_f32(-2.0f);
#endif
@@ -729,7 +716,6 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
j = 0;
#if CV_SIMD128
if (haveSimd)
{
for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
+3 -23
View File
@@ -446,8 +446,7 @@ struct RemapVec_8u
{
int cn = _src.channels(), x = 0, sstep = (int)_src.step;
if( (cn != 1 && cn != 3 && cn != 4) || !hasSIMD128() ||
sstep > 0x8000 )
if( (cn != 1 && cn != 3 && cn != 4) || sstep > 0x8000 )
return 0;
const uchar *S0 = _src.ptr(), *S1 = _src.ptr(1);
@@ -1098,9 +1097,6 @@ public:
int brows0 = std::min(128, dst->rows), map_depth = m1->depth();
int bcols0 = std::min(buf_size/brows0, dst->cols);
brows0 = std::min(buf_size/bcols0, dst->rows);
#if CV_SIMD128
bool useSIMD = hasSIMD128();
#endif
Mat _bufxy(brows0, bcols0, CV_16SC2), _bufa;
if( !nnfunc )
@@ -1147,7 +1143,6 @@ public:
x1 = 0;
#if CV_SIMD128
if( useSIMD )
{
int span = v_float32x4::nlanes;
for( ; x1 <= bcols - span * 2; x1 += span * 2 )
@@ -1189,7 +1184,6 @@ public:
x1 = 0;
#if CV_SIMD128
if (useSIMD)
{
v_uint16x8 v_scale = v_setall_u16(INTER_TAB_SIZE2 - 1);
int span = v_uint16x8::nlanes;
@@ -1207,7 +1201,6 @@ public:
x1 = 0;
#if CV_SIMD128
if( useSIMD )
{
v_float32x4 v_scale = v_setall_f32((float)INTER_TAB_SIZE);
v_int32x4 v_scale2 = v_setall_s32(INTER_TAB_SIZE - 1);
@@ -1245,7 +1238,6 @@ public:
x1 = 0;
#if CV_SIMD128
if( useSIMD )
{
v_float32x4 v_scale = v_setall_f32((float)INTER_TAB_SIZE);
v_int32x4 v_scale2 = v_setall_s32(INTER_TAB_SIZE - 1), v_scale3 = v_setall_s32(INTER_TAB_SIZE);
@@ -1898,9 +1890,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
size.height = 1;
}
#if CV_SIMD128
bool useSIMD = hasSIMD128();
#endif
#if CV_TRY_SSE4_1
bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1;
#endif
@@ -1931,7 +1920,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#endif
{
#if CV_SIMD128
if( useSIMD )
{
int span = v_int16x8::nlanes;
for( ; x <= size.width - span; x += span )
@@ -1961,7 +1949,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#endif
{
#if CV_SIMD128
if( useSIMD )
{
v_float32x4 v_scale = v_setall_f32((float)INTER_TAB_SIZE);
v_int32x4 v_mask = v_setall_s32(INTER_TAB_SIZE - 1);
@@ -2002,10 +1989,11 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
{
#if CV_SIMD128
int span = v_float32x4::nlanes;
if( useSIMD )
{
for( ; x <= (size.width << 1) - span * 2; x += span * 2 )
v_store(dst1 + x, v_pack(v_round(v_load(src1f + x)),
v_round(v_load(src1f + x + span))));
}
#endif
for( ; x < size.width; x++ )
{
@@ -2022,7 +2010,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#endif
{
#if CV_SIMD128
if( useSIMD )
{
v_float32x4 v_scale = v_setall_f32((float)INTER_TAB_SIZE);
v_int32x4 v_mask = v_setall_s32(INTER_TAB_SIZE - 1);
@@ -2063,7 +2050,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
else if( m1type == CV_16SC2 && dstm1type == CV_32FC1 )
{
#if CV_SIMD128
if( useSIMD )
{
v_uint16x8 v_mask2 = v_setall_u16(INTER_TAB_SIZE2-1);
v_uint32x4 v_zero = v_setzero_u32(), v_mask = v_setall_u32(INTER_TAB_SIZE-1);
@@ -2113,7 +2099,6 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
else if( m1type == CV_16SC2 && dstm1type == CV_32FC2 )
{
#if CV_SIMD128
if( useSIMD )
{
v_int16x8 v_mask2 = v_setall_s16(INTER_TAB_SIZE2-1);
v_int32x4 v_zero = v_setzero_s32(), v_mask = v_setall_s32(INTER_TAB_SIZE-1);
@@ -2189,9 +2174,6 @@ public:
#if CV_TRY_AVX2
bool useAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
#endif
#if CV_SIMD128
bool useSIMD = hasSIMD128();
#endif
#if CV_TRY_SSE4_1
bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1;
#endif
@@ -2226,7 +2208,6 @@ public:
#endif
{
#if CV_SIMD128
if( useSIMD )
{
v_int32x4 v_X0 = v_setall_s32(X0), v_Y0 = v_setall_s32(Y0);
int span = v_uint16x8::nlanes;
@@ -2260,7 +2241,6 @@ public:
x1 = opt_AVX2::warpAffineBlockline(adelta + x, bdelta + x, xy, alpha, X0, Y0, bw);
#endif
#if CV_SIMD128
if( useSIMD )
{
v_int32x4 v__X0 = v_setall_s32(X0), v__Y0 = v_setall_s32(Y0);
v_int32x4 v_mask = v_setall_s32(INTER_TAB_SIZE - 1);
+2 -6
View File
@@ -218,14 +218,13 @@ struct MomentsInTile_SIMD<uchar, int, int>
{
MomentsInTile_SIMD()
{
useSIMD = checkHardwareSupport(CV_CPU_SSE2);
// nothing
}
int operator() (const uchar * ptr, int len, int & x0, int & x1, int & x2, int & x3)
{
int x = 0;
if( useSIMD )
{
__m128i dx = _mm_set1_epi16(8);
__m128i z = _mm_setzero_si128(), qx0 = z, qx1 = z, qx2 = z, qx3 = z, qx = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
@@ -264,7 +263,6 @@ struct MomentsInTile_SIMD<uchar, int, int>
}
int CV_DECL_ALIGNED(16) buf[4];
bool useSIMD;
};
#elif CV_NEON
@@ -342,14 +340,13 @@ struct MomentsInTile_SIMD<ushort, int, int64>
{
MomentsInTile_SIMD()
{
useSIMD = checkHardwareSupport(CV_CPU_SSE4_1);
// nothing
}
int operator() (const ushort * ptr, int len, int & x0, int & x1, int & x2, int64 & x3)
{
int x = 0;
if (useSIMD)
{
__m128i v_delta = _mm_set1_epi32(4), v_zero = _mm_setzero_si128(), v_x0 = v_zero,
v_x1 = v_zero, v_x2 = v_zero, v_x3 = v_zero, v_ix0 = _mm_setr_epi32(0, 1, 2, 3);
@@ -395,7 +392,6 @@ struct MomentsInTile_SIMD<ushort, int, int64>
int CV_DECL_ALIGNED(16) buf[4];
int64 CV_DECL_ALIGNED(16) buf64[2];
bool useSIMD;
};
#endif