10#ifndef EIGEN_PACKET_MATH_ALTIVEC_H
11#define EIGEN_PACKET_MATH_ALTIVEC_H
14#include "../../InternalHeaderCheck.h"
20#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
21#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 4
24#ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD
25#define EIGEN_HAS_SINGLE_INSTRUCTION_MADD
29#ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS
30#define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 32
33typedef __vector
float Packet4f;
34typedef __vector
int Packet4i;
35typedef __vector
unsigned int Packet4ui;
36typedef __vector __bool
int Packet4bi;
37typedef __vector
short int Packet8s;
38typedef __vector
unsigned short int Packet8us;
39typedef __vector __bool
short Packet8bi;
40typedef __vector
signed char Packet16c;
41typedef __vector
unsigned char Packet16uc;
42typedef eigen_packet_wrapper<__vector unsigned short int, 0> Packet8bf;
46#define EIGEN_DECLARE_CONST_FAST_Packet4f(NAME, X) Packet4f p4f_##NAME = {X, X, X, X}
48#define EIGEN_DECLARE_CONST_FAST_Packet4i(NAME, X) Packet4i p4i_##NAME = vec_splat_s32(X)
50#define EIGEN_DECLARE_CONST_FAST_Packet4ui(NAME, X) Packet4ui p4ui_##NAME = {X, X, X, X}
52#define EIGEN_DECLARE_CONST_FAST_Packet8us(NAME, X) Packet8us p8us_##NAME = {X, X, X, X, X, X, X, X}
54#define EIGEN_DECLARE_CONST_FAST_Packet16uc(NAME, X) \
55 Packet16uc p16uc_##NAME = {X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X}
57#define EIGEN_DECLARE_CONST_Packet4f(NAME, X) Packet4f p4f_##NAME = pset1<Packet4f>(X)
59#define EIGEN_DECLARE_CONST_Packet4i(NAME, X) Packet4i p4i_##NAME = pset1<Packet4i>(X)
61#define EIGEN_DECLARE_CONST_Packet2d(NAME, X) Packet2d p2d_##NAME = pset1<Packet2d>(X)
63#define EIGEN_DECLARE_CONST_Packet2l(NAME, X) Packet2l p2l_##NAME = pset1<Packet2l>(X)
65#define EIGEN_DECLARE_CONST_Packet4f_FROM_INT(NAME, X) \
66 const Packet4f p4f_##NAME = reinterpret_cast<Packet4f>(pset1<Packet4i>(X))
69#define DST_CTRL(size, count, stride) (((size) << 24) | ((count) << 16) | (stride))
70#define __UNPACK_TYPE__(PACKETNAME) typename unpacket_traits<PACKETNAME>::type
73static EIGEN_DECLARE_CONST_FAST_Packet4f(ZERO, 0);
74static EIGEN_DECLARE_CONST_FAST_Packet4i(ZERO, 0);
75static EIGEN_DECLARE_CONST_FAST_Packet4i(ONE, 1);
76static EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS16, -16);
77static EIGEN_DECLARE_CONST_FAST_Packet4i(MINUS1, -1);
78static EIGEN_DECLARE_CONST_FAST_Packet4ui(SIGN, 0x80000000u);
79static EIGEN_DECLARE_CONST_FAST_Packet4ui(PREV0DOT5, 0x3EFFFFFFu);
80static EIGEN_DECLARE_CONST_FAST_Packet8us(ONE, 1);
81static Packet4f p4f_MZERO =
82 (Packet4f)vec_sl((Packet4ui)p4i_MINUS1, (Packet4ui)p4i_MINUS1);
84static Packet4f p4f_ONE = vec_ctf(p4i_ONE, 0);
87static Packet4f p4f_COUNTDOWN = {0.0, 1.0, 2.0, 3.0};
88static Packet4i p4i_COUNTDOWN = {0, 1, 2, 3};
89static Packet8s p8s_COUNTDOWN = {0, 1, 2, 3, 4, 5, 6, 7};
90static Packet8us p8us_COUNTDOWN = {0, 1, 2, 3, 4, 5, 6, 7};
92static Packet16c p16c_COUNTDOWN = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
93static Packet16uc p16uc_COUNTDOWN = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
95static Packet16uc p16uc_REVERSE32 = {12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3};
96static Packet16uc p16uc_REVERSE16 = {14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1};
97static Packet16uc p16uc_REVERSE8 = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
100static Packet16uc p16uc_DUPLICATE32_HI = {0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7};
102static const Packet16uc p16uc_DUPLICATE16_EVEN = {0, 1, 0, 1, 4, 5, 4, 5, 8, 9, 8, 9, 12, 13, 12, 13};
103static const Packet16uc p16uc_DUPLICATE16_ODD = {2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15};
105static Packet16uc p16uc_QUADRUPLICATE16_HI = {0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3};
106static Packet16uc p16uc_QUADRUPLICATE16 = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3};
108static Packet16uc p16uc_MERGEE16 = {0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29};
109static Packet16uc p16uc_MERGEO16 = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31};
111static Packet16uc p16uc_MERGEH16 = {0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29};
113static Packet16uc p16uc_MERGEL16 = {2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31};
119static Packet16uc p16uc_FORWARD = vec_lvsl(0, (
float*)0);
120static Packet16uc p16uc_PSET32_WODD =
121 vec_sld((Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 2),
123static Packet16uc p16uc_PSET32_WEVEN = vec_sld(p16uc_DUPLICATE32_HI, (Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 3),
125static Packet16uc p16uc_HALF64_0_16 = vec_sld((Packet16uc)p4i_ZERO, vec_splat((Packet16uc)vec_abs(p4i_MINUS16), 3),
128static Packet16uc p16uc_FORWARD = p16uc_REVERSE32;
129static Packet16uc p16uc_PSET32_WODD =
130 vec_sld((Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 1), (Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 3),
132static Packet16uc p16uc_PSET32_WEVEN =
133 vec_sld((Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 0), (Packet16uc)vec_splat((Packet4ui)p16uc_FORWARD, 2),
135static Packet16uc p16uc_HALF64_0_16 = vec_sld(vec_splat((Packet16uc)vec_abs(p4i_MINUS16), 0), (Packet16uc)p4i_ZERO,
139static Packet16uc p16uc_PSET64_HI = (Packet16uc)vec_mergeh(
140 (Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);
141static Packet16uc p16uc_PSET64_LO = (Packet16uc)vec_mergel(
142 (Packet4ui)p16uc_PSET32_WODD, (Packet4ui)p16uc_PSET32_WEVEN);
143static Packet16uc p16uc_TRANSPOSE64_HI =
144 p16uc_PSET64_HI + p16uc_HALF64_0_16;
145static Packet16uc p16uc_TRANSPOSE64_LO =
146 p16uc_PSET64_LO + p16uc_HALF64_0_16;
148static Packet16uc p16uc_COMPLEX32_REV =
149 vec_sld(p16uc_REVERSE32, p16uc_REVERSE32, 8);
151#if EIGEN_HAS_BUILTIN(__builtin_prefetch) || EIGEN_COMP_GNUC
152#define EIGEN_PPC_PREFETCH(ADDR) __builtin_prefetch(ADDR);
154#define EIGEN_PPC_PREFETCH(ADDR) asm(" dcbt [%[addr]]\n" ::[addr] "r"(ADDR) : "cc");
158#define LOAD_STORE_UNROLL_16 _Pragma("unroll 16")
160#define LOAD_STORE_UNROLL_16 _Pragma("GCC unroll(16)")
164struct packet_traits<float> : default_packet_traits {
165 typedef Packet4f type;
166 typedef Packet4f half;
179 HasSin = EIGEN_FAST_MATH,
180 HasCos = EIGEN_FAST_MATH,
187#ifdef EIGEN_VECTORIZE_VSX
194 HasTanh = EIGEN_FAST_MATH,
195 HasErf = EIGEN_FAST_MATH,
207struct packet_traits<bfloat16> : default_packet_traits {
208 typedef Packet8bf type;
209 typedef Packet8bf half;
222 HasSin = EIGEN_FAST_MATH,
223 HasCos = EIGEN_FAST_MATH,
226#ifdef EIGEN_VECTORIZE_VSX
245struct packet_traits<int> : default_packet_traits {
246 typedef Packet4i type;
247 typedef Packet4i half;
257#if defined(_ARCH_PWR10) && (EIGEN_COMP_LLVM || EIGEN_GNUC_STRICT_AT_LEAST(11, 0, 0))
268struct packet_traits<short int> : default_packet_traits {
269 typedef Packet8s type;
270 typedef Packet8s half;
286struct packet_traits<unsigned short int> : default_packet_traits {
287 typedef Packet8us type;
288 typedef Packet8us half;
304struct packet_traits<signed char> : default_packet_traits {
305 typedef Packet16c type;
306 typedef Packet16c half;
322struct packet_traits<unsigned char> : default_packet_traits {
323 typedef Packet16uc type;
324 typedef Packet16uc half;
340struct unpacket_traits<Packet4f> {
342 typedef Packet4f half;
343 typedef Packet4i integer_packet;
348 masked_load_available =
false,
349 masked_store_available =
false
353struct unpacket_traits<Packet4i> {
355 typedef Packet4i half;
360 masked_load_available =
false,
361 masked_store_available =
false
365struct unpacket_traits<Packet8s> {
366 typedef short int type;
367 typedef Packet8s half;
372 masked_load_available =
false,
373 masked_store_available =
false
377struct unpacket_traits<Packet8us> {
378 typedef unsigned short int type;
379 typedef Packet8us half;
384 masked_load_available =
false,
385 masked_store_available =
false
390struct unpacket_traits<Packet16c> {
391 typedef signed char type;
392 typedef Packet16c half;
397 masked_load_available =
false,
398 masked_store_available =
false
402struct unpacket_traits<Packet16uc> {
403 typedef unsigned char type;
404 typedef Packet16uc half;
409 masked_load_available =
false,
410 masked_store_available =
false
415struct unpacket_traits<Packet8bf> {
416 typedef bfloat16 type;
417 typedef Packet8bf half;
422 masked_load_available =
false,
423 masked_store_available =
false
426inline std::ostream& operator<<(std::ostream& s,
const Packet16c& v) {
432 for (
int i = 0; i < 16; i++) s << vt.n[i] <<
", ";
436inline std::ostream& operator<<(std::ostream& s,
const Packet16uc& v) {
442 for (
int i = 0; i < 16; i++) s << vt.n[i] <<
", ";
446inline std::ostream& operator<<(std::ostream& s,
const Packet4f& v) {
452 s << vt.n[0] <<
", " << vt.n[1] <<
", " << vt.n[2] <<
", " << vt.n[3];
456inline std::ostream& operator<<(std::ostream& s,
const Packet4i& v) {
462 s << vt.n[0] <<
", " << vt.n[1] <<
", " << vt.n[2] <<
", " << vt.n[3];
466inline std::ostream& operator<<(std::ostream& s,
const Packet4ui& v) {
472 s << vt.n[0] <<
", " << vt.n[1] <<
", " << vt.n[2] <<
", " << vt.n[3];
476template <
typename Packet>
477EIGEN_STRONG_INLINE Packet pload_common(
const __UNPACK_TYPE__(Packet) * from) {
480 EIGEN_UNUSED_VARIABLE(from);
481 EIGEN_DEBUG_ALIGNED_LOAD
482#ifdef EIGEN_VECTORIZE_VSX
483 return vec_xl(0,
const_cast<__UNPACK_TYPE__(Packet)*
>(from));
485 return vec_ld(0, from);
491EIGEN_STRONG_INLINE Packet4f pload<Packet4f>(
const float* from) {
492 return pload_common<Packet4f>(from);
496EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(
const int* from) {
497 return pload_common<Packet4i>(from);
501EIGEN_STRONG_INLINE Packet8s pload<Packet8s>(
const short int* from) {
502 return pload_common<Packet8s>(from);
506EIGEN_STRONG_INLINE Packet8us pload<Packet8us>(
const unsigned short int* from) {
507 return pload_common<Packet8us>(from);
511EIGEN_STRONG_INLINE Packet16c pload<Packet16c>(
const signed char* from) {
512 return pload_common<Packet16c>(from);
516EIGEN_STRONG_INLINE Packet16uc pload<Packet16uc>(
const unsigned char* from) {
517 return pload_common<Packet16uc>(from);
521EIGEN_STRONG_INLINE Packet8bf pload<Packet8bf>(
const bfloat16* from) {
522 return pload_common<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from));
525template <
typename Packet>
526EIGEN_ALWAYS_INLINE Packet pload_ignore(
const __UNPACK_TYPE__(Packet) * from) {
529 EIGEN_UNUSED_VARIABLE(from);
530 EIGEN_DEBUG_ALIGNED_LOAD
533#pragma GCC diagnostic push
534#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
536#ifdef EIGEN_VECTORIZE_VSX
537 return vec_xl(0,
const_cast<__UNPACK_TYPE__(Packet)*
>(from));
539 return vec_ld(0, from);
542#pragma GCC diagnostic pop
547EIGEN_ALWAYS_INLINE Packet8bf pload_ignore<Packet8bf>(
const bfloat16* from) {
548 return pload_ignore<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from));
551template <
typename Packet>
552EIGEN_ALWAYS_INLINE Packet pload_partial_common(
const __UNPACK_TYPE__(Packet) * from,
const Index n,
553 const Index offset) {
556 const Index packet_size = unpacket_traits<Packet>::size;
557 eigen_internal_assert(n + offset <= packet_size &&
"number of elements plus offset will read past end of packet");
558 const Index size =
sizeof(__UNPACK_TYPE__(Packet));
560 EIGEN_UNUSED_VARIABLE(packet_size);
561 EIGEN_DEBUG_ALIGNED_LOAD
562 EIGEN_UNUSED_VARIABLE(from);
563 Packet load = vec_xl_len(
const_cast<__UNPACK_TYPE__(Packet)*
>(from), n * size);
565 Packet16uc shift = pset1<Packet16uc>(offset * 8 * size);
567 load = Packet(vec_sro(Packet16uc(load), shift));
569 load = Packet(vec_slo(Packet16uc(load), shift));
575 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) load[packet_size];
576 unsigned char* load2 =
reinterpret_cast<unsigned char*
>(load + offset);
577 unsigned char* from2 =
reinterpret_cast<unsigned char*
>(
const_cast<__UNPACK_TYPE__(Packet)*
>(from));
580 pstoreu(load2, ploadu<Packet16uc>(from2));
582 memcpy((
void*)load2, (
void*)from2, n2);
584 return pload_ignore<Packet>(load);
586 return Packet(pset1<Packet16uc>(0));
592EIGEN_ALWAYS_INLINE Packet4f pload_partial<Packet4f>(
const float* from,
const Index n,
const Index offset) {
593 return pload_partial_common<Packet4f>(from, n, offset);
597EIGEN_ALWAYS_INLINE Packet4i pload_partial<Packet4i>(
const int* from,
const Index n,
const Index offset) {
598 return pload_partial_common<Packet4i>(from, n, offset);
602EIGEN_ALWAYS_INLINE Packet8s pload_partial<Packet8s>(
const short int* from,
const Index n,
const Index offset) {
603 return pload_partial_common<Packet8s>(from, n, offset);
607EIGEN_ALWAYS_INLINE Packet8us pload_partial<Packet8us>(
const unsigned short int* from,
const Index n,
608 const Index offset) {
609 return pload_partial_common<Packet8us>(from, n, offset);
613EIGEN_ALWAYS_INLINE Packet8bf pload_partial<Packet8bf>(
const bfloat16* from,
const Index n,
const Index offset) {
614 return pload_partial_common<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from), n, offset);
618EIGEN_ALWAYS_INLINE Packet16c pload_partial<Packet16c>(
const signed char* from,
const Index n,
const Index offset) {
619 return pload_partial_common<Packet16c>(from, n, offset);
623EIGEN_ALWAYS_INLINE Packet16uc pload_partial<Packet16uc>(
const unsigned char* from,
const Index n,
const Index offset) {
624 return pload_partial_common<Packet16uc>(from, n, offset);
627template <
typename Packet>
628EIGEN_STRONG_INLINE
void pstore_common(__UNPACK_TYPE__(Packet) * to,
const Packet& from) {
631 EIGEN_UNUSED_VARIABLE(to);
632 EIGEN_DEBUG_ALIGNED_STORE
633#ifdef EIGEN_VECTORIZE_VSX
634 vec_xst(from, 0, to);
641EIGEN_STRONG_INLINE
void pstore<float>(
float* to,
const Packet4f& from) {
642 pstore_common<Packet4f>(to, from);
646EIGEN_STRONG_INLINE
void pstore<int>(
int* to,
const Packet4i& from) {
647 pstore_common<Packet4i>(to, from);
651EIGEN_STRONG_INLINE
void pstore<short int>(
short int* to,
const Packet8s& from) {
652 pstore_common<Packet8s>(to, from);
656EIGEN_STRONG_INLINE
void pstore<unsigned short int>(
unsigned short int* to,
const Packet8us& from) {
657 pstore_common<Packet8us>(to, from);
661EIGEN_STRONG_INLINE
void pstore<bfloat16>(bfloat16* to,
const Packet8bf& from) {
662 pstore_common<Packet8us>(
reinterpret_cast<unsigned short int*
>(to), from.m_val);
666EIGEN_STRONG_INLINE
void pstore<signed char>(
signed char* to,
const Packet16c& from) {
667 pstore_common<Packet16c>(to, from);
671EIGEN_STRONG_INLINE
void pstore<unsigned char>(
unsigned char* to,
const Packet16uc& from) {
672 pstore_common<Packet16uc>(to, from);
675template <
typename Packet>
676EIGEN_ALWAYS_INLINE
void pstore_partial_common(__UNPACK_TYPE__(Packet) * to,
const Packet& from,
const Index n,
677 const Index offset) {
680 const Index packet_size = unpacket_traits<Packet>::size;
681 eigen_internal_assert(n + offset <= packet_size &&
"number of elements plus offset will write past end of packet");
682 const Index size =
sizeof(__UNPACK_TYPE__(Packet));
684 EIGEN_UNUSED_VARIABLE(packet_size);
685 EIGEN_UNUSED_VARIABLE(to);
686 EIGEN_DEBUG_ALIGNED_STORE
689 Packet16uc shift = pset1<Packet16uc>(offset * 8 * size);
691 store = Packet(vec_slo(Packet16uc(store), shift));
693 store = Packet(vec_sro(Packet16uc(store), shift));
696 vec_xst_len(store, to, n * size);
699 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) store[packet_size];
701 unsigned char* store2 =
reinterpret_cast<unsigned char*
>(store + offset);
702 unsigned char* to2 =
reinterpret_cast<unsigned char*
>(to);
705 pstore(to2, ploadu<Packet16uc>(store2));
707 memcpy((
void*)to2, (
void*)store2, n2);
714EIGEN_ALWAYS_INLINE
void pstore_partial<float>(
float* to,
const Packet4f& from,
const Index n,
const Index offset) {
715 pstore_partial_common<Packet4f>(to, from, n, offset);
719EIGEN_ALWAYS_INLINE
void pstore_partial<int>(
int* to,
const Packet4i& from,
const Index n,
const Index offset) {
720 pstore_partial_common<Packet4i>(to, from, n, offset);
724EIGEN_ALWAYS_INLINE
void pstore_partial<short int>(
short int* to,
const Packet8s& from,
const Index n,
725 const Index offset) {
726 pstore_partial_common<Packet8s>(to, from, n, offset);
730EIGEN_ALWAYS_INLINE
void pstore_partial<unsigned short int>(
unsigned short int* to,
const Packet8us& from,
731 const Index n,
const Index offset) {
732 pstore_partial_common<Packet8us>(to, from, n, offset);
736EIGEN_ALWAYS_INLINE
void pstore_partial<bfloat16>(bfloat16* to,
const Packet8bf& from,
const Index n,
737 const Index offset) {
738 pstore_partial_common<Packet8us>(
reinterpret_cast<unsigned short int*
>(to), from.m_val, n, offset);
742EIGEN_ALWAYS_INLINE
void pstore_partial<signed char>(
signed char* to,
const Packet16c& from,
const Index n,
743 const Index offset) {
744 pstore_partial_common<Packet16c>(to, from, n, offset);
748EIGEN_ALWAYS_INLINE
void pstore_partial<unsigned char>(
unsigned char* to,
const Packet16uc& from,
const Index n,
749 const Index offset) {
750 pstore_partial_common<Packet16uc>(to, from, n, offset);
753template <
typename Packet>
754EIGEN_STRONG_INLINE Packet pset1_size4(
const __UNPACK_TYPE__(Packet) & from) {
755 Packet v = {from, from, from, from};
759template <
typename Packet>
760EIGEN_STRONG_INLINE Packet pset1_size8(
const __UNPACK_TYPE__(Packet) & from) {
761 Packet v = {from, from, from, from, from, from, from, from};
765template <
typename Packet>
766EIGEN_STRONG_INLINE Packet pset1_size16(
const __UNPACK_TYPE__(Packet) & from) {
767 Packet v = {from, from, from, from, from, from, from, from, from, from, from, from, from, from, from, from};
772EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(
const float& from) {
773 return pset1_size4<Packet4f>(from);
777EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(
const int& from) {
778 return pset1_size4<Packet4i>(from);
782EIGEN_STRONG_INLINE Packet8s pset1<Packet8s>(
const short int& from) {
783 return pset1_size8<Packet8s>(from);
787EIGEN_STRONG_INLINE Packet8us pset1<Packet8us>(
const unsigned short int& from) {
788 return pset1_size8<Packet8us>(from);
792EIGEN_STRONG_INLINE Packet16c pset1<Packet16c>(
const signed char& from) {
793 return pset1_size16<Packet16c>(from);
797EIGEN_STRONG_INLINE Packet16uc pset1<Packet16uc>(
const unsigned char& from) {
798 return pset1_size16<Packet16uc>(from);
802EIGEN_STRONG_INLINE Packet4f pset1frombits<Packet4f>(
unsigned int from) {
803 return reinterpret_cast<Packet4f
>(pset1<Packet4i>(from));
807EIGEN_STRONG_INLINE Packet8bf pset1<Packet8bf>(
const bfloat16& from) {
808 return pset1_size8<Packet8us>(
reinterpret_cast<const unsigned short int&
>(from));
811template <
typename Packet>
812EIGEN_STRONG_INLINE
void pbroadcast4_common(
const __UNPACK_TYPE__(Packet) * a, Packet& a0, Packet& a1, Packet& a2,
814 a3 = pload<Packet>(a);
815 a0 = vec_splat(a3, 0);
816 a1 = vec_splat(a3, 1);
817 a2 = vec_splat(a3, 2);
818 a3 = vec_splat(a3, 3);
822EIGEN_STRONG_INLINE
void pbroadcast4<Packet4f>(
const float* a, Packet4f& a0, Packet4f& a1, Packet4f& a2, Packet4f& a3) {
823 pbroadcast4_common<Packet4f>(a, a0, a1, a2, a3);
826EIGEN_STRONG_INLINE
void pbroadcast4<Packet4i>(
const int* a, Packet4i& a0, Packet4i& a1, Packet4i& a2, Packet4i& a3) {
827 pbroadcast4_common<Packet4i>(a, a0, a1, a2, a3);
830template <
typename Packet>
831EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet pgather_common(
const __UNPACK_TYPE__(Packet) * from, Index stride,
832 const Index n = unpacket_traits<Packet>::size) {
833 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) a[unpacket_traits<Packet>::size];
834 eigen_internal_assert(n <= unpacket_traits<Packet>::size &&
"number of elements will gather past end of packet");
836 if (n == unpacket_traits<Packet>::size) {
837 return ploadu<Packet>(from);
839 return ploadu_partial<Packet>(from, n);
843 for (Index i = 0; i < n; i++) {
844 a[i] = from[i * stride];
847 return pload_ignore<Packet>(a);
852EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet4f pgather<float, Packet4f>(
const float* from, Index stride) {
853 return pgather_common<Packet4f>(from, stride);
857EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet4i pgather<int, Packet4i>(
const int* from, Index stride) {
858 return pgather_common<Packet4i>(from, stride);
862EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8s pgather<short int, Packet8s>(
const short int* from, Index stride) {
863 return pgather_common<Packet8s>(from, stride);
867EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8us pgather<unsigned short int, Packet8us>(
const unsigned short int* from,
869 return pgather_common<Packet8us>(from, stride);
873EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8bf pgather<bfloat16, Packet8bf>(
const bfloat16* from, Index stride) {
874 return pgather_common<Packet8bf>(from, stride);
878EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet16c pgather<signed char, Packet16c>(
const signed char* from, Index stride) {
879 return pgather_common<Packet16c>(from, stride);
883EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet16uc pgather<unsigned char, Packet16uc>(
const unsigned char* from,
885 return pgather_common<Packet16uc>(from, stride);
889EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet4f pgather_partial<float, Packet4f>(
const float* from, Index stride,
891 return pgather_common<Packet4f>(from, stride, n);
895EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet4i pgather_partial<int, Packet4i>(
const int* from, Index stride,
897 return pgather_common<Packet4i>(from, stride, n);
901EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8s pgather_partial<short int, Packet8s>(
const short int* from, Index stride,
903 return pgather_common<Packet8s>(from, stride, n);
907EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8us
908pgather_partial<unsigned short int, Packet8us>(
const unsigned short int* from, Index stride,
const Index n) {
909 return pgather_common<Packet8us>(from, stride, n);
913EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet8bf pgather_partial<bfloat16, Packet8bf>(
const bfloat16* from, Index stride,
915 return pgather_common<Packet8bf>(from, stride, n);
919EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet16c pgather_partial<signed char, Packet16c>(
const signed char* from,
920 Index stride,
const Index n) {
921 return pgather_common<Packet16c>(from, stride, n);
925EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet16uc pgather_partial<unsigned char, Packet16uc>(
const unsigned char* from,
928 return pgather_common<Packet16uc>(from, stride, n);
931template <
typename Packet>
932EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_common(__UNPACK_TYPE__(Packet) * to,
const Packet& from,
934 const Index n = unpacket_traits<Packet>::size) {
935 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) a[unpacket_traits<Packet>::size];
936 eigen_internal_assert(n <= unpacket_traits<Packet>::size &&
"number of elements will scatter past end of packet");
938 if (n == unpacket_traits<Packet>::size) {
939 return pstoreu(to, from);
941 return pstoreu_partial(to, from, n);
944 pstore<__UNPACK_TYPE__(Packet)>(a, from);
946 for (Index i = 0; i < n; i++) {
947 to[i * stride] = a[i];
953EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<float, Packet4f>(
float* to,
const Packet4f& from, Index stride) {
954 pscatter_common<Packet4f>(to, from, stride);
958EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<int, Packet4i>(
int* to,
const Packet4i& from, Index stride) {
959 pscatter_common<Packet4i>(to, from, stride);
963EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<short int, Packet8s>(
short int* to,
const Packet8s& from,
965 pscatter_common<Packet8s>(to, from, stride);
969EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<unsigned short int, Packet8us>(
unsigned short int* to,
970 const Packet8us& from,
972 pscatter_common<Packet8us>(to, from, stride);
976EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<bfloat16, Packet8bf>(bfloat16* to,
const Packet8bf& from,
978 pscatter_common<Packet8bf>(to, from, stride);
982EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<signed char, Packet16c>(
signed char* to,
const Packet16c& from,
984 pscatter_common<Packet16c>(to, from, stride);
988EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<unsigned char, Packet16uc>(
unsigned char* to,
989 const Packet16uc& from, Index stride) {
990 pscatter_common<Packet16uc>(to, from, stride);
994EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<float, Packet4f>(
float* to,
const Packet4f& from,
995 Index stride,
const Index n) {
996 pscatter_common<Packet4f>(to, from, stride, n);
1000EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<int, Packet4i>(
int* to,
const Packet4i& from, Index stride,
1002 pscatter_common<Packet4i>(to, from, stride, n);
1006EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<short int, Packet8s>(
short int* to,
const Packet8s& from,
1007 Index stride,
const Index n) {
1008 pscatter_common<Packet8s>(to, from, stride, n);
1012EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<unsigned short int, Packet8us>(
unsigned short int* to,
1013 const Packet8us& from,
1016 pscatter_common<Packet8us>(to, from, stride, n);
1020EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<bfloat16, Packet8bf>(bfloat16* to,
const Packet8bf& from,
1021 Index stride,
const Index n) {
1022 pscatter_common<Packet8bf>(to, from, stride, n);
1026EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<signed char, Packet16c>(
signed char* to,
1027 const Packet16c& from, Index stride,
1029 pscatter_common<Packet16c>(to, from, stride, n);
1033EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<unsigned char, Packet16uc>(
unsigned char* to,
1034 const Packet16uc& from,
1035 Index stride,
const Index n) {
1036 pscatter_common<Packet16uc>(to, from, stride, n);
1040EIGEN_STRONG_INLINE Packet4f plset<Packet4f>(
const float& a) {
1041 return pset1<Packet4f>(a) + p4f_COUNTDOWN;
1044EIGEN_STRONG_INLINE Packet4i plset<Packet4i>(
const int& a) {
1045 return pset1<Packet4i>(a) + p4i_COUNTDOWN;
1048EIGEN_STRONG_INLINE Packet8s plset<Packet8s>(
const short int& a) {
1049 return pset1<Packet8s>(a) + p8s_COUNTDOWN;
1052EIGEN_STRONG_INLINE Packet8us plset<Packet8us>(
const unsigned short int& a) {
1053 return pset1<Packet8us>(a) + p8us_COUNTDOWN;
1056EIGEN_STRONG_INLINE Packet16c plset<Packet16c>(
const signed char& a) {
1057 return pset1<Packet16c>(a) + p16c_COUNTDOWN;
1060EIGEN_STRONG_INLINE Packet16uc plset<Packet16uc>(
const unsigned char& a) {
1061 return pset1<Packet16uc>(a) + p16uc_COUNTDOWN;
1065EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1069EIGEN_STRONG_INLINE Packet4i padd<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1073EIGEN_STRONG_INLINE Packet4ui padd<Packet4ui>(
const Packet4ui& a,
const Packet4ui& b) {
1077EIGEN_STRONG_INLINE Packet8s padd<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1081EIGEN_STRONG_INLINE Packet8us padd<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1085EIGEN_STRONG_INLINE Packet16c padd<Packet16c>(
const Packet16c& a,
const Packet16c& b) {
1089EIGEN_STRONG_INLINE Packet16uc padd<Packet16uc>(
const Packet16uc& a,
const Packet16uc& b) {
1094EIGEN_STRONG_INLINE Packet4f psub<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1098EIGEN_STRONG_INLINE Packet4i psub<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1102EIGEN_STRONG_INLINE Packet8s psub<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1106EIGEN_STRONG_INLINE Packet8us psub<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1110EIGEN_STRONG_INLINE Packet16c psub<Packet16c>(
const Packet16c& a,
const Packet16c& b) {
1114EIGEN_STRONG_INLINE Packet16uc psub<Packet16uc>(
const Packet16uc& a,
const Packet16uc& b) {
1119EIGEN_STRONG_INLINE Packet4f pnegate(
const Packet4f& a) {
1120#ifdef __POWER8_VECTOR__
1123 return vec_xor(a, p4f_MZERO);
1127EIGEN_STRONG_INLINE Packet16c pnegate(
const Packet16c& a) {
1128#ifdef __POWER8_VECTOR__
1131 return reinterpret_cast<Packet16c
>(p4i_ZERO) - a;
1135EIGEN_STRONG_INLINE Packet8s pnegate(
const Packet8s& a) {
1136#ifdef __POWER8_VECTOR__
1139 return reinterpret_cast<Packet8s
>(p4i_ZERO) - a;
1143EIGEN_STRONG_INLINE Packet4i pnegate(
const Packet4i& a) {
1144#ifdef __POWER8_VECTOR__
1147 return p4i_ZERO - a;
1152EIGEN_STRONG_INLINE Packet4f pconj(
const Packet4f& a) {
1156EIGEN_STRONG_INLINE Packet4i pconj(
const Packet4i& a) {
1161EIGEN_STRONG_INLINE Packet4f pmul<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1162 return vec_madd(a, b, p4f_MZERO);
1165EIGEN_STRONG_INLINE Packet4i pmul<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1169EIGEN_STRONG_INLINE Packet8s pmul<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1170 return vec_mul(a, b);
1173EIGEN_STRONG_INLINE Packet8us pmul<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1174 return vec_mul(a, b);
1177EIGEN_STRONG_INLINE Packet16c pmul<Packet16c>(
const Packet16c& a,
const Packet16c& b) {
1178 return vec_mul(a, b);
1181EIGEN_STRONG_INLINE Packet16uc pmul<Packet16uc>(
const Packet16uc& a,
const Packet16uc& b) {
1182 return vec_mul(a, b);
1186EIGEN_STRONG_INLINE Packet4f pdiv<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1188 Packet4f t, y_0, y_1;
1194 t = vec_nmsub(y_0, b, p4f_ONE);
1195 y_1 = vec_madd(y_0, t, y_0);
1197 return vec_madd(a, y_1, p4f_MZERO);
1199 return vec_div(a, b);
1204EIGEN_STRONG_INLINE Packet4i pdiv<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1205#if defined(_ARCH_PWR10) && (EIGEN_COMP_LLVM || EIGEN_GNUC_STRICT_AT_LEAST(11, 0, 0))
1206 return vec_div(a, b);
1208 EIGEN_UNUSED_VARIABLE(a);
1209 EIGEN_UNUSED_VARIABLE(b);
1210 eigen_assert(
false &&
"packet integer division are not supported by AltiVec");
1211 return pset1<Packet4i>(0);
1217EIGEN_STRONG_INLINE Packet4f pmadd(
const Packet4f& a,
const Packet4f& b,
const Packet4f& c) {
1218 return vec_madd(a, b, c);
1221EIGEN_STRONG_INLINE Packet4i pmadd(
const Packet4i& a,
const Packet4i& b,
const Packet4i& c) {
1225EIGEN_STRONG_INLINE Packet8s pmadd(
const Packet8s& a,
const Packet8s& b,
const Packet8s& c) {
1226 return vec_madd(a, b, c);
1229EIGEN_STRONG_INLINE Packet8us pmadd(
const Packet8us& a,
const Packet8us& b,
const Packet8us& c) {
1230 return vec_madd(a, b, c);
1233#ifdef EIGEN_VECTORIZE_VSX
1235EIGEN_STRONG_INLINE Packet4f pmsub(
const Packet4f& a,
const Packet4f& b,
const Packet4f& c) {
1236 return vec_msub(a, b, c);
1239EIGEN_STRONG_INLINE Packet4f pnmadd(
const Packet4f& a,
const Packet4f& b,
const Packet4f& c) {
1240 return vec_nmsub(a, b, c);
1243EIGEN_STRONG_INLINE Packet4f pnmsub(
const Packet4f& a,
const Packet4f& b,
const Packet4f& c) {
1244 return vec_nmadd(a, b, c);
1249EIGEN_STRONG_INLINE Packet4f pmin<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1250#ifdef EIGEN_VECTORIZE_VSX
1253 __asm__(
"xvcmpgesp %x0,%x1,%x2\n\txxsel %x0,%x1,%x2,%x0" :
"=&wa"(ret) :
"wa"(a),
"wa"(b));
1256 return vec_min(a, b);
1260EIGEN_STRONG_INLINE Packet4i pmin<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1261 return vec_min(a, b);
1264EIGEN_STRONG_INLINE Packet8s pmin<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1265 return vec_min(a, b);
1268EIGEN_STRONG_INLINE Packet8us pmin<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1269 return vec_min(a, b);
1272EIGEN_STRONG_INLINE Packet16c pmin<Packet16c>(
const Packet16c& a,
const Packet16c& b) {
1273 return vec_min(a, b);
1276EIGEN_STRONG_INLINE Packet16uc pmin<Packet16uc>(
const Packet16uc& a,
const Packet16uc& b) {
1277 return vec_min(a, b);
1281EIGEN_STRONG_INLINE Packet4f pmax<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1282#ifdef EIGEN_VECTORIZE_VSX
1285 __asm__(
"xvcmpgtsp %x0,%x2,%x1\n\txxsel %x0,%x1,%x2,%x0" :
"=&wa"(ret) :
"wa"(a),
"wa"(b));
1288 return vec_max(a, b);
1292EIGEN_STRONG_INLINE Packet4i pmax<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1293 return vec_max(a, b);
1296EIGEN_STRONG_INLINE Packet8s pmax<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1297 return vec_max(a, b);
1300EIGEN_STRONG_INLINE Packet8us pmax<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1301 return vec_max(a, b);
1304EIGEN_STRONG_INLINE Packet16c pmax<Packet16c>(
const Packet16c& a,
const Packet16c& b) {
1305 return vec_max(a, b);
1308EIGEN_STRONG_INLINE Packet16uc pmax<Packet16uc>(
const Packet16uc& a,
const Packet16uc& b) {
1309 return vec_max(a, b);
1313EIGEN_STRONG_INLINE Packet4f pcmp_le(
const Packet4f& a,
const Packet4f& b) {
1314 return reinterpret_cast<Packet4f
>(vec_cmple(a, b));
1317#ifdef EIGEN_VECTORIZE_VSX
1319EIGEN_STRONG_INLINE Packet4f pcmp_lt(
const Packet4f& a,
const Packet4f& b) {
1320 return reinterpret_cast<Packet4f
>(vec_cmplt(a, b));
1324EIGEN_STRONG_INLINE Packet4f pcmp_eq(
const Packet4f& a,
const Packet4f& b) {
1325 return reinterpret_cast<Packet4f
>(vec_cmpeq(a, b));
1328EIGEN_STRONG_INLINE Packet4f pcmp_lt_or_nan(
const Packet4f& a,
const Packet4f& b) {
1329 Packet4f c =
reinterpret_cast<Packet4f
>(vec_cmpge(a, b));
1330 return vec_nor(c, c);
1333#ifdef EIGEN_VECTORIZE_VSX
1335EIGEN_STRONG_INLINE Packet4i pcmp_le(
const Packet4i& a,
const Packet4i& b) {
1336 return reinterpret_cast<Packet4i
>(vec_cmple(a, b));
1340EIGEN_STRONG_INLINE Packet4i pcmp_lt(
const Packet4i& a,
const Packet4i& b) {
1341 return reinterpret_cast<Packet4i
>(vec_cmplt(a, b));
1344EIGEN_STRONG_INLINE Packet4i pcmp_eq(
const Packet4i& a,
const Packet4i& b) {
1345 return reinterpret_cast<Packet4i
>(vec_cmpeq(a, b));
1347#ifdef EIGEN_VECTORIZE_VSX
1349EIGEN_STRONG_INLINE Packet8s pcmp_le(
const Packet8s& a,
const Packet8s& b) {
1350 return reinterpret_cast<Packet8s
>(vec_cmple(a, b));
1354EIGEN_STRONG_INLINE Packet8s pcmp_lt(
const Packet8s& a,
const Packet8s& b) {
1355 return reinterpret_cast<Packet8s
>(vec_cmplt(a, b));
1358EIGEN_STRONG_INLINE Packet8s pcmp_eq(
const Packet8s& a,
const Packet8s& b) {
1359 return reinterpret_cast<Packet8s
>(vec_cmpeq(a, b));
1361#ifdef EIGEN_VECTORIZE_VSX
1363EIGEN_STRONG_INLINE Packet8us pcmp_le(
const Packet8us& a,
const Packet8us& b) {
1364 return reinterpret_cast<Packet8us
>(vec_cmple(a, b));
1368EIGEN_STRONG_INLINE Packet8us pcmp_lt(
const Packet8us& a,
const Packet8us& b) {
1369 return reinterpret_cast<Packet8us
>(vec_cmplt(a, b));
1372EIGEN_STRONG_INLINE Packet8us pcmp_eq(
const Packet8us& a,
const Packet8us& b) {
1373 return reinterpret_cast<Packet8us
>(vec_cmpeq(a, b));
1375#ifdef EIGEN_VECTORIZE_VSX
1377EIGEN_STRONG_INLINE Packet16c pcmp_le(
const Packet16c& a,
const Packet16c& b) {
1378 return reinterpret_cast<Packet16c
>(vec_cmple(a, b));
1382EIGEN_STRONG_INLINE Packet16c pcmp_lt(
const Packet16c& a,
const Packet16c& b) {
1383 return reinterpret_cast<Packet16c
>(vec_cmplt(a, b));
1386EIGEN_STRONG_INLINE Packet16c pcmp_eq(
const Packet16c& a,
const Packet16c& b) {
1387 return reinterpret_cast<Packet16c
>(vec_cmpeq(a, b));
1389#ifdef EIGEN_VECTORIZE_VSX
1391EIGEN_STRONG_INLINE Packet16uc pcmp_le(
const Packet16uc& a,
const Packet16uc& b) {
1392 return reinterpret_cast<Packet16uc
>(vec_cmple(a, b));
1396EIGEN_STRONG_INLINE Packet16uc pcmp_lt(
const Packet16uc& a,
const Packet16uc& b) {
1397 return reinterpret_cast<Packet16uc
>(vec_cmplt(a, b));
1400EIGEN_STRONG_INLINE Packet16uc pcmp_eq(
const Packet16uc& a,
const Packet16uc& b) {
1401 return reinterpret_cast<Packet16uc
>(vec_cmpeq(a, b));
1405EIGEN_STRONG_INLINE Packet4f pand<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1406 return vec_and(a, b);
1409EIGEN_STRONG_INLINE Packet4i pand<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1410 return vec_and(a, b);
1413EIGEN_STRONG_INLINE Packet4ui pand<Packet4ui>(
const Packet4ui& a,
const Packet4ui& b) {
1414 return vec_and(a, b);
1417EIGEN_STRONG_INLINE Packet8us pand<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1418 return vec_and(a, b);
1421EIGEN_STRONG_INLINE Packet8bf pand<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
1422 return pand<Packet8us>(a, b);
1426EIGEN_STRONG_INLINE Packet4f por<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1427 return vec_or(a, b);
1430EIGEN_STRONG_INLINE Packet4i por<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1431 return vec_or(a, b);
1434EIGEN_STRONG_INLINE Packet8s por<Packet8s>(
const Packet8s& a,
const Packet8s& b) {
1435 return vec_or(a, b);
1438EIGEN_STRONG_INLINE Packet8us por<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1439 return vec_or(a, b);
1442EIGEN_STRONG_INLINE Packet8bf por<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
1443 return por<Packet8us>(a, b);
1447EIGEN_STRONG_INLINE Packet4f pxor<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1448 return vec_xor(a, b);
1451EIGEN_STRONG_INLINE Packet4i pxor<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1452 return vec_xor(a, b);
1455EIGEN_STRONG_INLINE Packet8us pxor<Packet8us>(
const Packet8us& a,
const Packet8us& b) {
1456 return vec_xor(a, b);
1459EIGEN_STRONG_INLINE Packet8bf pxor<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
1460 return pxor<Packet8us>(a, b);
1464EIGEN_STRONG_INLINE Packet4f pandnot<Packet4f>(
const Packet4f& a,
const Packet4f& b) {
1465 return vec_andc(a, b);
1468EIGEN_STRONG_INLINE Packet4i pandnot<Packet4i>(
const Packet4i& a,
const Packet4i& b) {
1469 return vec_andc(a, b);
1473EIGEN_STRONG_INLINE Packet4f pselect(
const Packet4f& mask,
const Packet4f& a,
const Packet4f& b) {
1474 return vec_sel(b, a,
reinterpret_cast<Packet4ui
>(mask));
1478EIGEN_STRONG_INLINE Packet4f pround<Packet4f>(
const Packet4f& a) {
1479 Packet4f t = vec_add(
1480 reinterpret_cast<Packet4f
>(vec_or(vec_and(
reinterpret_cast<Packet4ui
>(a), p4ui_SIGN), p4ui_PREV0DOT5)), a);
1483#ifdef EIGEN_VECTORIZE_VSX
1484 __asm__(
"xvrspiz %x0, %x1\n\t" :
"=&wa"(res) :
"wa"(t));
1486 __asm__(
"vrfiz %0, %1\n\t" :
"=v"(res) :
"v"(t));
1492EIGEN_STRONG_INLINE Packet4f pceil<Packet4f>(
const Packet4f& a) {
1496EIGEN_STRONG_INLINE Packet4f pfloor<Packet4f>(
const Packet4f& a) {
1497 return vec_floor(a);
1500EIGEN_STRONG_INLINE Packet4f ptrunc<Packet4f>(
const Packet4f& a) {
1501 return vec_trunc(a);
1503#ifdef EIGEN_VECTORIZE_VSX
1505EIGEN_STRONG_INLINE Packet4f print<Packet4f>(
const Packet4f& a) {
1508 __asm__(
"xvrspic %x0, %x1\n\t" :
"=&wa"(res) :
"wa"(a));
1514template <
typename Packet>
1515EIGEN_STRONG_INLINE Packet ploadu_common(
const __UNPACK_TYPE__(Packet) * from) {
1516 EIGEN_DEBUG_ALIGNED_LOAD
1517#if defined(EIGEN_VECTORIZE_VSX) || !defined(_BIG_ENDIAN)
1518 EIGEN_DEBUG_UNALIGNED_LOAD
1519 return vec_xl(0,
const_cast<__UNPACK_TYPE__(Packet)*
>(from));
1521 Packet16uc MSQ, LSQ;
1523 MSQ = vec_ld(0, (
unsigned char*)from);
1524 LSQ = vec_ld(15, (
unsigned char*)from);
1525 mask = vec_lvsl(0, from);
1527 return (Packet)vec_perm(MSQ, LSQ, mask);
1532EIGEN_STRONG_INLINE Packet4f ploadu<Packet4f>(
const float* from) {
1533 return ploadu_common<Packet4f>(from);
1536EIGEN_STRONG_INLINE Packet4i ploadu<Packet4i>(
const int* from) {
1537 return ploadu_common<Packet4i>(from);
1540EIGEN_STRONG_INLINE Packet8s ploadu<Packet8s>(
const short int* from) {
1541 return ploadu_common<Packet8s>(from);
1544EIGEN_STRONG_INLINE Packet8us ploadu<Packet8us>(
const unsigned short int* from) {
1545 return ploadu_common<Packet8us>(from);
1548EIGEN_STRONG_INLINE Packet8bf ploadu<Packet8bf>(
const bfloat16* from) {
1549 return ploadu_common<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from));
1552EIGEN_STRONG_INLINE Packet16c ploadu<Packet16c>(
const signed char* from) {
1553 return ploadu_common<Packet16c>(from);
1556EIGEN_STRONG_INLINE Packet16uc ploadu<Packet16uc>(
const unsigned char* from) {
1557 return ploadu_common<Packet16uc>(from);
1560template <
typename Packet>
1561EIGEN_ALWAYS_INLINE Packet ploadu_partial_common(
const __UNPACK_TYPE__(Packet) * from,
const Index n,
1562 const Index offset) {
1563 const Index packet_size = unpacket_traits<Packet>::size;
1564 eigen_internal_assert(n + offset <= packet_size &&
"number of elements plus offset will read past end of packet");
1565 const Index size =
sizeof(__UNPACK_TYPE__(Packet));
1567 EIGEN_UNUSED_VARIABLE(packet_size);
1568 EIGEN_DEBUG_ALIGNED_LOAD
1569 EIGEN_DEBUG_UNALIGNED_LOAD
1570 Packet load = vec_xl_len(
const_cast<__UNPACK_TYPE__(Packet)*
>(from), n * size);
1572 Packet16uc shift = pset1<Packet16uc>(offset * 8 * size);
1574 load = Packet(vec_sro(Packet16uc(load), shift));
1576 load = Packet(vec_slo(Packet16uc(load), shift));
1582 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) load[packet_size];
1583 unsigned char* load2 =
reinterpret_cast<unsigned char*
>(load + offset);
1584 unsigned char* from2 =
reinterpret_cast<unsigned char*
>(
const_cast<__UNPACK_TYPE__(Packet)*
>(from));
1585 Index n2 = n * size;
1587 pstoreu(load2, ploadu<Packet16uc>(from2));
1589 memcpy((
void*)load2, (
void*)from2, n2);
1591 return pload_ignore<Packet>(load);
1593 return Packet(pset1<Packet16uc>(0));
1599EIGEN_ALWAYS_INLINE Packet4f ploadu_partial<Packet4f>(
const float* from,
const Index n,
const Index offset) {
1600 return ploadu_partial_common<Packet4f>(from, n, offset);
1603EIGEN_ALWAYS_INLINE Packet4i ploadu_partial<Packet4i>(
const int* from,
const Index n,
const Index offset) {
1604 return ploadu_partial_common<Packet4i>(from, n, offset);
1607EIGEN_ALWAYS_INLINE Packet8s ploadu_partial<Packet8s>(
const short int* from,
const Index n,
const Index offset) {
1608 return ploadu_partial_common<Packet8s>(from, n, offset);
1611EIGEN_ALWAYS_INLINE Packet8us ploadu_partial<Packet8us>(
const unsigned short int* from,
const Index n,
1612 const Index offset) {
1613 return ploadu_partial_common<Packet8us>(from, n, offset);
1616EIGEN_ALWAYS_INLINE Packet8bf ploadu_partial<Packet8bf>(
const bfloat16* from,
const Index n,
const Index offset) {
1617 return ploadu_partial_common<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from), n, offset);
1620EIGEN_ALWAYS_INLINE Packet16c ploadu_partial<Packet16c>(
const signed char* from,
const Index n,
const Index offset) {
1621 return ploadu_partial_common<Packet16c>(from, n, offset);
1624EIGEN_ALWAYS_INLINE Packet16uc ploadu_partial<Packet16uc>(
const unsigned char* from,
const Index n,
1625 const Index offset) {
1626 return ploadu_partial_common<Packet16uc>(from, n, offset);
1629template <
typename Packet>
1630EIGEN_STRONG_INLINE Packet ploaddup_common(
const __UNPACK_TYPE__(Packet) * from) {
1632 if ((std::ptrdiff_t(from) % 16) == 0)
1633 p = pload<Packet>(from);
1635 p = ploadu<Packet>(from);
1636 return vec_mergeh(p, p);
1639EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(
const float* from) {
1640 return ploaddup_common<Packet4f>(from);
1643EIGEN_STRONG_INLINE Packet4i ploaddup<Packet4i>(
const int* from) {
1644 return ploaddup_common<Packet4i>(from);
1648EIGEN_STRONG_INLINE Packet8s ploaddup<Packet8s>(
const short int* from) {
1650 if ((std::ptrdiff_t(from) % 16) == 0)
1651 p = pload<Packet8s>(from);
1653 p = ploadu<Packet8s>(from);
1654 return vec_mergeh(p, p);
1658EIGEN_STRONG_INLINE Packet8us ploaddup<Packet8us>(
const unsigned short int* from) {
1660 if ((std::ptrdiff_t(from) % 16) == 0)
1661 p = pload<Packet8us>(from);
1663 p = ploadu<Packet8us>(from);
1664 return vec_mergeh(p, p);
1668EIGEN_STRONG_INLINE Packet8s ploadquad<Packet8s>(
const short int* from) {
1670 if ((std::ptrdiff_t(from) % 16) == 0)
1671 p = pload<Packet8s>(from);
1673 p = ploadu<Packet8s>(from);
1674 return vec_perm(p, p, p16uc_QUADRUPLICATE16_HI);
1678EIGEN_STRONG_INLINE Packet8us ploadquad<Packet8us>(
const unsigned short int* from) {
1680 if ((std::ptrdiff_t(from) % 16) == 0)
1681 p = pload<Packet8us>(from);
1683 p = ploadu<Packet8us>(from);
1684 return vec_perm(p, p, p16uc_QUADRUPLICATE16_HI);
1688EIGEN_STRONG_INLINE Packet8bf ploadquad<Packet8bf>(
const bfloat16* from) {
1689 return ploadquad<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from));
1693EIGEN_STRONG_INLINE Packet16c ploaddup<Packet16c>(
const signed char* from) {
1695 if ((std::ptrdiff_t(from) % 16) == 0)
1696 p = pload<Packet16c>(from);
1698 p = ploadu<Packet16c>(from);
1699 return vec_mergeh(p, p);
1703EIGEN_STRONG_INLINE Packet16uc ploaddup<Packet16uc>(
const unsigned char* from) {
1705 if ((std::ptrdiff_t(from) % 16) == 0)
1706 p = pload<Packet16uc>(from);
1708 p = ploadu<Packet16uc>(from);
1709 return vec_mergeh(p, p);
1713EIGEN_STRONG_INLINE Packet16c ploadquad<Packet16c>(
const signed char* from) {
1715 if ((std::ptrdiff_t(from) % 16) == 0)
1716 p = pload<Packet16c>(from);
1718 p = ploadu<Packet16c>(from);
1719 return vec_perm(p, p, p16uc_QUADRUPLICATE16);
1723EIGEN_STRONG_INLINE Packet16uc ploadquad<Packet16uc>(
const unsigned char* from) {
1725 if ((std::ptrdiff_t(from) % 16) == 0)
1726 p = pload<Packet16uc>(from);
1728 p = ploadu<Packet16uc>(from);
1729 return vec_perm(p, p, p16uc_QUADRUPLICATE16);
1732template <
typename Packet>
1733EIGEN_STRONG_INLINE
void pstoreu_common(__UNPACK_TYPE__(Packet) * to,
const Packet& from) {
1734 EIGEN_DEBUG_UNALIGNED_STORE
1735#if defined(EIGEN_VECTORIZE_VSX) || !defined(_BIG_ENDIAN)
1736 vec_xst(from, 0, to);
1740 Packet16uc MSQ, LSQ, edges;
1741 Packet16uc edgeAlign, align;
1743 MSQ = vec_ld(0, (
unsigned char*)to);
1744 LSQ = vec_ld(15, (
unsigned char*)to);
1745 edgeAlign = vec_lvsl(0, to);
1746 edges = vec_perm(LSQ, MSQ, edgeAlign);
1747 align = vec_lvsr(0, to);
1748 MSQ = vec_perm(edges, (Packet16uc)from, align);
1749 LSQ = vec_perm((Packet16uc)from, edges, align);
1750 vec_st(LSQ, 15, (
unsigned char*)to);
1751 vec_st(MSQ, 0, (
unsigned char*)to);
1755EIGEN_STRONG_INLINE
void pstoreu<float>(
float* to,
const Packet4f& from) {
1756 pstoreu_common<Packet4f>(to, from);
1759EIGEN_STRONG_INLINE
void pstoreu<int>(
int* to,
const Packet4i& from) {
1760 pstoreu_common<Packet4i>(to, from);
1763EIGEN_STRONG_INLINE
void pstoreu<short int>(
short int* to,
const Packet8s& from) {
1764 pstoreu_common<Packet8s>(to, from);
1767EIGEN_STRONG_INLINE
void pstoreu<unsigned short int>(
unsigned short int* to,
const Packet8us& from) {
1768 pstoreu_common<Packet8us>(to, from);
1771EIGEN_STRONG_INLINE
void pstoreu<bfloat16>(bfloat16* to,
const Packet8bf& from) {
1772 pstoreu_common<Packet8us>(
reinterpret_cast<unsigned short int*
>(to), from.m_val);
1775EIGEN_STRONG_INLINE
void pstoreu<signed char>(
signed char* to,
const Packet16c& from) {
1776 pstoreu_common<Packet16c>(to, from);
1779EIGEN_STRONG_INLINE
void pstoreu<unsigned char>(
unsigned char* to,
const Packet16uc& from) {
1780 pstoreu_common<Packet16uc>(to, from);
1783template <
typename Packet>
1784EIGEN_ALWAYS_INLINE
void pstoreu_partial_common(__UNPACK_TYPE__(Packet) * to,
const Packet& from,
const Index n,
1785 const Index offset) {
1786 const Index packet_size = unpacket_traits<Packet>::size;
1787 eigen_internal_assert(n + offset <= packet_size &&
"number of elements plus offset will write past end of packet");
1788 const Index size =
sizeof(__UNPACK_TYPE__(Packet));
1790 EIGEN_UNUSED_VARIABLE(packet_size);
1791 EIGEN_DEBUG_UNALIGNED_STORE
1792 Packet store = from;
1794 Packet16uc shift = pset1<Packet16uc>(offset * 8 * size);
1796 store = Packet(vec_slo(Packet16uc(store), shift));
1798 store = Packet(vec_sro(Packet16uc(store), shift));
1801 vec_xst_len(store, to, n * size);
1804 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) store[packet_size];
1805 pstore(store, from);
1806 unsigned char* store2 =
reinterpret_cast<unsigned char*
>(store + offset);
1807 unsigned char* to2 =
reinterpret_cast<unsigned char*
>(to);
1808 Index n2 = n * size;
1810 pstoreu(to2, ploadu<Packet16uc>(store2));
1812 memcpy((
void*)to2, (
void*)store2, n2);
1819EIGEN_ALWAYS_INLINE
void pstoreu_partial<float>(
float* to,
const Packet4f& from,
const Index n,
const Index offset) {
1820 pstoreu_partial_common<Packet4f>(to, from, n, offset);
1823EIGEN_ALWAYS_INLINE
void pstoreu_partial<int>(
int* to,
const Packet4i& from,
const Index n,
const Index offset) {
1824 pstoreu_partial_common<Packet4i>(to, from, n, offset);
1827EIGEN_ALWAYS_INLINE
void pstoreu_partial<short int>(
short int* to,
const Packet8s& from,
const Index n,
1828 const Index offset) {
1829 pstoreu_partial_common<Packet8s>(to, from, n, offset);
1832EIGEN_ALWAYS_INLINE
void pstoreu_partial<unsigned short int>(
unsigned short int* to,
const Packet8us& from,
1833 const Index n,
const Index offset) {
1834 pstoreu_partial_common<Packet8us>(to, from, n, offset);
1837EIGEN_ALWAYS_INLINE
void pstoreu_partial<bfloat16>(bfloat16* to,
const Packet8bf& from,
const Index n,
1838 const Index offset) {
1839 pstoreu_partial_common<Packet8us>(
reinterpret_cast<unsigned short int*
>(to), from, n, offset);
1842EIGEN_ALWAYS_INLINE
void pstoreu_partial<signed char>(
signed char* to,
const Packet16c& from,
const Index n,
1843 const Index offset) {
1844 pstoreu_partial_common<Packet16c>(to, from, n, offset);
1847EIGEN_ALWAYS_INLINE
void pstoreu_partial<unsigned char>(
unsigned char* to,
const Packet16uc& from,
const Index n,
1848 const Index offset) {
1849 pstoreu_partial_common<Packet16uc>(to, from, n, offset);
1853EIGEN_STRONG_INLINE
void prefetch<float>(
const float* addr) {
1854 EIGEN_PPC_PREFETCH(addr);
1857EIGEN_STRONG_INLINE
void prefetch<int>(
const int* addr) {
1858 EIGEN_PPC_PREFETCH(addr);
1862EIGEN_STRONG_INLINE
float pfirst<Packet4f>(
const Packet4f& a) {
1863 EIGEN_ALIGN16
float x;
1868EIGEN_STRONG_INLINE
int pfirst<Packet4i>(
const Packet4i& a) {
1869 EIGEN_ALIGN16
int x;
1874template <
typename Packet>
1875EIGEN_STRONG_INLINE __UNPACK_TYPE__(Packet) pfirst_common(
const Packet& a) {
1876 EIGEN_ALIGN16 __UNPACK_TYPE__(Packet) x;
1882EIGEN_STRONG_INLINE
short int pfirst<Packet8s>(
const Packet8s& a) {
1883 return pfirst_common<Packet8s>(a);
1887EIGEN_STRONG_INLINE
unsigned short int pfirst<Packet8us>(
const Packet8us& a) {
1888 return pfirst_common<Packet8us>(a);
1892EIGEN_STRONG_INLINE
signed char pfirst<Packet16c>(
const Packet16c& a) {
1893 return pfirst_common<Packet16c>(a);
1897EIGEN_STRONG_INLINE
unsigned char pfirst<Packet16uc>(
const Packet16uc& a) {
1898 return pfirst_common<Packet16uc>(a);
1902EIGEN_STRONG_INLINE Packet4f preverse(
const Packet4f& a) {
1903 return reinterpret_cast<Packet4f
>(
1904 vec_perm(
reinterpret_cast<Packet16uc
>(a),
reinterpret_cast<Packet16uc
>(a), p16uc_REVERSE32));
1907EIGEN_STRONG_INLINE Packet4i preverse(
const Packet4i& a) {
1908 return reinterpret_cast<Packet4i
>(
1909 vec_perm(
reinterpret_cast<Packet16uc
>(a),
reinterpret_cast<Packet16uc
>(a), p16uc_REVERSE32));
1912EIGEN_STRONG_INLINE Packet8s preverse(
const Packet8s& a) {
1913 return reinterpret_cast<Packet8s
>(
1914 vec_perm(
reinterpret_cast<Packet16uc
>(a),
reinterpret_cast<Packet16uc
>(a), p16uc_REVERSE16));
1917EIGEN_STRONG_INLINE Packet8us preverse(
const Packet8us& a) {
1918 return reinterpret_cast<Packet8us
>(
1919 vec_perm(
reinterpret_cast<Packet16uc
>(a),
reinterpret_cast<Packet16uc
>(a), p16uc_REVERSE16));
1922EIGEN_STRONG_INLINE Packet16c preverse(
const Packet16c& a) {
1923 return vec_perm(a, a, p16uc_REVERSE8);
1926EIGEN_STRONG_INLINE Packet16uc preverse(
const Packet16uc& a) {
1927 return vec_perm(a, a, p16uc_REVERSE8);
1930EIGEN_STRONG_INLINE Packet8bf preverse(
const Packet8bf& a) {
1931 return preverse<Packet8us>(a);
1935EIGEN_STRONG_INLINE Packet4f pabs(
const Packet4f& a) {
1939EIGEN_STRONG_INLINE Packet4i pabs(
const Packet4i& a) {
1943EIGEN_STRONG_INLINE Packet8s pabs(
const Packet8s& a) {
1947EIGEN_STRONG_INLINE Packet8us pabs(
const Packet8us& a) {
1951EIGEN_STRONG_INLINE Packet16c pabs(
const Packet16c& a) {
1955EIGEN_STRONG_INLINE Packet16uc pabs(
const Packet16uc& a) {
1959EIGEN_STRONG_INLINE Packet8bf pabs(
const Packet8bf& a) {
1960 EIGEN_DECLARE_CONST_FAST_Packet8us(abs_mask, 0x7FFF);
1961 return pand<Packet8us>(p8us_abs_mask, a);
1965EIGEN_STRONG_INLINE Packet8bf psignbit(
const Packet8bf& a) {
1966 return vec_sra(a.m_val, vec_splat_u16(15));
1969EIGEN_STRONG_INLINE Packet4f psignbit(
const Packet4f& a) {
1970 return (Packet4f)vec_sra((Packet4i)a, vec_splats((
unsigned int)(31)));
1974EIGEN_STRONG_INLINE Packet4i parithmetic_shift_right(
const Packet4i& a) {
1975 return vec_sra(a,
reinterpret_cast<Packet4ui
>(pset1<Packet4i>(N)));
1978EIGEN_STRONG_INLINE Packet4i plogical_shift_right(
const Packet4i& a) {
1979 return vec_sr(a,
reinterpret_cast<Packet4ui
>(pset1<Packet4i>(N)));
1982EIGEN_STRONG_INLINE Packet4i plogical_shift_left(
const Packet4i& a) {
1983 return vec_sl(a,
reinterpret_cast<Packet4ui
>(pset1<Packet4i>(N)));
1986EIGEN_STRONG_INLINE Packet4f plogical_shift_left(
const Packet4f& a) {
1987 const EIGEN_DECLARE_CONST_FAST_Packet4ui(mask, N);
1988 Packet4ui r = vec_sl(
reinterpret_cast<Packet4ui
>(a), p4ui_mask);
1989 return reinterpret_cast<Packet4f
>(r);
1993EIGEN_STRONG_INLINE Packet4f plogical_shift_right(
const Packet4f& a) {
1994 const EIGEN_DECLARE_CONST_FAST_Packet4ui(mask, N);
1995 Packet4ui r = vec_sr(
reinterpret_cast<Packet4ui
>(a), p4ui_mask);
1996 return reinterpret_cast<Packet4f
>(r);
2000EIGEN_STRONG_INLINE Packet4ui plogical_shift_right(
const Packet4ui& a) {
2001 const EIGEN_DECLARE_CONST_FAST_Packet4ui(mask, N);
2002 return vec_sr(a, p4ui_mask);
2006EIGEN_STRONG_INLINE Packet4ui plogical_shift_left(
const Packet4ui& a) {
2007 const EIGEN_DECLARE_CONST_FAST_Packet4ui(mask, N);
2008 return vec_sl(a, p4ui_mask);
2012EIGEN_STRONG_INLINE Packet8us plogical_shift_left(
const Packet8us& a) {
2013 const EIGEN_DECLARE_CONST_FAST_Packet8us(mask, N);
2014 return vec_sl(a, p8us_mask);
2017EIGEN_STRONG_INLINE Packet8us plogical_shift_right(
const Packet8us& a) {
2018 const EIGEN_DECLARE_CONST_FAST_Packet8us(mask, N);
2019 return vec_sr(a, p8us_mask);
2022EIGEN_STRONG_INLINE Packet4f Bf16ToF32Even(
const Packet8bf& bf) {
2023 return plogical_shift_left<16>(
reinterpret_cast<Packet4f
>(bf.m_val));
2026EIGEN_STRONG_INLINE Packet4f Bf16ToF32Odd(
const Packet8bf& bf) {
2027 const EIGEN_DECLARE_CONST_FAST_Packet4ui(high_mask, 0xFFFF0000);
2028 return pand<Packet4f>(
reinterpret_cast<Packet4f
>(bf.m_val),
reinterpret_cast<Packet4f
>(p4ui_high_mask));
2031EIGEN_ALWAYS_INLINE Packet8us pmerge(Packet4ui even, Packet4ui odd) {
2033 return vec_perm(
reinterpret_cast<Packet8us
>(odd),
reinterpret_cast<Packet8us
>(even), p16uc_MERGEO16);
2035 return vec_perm(
reinterpret_cast<Packet8us
>(even),
reinterpret_cast<Packet8us
>(odd), p16uc_MERGEE16);
2041EIGEN_STRONG_INLINE Packet8bf F32ToBf16Bool(Packet4f even, Packet4f odd) {
2042 return pmerge(
reinterpret_cast<Packet4ui
>(even),
reinterpret_cast<Packet4ui
>(odd));
2047#ifndef __VEC_CLASS_FP_NAN
2048#define __VEC_CLASS_FP_NAN (1 << 6)
2051#if defined(SUPPORT_BF16_SUBNORMALS) && !defined(__VEC_CLASS_FP_SUBNORMAL)
2052#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 1)
2053#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0)
2055#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | __VEC_CLASS_FP_SUBNORMAL_N)
2058EIGEN_STRONG_INLINE Packet8bf F32ToBf16(Packet4f p4f) {
2060 return reinterpret_cast<Packet8us
>(__builtin_vsx_xvcvspbf16(
reinterpret_cast<Packet16uc
>(p4f)));
2062 Packet4ui input =
reinterpret_cast<Packet4ui
>(p4f);
2063 Packet4ui lsb = plogical_shift_right<16>(input);
2064 lsb = pand<Packet4ui>(lsb,
reinterpret_cast<Packet4ui
>(p4i_ONE));
2066 EIGEN_DECLARE_CONST_FAST_Packet4ui(BIAS, 0x7FFFu);
2067 Packet4ui rounding_bias = padd<Packet4ui>(lsb, p4ui_BIAS);
2068 input = padd<Packet4ui>(input, rounding_bias);
2070 const EIGEN_DECLARE_CONST_FAST_Packet4ui(nan, 0x7FC00000);
2072 Packet4bi nan_selector = vec_test_data_class(p4f, __VEC_CLASS_FP_NAN);
2073 input = vec_sel(input, p4ui_nan, nan_selector);
2075#ifdef SUPPORT_BF16_SUBNORMALS
2076 Packet4bi subnormal_selector = vec_test_data_class(p4f, __VEC_CLASS_FP_SUBNORMAL);
2077 input = vec_sel(input,
reinterpret_cast<Packet4ui
>(p4f), subnormal_selector);
2080#ifdef SUPPORT_BF16_SUBNORMALS
2082 const EIGEN_DECLARE_CONST_FAST_Packet4ui(exp_mask, 0x7F800000);
2083 Packet4ui
exp = pand<Packet4ui>(p4ui_exp_mask,
reinterpret_cast<Packet4ui
>(p4f));
2085 const EIGEN_DECLARE_CONST_FAST_Packet4ui(mantissa_mask, 0x7FFFFF);
2086 Packet4ui mantissa = pand<Packet4ui>(p4ui_mantissa_mask,
reinterpret_cast<Packet4ui
>(p4f));
2088 Packet4bi is_max_exp = vec_cmpeq(
exp, p4ui_exp_mask);
2089 Packet4bi is_mant_zero = vec_cmpeq(mantissa,
reinterpret_cast<Packet4ui
>(p4i_ZERO));
2091 Packet4ui nan_selector =
2092 pandnot<Packet4ui>(
reinterpret_cast<Packet4ui
>(is_max_exp),
reinterpret_cast<Packet4ui
>(is_mant_zero));
2094 Packet4bi is_zero_exp = vec_cmpeq(
exp,
reinterpret_cast<Packet4ui
>(p4i_ZERO));
2096 Packet4ui subnormal_selector =
2097 pandnot<Packet4ui>(
reinterpret_cast<Packet4ui
>(is_zero_exp),
reinterpret_cast<Packet4ui
>(is_mant_zero));
2099 input = vec_sel(input, p4ui_nan, nan_selector);
2100 input = vec_sel(input,
reinterpret_cast<Packet4ui
>(p4f), subnormal_selector);
2103 Packet4bi nan_selector = vec_cmpeq(p4f, p4f);
2105 input = vec_sel(p4ui_nan, input, nan_selector);
2109 input = plogical_shift_right<16>(input);
2110 return reinterpret_cast<Packet8us
>(input);
2121EIGEN_ALWAYS_INLINE Packet8bf Bf16PackHigh(Packet4f lo, Packet4f hi) {
2123 return vec_perm(
reinterpret_cast<Packet8us
>(lo),
reinterpret_cast<Packet8us
>(hi), p16uc_MERGEH16);
2125 return vec_perm(
reinterpret_cast<Packet8us
>(hi),
reinterpret_cast<Packet8us
>(lo), p16uc_MERGEE16);
2135EIGEN_ALWAYS_INLINE Packet8bf Bf16PackLow(Packet4f lo, Packet4f hi) {
2137 return vec_pack(
reinterpret_cast<Packet4ui
>(lo),
reinterpret_cast<Packet4ui
>(hi));
2139 return vec_perm(
reinterpret_cast<Packet8us
>(hi),
reinterpret_cast<Packet8us
>(lo), p16uc_MERGEO16);
2144EIGEN_ALWAYS_INLINE Packet8bf Bf16PackLow(Packet4f hi, Packet4f lo) {
2146 return vec_pack(
reinterpret_cast<Packet4ui
>(hi),
reinterpret_cast<Packet4ui
>(lo));
2148 return vec_perm(
reinterpret_cast<Packet8us
>(hi),
reinterpret_cast<Packet8us
>(lo), p16uc_MERGEE16);
2153EIGEN_ALWAYS_INLINE Packet8bf Bf16PackHigh(Packet4f hi, Packet4f lo) {
2155 return vec_perm(
reinterpret_cast<Packet8us
>(hi),
reinterpret_cast<Packet8us
>(lo), p16uc_MERGEL16);
2157 return vec_perm(
reinterpret_cast<Packet8us
>(hi),
reinterpret_cast<Packet8us
>(lo), p16uc_MERGEO16);
2167template <
bool lohi = true>
2168EIGEN_ALWAYS_INLINE Packet8bf F32ToBf16Two(Packet4f lo, Packet4f hi) {
2169 Packet8us p4f = Bf16PackHigh<lohi>(lo, hi);
2170 Packet8us p4f2 = Bf16PackLow<lohi>(lo, hi);
2172 Packet8us lsb = pand<Packet8us>(p4f, p8us_ONE);
2173 EIGEN_DECLARE_CONST_FAST_Packet8us(BIAS, 0x7FFFu);
2174 lsb = padd<Packet8us>(lsb, p8us_BIAS);
2175 lsb = padd<Packet8us>(lsb, p4f2);
2177 Packet8bi rounding_bias = vec_cmplt(lsb, p4f2);
2178 Packet8us input = psub<Packet8us>(p4f,
reinterpret_cast<Packet8us
>(rounding_bias));
2181 Packet4bi nan_selector_lo = vec_test_data_class(lo, __VEC_CLASS_FP_NAN);
2182 Packet4bi nan_selector_hi = vec_test_data_class(hi, __VEC_CLASS_FP_NAN);
2183 Packet8us nan_selector =
2184 Bf16PackLow<lohi>(
reinterpret_cast<Packet4f
>(nan_selector_lo),
reinterpret_cast<Packet4f
>(nan_selector_hi));
2186 input = vec_sel(input, p8us_BIAS, nan_selector);
2188#ifdef SUPPORT_BF16_SUBNORMALS
2189 Packet4bi subnormal_selector_lo = vec_test_data_class(lo, __VEC_CLASS_FP_SUBNORMAL);
2190 Packet4bi subnormal_selector_hi = vec_test_data_class(hi, __VEC_CLASS_FP_SUBNORMAL);
2191 Packet8us subnormal_selector = Bf16PackLow<lohi>(
reinterpret_cast<Packet4f
>(subnormal_selector_lo),
2192 reinterpret_cast<Packet4f
>(subnormal_selector_hi));
2194 input = vec_sel(input,
reinterpret_cast<Packet8us
>(p4f), subnormal_selector);
2197#ifdef SUPPORT_BF16_SUBNORMALS
2199 const EIGEN_DECLARE_CONST_FAST_Packet8us(exp_mask, 0x7F80);
2200 Packet8us
exp = pand<Packet8us>(p8us_exp_mask, p4f);
2202 const EIGEN_DECLARE_CONST_FAST_Packet8us(mantissa_mask, 0x7Fu);
2203 Packet8us mantissa = pand<Packet8us>(p8us_mantissa_mask, p4f);
2205 Packet8bi is_max_exp = vec_cmpeq(
exp, p8us_exp_mask);
2206 Packet8bi is_mant_zero = vec_cmpeq(mantissa,
reinterpret_cast<Packet8us
>(p4i_ZERO));
2208 Packet8us nan_selector =
2209 pandnot<Packet8us>(
reinterpret_cast<Packet8us
>(is_max_exp),
reinterpret_cast<Packet8us
>(is_mant_zero));
2211 Packet8bi is_zero_exp = vec_cmpeq(
exp,
reinterpret_cast<Packet8us
>(p4i_ZERO));
2213 Packet8us subnormal_selector =
2214 pandnot<Packet8us>(
reinterpret_cast<Packet8us
>(is_zero_exp),
reinterpret_cast<Packet8us
>(is_mant_zero));
2217 input = vec_sel(input, p8us_BIAS, nan_selector);
2218 input = vec_sel(input,
reinterpret_cast<Packet8us
>(p4f), subnormal_selector);
2221 Packet4bi nan_selector_lo = vec_cmpeq(lo, lo);
2222 Packet4bi nan_selector_hi = vec_cmpeq(hi, hi);
2223 Packet8us nan_selector =
2224 Bf16PackLow<lohi>(
reinterpret_cast<Packet4f
>(nan_selector_lo),
reinterpret_cast<Packet4f
>(nan_selector_hi));
2226 input = vec_sel(p8us_BIAS, input, nan_selector);
2236EIGEN_STRONG_INLINE Packet8bf F32ToBf16Both(Packet4f lo, Packet4f hi) {
2238 Packet8bf fp16_0 = F32ToBf16(lo);
2239 Packet8bf fp16_1 = F32ToBf16(hi);
2240 return vec_pack(
reinterpret_cast<Packet4ui
>(fp16_0.m_val),
reinterpret_cast<Packet4ui
>(fp16_1.m_val));
2242 return F32ToBf16Two(lo, hi);
2249EIGEN_STRONG_INLINE Packet8bf F32ToBf16(Packet4f even, Packet4f odd) {
2251 return pmerge(
reinterpret_cast<Packet4ui
>(F32ToBf16(even).m_val),
reinterpret_cast<Packet4ui
>(F32ToBf16(odd).m_val));
2253 return F32ToBf16Two<false>(even, odd);
2256#define BF16_TO_F32_UNARY_OP_WRAPPER(OP, A) \
2257 Packet4f a_even = Bf16ToF32Even(A); \
2258 Packet4f a_odd = Bf16ToF32Odd(A); \
2259 Packet4f op_even = OP(a_even); \
2260 Packet4f op_odd = OP(a_odd); \
2261 return F32ToBf16(op_even, op_odd);
2263#define BF16_TO_F32_BINARY_OP_WRAPPER(OP, A, B) \
2264 Packet4f a_even = Bf16ToF32Even(A); \
2265 Packet4f a_odd = Bf16ToF32Odd(A); \
2266 Packet4f b_even = Bf16ToF32Even(B); \
2267 Packet4f b_odd = Bf16ToF32Odd(B); \
2268 Packet4f op_even = OP(a_even, b_even); \
2269 Packet4f op_odd = OP(a_odd, b_odd); \
2270 return F32ToBf16(op_even, op_odd);
2272#define BF16_TO_F32_BINARY_OP_WRAPPER_BOOL(OP, A, B) \
2273 Packet4f a_even = Bf16ToF32Even(A); \
2274 Packet4f a_odd = Bf16ToF32Odd(A); \
2275 Packet4f b_even = Bf16ToF32Even(B); \
2276 Packet4f b_odd = Bf16ToF32Odd(B); \
2277 Packet4f op_even = OP(a_even, b_even); \
2278 Packet4f op_odd = OP(a_odd, b_odd); \
2279 return F32ToBf16Bool(op_even, op_odd);
2282EIGEN_STRONG_INLINE Packet8bf padd<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2283 BF16_TO_F32_BINARY_OP_WRAPPER(padd<Packet4f>, a, b);
2287EIGEN_STRONG_INLINE Packet8bf pmul<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2288 BF16_TO_F32_BINARY_OP_WRAPPER(pmul<Packet4f>, a, b);
2292EIGEN_STRONG_INLINE Packet8bf pdiv<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2293 BF16_TO_F32_BINARY_OP_WRAPPER(pdiv<Packet4f>, a, b);
2297EIGEN_STRONG_INLINE Packet8bf pnegate<Packet8bf>(
const Packet8bf& a) {
2298 EIGEN_DECLARE_CONST_FAST_Packet8us(neg_mask, 0x8000);
2299 return pxor<Packet8us>(p8us_neg_mask, a);
2303EIGEN_STRONG_INLINE Packet8bf psub<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2304 BF16_TO_F32_BINARY_OP_WRAPPER(psub<Packet4f>, a, b);
2308EIGEN_STRONG_INLINE Packet8bf pexp<Packet8bf>(
const Packet8bf& a) {
2309 BF16_TO_F32_UNARY_OP_WRAPPER(pexp_float, a);
2313EIGEN_STRONG_INLINE Packet4f pldexp<Packet4f>(
const Packet4f& a,
const Packet4f& exponent) {
2314 return pldexp_generic(a, exponent);
2317EIGEN_STRONG_INLINE Packet8bf pldexp<Packet8bf>(
const Packet8bf& a,
const Packet8bf& exponent) {
2318 BF16_TO_F32_BINARY_OP_WRAPPER(pldexp<Packet4f>, a, exponent);
2322EIGEN_STRONG_INLINE Packet4f pfrexp<Packet4f>(
const Packet4f& a, Packet4f& exponent) {
2323 return pfrexp_generic(a, exponent);
2326EIGEN_STRONG_INLINE Packet8bf pfrexp<Packet8bf>(
const Packet8bf& a, Packet8bf& e) {
2327 Packet4f a_even = Bf16ToF32Even(a);
2328 Packet4f a_odd = Bf16ToF32Odd(a);
2331 Packet4f op_even = pfrexp<Packet4f>(a_even, e_even);
2332 Packet4f op_odd = pfrexp<Packet4f>(a_odd, e_odd);
2333 e = F32ToBf16(e_even, e_odd);
2334 return F32ToBf16(op_even, op_odd);
2338EIGEN_STRONG_INLINE Packet8bf psin<Packet8bf>(
const Packet8bf& a) {
2339 BF16_TO_F32_UNARY_OP_WRAPPER(psin_float, a);
2342EIGEN_STRONG_INLINE Packet8bf pcos<Packet8bf>(
const Packet8bf& a) {
2343 BF16_TO_F32_UNARY_OP_WRAPPER(pcos_float, a);
2346EIGEN_STRONG_INLINE Packet8bf plog<Packet8bf>(
const Packet8bf& a) {
2347 BF16_TO_F32_UNARY_OP_WRAPPER(plog_float, a);
2350EIGEN_STRONG_INLINE Packet8bf pfloor<Packet8bf>(
const Packet8bf& a) {
2351 BF16_TO_F32_UNARY_OP_WRAPPER(pfloor<Packet4f>, a);
2354EIGEN_STRONG_INLINE Packet8bf pceil<Packet8bf>(
const Packet8bf& a) {
2355 BF16_TO_F32_UNARY_OP_WRAPPER(pceil<Packet4f>, a);
2358EIGEN_STRONG_INLINE Packet8bf pround<Packet8bf>(
const Packet8bf& a) {
2359 BF16_TO_F32_UNARY_OP_WRAPPER(pround<Packet4f>, a);
2362EIGEN_STRONG_INLINE Packet8bf ptrunc<Packet8bf>(
const Packet8bf& a) {
2363 BF16_TO_F32_UNARY_OP_WRAPPER(ptrunc<Packet4f>, a);
2365#ifdef EIGEN_VECTORIZE_VSX
2367EIGEN_STRONG_INLINE Packet8bf print<Packet8bf>(
const Packet8bf& a) {
2368 BF16_TO_F32_UNARY_OP_WRAPPER(print<Packet4f>, a);
2372EIGEN_STRONG_INLINE Packet8bf pmadd(
const Packet8bf& a,
const Packet8bf& b,
const Packet8bf& c) {
2373 Packet4f a_even = Bf16ToF32Even(a);
2374 Packet4f a_odd = Bf16ToF32Odd(a);
2375 Packet4f b_even = Bf16ToF32Even(b);
2376 Packet4f b_odd = Bf16ToF32Odd(b);
2377 Packet4f c_even = Bf16ToF32Even(c);
2378 Packet4f c_odd = Bf16ToF32Odd(c);
2379 Packet4f pmadd_even = pmadd<Packet4f>(a_even, b_even, c_even);
2380 Packet4f pmadd_odd = pmadd<Packet4f>(a_odd, b_odd, c_odd);
2381 return F32ToBf16(pmadd_even, pmadd_odd);
2385EIGEN_STRONG_INLINE Packet8bf pmin<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2386 BF16_TO_F32_BINARY_OP_WRAPPER(pmin<Packet4f>, a, b);
2390EIGEN_STRONG_INLINE Packet8bf pmax<Packet8bf>(
const Packet8bf& a,
const Packet8bf& b) {
2391 BF16_TO_F32_BINARY_OP_WRAPPER(pmax<Packet4f>, a, b);
2395EIGEN_STRONG_INLINE Packet8bf pcmp_lt(
const Packet8bf& a,
const Packet8bf& b) {
2396 BF16_TO_F32_BINARY_OP_WRAPPER_BOOL(pcmp_lt<Packet4f>, a, b);
2399EIGEN_STRONG_INLINE Packet8bf pcmp_lt_or_nan(
const Packet8bf& a,
const Packet8bf& b) {
2400 BF16_TO_F32_BINARY_OP_WRAPPER_BOOL(pcmp_lt_or_nan<Packet4f>, a, b);
2403EIGEN_STRONG_INLINE Packet8bf pcmp_le(
const Packet8bf& a,
const Packet8bf& b) {
2404 BF16_TO_F32_BINARY_OP_WRAPPER_BOOL(pcmp_le<Packet4f>, a, b);
2407EIGEN_STRONG_INLINE Packet8bf pcmp_eq(
const Packet8bf& a,
const Packet8bf& b) {
2408 BF16_TO_F32_BINARY_OP_WRAPPER_BOOL(pcmp_eq<Packet4f>, a, b);
2412EIGEN_STRONG_INLINE bfloat16 pfirst(
const Packet8bf& a) {
2413 return Eigen::bfloat16_impl::raw_uint16_to_bfloat16((pfirst<Packet8us>(a)));
2417EIGEN_STRONG_INLINE Packet8bf ploaddup<Packet8bf>(
const bfloat16* from) {
2418 return ploaddup<Packet8us>(
reinterpret_cast<const unsigned short int*
>(from));
2422EIGEN_STRONG_INLINE Packet8bf plset<Packet8bf>(
const bfloat16& a) {
2423 bfloat16 countdown[8] = {bfloat16(0), bfloat16(1), bfloat16(2), bfloat16(3),
2424 bfloat16(4), bfloat16(5), bfloat16(6), bfloat16(7)};
2425 return padd<Packet8bf>(pset1<Packet8bf>(a), pload<Packet8bf>(countdown));
2429EIGEN_STRONG_INLINE
float predux<Packet4f>(
const Packet4f& a) {
2431 b = vec_sld(a, a, 8);
2433 b = vec_sld(sum, sum, 4);
2439EIGEN_STRONG_INLINE
int predux<Packet4i>(
const Packet4i& a) {
2441 b = vec_sld(a, a, 8);
2443 b = vec_sld(sum, sum, 4);
2449EIGEN_STRONG_INLINE bfloat16 predux<Packet8bf>(
const Packet8bf& a) {
2450 float redux_even = predux<Packet4f>(Bf16ToF32Even(a));
2451 float redux_odd = predux<Packet4f>(Bf16ToF32Odd(a));
2452 float f32_result = redux_even + redux_odd;
2453 return bfloat16(f32_result);
2455template <
typename Packet>
2456EIGEN_STRONG_INLINE __UNPACK_TYPE__(Packet) predux_size8(
const Packet& a) {
2459 __UNPACK_TYPE__(Packet) n[8];
2463 EIGEN_ALIGN16
int first_loader[4] = {vt.n[0], vt.n[1], vt.n[2], vt.n[3]};
2464 EIGEN_ALIGN16
int second_loader[4] = {vt.n[4], vt.n[5], vt.n[6], vt.n[7]};
2465 Packet4i first_half = pload<Packet4i>(first_loader);
2466 Packet4i second_half = pload<Packet4i>(second_loader);
2468 return static_cast<__UNPACK_TYPE__(Packet)
>(predux(first_half) + predux(second_half));
2472EIGEN_STRONG_INLINE
short int predux<Packet8s>(
const Packet8s& a) {
2473 return predux_size8<Packet8s>(a);
2477EIGEN_STRONG_INLINE
unsigned short int predux<Packet8us>(
const Packet8us& a) {
2478 return predux_size8<Packet8us>(a);
2481template <
typename Packet>
2482EIGEN_STRONG_INLINE __UNPACK_TYPE__(Packet) predux_size16(
const Packet& a) {
2485 __UNPACK_TYPE__(Packet) n[16];
2489 EIGEN_ALIGN16
int first_loader[4] = {vt.n[0], vt.n[1], vt.n[2], vt.n[3]};
2490 EIGEN_ALIGN16
int second_loader[4] = {vt.n[4], vt.n[5], vt.n[6], vt.n[7]};
2491 EIGEN_ALIGN16
int third_loader[4] = {vt.n[8], vt.n[9], vt.n[10], vt.n[11]};
2492 EIGEN_ALIGN16
int fourth_loader[4] = {vt.n[12], vt.n[13], vt.n[14], vt.n[15]};
2494 Packet4i first_quarter = pload<Packet4i>(first_loader);
2495 Packet4i second_quarter = pload<Packet4i>(second_loader);
2496 Packet4i third_quarter = pload<Packet4i>(third_loader);
2497 Packet4i fourth_quarter = pload<Packet4i>(fourth_loader);
2499 return static_cast<__UNPACK_TYPE__(Packet)
>(predux(first_quarter) + predux(second_quarter) + predux(third_quarter) +
2500 predux(fourth_quarter));
2504EIGEN_STRONG_INLINE
signed char predux<Packet16c>(
const Packet16c& a) {
2505 return predux_size16<Packet16c>(a);
2509EIGEN_STRONG_INLINE
unsigned char predux<Packet16uc>(
const Packet16uc& a) {
2510 return predux_size16<Packet16uc>(a);
2516EIGEN_STRONG_INLINE
float predux_mul<Packet4f>(
const Packet4f& a) {
2518 prod = pmul(a, vec_sld(a, a, 8));
2519 return pfirst(pmul(prod, vec_sld(prod, prod, 4)));
2523EIGEN_STRONG_INLINE
int predux_mul<Packet4i>(
const Packet4i& a) {
2524 EIGEN_ALIGN16
int aux[4];
2526 return aux[0] * aux[1] * aux[2] * aux[3];
2530EIGEN_STRONG_INLINE
short int predux_mul<Packet8s>(
const Packet8s& a) {
2531 Packet8s pair, quad, octo;
2533 pair = vec_mul(a, vec_sld(a, a, 8));
2534 quad = vec_mul(pair, vec_sld(pair, pair, 4));
2535 octo = vec_mul(quad, vec_sld(quad, quad, 2));
2537 return pfirst(octo);
2541EIGEN_STRONG_INLINE
unsigned short int predux_mul<Packet8us>(
const Packet8us& a) {
2542 Packet8us pair, quad, octo;
2544 pair = vec_mul(a, vec_sld(a, a, 8));
2545 quad = vec_mul(pair, vec_sld(pair, pair, 4));
2546 octo = vec_mul(quad, vec_sld(quad, quad, 2));
2548 return pfirst(octo);
2552EIGEN_STRONG_INLINE bfloat16 predux_mul<Packet8bf>(
const Packet8bf& a) {
2553 float redux_even = predux_mul<Packet4f>(Bf16ToF32Even(a));
2554 float redux_odd = predux_mul<Packet4f>(Bf16ToF32Odd(a));
2555 float f32_result = redux_even * redux_odd;
2556 return bfloat16(f32_result);
2560EIGEN_STRONG_INLINE
signed char predux_mul<Packet16c>(
const Packet16c& a) {
2561 Packet16c pair, quad, octo, result;
2563 pair = vec_mul(a, vec_sld(a, a, 8));
2564 quad = vec_mul(pair, vec_sld(pair, pair, 4));
2565 octo = vec_mul(quad, vec_sld(quad, quad, 2));
2566 result = vec_mul(octo, vec_sld(octo, octo, 1));
2568 return pfirst(result);
2572EIGEN_STRONG_INLINE
unsigned char predux_mul<Packet16uc>(
const Packet16uc& a) {
2573 Packet16uc pair, quad, octo, result;
2575 pair = vec_mul(a, vec_sld(a, a, 8));
2576 quad = vec_mul(pair, vec_sld(pair, pair, 4));
2577 octo = vec_mul(quad, vec_sld(quad, quad, 2));
2578 result = vec_mul(octo, vec_sld(octo, octo, 1));
2580 return pfirst(result);
2584template <
typename Packet>
2585EIGEN_STRONG_INLINE __UNPACK_TYPE__(Packet) predux_min4(
const Packet& a) {
2587 b = vec_min(a, vec_sld(a, a, 8));
2588 res = vec_min(b, vec_sld(b, b, 4));
2593EIGEN_STRONG_INLINE
float predux_min<Packet4f>(
const Packet4f& a) {
2594 return predux_min4<Packet4f>(a);
2598EIGEN_STRONG_INLINE
int predux_min<Packet4i>(
const Packet4i& a) {
2599 return predux_min4<Packet4i>(a);
2603EIGEN_STRONG_INLINE bfloat16 predux_min<Packet8bf>(
const Packet8bf& a) {
2604 float redux_even = predux_min<Packet4f>(Bf16ToF32Even(a));
2605 float redux_odd = predux_min<Packet4f>(Bf16ToF32Odd(a));
2606 float f32_result = (std::min)(redux_even, redux_odd);
2607 return bfloat16(f32_result);
2611EIGEN_STRONG_INLINE
short int predux_min<Packet8s>(
const Packet8s& a) {
2612 Packet8s pair, quad, octo;
2615 pair = vec_min(a, vec_sld(a, a, 8));
2618 quad = vec_min(pair, vec_sld(pair, pair, 4));
2621 octo = vec_min(quad, vec_sld(quad, quad, 2));
2622 return pfirst(octo);
2626EIGEN_STRONG_INLINE
unsigned short int predux_min<Packet8us>(
const Packet8us& a) {
2627 Packet8us pair, quad, octo;
2630 pair = vec_min(a, vec_sld(a, a, 8));
2633 quad = vec_min(pair, vec_sld(pair, pair, 4));
2636 octo = vec_min(quad, vec_sld(quad, quad, 2));
2637 return pfirst(octo);
2641EIGEN_STRONG_INLINE
signed char predux_min<Packet16c>(
const Packet16c& a) {
2642 Packet16c pair, quad, octo, result;
2644 pair = vec_min(a, vec_sld(a, a, 8));
2645 quad = vec_min(pair, vec_sld(pair, pair, 4));
2646 octo = vec_min(quad, vec_sld(quad, quad, 2));
2647 result = vec_min(octo, vec_sld(octo, octo, 1));
2649 return pfirst(result);
2653EIGEN_STRONG_INLINE
unsigned char predux_min<Packet16uc>(
const Packet16uc& a) {
2654 Packet16uc pair, quad, octo, result;
2656 pair = vec_min(a, vec_sld(a, a, 8));
2657 quad = vec_min(pair, vec_sld(pair, pair, 4));
2658 octo = vec_min(quad, vec_sld(quad, quad, 2));
2659 result = vec_min(octo, vec_sld(octo, octo, 1));
2661 return pfirst(result);
2664template <
typename Packet>
2665EIGEN_STRONG_INLINE __UNPACK_TYPE__(Packet) predux_max4(
const Packet& a) {
2667 b = vec_max(a, vec_sld(a, a, 8));
2668 res = vec_max(b, vec_sld(b, b, 4));
2673EIGEN_STRONG_INLINE
float predux_max<Packet4f>(
const Packet4f& a) {
2674 return predux_max4<Packet4f>(a);
2678EIGEN_STRONG_INLINE
int predux_max<Packet4i>(
const Packet4i& a) {
2679 return predux_max4<Packet4i>(a);
2683EIGEN_STRONG_INLINE bfloat16 predux_max<Packet8bf>(
const Packet8bf& a) {
2684 float redux_even = predux_max<Packet4f>(Bf16ToF32Even(a));
2685 float redux_odd = predux_max<Packet4f>(Bf16ToF32Odd(a));
2686 float f32_result = (std::max)(redux_even, redux_odd);
2687 return bfloat16(f32_result);
2691EIGEN_STRONG_INLINE
short int predux_max<Packet8s>(
const Packet8s& a) {
2692 Packet8s pair, quad, octo;
2695 pair = vec_max(a, vec_sld(a, a, 8));
2698 quad = vec_max(pair, vec_sld(pair, pair, 4));
2701 octo = vec_max(quad, vec_sld(quad, quad, 2));
2702 return pfirst(octo);
2706EIGEN_STRONG_INLINE
unsigned short int predux_max<Packet8us>(
const Packet8us& a) {
2707 Packet8us pair, quad, octo;
2710 pair = vec_max(a, vec_sld(a, a, 8));
2713 quad = vec_max(pair, vec_sld(pair, pair, 4));
2716 octo = vec_max(quad, vec_sld(quad, quad, 2));
2717 return pfirst(octo);
2721EIGEN_STRONG_INLINE
signed char predux_max<Packet16c>(
const Packet16c& a) {
2722 Packet16c pair, quad, octo, result;
2724 pair = vec_max(a, vec_sld(a, a, 8));
2725 quad = vec_max(pair, vec_sld(pair, pair, 4));
2726 octo = vec_max(quad, vec_sld(quad, quad, 2));
2727 result = vec_max(octo, vec_sld(octo, octo, 1));
2729 return pfirst(result);
2733EIGEN_STRONG_INLINE
unsigned char predux_max<Packet16uc>(
const Packet16uc& a) {
2734 Packet16uc pair, quad, octo, result;
2736 pair = vec_max(a, vec_sld(a, a, 8));
2737 quad = vec_max(pair, vec_sld(pair, pair, 4));
2738 octo = vec_max(quad, vec_sld(quad, quad, 2));
2739 result = vec_max(octo, vec_sld(octo, octo, 1));
2741 return pfirst(result);
2745EIGEN_STRONG_INLINE
bool predux_any(
const Packet4f& x) {
2746 return vec_any_ne(x, pzero(x));
2749template <
typename T>
2750EIGEN_DEVICE_FUNC
inline void ptranpose_common(PacketBlock<T, 4>& kernel) {
2752 t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);
2753 t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);
2754 t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);
2755 t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);
2756 kernel.packet[0] = vec_mergeh(t0, t2);
2757 kernel.packet[1] = vec_mergel(t0, t2);
2758 kernel.packet[2] = vec_mergeh(t1, t3);
2759 kernel.packet[3] = vec_mergel(t1, t3);
2762EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet4f, 4>& kernel) { ptranpose_common<Packet4f>(kernel); }
2764EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet4i, 4>& kernel) { ptranpose_common<Packet4i>(kernel); }
2766EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8s, 4>& kernel) {
2767 Packet8s t0, t1, t2, t3;
2768 t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);
2769 t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);
2770 t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);
2771 t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);
2772 kernel.packet[0] = vec_mergeh(t0, t2);
2773 kernel.packet[1] = vec_mergel(t0, t2);
2774 kernel.packet[2] = vec_mergeh(t1, t3);
2775 kernel.packet[3] = vec_mergel(t1, t3);
2778EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8us, 4>& kernel) {
2779 Packet8us t0, t1, t2, t3;
2780 t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);
2781 t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);
2782 t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);
2783 t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);
2784 kernel.packet[0] = vec_mergeh(t0, t2);
2785 kernel.packet[1] = vec_mergel(t0, t2);
2786 kernel.packet[2] = vec_mergeh(t1, t3);
2787 kernel.packet[3] = vec_mergel(t1, t3);
2790EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8bf, 4>& kernel) {
2791 Packet8us t0, t1, t2, t3;
2793 t0 = vec_mergeh(kernel.packet[0].m_val, kernel.packet[2].m_val);
2794 t1 = vec_mergel(kernel.packet[0].m_val, kernel.packet[2].m_val);
2795 t2 = vec_mergeh(kernel.packet[1].m_val, kernel.packet[3].m_val);
2796 t3 = vec_mergel(kernel.packet[1].m_val, kernel.packet[3].m_val);
2797 kernel.packet[0] = vec_mergeh(t0, t2);
2798 kernel.packet[1] = vec_mergel(t0, t2);
2799 kernel.packet[2] = vec_mergeh(t1, t3);
2800 kernel.packet[3] = vec_mergel(t1, t3);
2803EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet16c, 4>& kernel) {
2804 Packet16c t0, t1, t2, t3;
2805 t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);
2806 t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);
2807 t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);
2808 t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);
2809 kernel.packet[0] = vec_mergeh(t0, t2);
2810 kernel.packet[1] = vec_mergel(t0, t2);
2811 kernel.packet[2] = vec_mergeh(t1, t3);
2812 kernel.packet[3] = vec_mergel(t1, t3);
2815EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet16uc, 4>& kernel) {
2816 Packet16uc t0, t1, t2, t3;
2817 t0 = vec_mergeh(kernel.packet[0], kernel.packet[2]);
2818 t1 = vec_mergel(kernel.packet[0], kernel.packet[2]);
2819 t2 = vec_mergeh(kernel.packet[1], kernel.packet[3]);
2820 t3 = vec_mergel(kernel.packet[1], kernel.packet[3]);
2821 kernel.packet[0] = vec_mergeh(t0, t2);
2822 kernel.packet[1] = vec_mergel(t0, t2);
2823 kernel.packet[2] = vec_mergeh(t1, t3);
2824 kernel.packet[3] = vec_mergel(t1, t3);
2827EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8s, 8>& kernel) {
2828 Packet8s v[8], sum[8];
2830 v[0] = vec_mergeh(kernel.packet[0], kernel.packet[4]);
2831 v[1] = vec_mergel(kernel.packet[0], kernel.packet[4]);
2832 v[2] = vec_mergeh(kernel.packet[1], kernel.packet[5]);
2833 v[3] = vec_mergel(kernel.packet[1], kernel.packet[5]);
2834 v[4] = vec_mergeh(kernel.packet[2], kernel.packet[6]);
2835 v[5] = vec_mergel(kernel.packet[2], kernel.packet[6]);
2836 v[6] = vec_mergeh(kernel.packet[3], kernel.packet[7]);
2837 v[7] = vec_mergel(kernel.packet[3], kernel.packet[7]);
2838 sum[0] = vec_mergeh(v[0], v[4]);
2839 sum[1] = vec_mergel(v[0], v[4]);
2840 sum[2] = vec_mergeh(v[1], v[5]);
2841 sum[3] = vec_mergel(v[1], v[5]);
2842 sum[4] = vec_mergeh(v[2], v[6]);
2843 sum[5] = vec_mergel(v[2], v[6]);
2844 sum[6] = vec_mergeh(v[3], v[7]);
2845 sum[7] = vec_mergel(v[3], v[7]);
2847 kernel.packet[0] = vec_mergeh(sum[0], sum[4]);
2848 kernel.packet[1] = vec_mergel(sum[0], sum[4]);
2849 kernel.packet[2] = vec_mergeh(sum[1], sum[5]);
2850 kernel.packet[3] = vec_mergel(sum[1], sum[5]);
2851 kernel.packet[4] = vec_mergeh(sum[2], sum[6]);
2852 kernel.packet[5] = vec_mergel(sum[2], sum[6]);
2853 kernel.packet[6] = vec_mergeh(sum[3], sum[7]);
2854 kernel.packet[7] = vec_mergel(sum[3], sum[7]);
2857EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8us, 8>& kernel) {
2858 Packet8us v[8], sum[8];
2860 v[0] = vec_mergeh(kernel.packet[0], kernel.packet[4]);
2861 v[1] = vec_mergel(kernel.packet[0], kernel.packet[4]);
2862 v[2] = vec_mergeh(kernel.packet[1], kernel.packet[5]);
2863 v[3] = vec_mergel(kernel.packet[1], kernel.packet[5]);
2864 v[4] = vec_mergeh(kernel.packet[2], kernel.packet[6]);
2865 v[5] = vec_mergel(kernel.packet[2], kernel.packet[6]);
2866 v[6] = vec_mergeh(kernel.packet[3], kernel.packet[7]);
2867 v[7] = vec_mergel(kernel.packet[3], kernel.packet[7]);
2868 sum[0] = vec_mergeh(v[0], v[4]);
2869 sum[1] = vec_mergel(v[0], v[4]);
2870 sum[2] = vec_mergeh(v[1], v[5]);
2871 sum[3] = vec_mergel(v[1], v[5]);
2872 sum[4] = vec_mergeh(v[2], v[6]);
2873 sum[5] = vec_mergel(v[2], v[6]);
2874 sum[6] = vec_mergeh(v[3], v[7]);
2875 sum[7] = vec_mergel(v[3], v[7]);
2877 kernel.packet[0] = vec_mergeh(sum[0], sum[4]);
2878 kernel.packet[1] = vec_mergel(sum[0], sum[4]);
2879 kernel.packet[2] = vec_mergeh(sum[1], sum[5]);
2880 kernel.packet[3] = vec_mergel(sum[1], sum[5]);
2881 kernel.packet[4] = vec_mergeh(sum[2], sum[6]);
2882 kernel.packet[5] = vec_mergel(sum[2], sum[6]);
2883 kernel.packet[6] = vec_mergeh(sum[3], sum[7]);
2884 kernel.packet[7] = vec_mergel(sum[3], sum[7]);
2887EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet8bf, 8>& kernel) {
2888 Packet8bf v[8], sum[8];
2890 v[0] = vec_mergeh(kernel.packet[0].m_val, kernel.packet[4].m_val);
2891 v[1] = vec_mergel(kernel.packet[0].m_val, kernel.packet[4].m_val);
2892 v[2] = vec_mergeh(kernel.packet[1].m_val, kernel.packet[5].m_val);
2893 v[3] = vec_mergel(kernel.packet[1].m_val, kernel.packet[5].m_val);
2894 v[4] = vec_mergeh(kernel.packet[2].m_val, kernel.packet[6].m_val);
2895 v[5] = vec_mergel(kernel.packet[2].m_val, kernel.packet[6].m_val);
2896 v[6] = vec_mergeh(kernel.packet[3].m_val, kernel.packet[7].m_val);
2897 v[7] = vec_mergel(kernel.packet[3].m_val, kernel.packet[7].m_val);
2898 sum[0] = vec_mergeh(v[0].m_val, v[4].m_val);
2899 sum[1] = vec_mergel(v[0].m_val, v[4].m_val);
2900 sum[2] = vec_mergeh(v[1].m_val, v[5].m_val);
2901 sum[3] = vec_mergel(v[1].m_val, v[5].m_val);
2902 sum[4] = vec_mergeh(v[2].m_val, v[6].m_val);
2903 sum[5] = vec_mergel(v[2].m_val, v[6].m_val);
2904 sum[6] = vec_mergeh(v[3].m_val, v[7].m_val);
2905 sum[7] = vec_mergel(v[3].m_val, v[7].m_val);
2907 kernel.packet[0] = vec_mergeh(sum[0].m_val, sum[4].m_val);
2908 kernel.packet[1] = vec_mergel(sum[0].m_val, sum[4].m_val);
2909 kernel.packet[2] = vec_mergeh(sum[1].m_val, sum[5].m_val);
2910 kernel.packet[3] = vec_mergel(sum[1].m_val, sum[5].m_val);
2911 kernel.packet[4] = vec_mergeh(sum[2].m_val, sum[6].m_val);
2912 kernel.packet[5] = vec_mergel(sum[2].m_val, sum[6].m_val);
2913 kernel.packet[6] = vec_mergeh(sum[3].m_val, sum[7].m_val);
2914 kernel.packet[7] = vec_mergel(sum[3].m_val, sum[7].m_val);
2917EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet16c, 16>& kernel) {
2918 Packet16c step1[16], step2[16], step3[16];
2920 step1[0] = vec_mergeh(kernel.packet[0], kernel.packet[8]);
2921 step1[1] = vec_mergel(kernel.packet[0], kernel.packet[8]);
2922 step1[2] = vec_mergeh(kernel.packet[1], kernel.packet[9]);
2923 step1[3] = vec_mergel(kernel.packet[1], kernel.packet[9]);
2924 step1[4] = vec_mergeh(kernel.packet[2], kernel.packet[10]);
2925 step1[5] = vec_mergel(kernel.packet[2], kernel.packet[10]);
2926 step1[6] = vec_mergeh(kernel.packet[3], kernel.packet[11]);
2927 step1[7] = vec_mergel(kernel.packet[3], kernel.packet[11]);
2928 step1[8] = vec_mergeh(kernel.packet[4], kernel.packet[12]);
2929 step1[9] = vec_mergel(kernel.packet[4], kernel.packet[12]);
2930 step1[10] = vec_mergeh(kernel.packet[5], kernel.packet[13]);
2931 step1[11] = vec_mergel(kernel.packet[5], kernel.packet[13]);
2932 step1[12] = vec_mergeh(kernel.packet[6], kernel.packet[14]);
2933 step1[13] = vec_mergel(kernel.packet[6], kernel.packet[14]);
2934 step1[14] = vec_mergeh(kernel.packet[7], kernel.packet[15]);
2935 step1[15] = vec_mergel(kernel.packet[7], kernel.packet[15]);
2937 step2[0] = vec_mergeh(step1[0], step1[8]);
2938 step2[1] = vec_mergel(step1[0], step1[8]);
2939 step2[2] = vec_mergeh(step1[1], step1[9]);
2940 step2[3] = vec_mergel(step1[1], step1[9]);
2941 step2[4] = vec_mergeh(step1[2], step1[10]);
2942 step2[5] = vec_mergel(step1[2], step1[10]);
2943 step2[6] = vec_mergeh(step1[3], step1[11]);
2944 step2[7] = vec_mergel(step1[3], step1[11]);
2945 step2[8] = vec_mergeh(step1[4], step1[12]);
2946 step2[9] = vec_mergel(step1[4], step1[12]);
2947 step2[10] = vec_mergeh(step1[5], step1[13]);
2948 step2[11] = vec_mergel(step1[5], step1[13]);
2949 step2[12] = vec_mergeh(step1[6], step1[14]);
2950 step2[13] = vec_mergel(step1[6], step1[14]);
2951 step2[14] = vec_mergeh(step1[7], step1[15]);
2952 step2[15] = vec_mergel(step1[7], step1[15]);
2954 step3[0] = vec_mergeh(step2[0], step2[8]);
2955 step3[1] = vec_mergel(step2[0], step2[8]);
2956 step3[2] = vec_mergeh(step2[1], step2[9]);
2957 step3[3] = vec_mergel(step2[1], step2[9]);
2958 step3[4] = vec_mergeh(step2[2], step2[10]);
2959 step3[5] = vec_mergel(step2[2], step2[10]);
2960 step3[6] = vec_mergeh(step2[3], step2[11]);
2961 step3[7] = vec_mergel(step2[3], step2[11]);
2962 step3[8] = vec_mergeh(step2[4], step2[12]);
2963 step3[9] = vec_mergel(step2[4], step2[12]);
2964 step3[10] = vec_mergeh(step2[5], step2[13]);
2965 step3[11] = vec_mergel(step2[5], step2[13]);
2966 step3[12] = vec_mergeh(step2[6], step2[14]);
2967 step3[13] = vec_mergel(step2[6], step2[14]);
2968 step3[14] = vec_mergeh(step2[7], step2[15]);
2969 step3[15] = vec_mergel(step2[7], step2[15]);
2971 kernel.packet[0] = vec_mergeh(step3[0], step3[8]);
2972 kernel.packet[1] = vec_mergel(step3[0], step3[8]);
2973 kernel.packet[2] = vec_mergeh(step3[1], step3[9]);
2974 kernel.packet[3] = vec_mergel(step3[1], step3[9]);
2975 kernel.packet[4] = vec_mergeh(step3[2], step3[10]);
2976 kernel.packet[5] = vec_mergel(step3[2], step3[10]);
2977 kernel.packet[6] = vec_mergeh(step3[3], step3[11]);
2978 kernel.packet[7] = vec_mergel(step3[3], step3[11]);
2979 kernel.packet[8] = vec_mergeh(step3[4], step3[12]);
2980 kernel.packet[9] = vec_mergel(step3[4], step3[12]);
2981 kernel.packet[10] = vec_mergeh(step3[5], step3[13]);
2982 kernel.packet[11] = vec_mergel(step3[5], step3[13]);
2983 kernel.packet[12] = vec_mergeh(step3[6], step3[14]);
2984 kernel.packet[13] = vec_mergel(step3[6], step3[14]);
2985 kernel.packet[14] = vec_mergeh(step3[7], step3[15]);
2986 kernel.packet[15] = vec_mergel(step3[7], step3[15]);
2989EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet16uc, 16>& kernel) {
2990 Packet16uc step1[16], step2[16], step3[16];
2992 step1[0] = vec_mergeh(kernel.packet[0], kernel.packet[8]);
2993 step1[1] = vec_mergel(kernel.packet[0], kernel.packet[8]);
2994 step1[2] = vec_mergeh(kernel.packet[1], kernel.packet[9]);
2995 step1[3] = vec_mergel(kernel.packet[1], kernel.packet[9]);
2996 step1[4] = vec_mergeh(kernel.packet[2], kernel.packet[10]);
2997 step1[5] = vec_mergel(kernel.packet[2], kernel.packet[10]);
2998 step1[6] = vec_mergeh(kernel.packet[3], kernel.packet[11]);
2999 step1[7] = vec_mergel(kernel.packet[3], kernel.packet[11]);
3000 step1[8] = vec_mergeh(kernel.packet[4], kernel.packet[12]);
3001 step1[9] = vec_mergel(kernel.packet[4], kernel.packet[12]);
3002 step1[10] = vec_mergeh(kernel.packet[5], kernel.packet[13]);
3003 step1[11] = vec_mergel(kernel.packet[5], kernel.packet[13]);
3004 step1[12] = vec_mergeh(kernel.packet[6], kernel.packet[14]);
3005 step1[13] = vec_mergel(kernel.packet[6], kernel.packet[14]);
3006 step1[14] = vec_mergeh(kernel.packet[7], kernel.packet[15]);
3007 step1[15] = vec_mergel(kernel.packet[7], kernel.packet[15]);
3009 step2[0] = vec_mergeh(step1[0], step1[8]);
3010 step2[1] = vec_mergel(step1[0], step1[8]);
3011 step2[2] = vec_mergeh(step1[1], step1[9]);
3012 step2[3] = vec_mergel(step1[1], step1[9]);
3013 step2[4] = vec_mergeh(step1[2], step1[10]);
3014 step2[5] = vec_mergel(step1[2], step1[10]);
3015 step2[6] = vec_mergeh(step1[3], step1[11]);
3016 step2[7] = vec_mergel(step1[3], step1[11]);
3017 step2[8] = vec_mergeh(step1[4], step1[12]);
3018 step2[9] = vec_mergel(step1[4], step1[12]);
3019 step2[10] = vec_mergeh(step1[5], step1[13]);
3020 step2[11] = vec_mergel(step1[5], step1[13]);
3021 step2[12] = vec_mergeh(step1[6], step1[14]);
3022 step2[13] = vec_mergel(step1[6], step1[14]);
3023 step2[14] = vec_mergeh(step1[7], step1[15]);
3024 step2[15] = vec_mergel(step1[7], step1[15]);
3026 step3[0] = vec_mergeh(step2[0], step2[8]);
3027 step3[1] = vec_mergel(step2[0], step2[8]);
3028 step3[2] = vec_mergeh(step2[1], step2[9]);
3029 step3[3] = vec_mergel(step2[1], step2[9]);
3030 step3[4] = vec_mergeh(step2[2], step2[10]);
3031 step3[5] = vec_mergel(step2[2], step2[10]);
3032 step3[6] = vec_mergeh(step2[3], step2[11]);
3033 step3[7] = vec_mergel(step2[3], step2[11]);
3034 step3[8] = vec_mergeh(step2[4], step2[12]);
3035 step3[9] = vec_mergel(step2[4], step2[12]);
3036 step3[10] = vec_mergeh(step2[5], step2[13]);
3037 step3[11] = vec_mergel(step2[5], step2[13]);
3038 step3[12] = vec_mergeh(step2[6], step2[14]);
3039 step3[13] = vec_mergel(step2[6], step2[14]);
3040 step3[14] = vec_mergeh(step2[7], step2[15]);
3041 step3[15] = vec_mergel(step2[7], step2[15]);
3043 kernel.packet[0] = vec_mergeh(step3[0], step3[8]);
3044 kernel.packet[1] = vec_mergel(step3[0], step3[8]);
3045 kernel.packet[2] = vec_mergeh(step3[1], step3[9]);
3046 kernel.packet[3] = vec_mergel(step3[1], step3[9]);
3047 kernel.packet[4] = vec_mergeh(step3[2], step3[10]);
3048 kernel.packet[5] = vec_mergel(step3[2], step3[10]);
3049 kernel.packet[6] = vec_mergeh(step3[3], step3[11]);
3050 kernel.packet[7] = vec_mergel(step3[3], step3[11]);
3051 kernel.packet[8] = vec_mergeh(step3[4], step3[12]);
3052 kernel.packet[9] = vec_mergel(step3[4], step3[12]);
3053 kernel.packet[10] = vec_mergeh(step3[5], step3[13]);
3054 kernel.packet[11] = vec_mergel(step3[5], step3[13]);
3055 kernel.packet[12] = vec_mergeh(step3[6], step3[14]);
3056 kernel.packet[13] = vec_mergel(step3[6], step3[14]);
3057 kernel.packet[14] = vec_mergeh(step3[7], step3[15]);
3058 kernel.packet[15] = vec_mergel(step3[7], step3[15]);
3061template <
typename Packet>
3062EIGEN_STRONG_INLINE Packet pblend4(
const Selector<4>& ifPacket,
const Packet& thenPacket,
const Packet& elsePacket) {
3063 Packet4ui select = {ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3]};
3064 Packet4ui mask =
reinterpret_cast<Packet4ui
>(pnegate(
reinterpret_cast<Packet4i
>(select)));
3065 return vec_sel(elsePacket, thenPacket, mask);
3069EIGEN_STRONG_INLINE Packet4i pblend(
const Selector<4>& ifPacket,
const Packet4i& thenPacket,
3070 const Packet4i& elsePacket) {
3071 return pblend4<Packet4i>(ifPacket, thenPacket, elsePacket);
3075EIGEN_STRONG_INLINE Packet4f pblend(
const Selector<4>& ifPacket,
const Packet4f& thenPacket,
3076 const Packet4f& elsePacket) {
3077 return pblend4<Packet4f>(ifPacket, thenPacket, elsePacket);
3081EIGEN_STRONG_INLINE Packet8s pblend(
const Selector<8>& ifPacket,
const Packet8s& thenPacket,
3082 const Packet8s& elsePacket) {
3083 Packet8us select = {ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3],
3084 ifPacket.select[4], ifPacket.select[5], ifPacket.select[6], ifPacket.select[7]};
3085 Packet8us mask =
reinterpret_cast<Packet8us
>(pnegate(
reinterpret_cast<Packet8s
>(select)));
3086 Packet8s result = vec_sel(elsePacket, thenPacket, mask);
3091EIGEN_STRONG_INLINE Packet8us pblend(
const Selector<8>& ifPacket,
const Packet8us& thenPacket,
3092 const Packet8us& elsePacket) {
3093 Packet8us select = {ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3],
3094 ifPacket.select[4], ifPacket.select[5], ifPacket.select[6], ifPacket.select[7]};
3095 Packet8us mask =
reinterpret_cast<Packet8us
>(pnegate(
reinterpret_cast<Packet8s
>(select)));
3096 return vec_sel(elsePacket, thenPacket, mask);
3100EIGEN_STRONG_INLINE Packet8bf pblend(
const Selector<8>& ifPacket,
const Packet8bf& thenPacket,
3101 const Packet8bf& elsePacket) {
3102 return pblend<Packet8us>(ifPacket, thenPacket, elsePacket);
3106EIGEN_STRONG_INLINE Packet16c pblend(
const Selector<16>& ifPacket,
const Packet16c& thenPacket,
3107 const Packet16c& elsePacket) {
3108 Packet16uc select = {ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3],
3109 ifPacket.select[4], ifPacket.select[5], ifPacket.select[6], ifPacket.select[7],
3110 ifPacket.select[8], ifPacket.select[9], ifPacket.select[10], ifPacket.select[11],
3111 ifPacket.select[12], ifPacket.select[13], ifPacket.select[14], ifPacket.select[15]};
3113 Packet16uc mask =
reinterpret_cast<Packet16uc
>(pnegate(
reinterpret_cast<Packet16c
>(select)));
3114 return vec_sel(elsePacket, thenPacket, mask);
3118EIGEN_STRONG_INLINE Packet16uc pblend(
const Selector<16>& ifPacket,
const Packet16uc& thenPacket,
3119 const Packet16uc& elsePacket) {
3120 Packet16uc select = {ifPacket.select[0], ifPacket.select[1], ifPacket.select[2], ifPacket.select[3],
3121 ifPacket.select[4], ifPacket.select[5], ifPacket.select[6], ifPacket.select[7],
3122 ifPacket.select[8], ifPacket.select[9], ifPacket.select[10], ifPacket.select[11],
3123 ifPacket.select[12], ifPacket.select[13], ifPacket.select[14], ifPacket.select[15]};
3125 Packet16uc mask =
reinterpret_cast<Packet16uc
>(pnegate(
reinterpret_cast<Packet16c
>(select)));
3126 return vec_sel(elsePacket, thenPacket, mask);
3130#ifdef EIGEN_VECTORIZE_VSX
3131typedef __vector
double Packet2d;
3132typedef __vector
unsigned long long Packet2ul;
3133typedef __vector
long long Packet2l;
3135typedef Packet2ul Packet2bl;
3137typedef __vector __bool
long Packet2bl;
3140static Packet2l p2l_ZERO =
reinterpret_cast<Packet2l
>(p4i_ZERO);
3141static Packet2ul p2ul_SIGN = {0x8000000000000000ull, 0x8000000000000000ull};
3142static Packet2ul p2ul_PREV0DOT5 = {0x3FDFFFFFFFFFFFFFull, 0x3FDFFFFFFFFFFFFFull};
3143static Packet2d p2d_ONE = {1.0, 1.0};
3144static Packet2d p2d_ZERO =
reinterpret_cast<Packet2d
>(p4f_ZERO);
3145static Packet2d p2d_MZERO = {numext::bit_cast<double>(0x8000000000000000ull),
3146 numext::bit_cast<double>(0x8000000000000000ull)};
3149static Packet2d p2d_COUNTDOWN =
3150 reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4f
>(p2d_ZERO),
reinterpret_cast<Packet4f
>(p2d_ONE), 8));
3152static Packet2d p2d_COUNTDOWN =
3153 reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4f
>(p2d_ONE),
reinterpret_cast<Packet4f
>(p2d_ZERO), 8));
3157Packet2d vec_splat_dbl(Packet2d& a) {
3158 return vec_splat(a, index);
3162struct packet_traits<double> : default_packet_traits {
3163 typedef Packet2d type;
3164 typedef Packet2d half;
3167 AlignedOnScalar = 1,
3177 HasSin = EIGEN_FAST_MATH,
3178 HasCos = EIGEN_FAST_MATH,
3183#if !EIGEN_COMP_CLANG
3194struct unpacket_traits<Packet2d> {
3195 typedef double type;
3196 typedef Packet2l integer_packet;
3200 vectorizable =
true,
3201 masked_load_available =
false,
3202 masked_store_available =
false
3204 typedef Packet2d half;
3207struct unpacket_traits<Packet2l> {
3208 typedef int64_t type;
3209 typedef Packet2l half;
3213 vectorizable =
false,
3214 masked_load_available =
false,
3215 masked_store_available =
false
3219inline std::ostream& operator<<(std::ostream& s,
const Packet2l& v) {
3225 s << vt.n[0] <<
", " << vt.n[1];
3229inline std::ostream& operator<<(std::ostream& s,
const Packet2d& v) {
3235 s << vt.n[0] <<
", " << vt.n[1];
3241EIGEN_STRONG_INLINE Packet2d pload<Packet2d>(
const double* from) {
3242 EIGEN_DEBUG_ALIGNED_LOAD
3243 return vec_xl(0,
const_cast<double*
>(from));
3247EIGEN_ALWAYS_INLINE Packet2d pload_partial<Packet2d>(
const double* from,
const Index n,
const Index offset) {
3248 return pload_partial_common<Packet2d>(from, n, offset);
3252EIGEN_STRONG_INLINE
void pstore<double>(
double* to,
const Packet2d& from) {
3253 EIGEN_DEBUG_ALIGNED_STORE
3254 vec_xst(from, 0, to);
3258EIGEN_ALWAYS_INLINE
void pstore_partial<double>(
double* to,
const Packet2d& from,
const Index n,
const Index offset) {
3259 pstore_partial_common<Packet2d>(to, from, n, offset);
3263EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(
const double& from) {
3264 Packet2d v = {from, from};
3268EIGEN_STRONG_INLINE Packet2l pset1<Packet2l>(
const int64_t& from) {
3269 Packet2l v = {from, from};
3274EIGEN_STRONG_INLINE Packet2d pset1frombits<Packet2d>(
unsigned long from) {
3275 Packet2l v = {
static_cast<long long>(from),
static_cast<long long>(from)};
3276 return reinterpret_cast<Packet2d
>(v);
3280EIGEN_STRONG_INLINE
void pbroadcast4<Packet2d>(
const double* a, Packet2d& a0, Packet2d& a1, Packet2d& a2,
3283 a0 = pset1<Packet2d>(a[0]);
3284 a1 = pset1<Packet2d>(a[1]);
3285 a2 = pset1<Packet2d>(a[2]);
3286 a3 = pset1<Packet2d>(a[3]);
3290EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet2d pgather<double, Packet2d>(
const double* from, Index stride) {
3291 return pgather_common<Packet2d>(from, stride);
3294EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet2d pgather_partial<double, Packet2d>(
const double* from, Index stride,
3296 return pgather_common<Packet2d>(from, stride, n);
3299EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter<double, Packet2d>(
double* to,
const Packet2d& from, Index stride) {
3300 pscatter_common<Packet2d>(to, from, stride);
3303EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
void pscatter_partial<double, Packet2d>(
double* to,
const Packet2d& from,
3304 Index stride,
const Index n) {
3305 pscatter_common<Packet2d>(to, from, stride, n);
3309EIGEN_STRONG_INLINE Packet2d plset<Packet2d>(
const double& a) {
3310 return pset1<Packet2d>(a) + p2d_COUNTDOWN;
3314EIGEN_STRONG_INLINE Packet2d padd<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3319EIGEN_STRONG_INLINE Packet2d psub<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3324EIGEN_STRONG_INLINE Packet2d pnegate(
const Packet2d& a) {
3325#ifdef __POWER8_VECTOR__
3328 return vec_xor(a, p2d_MZERO);
3333EIGEN_STRONG_INLINE Packet2d pconj(
const Packet2d& a) {
3338EIGEN_STRONG_INLINE Packet2d pmul<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3339 return vec_madd(a, b, p2d_MZERO);
3342EIGEN_STRONG_INLINE Packet2d pdiv<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3343 return vec_div(a, b);
3348EIGEN_STRONG_INLINE Packet2d pmadd(
const Packet2d& a,
const Packet2d& b,
const Packet2d& c) {
3349 return vec_madd(a, b, c);
3352EIGEN_STRONG_INLINE Packet2d pmsub(
const Packet2d& a,
const Packet2d& b,
const Packet2d& c) {
3353 return vec_msub(a, b, c);
3356EIGEN_STRONG_INLINE Packet2d pnmadd(
const Packet2d& a,
const Packet2d& b,
const Packet2d& c) {
3357 return vec_nmsub(a, b, c);
3360EIGEN_STRONG_INLINE Packet2d pnmsub(
const Packet2d& a,
const Packet2d& b,
const Packet2d& c) {
3361 return vec_nmadd(a, b, c);
3365EIGEN_STRONG_INLINE Packet2d pmin<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3368 __asm__(
"xvcmpgedp %x0,%x1,%x2\n\txxsel %x0,%x1,%x2,%x0" :
"=&wa"(ret) :
"wa"(a),
"wa"(b));
3373EIGEN_STRONG_INLINE Packet2d pmax<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3376 __asm__(
"xvcmpgtdp %x0,%x2,%x1\n\txxsel %x0,%x1,%x2,%x0" :
"=&wa"(ret) :
"wa"(a),
"wa"(b));
3381EIGEN_STRONG_INLINE Packet2d pcmp_le(
const Packet2d& a,
const Packet2d& b) {
3382 return reinterpret_cast<Packet2d
>(vec_cmple(a, b));
3385EIGEN_STRONG_INLINE Packet2d pcmp_lt(
const Packet2d& a,
const Packet2d& b) {
3386 return reinterpret_cast<Packet2d
>(vec_cmplt(a, b));
3389EIGEN_STRONG_INLINE Packet2d pcmp_eq(
const Packet2d& a,
const Packet2d& b) {
3390 return reinterpret_cast<Packet2d
>(vec_cmpeq(a, b));
3393EIGEN_STRONG_INLINE Packet2l pcmp_eq(
const Packet2l& a,
const Packet2l& b) {
3394 return reinterpret_cast<Packet2l
>(vec_cmpeq(a, b));
3397EIGEN_STRONG_INLINE Packet2d pcmp_lt_or_nan(
const Packet2d& a,
const Packet2d& b) {
3398 Packet2d c =
reinterpret_cast<Packet2d
>(vec_cmpge(a, b));
3399 return vec_nor(c, c);
3403EIGEN_STRONG_INLINE Packet2d pand<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3404 return vec_and(a, b);
3408EIGEN_STRONG_INLINE Packet2d por<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3409 return vec_or(a, b);
3413EIGEN_STRONG_INLINE Packet2d pxor<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3414 return vec_xor(a, b);
3418EIGEN_STRONG_INLINE Packet2d pandnot<Packet2d>(
const Packet2d& a,
const Packet2d& b) {
3419 return vec_and(a, vec_nor(b, b));
3423EIGEN_STRONG_INLINE Packet2d pround<Packet2d>(
const Packet2d& a) {
3424 Packet2d t = vec_add(
3425 reinterpret_cast<Packet2d
>(vec_or(vec_and(
reinterpret_cast<Packet2ul
>(a), p2ul_SIGN), p2ul_PREV0DOT5)), a);
3428 __asm__(
"xvrdpiz %x0, %x1\n\t" :
"=&wa"(res) :
"wa"(t));
3433EIGEN_STRONG_INLINE Packet2d pceil<Packet2d>(
const Packet2d& a) {
3437EIGEN_STRONG_INLINE Packet2d pfloor<Packet2d>(
const Packet2d& a) {
3438 return vec_floor(a);
3441EIGEN_STRONG_INLINE Packet2d ptrunc<Packet2d>(
const Packet2d& a) {
3442 return vec_trunc(a);
3445EIGEN_STRONG_INLINE Packet2d print<Packet2d>(
const Packet2d& a) {
3448 __asm__(
"xvrdpic %x0, %x1\n\t" :
"=&wa"(res) :
"wa"(a));
3454EIGEN_STRONG_INLINE Packet2d ploadu<Packet2d>(
const double* from) {
3455 EIGEN_DEBUG_UNALIGNED_LOAD
3456 return vec_xl(0,
const_cast<double*
>(from));
3460EIGEN_ALWAYS_INLINE Packet2d ploadu_partial<Packet2d>(
const double* from,
const Index n,
const Index offset) {
3461 return ploadu_partial_common<Packet2d>(from, n, offset);
3465EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(
const double* from) {
3467 if ((std::ptrdiff_t(from) % 16) == 0)
3468 p = pload<Packet2d>(from);
3470 p = ploadu<Packet2d>(from);
3471 return vec_splat_dbl<0>(p);
3475EIGEN_STRONG_INLINE
void pstoreu<double>(
double* to,
const Packet2d& from) {
3476 EIGEN_DEBUG_UNALIGNED_STORE
3477 vec_xst(from, 0, to);
3481EIGEN_ALWAYS_INLINE
void pstoreu_partial<double>(
double* to,
const Packet2d& from,
const Index n,
const Index offset) {
3482 pstoreu_partial_common<Packet2d>(to, from, n, offset);
3486EIGEN_STRONG_INLINE
void prefetch<double>(
const double* addr) {
3487 EIGEN_PPC_PREFETCH(addr);
3491EIGEN_STRONG_INLINE
double pfirst<Packet2d>(
const Packet2d& a) {
3492 EIGEN_ALIGN16
double x[2];
3493 pstore<double>(x, a);
3498EIGEN_STRONG_INLINE Packet2d preverse(
const Packet2d& a) {
3499 return vec_sld(a, a, 8);
3502EIGEN_STRONG_INLINE Packet2d pabs(
const Packet2d& a) {
3505#ifdef __POWER8_VECTOR__
3507EIGEN_STRONG_INLINE Packet2d psignbit(
const Packet2d& a) {
3508 return (Packet2d)vec_sra((Packet2l)a, vec_splats((
unsigned long long)(63)));
3512static Packet16uc p16uc_DUPSIGN = {0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8};
3514static Packet16uc p16uc_DUPSIGN = {7, 7, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15, 15, 15};
3518EIGEN_STRONG_INLINE Packet2d psignbit(
const Packet2d& a) {
3519 Packet16c tmp = vec_sra(
reinterpret_cast<Packet16c
>(a), vec_splats((
unsigned char)(7)));
3520 return reinterpret_cast<Packet2d
>(vec_perm(tmp, tmp, p16uc_DUPSIGN));
3525inline Packet2l pcast<Packet2d, Packet2l>(
const Packet2d& x);
3528inline Packet2d pcast<Packet2l, Packet2d>(
const Packet2l& x);
3536#ifdef __POWER8_VECTOR__
3539EIGEN_STRONG_INLINE Packet2l plogical_shift_left(
const Packet2l& a) {
3540 const Packet2ul shift = {N, N};
3541 return vec_sl(a, shift);
3545EIGEN_STRONG_INLINE Packet2l plogical_shift_right(
const Packet2l& a) {
3546 const Packet2ul shift = {N, N};
3547 return vec_sr(a, shift);
3554EIGEN_ALWAYS_INLINE Packet4i shift_even_left(
const Packet4i& a) {
3555 static const Packet16uc perm = {0x14, 0x15, 0x16, 0x17, 0x00, 0x01, 0x02, 0x03,
3556 0x1c, 0x1d, 0x1e, 0x1f, 0x08, 0x09, 0x0a, 0x0b};
3558 return vec_perm(p4i_ZERO, a, perm);
3560 return vec_perm(a, p4i_ZERO, perm);
3566EIGEN_ALWAYS_INLINE Packet4i shift_odd_right(
const Packet4i& a) {
3567 static const Packet16uc perm = {0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
3568 0x0c, 0x0d, 0x0e, 0x0f, 0x18, 0x19, 0x1a, 0x1b};
3570 return vec_perm(p4i_ZERO, a, perm);
3572 return vec_perm(a, p4i_ZERO, perm);
3576template <
int N,
typename EnableIf =
void>
3577struct plogical_shift_left_impl;
3580struct plogical_shift_left_impl<N, std::enable_if_t<(N < 32) && (N >= 0)> > {
3581 static EIGEN_STRONG_INLINE Packet2l run(
const Packet2l& a) {
3582 static const unsigned n =
static_cast<unsigned>(N);
3583 const Packet4ui shift = {n, n, n, n};
3584 const Packet4i ai =
reinterpret_cast<Packet4i
>(a);
3585 static const unsigned m =
static_cast<unsigned>(32 - N);
3586 const Packet4ui shift_right = {m, m, m, m};
3587 const Packet4i out_hi = vec_sl(ai, shift);
3588 const Packet4i out_lo = shift_even_left(vec_sr(ai, shift_right));
3589 return reinterpret_cast<Packet2l
>(por<Packet4i>(out_hi, out_lo));
3594struct plogical_shift_left_impl<N, std::enable_if_t<(N >= 32)> > {
3595 static EIGEN_STRONG_INLINE Packet2l run(
const Packet2l& a) {
3596 static const unsigned m =
static_cast<unsigned>(N - 32);
3597 const Packet4ui shift = {m, m, m, m};
3598 const Packet4i ai =
reinterpret_cast<Packet4i
>(a);
3599 return reinterpret_cast<Packet2l
>(shift_even_left(vec_sl(ai, shift)));
3604EIGEN_STRONG_INLINE Packet2l plogical_shift_left(
const Packet2l& a) {
3605 return plogical_shift_left_impl<N>::run(a);
3608template <
int N,
typename EnableIf =
void>
3609struct plogical_shift_right_impl;
3612struct plogical_shift_right_impl<N, std::enable_if_t<(N < 32) && (N >= 0)> > {
3613 static EIGEN_STRONG_INLINE Packet2l run(
const Packet2l& a) {
3614 static const unsigned n =
static_cast<unsigned>(N);
3615 const Packet4ui shift = {n, n, n, n};
3616 const Packet4i ai =
reinterpret_cast<Packet4i
>(a);
3617 static const unsigned m =
static_cast<unsigned>(32 - N);
3618 const Packet4ui shift_left = {m, m, m, m};
3619 const Packet4i out_lo = vec_sr(ai, shift);
3620 const Packet4i out_hi = shift_odd_right(vec_sl(ai, shift_left));
3621 return reinterpret_cast<Packet2l
>(por<Packet4i>(out_hi, out_lo));
3626struct plogical_shift_right_impl<N, std::enable_if_t<(N >= 32)> > {
3627 static EIGEN_STRONG_INLINE Packet2l run(
const Packet2l& a) {
3628 static const unsigned m =
static_cast<unsigned>(N - 32);
3629 const Packet4ui shift = {m, m, m, m};
3630 const Packet4i ai =
reinterpret_cast<Packet4i
>(a);
3631 return reinterpret_cast<Packet2l
>(shift_odd_right(vec_sr(ai, shift)));
3636EIGEN_STRONG_INLINE Packet2l plogical_shift_right(
const Packet2l& a) {
3637 return plogical_shift_right_impl<N>::run(a);
3642EIGEN_STRONG_INLINE Packet2d pldexp<Packet2d>(
const Packet2d& a,
const Packet2d& exponent) {
3644 const Packet2d max_exponent = pset1<Packet2d>(2099.0);
3645 const Packet2l e = pcast<Packet2d, Packet2l>(pmin(pmax(exponent, pnegate(max_exponent)), max_exponent));
3648 const Packet2l bias = {1023, 1023};
3649 Packet2l b = plogical_shift_right<2>(e);
3650 Packet2d c =
reinterpret_cast<Packet2d
>(plogical_shift_left<52>(b + bias));
3651 Packet2d out = pmul(pmul(pmul(a, c), c), c);
3652 b = psub(psub(psub(e, b), b), b);
3653 c =
reinterpret_cast<Packet2d
>(plogical_shift_left<52>(b + bias));
3660EIGEN_STRONG_INLINE Packet2d pfrexp_generic_get_biased_exponent(
const Packet2d& a) {
3661 return pcast<Packet2l, Packet2d>(plogical_shift_right<52>(
reinterpret_cast<Packet2l
>(pabs(a))));
3665EIGEN_STRONG_INLINE Packet2d pfrexp<Packet2d>(
const Packet2d& a, Packet2d& exponent) {
3666 return pfrexp_generic(a, exponent);
3670EIGEN_STRONG_INLINE
double predux<Packet2d>(
const Packet2d& a) {
3672 b =
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4f
>(a),
reinterpret_cast<Packet4f
>(a), 8));
3674 return pfirst<Packet2d>(sum);
3680EIGEN_STRONG_INLINE
double predux_mul<Packet2d>(
const Packet2d& a) {
3682 pmul(a,
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(a),
reinterpret_cast<Packet4ui
>(a), 8))));
3687EIGEN_STRONG_INLINE
double predux_min<Packet2d>(
const Packet2d& a) {
3689 pmin(a,
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(a),
reinterpret_cast<Packet4ui
>(a), 8))));
3694EIGEN_STRONG_INLINE
double predux_max<Packet2d>(
const Packet2d& a) {
3696 pmax(a,
reinterpret_cast<Packet2d
>(vec_sld(
reinterpret_cast<Packet4ui
>(a),
reinterpret_cast<Packet4ui
>(a), 8))));
3699EIGEN_DEVICE_FUNC
inline void ptranspose(PacketBlock<Packet2d, 2>& kernel) {
3701 t0 = vec_mergeh(kernel.packet[0], kernel.packet[1]);
3702 t1 = vec_mergel(kernel.packet[0], kernel.packet[1]);
3703 kernel.packet[0] = t0;
3704 kernel.packet[1] = t1;
3708EIGEN_STRONG_INLINE Packet2d pblend(
const Selector<2>& ifPacket,
const Packet2d& thenPacket,
3709 const Packet2d& elsePacket) {
3710 Packet2l select = {ifPacket.select[0], ifPacket.select[1]};
3711 Packet2ul mask =
reinterpret_cast<Packet2ul
>(pnegate(
reinterpret_cast<Packet2l
>(select)));
3712 return vec_sel(elsePacket, thenPacket, mask);
@ Aligned16
Definition Constants.h:237
Namespace containing all symbols from the Eigen library.
Definition Core:137
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)