6 #ifdef OPENCV_HAL_INTRIN_HPP
9 #if CV_SIMD128 || CV_SIMD128_CPP
11 template<
typename _T>
struct Type2Vec128_Traits;
12 #define CV_INTRIN_DEF_TYPE2VEC128_TRAITS(type_, vec_type_) \
13 template<> struct Type2Vec128_Traits<type_> \
15 typedef vec_type_ vec_type; \
21 CV_INTRIN_DEF_TYPE2VEC128_TRAITS(
short,
v_int16x8);
22 CV_INTRIN_DEF_TYPE2VEC128_TRAITS(
unsigned,
v_uint32x4);
23 CV_INTRIN_DEF_TYPE2VEC128_TRAITS(
int,
v_int32x4);
24 CV_INTRIN_DEF_TYPE2VEC128_TRAITS(
float,
v_float32x4);
28 CV_INTRIN_DEF_TYPE2VEC128_TRAITS(
double,
v_float64x2);
31 template<
typename _T>
static inline
32 typename Type2Vec128_Traits<_T>::vec_type v_setall(
const _T& a);
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); }
44 template<>
inline Type2Vec128_Traits<double>::vec_type v_setall<double>(
const double& a) {
return v_setall_f64(a); }
52 template<
typename _T>
struct Type2Vec256_Traits;
53 #define CV_INTRIN_DEF_TYPE2VEC256_TRAITS(type_, vec_type_) \
54 template<> struct Type2Vec256_Traits<type_> \
56 typedef vec_type_ vec_type; \
59 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
uchar, v_uint8x32);
60 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
schar, v_int8x32);
61 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
ushort, v_uint16x16);
62 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
short, v_int16x16);
63 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
unsigned, v_uint32x8);
64 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
int, v_int32x8);
65 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
float, v_float32x8);
66 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
uint64, v_uint64x4);
67 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
int64, v_int64x4);
69 CV_INTRIN_DEF_TYPE2VEC256_TRAITS(
double, v_float64x4);
72 template<
typename _T>
static inline
73 typename Type2Vec256_Traits<_T>::vec_type v256_setall(
const _T& a);
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); }
85 template<>
inline Type2Vec256_Traits<double>::vec_type v256_setall<double>(
const double& a) {
return v256_setall_f64(a); }
93 template<
typename _T>
struct Type2Vec512_Traits;
94 #define CV_INTRIN_DEF_TYPE2VEC512_TRAITS(type_, vec_type_) \
95 template<> struct Type2Vec512_Traits<type_> \
97 typedef vec_type_ vec_type; \
100 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
uchar, v_uint8x64);
101 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
schar, v_int8x64);
102 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
ushort, v_uint16x32);
103 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
short, v_int16x32);
104 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
unsigned, v_uint32x16);
105 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
int, v_int32x16);
106 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
float, v_float32x16);
107 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
uint64, v_uint64x8);
108 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
int64, v_int64x8);
110 CV_INTRIN_DEF_TYPE2VEC512_TRAITS(
double, v_float64x8);
113 template<
typename _T>
static inline
114 typename Type2Vec512_Traits<_T>::vec_type v512_setall(
const _T& a);
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); }
126 template<>
inline Type2Vec512_Traits<double>::vec_type v512_setall<double>(
const double& a) {
return v512_setall_f64(a); }
132 template<
typename _T>
struct Type2Vec_Traits;
133 #define CV_INTRIN_DEF_TYPE2VEC_TRAITS(type_, vec_type_) \
134 template<> struct Type2Vec_Traits<type_> \
136 typedef vec_type_ vec_type; \
139 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
uchar, v_uint8);
140 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
schar, v_int8);
141 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
ushort, v_uint16);
142 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
short, v_int16);
143 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
unsigned, v_uint32);
144 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
int, v_int32);
145 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
float, v_float32);
146 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
uint64, v_uint64);
147 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
int64, v_int64);
148 #if CV_SIMD_SCALABLE_64F
149 CV_INTRIN_DEF_TYPE2VEC_TRAITS(
double, v_float64);
151 template<
typename _T>
static inline
152 typename Type2Vec_Traits<_T>::vec_type v_setall(
const _T& a);
154 template<>
inline Type2Vec_Traits< uchar>::vec_type v_setall< uchar>(
const uchar& a) {
return v_setall_u8(a); }
155 template<>
inline Type2Vec_Traits< schar>::vec_type v_setall< schar>(
const schar& a) {
return v_setall_s8(a); }
156 template<>
inline Type2Vec_Traits<ushort>::vec_type v_setall<ushort>(
const ushort& a) {
return v_setall_u16(a); }
157 template<>
inline Type2Vec_Traits< short>::vec_type v_setall< short>(
const short& a) {
return v_setall_s16(a); }
158 template<>
inline Type2Vec_Traits< uint>::vec_type v_setall< uint>(
const uint& a) {
return v_setall_u32(a); }
159 template<>
inline Type2Vec_Traits< int>::vec_type v_setall< int>(
const int& a) {
return v_setall_s32(a); }
160 template<>
inline Type2Vec_Traits<uint64>::vec_type v_setall<uint64>(
const uint64& a) {
return v_setall_u64(a); }
161 template<>
inline Type2Vec_Traits< int64>::vec_type v_setall< int64>(
const int64& a) {
return v_setall_s64(a); }
162 template<>
inline Type2Vec_Traits< float>::vec_type v_setall< float>(
const float& a) {
return v_setall_f32(a); }
163 #if CV_SIMD_SCALABLE_64F
164 template<>
inline Type2Vec_Traits<double>::vec_type v_setall<double>(
const double& a) {
return v_setall_f64(a); }
170 template<
typename _T>
static inline
171 typename Type2Vec_Traits<_T>::vec_type vx_setall(
const _T& a) {
return v_setall(a); }
172 #elif CV_SIMD_WIDTH == 16
173 template<
typename _T>
static inline
174 typename Type2Vec128_Traits<_T>::vec_type vx_setall(
const _T& a) {
return v_setall(a); }
175 #elif CV_SIMD_WIDTH == 32
176 template<
typename _T>
static inline
177 typename Type2Vec256_Traits<_T>::vec_type vx_setall(
const _T& a) {
return v256_setall(a); }
178 #elif CV_SIMD_WIDTH == 64
179 template<
typename _T>
static inline
180 typename Type2Vec512_Traits<_T>::vec_type vx_setall(
const _T& a) {
return v512_setall(a); }
182 #error "Build configuration error, unsupported CV_SIMD_WIDTH"
signed char schar
Definition: interface.h:48
uint32_t uint
Definition: interface.h:42
unsigned char uchar
Definition: interface.h:51
int64_t int64
Definition: interface.h:61
unsigned short ushort
Definition: interface.h:52
uint64_t uint64
Definition: interface.h:62
v_reg< schar, 16 > v_int8x16
Sixteen 8-bit signed integer values.
Definition: intrin_cpp.hpp:491
v_reg< uchar, 16 > v_uint8x16
Sixteen 8-bit unsigned integer values.
Definition: intrin_cpp.hpp:489
v_reg< int64, 2 > v_int64x2
Two 64-bit signed integer values.
Definition: intrin_cpp.hpp:507
v_reg< ushort, 8 > v_uint16x8
Eight 16-bit unsigned integer values.
Definition: intrin_cpp.hpp:493
v_reg< int, 4 > v_int32x4
Four 32-bit signed integer values.
Definition: intrin_cpp.hpp:499
v_reg< unsigned, 4 > v_uint32x4
Four 32-bit unsigned integer values.
Definition: intrin_cpp.hpp:497
v_reg< uint64, 2 > v_uint64x2
Two 64-bit unsigned integer values.
Definition: intrin_cpp.hpp:505
v_reg< float, 4 > v_float32x4
Four 32-bit floating point values (single precision)
Definition: intrin_cpp.hpp:501
v_reg< short, 8 > v_int16x8
Eight 16-bit signed integer values.
Definition: intrin_cpp.hpp:495
v_reg< double, 2 > v_float64x2
Two 64-bit floating point values (double precision)
Definition: intrin_cpp.hpp:503