10 #ifndef EIGEN_COMPLEX_SSE_H 11 #define EIGEN_COMPLEX_SSE_H 20 EIGEN_STRONG_INLINE Packet2cf() {}
21 EIGEN_STRONG_INLINE
explicit Packet2cf(
const __m128& a) : v(a) {}
27 #ifndef EIGEN_VECTORIZE_AVX 28 template<>
struct packet_traits<
std::
complex<float> > : default_packet_traits
30 typedef Packet2cf type;
31 typedef Packet2cf half;
53 template<>
struct unpacket_traits<Packet2cf> {
typedef std::complex<float> type;
enum {size=2, alignment=
Aligned16};
typedef Packet2cf half; };
55 template<> EIGEN_STRONG_INLINE Packet2cf padd<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_add_ps(a.v,b.v)); }
56 template<> EIGEN_STRONG_INLINE Packet2cf psub<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_sub_ps(a.v,b.v)); }
57 template<> EIGEN_STRONG_INLINE Packet2cf pnegate(
const Packet2cf& a)
59 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x80000000,0x80000000,0x80000000));
60 return Packet2cf(_mm_xor_ps(a.v,mask));
62 template<> EIGEN_STRONG_INLINE Packet2cf pconj(
const Packet2cf& a)
64 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
65 return Packet2cf(_mm_xor_ps(a.v,mask));
68 template<> EIGEN_STRONG_INLINE Packet2cf pmul<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
70 #ifdef EIGEN_VECTORIZE_SSE3 71 return Packet2cf(_mm_addsub_ps(_mm_mul_ps(_mm_moveldup_ps(a.v), b.v),
72 _mm_mul_ps(_mm_movehdup_ps(a.v),
73 vec4f_swizzle1(b.v, 1, 0, 3, 2))));
78 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x80000000,0x00000000,0x80000000,0x00000000));
79 return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
80 _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
81 vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));
85 template<> EIGEN_STRONG_INLINE Packet2cf pand <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_and_ps(a.v,b.v)); }
86 template<> EIGEN_STRONG_INLINE Packet2cf por <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_or_ps(a.v,b.v)); }
87 template<> EIGEN_STRONG_INLINE Packet2cf pxor <Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_xor_ps(a.v,b.v)); }
88 template<> EIGEN_STRONG_INLINE Packet2cf pandnot<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b) {
return Packet2cf(_mm_andnot_ps(a.v,b.v)); }
90 template<> EIGEN_STRONG_INLINE Packet2cf pload <Packet2cf>(
const std::complex<float>* from) { EIGEN_DEBUG_ALIGNED_LOAD
return Packet2cf(pload<Packet4f>(&numext::real_ref(*from))); }
91 template<> EIGEN_STRONG_INLINE Packet2cf ploadu<Packet2cf>(
const std::complex<float>* from) { EIGEN_DEBUG_UNALIGNED_LOAD
return Packet2cf(ploadu<Packet4f>(&numext::real_ref(*from))); }
93 template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(
const std::complex<float>& from)
96 #if EIGEN_GNUC_AT_MOST(4,2) 98 res.v = _mm_loadl_pi(_mm_set1_ps(0.0f), reinterpret_cast<const __m64*>(&from));
99 #elif EIGEN_GNUC_AT_LEAST(4,6) 101 #pragma GCC diagnostic push 102 #pragma GCC diagnostic ignored "-Wuninitialized" 103 res.v = _mm_loadl_pi(res.v, (
const __m64*)&from);
104 #pragma GCC diagnostic pop 106 res.v = _mm_loadl_pi(res.v, (
const __m64*)&from);
108 return Packet2cf(_mm_movelh_ps(res.v,res.v));
111 template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(
const std::complex<float>* from) {
return pset1<Packet2cf>(*from); }
113 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), Packet4f(from.v)); }
114 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<float> >(std::complex<float> * to,
const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), Packet4f(from.v)); }
117 template<> EIGEN_DEVICE_FUNC
inline Packet2cf pgather<std::complex<float>, Packet2cf>(
const std::complex<float>* from,
Index stride)
119 return Packet2cf(_mm_set_ps(std::imag(from[1*stride]), std::real(from[1*stride]),
120 std::imag(from[0*stride]), std::real(from[0*stride])));
123 template<> EIGEN_DEVICE_FUNC
inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to,
const Packet2cf& from,
Index stride)
125 to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)),
126 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1)));
127 to[stride*1] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 2)),
128 _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 3)));
131 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<float> >(
const std::complex<float> * addr) { _mm_prefetch((
const char*)(addr), _MM_HINT_T0); }
133 template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(
const Packet2cf& a)
135 #if EIGEN_GNUC_AT_MOST(4,3) 138 EIGEN_ALIGN16 std::complex<float> res[2];
139 _mm_store_ps((
float*)res, a.v);
142 std::complex<float> res;
143 _mm_storel_pi((__m64*)&res, a.v);
148 template<> EIGEN_STRONG_INLINE Packet2cf preverse(
const Packet2cf& a) {
return Packet2cf(_mm_castpd_ps(preverse(Packet2d(_mm_castps_pd(a.v))))); }
150 template<> EIGEN_STRONG_INLINE std::complex<float> predux<Packet2cf>(
const Packet2cf& a)
152 return pfirst(Packet2cf(_mm_add_ps(a.v, _mm_movehl_ps(a.v,a.v))));
155 template<> EIGEN_STRONG_INLINE Packet2cf preduxp<Packet2cf>(
const Packet2cf* vecs)
157 return Packet2cf(_mm_add_ps(_mm_movelh_ps(vecs[0].v,vecs[1].v), _mm_movehl_ps(vecs[1].v,vecs[0].v)));
160 template<> EIGEN_STRONG_INLINE std::complex<float> predux_mul<Packet2cf>(
const Packet2cf& a)
162 return pfirst(pmul(a, Packet2cf(_mm_movehl_ps(a.v,a.v))));
166 struct palign_impl<Offset,Packet2cf>
168 static EIGEN_STRONG_INLINE
void run(Packet2cf& first,
const Packet2cf& second)
172 first.v = _mm_movehl_ps(first.v, first.v);
173 first.v = _mm_movelh_ps(first.v, second.v);
178 template<>
struct conj_helper<Packet2cf, Packet2cf, false,true>
180 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 181 {
return padd(pmul(x,y),c); }
183 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 185 #ifdef EIGEN_VECTORIZE_SSE3 186 return internal::pmul(a, pconj(b));
188 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
189 return Packet2cf(_mm_add_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),
190 _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
191 vec4f_swizzle1(b.v, 1, 0, 3, 2))));
196 template<>
struct conj_helper<Packet2cf, Packet2cf, true,false>
198 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 199 {
return padd(pmul(x,y),c); }
201 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 203 #ifdef EIGEN_VECTORIZE_SSE3 204 return internal::pmul(pconj(a), b);
206 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
207 return Packet2cf(_mm_add_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v),
208 _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
209 vec4f_swizzle1(b.v, 1, 0, 3, 2)), mask)));
214 template<>
struct conj_helper<Packet2cf, Packet2cf, true,true>
216 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet2cf& y,
const Packet2cf& c)
const 217 {
return padd(pmul(x,y),c); }
219 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& a,
const Packet2cf& b)
const 221 #ifdef EIGEN_VECTORIZE_SSE3 222 return pconj(internal::pmul(a, b));
224 const __m128 mask = _mm_castsi128_ps(_mm_setr_epi32(0x00000000,0x80000000,0x00000000,0x80000000));
225 return Packet2cf(_mm_sub_ps(_mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a.v, 0, 0, 2, 2), b.v), mask),
226 _mm_mul_ps(vec4f_swizzle1(a.v, 1, 1, 3, 3),
227 vec4f_swizzle1(b.v, 1, 0, 3, 2))));
232 template<>
struct conj_helper<Packet4f, Packet2cf, false,false>
234 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet4f& x,
const Packet2cf& y,
const Packet2cf& c)
const 235 {
return padd(c, pmul(x,y)); }
237 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet4f& x,
const Packet2cf& y)
const 238 {
return Packet2cf(Eigen::internal::pmul<Packet4f>(x, y.v)); }
241 template<>
struct conj_helper<Packet2cf, Packet4f, false,false>
243 EIGEN_STRONG_INLINE Packet2cf pmadd(
const Packet2cf& x,
const Packet4f& y,
const Packet2cf& c)
const 244 {
return padd(c, pmul(x,y)); }
246 EIGEN_STRONG_INLINE Packet2cf pmul(
const Packet2cf& x,
const Packet4f& y)
const 247 {
return Packet2cf(Eigen::internal::pmul<Packet4f>(x.v, y)); }
250 template<> EIGEN_STRONG_INLINE Packet2cf pdiv<Packet2cf>(
const Packet2cf& a,
const Packet2cf& b)
253 Packet2cf res = conj_helper<Packet2cf,Packet2cf,false,true>().pmul(a,b);
254 __m128 s = _mm_mul_ps(b.v,b.v);
255 return Packet2cf(_mm_div_ps(res.v,_mm_add_ps(s,_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(s), 0xb1)))));
258 EIGEN_STRONG_INLINE Packet2cf pcplxflip(
const Packet2cf& x)
260 return Packet2cf(vec4f_swizzle1(x.v, 1, 0, 3, 2));
268 EIGEN_STRONG_INLINE
explicit Packet1cd(
const __m128d& a) : v(a) {}
274 #ifndef EIGEN_VECTORIZE_AVX 306 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
312 #ifdef EIGEN_VECTORIZE_SSE3 313 return Packet1cd(_mm_addsub_pd(_mm_mul_pd(_mm_movedup_pd(a.v), b.v),
314 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
315 vec2d_swizzle1(b.v, 1, 0))));
317 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x0,0x0,0x80000000,0x0));
318 return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
319 _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
320 vec2d_swizzle1(b.v, 1, 0)), mask)));
330 template<> EIGEN_STRONG_INLINE
Packet1cd pload <Packet1cd>(
const std::complex<double>* from)
331 { EIGEN_DEBUG_ALIGNED_LOAD
return Packet1cd(pload<Packet2d>((
const double*)from)); }
332 template<> EIGEN_STRONG_INLINE
Packet1cd ploadu<Packet1cd>(
const std::complex<double>* from)
333 { EIGEN_DEBUG_UNALIGNED_LOAD
return Packet1cd(ploadu<Packet2d>((
const double*)from)); }
334 template<> EIGEN_STRONG_INLINE
Packet1cd pset1<Packet1cd>(
const std::complex<double>& from)
335 {
return ploadu<Packet1cd>(&from); }
337 template<> EIGEN_STRONG_INLINE
Packet1cd ploaddup<Packet1cd>(
const std::complex<double>* from) {
return pset1<Packet1cd>(*from); }
340 template<> EIGEN_STRONG_INLINE
void pstore <std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((
double*)to, Packet2d(from.v)); }
341 template<> EIGEN_STRONG_INLINE
void pstoreu<std::complex<double> >(std::complex<double> * to,
const Packet1cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((
double*)to, Packet2d(from.v)); }
343 template<> EIGEN_STRONG_INLINE
void prefetch<std::complex<double> >(
const std::complex<double> * addr) { _mm_prefetch((
const char*)(addr), _MM_HINT_T0); }
345 template<> EIGEN_STRONG_INLINE std::complex<double> pfirst<Packet1cd>(
const Packet1cd& a)
347 EIGEN_ALIGN16
double res[2];
348 _mm_store_pd(res, a.v);
349 return std::complex<double>(res[0],res[1]);
354 template<> EIGEN_STRONG_INLINE std::complex<double> predux<Packet1cd>(
const Packet1cd& a)
364 template<> EIGEN_STRONG_INLINE std::complex<double> predux_mul<Packet1cd>(
const Packet1cd& a)
382 {
return padd(pmul(x,y),c); }
386 #ifdef EIGEN_VECTORIZE_SSE3 387 return internal::pmul(a, pconj(b));
389 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
390 return Packet1cd(_mm_add_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),
391 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
392 vec2d_swizzle1(b.v, 1, 0))));
400 {
return padd(pmul(x,y),c); }
404 #ifdef EIGEN_VECTORIZE_SSE3 405 return internal::pmul(pconj(a), b);
407 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
408 return Packet1cd(_mm_add_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v),
409 _mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
410 vec2d_swizzle1(b.v, 1, 0)), mask)));
418 {
return padd(pmul(x,y),c); }
422 #ifdef EIGEN_VECTORIZE_SSE3 423 return pconj(internal::pmul(a, b));
425 const __m128d mask = _mm_castsi128_pd(_mm_set_epi32(0x80000000,0x0,0x0,0x0));
426 return Packet1cd(_mm_sub_pd(_mm_xor_pd(_mm_mul_pd(vec2d_swizzle1(a.v, 0, 0), b.v), mask),
427 _mm_mul_pd(vec2d_swizzle1(a.v, 1, 1),
428 vec2d_swizzle1(b.v, 1, 0))));
436 {
return padd(c, pmul(x,y)); }
439 {
return Packet1cd(Eigen::internal::pmul<Packet2d>(x, y.v)); }
445 {
return padd(c, pmul(x,y)); }
448 {
return Packet1cd(Eigen::internal::pmul<Packet2d>(x.v, y)); }
455 __m128d s = _mm_mul_pd(b.v,b.v);
456 return Packet1cd(_mm_div_pd(res.v, _mm_add_pd(s,_mm_shuffle_pd(s, s, 0x1))));
461 return Packet1cd(preverse(Packet2d(x.v)));
464 EIGEN_DEVICE_FUNC
inline void 466 __m128d w1 = _mm_castps_pd(kernel.packet[0].v);
467 __m128d w2 = _mm_castps_pd(kernel.packet[1].v);
469 __m128 tmp = _mm_castpd_ps(_mm_unpackhi_pd(w1, w2));
470 kernel.packet[0].v = _mm_castpd_ps(_mm_unpacklo_pd(w1, w2));
471 kernel.packet[1].v = tmp;
475 __m128d result = pblend<Packet2d>(ifPacket, _mm_castps_pd(thenPacket.v), _mm_castps_pd(elsePacket.v));
479 template<> EIGEN_STRONG_INLINE
Packet2cf pinsertfirst(
const Packet2cf& a, std::complex<float> b)
481 return Packet2cf(_mm_loadl_pi(a.v, reinterpret_cast<const __m64*>(&b)));
484 template<> EIGEN_STRONG_INLINE
Packet1cd pinsertfirst(
const Packet1cd&, std::complex<double> b)
486 return pset1<Packet1cd>(b);
489 template<> EIGEN_STRONG_INLINE
Packet2cf pinsertlast(
const Packet2cf& a, std::complex<float> b)
491 return Packet2cf(_mm_loadh_pi(a.v, reinterpret_cast<const __m64*>(&b)));
494 template<> EIGEN_STRONG_INLINE
Packet1cd pinsertlast(
const Packet1cd&, std::complex<double> b)
496 return pset1<Packet1cd>(b);
503 #endif // EIGEN_COMPLEX_SSE_H
Data pointer is aligned on a 16 bytes boundary.
Definition: Constants.h:230
Definition: BlasUtil.h:61
Definition: XprHelper.h:158
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Definition: GenericPacketMath.h:96
Definition: Complex.h:265
Definition: GenericPacketMath.h:42
Definition: Complex.h:379
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: GenericPacketMath.h:539
Definition: BandTriangularSolver.h:13
Definition: datatypes.h:12
Definition: GenericPacketMath.h:492
Definition: GenericPacketMath.h:552