Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/core/test/test_intrin.cpp
16337 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
#include "test_precomp.hpp"
5
6
#include "test_intrin128.simd.hpp"
7
#include "test_intrin128.simd_declarations.hpp"
8
9
#undef CV_CPU_DISPATCH_MODES_ALL
10
11
#include "opencv2/core/cv_cpu_dispatch.h"
12
#include "test_intrin256.simd.hpp"
13
#include "test_intrin256.simd_declarations.hpp"
14
15
#ifdef _MSC_VER
16
# pragma warning(disable:4702) // unreachable code
17
#endif
18
19
namespace opencv_test { namespace hal {
20
21
#define CV_CPU_CALL_BASELINE_(fn, args) CV_CPU_CALL_BASELINE(fn, args)
22
23
#define DISPATCH_SIMD128(fn, cpu_opt) do { \
24
CV_CPU_CALL_ ## cpu_opt ## _(fn, ()); \
25
throw SkipTestException("SIMD128 (" #cpu_opt ") is not available or disabled"); \
26
} while(0)
27
28
#define DISPATCH_SIMD256(fn, cpu_opt) do { \
29
CV_CPU_CALL_ ## cpu_opt ## _(fn, ()); \
30
throw SkipTestException("SIMD256 (" #cpu_opt ") is not available or disabled"); \
31
} while(0)
32
33
#define DEFINE_SIMD_TESTS(simd_size, cpu_opt) \
34
TEST(hal_intrin ## simd_size, uint8x16_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint8, cpu_opt); } \
35
TEST(hal_intrin ## simd_size, int8x16_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int8, cpu_opt); } \
36
TEST(hal_intrin ## simd_size, uint16x8_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint16, cpu_opt); } \
37
TEST(hal_intrin ## simd_size, int16x8_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int16, cpu_opt); } \
38
TEST(hal_intrin ## simd_size, int32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int32, cpu_opt); } \
39
TEST(hal_intrin ## simd_size, uint32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint32, cpu_opt); } \
40
TEST(hal_intrin ## simd_size, uint64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_uint64, cpu_opt); } \
41
TEST(hal_intrin ## simd_size, int64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_int64, cpu_opt); } \
42
TEST(hal_intrin ## simd_size, float32x4_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_float32, cpu_opt); } \
43
TEST(hal_intrin ## simd_size, float64x2_ ## cpu_opt) { DISPATCH_SIMD ## simd_size(test_hal_intrin_float64, cpu_opt); } \
44
45
namespace intrin128 {
46
47
DEFINE_SIMD_TESTS(128, BASELINE)
48
49
#if defined CV_CPU_DISPATCH_COMPILE_SSE2 || defined CV_CPU_BASELINE_COMPILE_SSE2
50
DEFINE_SIMD_TESTS(128, SSE2)
51
#endif
52
#if defined CV_CPU_DISPATCH_COMPILE_SSE3 || defined CV_CPU_BASELINE_COMPILE_SSE3
53
DEFINE_SIMD_TESTS(128, SSE3)
54
#endif
55
#if defined CV_CPU_DISPATCH_COMPILE_SSSE3 || defined CV_CPU_BASELINE_COMPILE_SSSE3
56
DEFINE_SIMD_TESTS(128, SSSE3)
57
#endif
58
#if defined CV_CPU_DISPATCH_COMPILE_SSE4_1 || defined CV_CPU_BASELINE_COMPILE_SSE4_1
59
DEFINE_SIMD_TESTS(128, SSE4_1)
60
#endif
61
#if defined CV_CPU_DISPATCH_COMPILE_SSE4_2 || defined CV_CPU_BASELINE_COMPILE_SSE4_2
62
DEFINE_SIMD_TESTS(128, SSE4_2)
63
#endif
64
#if defined CV_CPU_DISPATCH_COMPILE_AVX || defined CV_CPU_BASELINE_COMPILE_AVX
65
DEFINE_SIMD_TESTS(128, AVX)
66
#endif
67
#if defined CV_CPU_DISPATCH_COMPILE_AVX2 || defined CV_CPU_BASELINE_COMPILE_AVX2
68
DEFINE_SIMD_TESTS(128, AVX2)
69
#endif
70
71
TEST(hal_intrin128, float16x8_FP16)
72
{
73
CV_CPU_CALL_FP16_(test_hal_intrin_float16, ());
74
throw SkipTestException("Unsupported hardware: FP16 is not available");
75
}
76
77
} // namespace intrin128
78
79
80
namespace intrin256 {
81
82
83
// Not available due missing C++ backend for SIMD256
84
//DEFINE_SIMD_TESTS(256, BASELINE)
85
86
//#if defined CV_CPU_DISPATCH_COMPILE_AVX
87
//DEFINE_SIMD_TESTS(256, AVX)
88
//#endif
89
90
#if defined CV_CPU_DISPATCH_COMPILE_AVX2 || defined CV_CPU_BASELINE_COMPILE_AVX2
91
DEFINE_SIMD_TESTS(256, AVX2)
92
#endif
93
94
TEST(hal_intrin256, float16x16_FP16)
95
{
96
//CV_CPU_CALL_FP16_(test_hal_intrin_float16, ());
97
CV_CPU_CALL_AVX2_(test_hal_intrin_float16, ());
98
throw SkipTestException("Unsupported hardware: FP16 is not available");
99
}
100
101
102
} // namespace intrin256
103
104
}} // namespace
105