OpenCV 4.5.3(日本語機械翻訳)
simd_utils.impl.hpp
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
5 // This header is not standalone. Don't include directly, use "intrin.hpp" instead.
6 #ifdef OPENCV_HAL_INTRIN_HPP // defined in intrin.hpp
7
8
9 #if CV_SIMD128 || CV_SIMD128_CPP
10
11 template<typename _T> struct Type2Vec128_Traits;
12 #define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \
13 template<> struct Type2Vec128_Traits<type_> \
14 { \
15 typedef vec_type_ vec_type; \
16 }
17
18CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uchar, v_uint8x16);
19CV_INTRIN_DEF_TYPE2VEC128_TRAITS(schar, v_int8x16);
20CV_INTRIN_DEF_TYPE2VEC128_TRAITS(ushort, v_uint16x8);
21CV_INTRIN_DEF_TYPE2VEC128_TRAITS(short, v_int16x8);
22CV_INTRIN_DEF_TYPE2VEC128_TRAITS(unsigned, v_uint32x4);
23CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int, v_int32x4);
24CV_INTRIN_DEF_TYPE2VEC128_TRAITS(float, v_float32x4);
25CV_INTRIN_DEF_TYPE2VEC128_TRAITS(uint64, v_uint64x2);
26CV_INTRIN_DEF_TYPE2VEC128_TRAITS(int64, v_int64x2);
27 #if CV_SIMD128_64F
28CV_INTRIN_DEF_TYPE2VEC128_TRAITS(double, v_float64x2);
29 #endif
30
31 template<typename _T> static inline
32 typename Type2Vec128_Traits<_T>::vec_type v_setall(const _T& a);
33
34 template<> inline Type2Vec128_Traits< uchar>::vec_type v_setall< uchar>(const uchar& a) { return v_setall_u8(a); }
35 template<> inline Type2Vec128_Traits< schar>::vec_type v_setall< schar>(const schar& a) { return v_setall_s8(a); }
36 template<> inline Type2Vec128_Traits<ushort>::vec_type v_setall<ushort>(const ushort& a) { return v_setall_u16(a); }
37 template<> inline Type2Vec128_Traits< short>::vec_type v_setall< short>(const short& a) { return v_setall_s16(a); }
38 template<> inline Type2Vec128_Traits< uint>::vec_type v_setall< uint>(const uint& a) { return v_setall_u32(a); }
39 template<> inline Type2Vec128_Traits< int>::vec_type v_setall< int>(const int& a) { return v_setall_s32(a); }
40 template<> inline Type2Vec128_Traits<uint64>::vec_type v_setall<uint64>(const uint64& a) { return v_setall_u64(a); }
41 template<> inline Type2Vec128_Traits< int64>::vec_type v_setall< int64>(const int64& a) { return v_setall_s64(a); }
42 template<> inline Type2Vec128_Traits< float>::vec_type v_setall< float>(const float& a) { return v_setall_f32(a); }
43 #if CV_SIMD128_64F
44 template<> inline Type2Vec128_Traits<double>::vec_type v_setall<double>(const double& a) { return v_setall_f64(a); }
45 #endif
46
47 #endif // SIMD128
48
49
50 #if CV_SIMD256
51
52 template<typename _T> struct Type2Vec256_Traits;
53 #define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \
54 template<> struct Type2Vec256_Traits<type_> \
55 { \
56 typedef vec_type_ vec_type; \
57 }
58
59CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uchar, v_uint8x32);
60CV_INTRIN_DEF_TYPE2VEC256_TRAITS(schar, v_int8x32);
61CV_INTRIN_DEF_TYPE2VEC256_TRAITS(ushort, v_uint16x16);
62CV_INTRIN_DEF_TYPE2VEC256_TRAITS(short, v_int16x16);
63CV_INTRIN_DEF_TYPE2VEC256_TRAITS(unsigned, v_uint32x8);
64CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int, v_int32x8);
65CV_INTRIN_DEF_TYPE2VEC256_TRAITS(float, v_float32x8);
66CV_INTRIN_DEF_TYPE2VEC256_TRAITS(uint64, v_uint64x4);
67CV_INTRIN_DEF_TYPE2VEC256_TRAITS(int64, v_int64x4);
68 #if CV_SIMD256_64F
69CV_INTRIN_DEF_TYPE2VEC256_TRAITS(double, v_float64x4);
70 #endif
71
72 template<typename _T> static inline
73 typename Type2Vec256_Traits<_T>::vec_type v256_setall(const _T& a);
74
75 template<> inline Type2Vec256_Traits< uchar>::vec_type v256_setall< uchar>(const uchar& a) { return v256_setall_u8(a); }
76 template<> inline Type2Vec256_Traits< schar>::vec_type v256_setall< schar>(const schar& a) { return v256_setall_s8(a); }
77 template<> inline Type2Vec256_Traits<ushort>::vec_type v256_setall<ushort>(const ushort& a) { return v256_setall_u16(a); }
78 template<> inline Type2Vec256_Traits< short>::vec_type v256_setall< short>(const short& a) { return v256_setall_s16(a); }
79 template<> inline Type2Vec256_Traits< uint>::vec_type v256_setall< uint>(const uint& a) { return v256_setall_u32(a); }
80 template<> inline Type2Vec256_Traits< int>::vec_type v256_setall< int>(const int& a) { return v256_setall_s32(a); }
81 template<> inline Type2Vec256_Traits<uint64>::vec_type v256_setall<uint64>(const uint64& a) { return v256_setall_u64(a); }
82 template<> inline Type2Vec256_Traits< int64>::vec_type v256_setall< int64>(const int64& a) { return v256_setall_s64(a); }
83 template<> inline Type2Vec256_Traits< float>::vec_type v256_setall< float>(const float& a) { return v256_setall_f32(a); }
84 #if CV_SIMD256_64F
85 template<> inline Type2Vec256_Traits<double>::vec_type v256_setall<double>(const double& a) { return v256_setall_f64(a); }
86 #endif
87
88 #endif // SIMD256
89
90
91 #if CV_SIMD512
92
93 template<typename _T> struct Type2Vec512_Traits;
94 #define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \
95 template<> struct Type2Vec512_Traits<type_> \
96 { \
97 typedef vec_type_ vec_type; \
98 }
99
100CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uchar, v_uint8x64);
101CV_INTRIN_DEF_TYPE2VEC512_TRAITS(schar, v_int8x64);
102CV_INTRIN_DEF_TYPE2VEC512_TRAITS(ushort, v_uint16x32);
103CV_INTRIN_DEF_TYPE2VEC512_TRAITS(short, v_int16x32);
104CV_INTRIN_DEF_TYPE2VEC512_TRAITS(unsigned, v_uint32x16);
105CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int, v_int32x16);
106CV_INTRIN_DEF_TYPE2VEC512_TRAITS(float, v_float32x16);
107CV_INTRIN_DEF_TYPE2VEC512_TRAITS(uint64, v_uint64x8);
108CV_INTRIN_DEF_TYPE2VEC512_TRAITS(int64, v_int64x8);
109 #if CV_SIMD512_64F
110CV_INTRIN_DEF_TYPE2VEC512_TRAITS(double, v_float64x8);
111 #endif
112
113 template<typename _T> static inline
114 typename Type2Vec512_Traits<_T>::vec_type v512_setall(const _T& a);
115
116 template<> inline Type2Vec512_Traits< uchar>::vec_type v512_setall< uchar>(const uchar& a) { return v512_setall_u8(a); }
117 template<> inline Type2Vec512_Traits< schar>::vec_type v512_setall< schar>(const schar& a) { return v512_setall_s8(a); }
118 template<> inline Type2Vec512_Traits<ushort>::vec_type v512_setall<ushort>(const ushort& a) { return v512_setall_u16(a); }
119 template<> inline Type2Vec512_Traits< short>::vec_type v512_setall< short>(const short& a) { return v512_setall_s16(a); }
120 template<> inline Type2Vec512_Traits< uint>::vec_type v512_setall< uint>(const uint& a) { return v512_setall_u32(a); }
121 template<> inline Type2Vec512_Traits< int>::vec_type v512_setall< int>(const int& a) { return v512_setall_s32(a); }
122 template<> inline Type2Vec512_Traits<uint64>::vec_type v512_setall<uint64>(const uint64& a) { return v512_setall_u64(a); }
123 template<> inline Type2Vec512_Traits< int64>::vec_type v512_setall< int64>(const int64& a) { return v512_setall_s64(a); }
124 template<> inline Type2Vec512_Traits< float>::vec_type v512_setall< float>(const float& a) { return v512_setall_f32(a); }
125 #if CV_SIMD512_64F
126 template<> inline Type2Vec512_Traits<double>::vec_type v512_setall<double>(const double& a) { return v512_setall_f64(a); }
127 #endif
128
129 #endif // SIMD512
130
131
132 #if CV_SIMD_WIDTH == 16
133 template<typename _T> static inline
134 typename Type2Vec128_Traits<_T>::vec_type vx_setall(const _T& a) { return v_setall(a); }
135 #elif CV_SIMD_WIDTH == 32
136 template<typename _T> static inline
137 typename Type2Vec256_Traits<_T>::vec_type vx_setall(const _T& a) { return v256_setall(a); }
138 #elif CV_SIMD_WIDTH == 64
139 template<typename _T> static inline
140 typename Type2Vec512_Traits<_T>::vec_type vx_setall(const _T& a) { return v512_setall(a); }
141 #else
142 #error "Build configuration error, unsupported CV_SIMD_WIDTH"
143 #endif
144
145
146 #endif // OPENCV_HAL_INTRIN_HPP
v_reg< schar, 16 > v_int8x16
Sixteen 8-bit signed integer values
Definition: intrin_cpp.hpp:490
v_reg< uchar, 16 > v_uint8x16
Sixteen 8-bit unsigned integer values
Definition: intrin_cpp.hpp:488
v_reg< int64, 2 > v_int64x2
Two 64-bit signed integer values
Definition: intrin_cpp.hpp:506
v_reg< ushort, 8 > v_uint16x8
Eight 16-bit unsigned integer values
Definition: intrin_cpp.hpp:492
v_reg< int, 4 > v_int32x4
Four 32-bit signed integer values
Definition: intrin_cpp.hpp:498
v_reg< unsigned, 4 > v_uint32x4
Four 32-bit unsigned integer values
Definition: intrin_cpp.hpp:496
v_reg< uint64, 2 > v_uint64x2
Two 64-bit unsigned integer values
Definition: intrin_cpp.hpp:504
v_reg< float, 4 > v_float32x4
Four 32-bit floating point values (single precision)
Definition: intrin_cpp.hpp:500
v_reg< short, 8 > v_int16x8
Eight 16-bit signed integer values
Definition: intrin_cpp.hpp:494
v_reg< double, 2 > v_float64x2
Two 64-bit floating point values (double precision)
Definition: intrin_cpp.hpp:502