IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PolynomPack.h
Go to the documentation of this file.
1 // PolynomPack.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX2_POLYNOMPACK_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX2_POLYNOMPACK_H__
17 
20 #include <IPSDKUtil/InstructionSet/Arithmetic/detail/PolynomReg.h>
22 
23 #include <boost/mpl/not_equal_to.hpp>
24 
25 namespace ipsdk {
26 namespace simd {
27 namespace detail {
28 
31 
32 #define DEFINE_POLYNOMPACK_AVX2(N) \
33 template <typename T> \
34 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<1> >::value>::type> \
35 { \
36  static IPSDK_FORCEINLINE \
37  BasePack<ePackType::ePT_Avx, T> \
38  act(const BasePack<ePackType::ePT_Avx, T>& in, \
39  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
40  { \
41  BasePack<ePackType::ePT_Scalar, T> out; \
42  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
43  return out; \
44  } \
45  \
46  static IPSDK_FORCEINLINE \
47  void \
48  act(const BasePack<ePackType::ePT_Avx, T>& in, \
49  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
50  BasePack<ePackType::ePT_Avx, T>& out) \
51  { \
52  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
53  } \
54 }; \
55  \
56 template <typename T> \
57 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<1> >::value>::type> \
58 { \
59  static IPSDK_FORCEINLINE \
60  BasePack<ePackType::ePT_Avx, T> \
61  act(const BasePack<ePackType::ePT_Avx, T>& in, \
62  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
63  { \
64  BasePack<ePackType::ePT_Scalar, T> out; \
65  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
66  return out; \
67  } \
68  \
69  static IPSDK_FORCEINLINE \
70  void \
71  act(const BasePack<ePackType::ePT_Avx, T>& in, \
72  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
73  BasePack<ePackType::ePT_Avx, T>& out) \
74  { \
75  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
76  } \
77 }; \
78  \
79 template <typename T> \
80 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<2> >::value>::type> \
81 { \
82  static IPSDK_FORCEINLINE \
83  BasePack<ePackType::ePT_Avx, T> \
84  act(const BasePack<ePackType::ePT_Avx, T>& in, \
85  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
86  { \
87  BasePack<ePackType::ePT_Scalar, T> out; \
88  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
89  return out; \
90  } \
91  \
92  static IPSDK_FORCEINLINE \
93  void \
94  act(const BasePack<ePackType::ePT_Avx, T>& in, \
95  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
96  BasePack<ePackType::ePT_Avx, T>& out) \
97  { \
98  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
99  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[1], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[1]); \
100  } \
101 }; \
102  \
103 template <typename T> \
104 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<2> >::value>::type> \
105 { \
106  static IPSDK_FORCEINLINE \
107  BasePack<ePackType::ePT_Avx, T> \
108  act(const BasePack<ePackType::ePT_Avx, T>& in, \
109  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
110  { \
111  BasePack<ePackType::ePT_Scalar, T> out; \
112  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
113  return out; \
114  } \
115  \
116  static IPSDK_FORCEINLINE \
117  void \
118  act(const BasePack<ePackType::ePT_Avx, T>& in, \
119  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
120  BasePack<ePackType::ePT_Avx, T>& out) \
121  { \
122  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
123  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[1], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[1]); \
124  } \
125 }; \
126  \
127 template <typename T> \
128 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::value>::type> \
129 { \
130  static IPSDK_FORCEINLINE \
131  BasePack<ePackType::ePT_Avx, T> \
132  act(const BasePack<ePackType::ePT_Avx, T>& in, \
133  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
134  { \
135  BasePack<ePackType::ePT_Scalar, T> out; \
136  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
137  return out; \
138  } \
139  \
140  static IPSDK_FORCEINLINE \
141  void \
142  act(const BasePack<ePackType::ePT_Avx, T>& in, \
143  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
144  BasePack<ePackType::ePT_Avx, T>& out) \
145  { \
146  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
147  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[1], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[1]); \
148  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[2], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[2]); \
149  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Avx2, N, T>::act(in._val[3], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[3]); \
150  } \
151 }; \
152  \
153 template <typename T> \
154 struct PolynomPack<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T, typename boost::enable_if_c<boost::mpl::equal_to<boost::mpl::int_<sizeof(T)>, boost::mpl::int_<4> >::value>::type> \
155 { \
156  static IPSDK_FORCEINLINE \
157  BasePack<ePackType::ePT_Avx, T> \
158  act(const BasePack<ePackType::ePT_Avx, T>& in, \
159  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c)) \
160  { \
161  BasePack<ePackType::ePT_Scalar, T> out; \
162  act(in, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out); \
163  return out; \
164  } \
165  \
166  static IPSDK_FORCEINLINE \
167  void \
168  act(const BasePack<ePackType::ePT_Avx, T>& in, \
169  BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), const T& c), \
170  BasePack<ePackType::ePT_Avx, T>& out) \
171  { \
172  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[0], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[0]); \
173  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[1], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[1]); \
174  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[2], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[2]); \
175  PolynomReg<eInstructionSet::eIS_Avx2, eInstructionSet::eIS_Fma3, N, T>::act(in._val[3], BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N), c), out._val[3]); \
176  } \
177 };
178 
179 DEFINE_POLYNOMPACK_AVX2(20)
180 DEFINE_POLYNOMPACK_AVX2(19)
181 DEFINE_POLYNOMPACK_AVX2(18)
182 DEFINE_POLYNOMPACK_AVX2(17)
183 DEFINE_POLYNOMPACK_AVX2(16)
184 DEFINE_POLYNOMPACK_AVX2(15)
185 DEFINE_POLYNOMPACK_AVX2(14)
186 DEFINE_POLYNOMPACK_AVX2(13)
187 DEFINE_POLYNOMPACK_AVX2(12)
188 DEFINE_POLYNOMPACK_AVX2(11)
189 DEFINE_POLYNOMPACK_AVX2(10)
190 DEFINE_POLYNOMPACK_AVX2(9)
191 DEFINE_POLYNOMPACK_AVX2(8)
192 DEFINE_POLYNOMPACK_AVX2(7)
193 DEFINE_POLYNOMPACK_AVX2(6)
194 DEFINE_POLYNOMPACK_AVX2(5)
195 DEFINE_POLYNOMPACK_AVX2(4)
196 DEFINE_POLYNOMPACK_AVX2(3)
197 DEFINE_POLYNOMPACK_AVX2(2)
198 DEFINE_POLYNOMPACK_AVX2(1)
199 
202 
203 } // end of namespace detail
204 } // end of namespace simd
205 } // end of namespace ipsdk
206 
207 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_AVX2_POLYNOMPACK_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
BasePack class; defines a set of scalars (for instruction set "standard") or registers (for all other...
Definition of import/export macro for library.