Skip to content

Commit bd2ddea

Browse files
WIP
1 parent 49fc69f commit bd2ddea

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ namespace xsimd
6161
XSIMD_INLINE batch<T, A> insert(batch<T, A> const& self, T val, index<I>, requires_arch<common>) noexcept;
6262
template <class A, typename T, typename ITy, ITy... Indices>
6363
XSIMD_INLINE batch<T, A> shuffle(batch<T, A> const& x, batch<T, A> const& y, batch_constant<ITy, A, Indices...>, requires_arch<common>) noexcept;
64+
#endif
6465
template <class A, class T>
6566
XSIMD_INLINE batch<T, A> avg(batch<T, A> const&, batch<T, A> const&, requires_arch<common>) noexcept;
6667
template <class A, class T>
6768
XSIMD_INLINE batch<T, A> avgr(batch<T, A> const&, batch<T, A> const&, requires_arch<common>) noexcept;
68-
#endif
6969

7070
// abs
7171
template <class A>
@@ -107,6 +107,16 @@ namespace xsimd
107107
{
108108
return vec_avg(self.data, other.data);
109109
}
110+
template <class A>
111+
XSIMD_INLINE batch<float, A> avgr(batch<float, A> const& self, batch<float, A> const& other, requires_arch<altivec>) noexcept
112+
{
113+
return avgr(self, other, common {});
114+
}
115+
template <class A>
116+
XSIMD_INLINE batch<double, A> avgr(batch<double, A> const& self, batch<double, A> const& other, requires_arch<altivec>) noexcept
117+
{
118+
return avgr(self, other, common {});
119+
}
110120

111121
// avg
112122
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
@@ -116,6 +126,16 @@ namespace xsimd
116126
auto adj = ((self ^ other) << nbit) >> nbit;
117127
return avgr(self, other, A {}) - adj;
118128
}
129+
template <class A>
130+
XSIMD_INLINE batch<float, A> avg(batch<float, A> const& self, batch<float, A> const& other, requires_arch<altivec>) noexcept
131+
{
132+
return avg(self, other, common {});
133+
}
134+
template <class A>
135+
XSIMD_INLINE batch<double, A> avg(batch<double, A> const& self, batch<double, A> const& other, requires_arch<altivec>) noexcept
136+
{
137+
return avg(self, other, common {});
138+
}
119139

120140
// batch_bool_cast
121141
template <class A, class T_out, class T_in>
@@ -439,6 +459,14 @@ namespace xsimd
439459
return vec_add(tmp6, tmp7);
440460
}
441461

462+
template <class A>
463+
XSIMD_INLINE batch<double, A> haddp(batch<double, A> const* row, requires_arch<altivec>) noexcept
464+
{
465+
auto tmp0 = vec_mergee(row[0].data, row[1].data); // v00 v10 v02 v12
466+
auto tmp1 = vec_mergeo(row[0].data, row[1].data); // v01 v11 v03 v13
467+
return vec_add(tmp0, tmp1);
468+
}
469+
442470
// incr_if
443471
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
444472
XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& self, batch_bool<T, A> const& mask, requires_arch<altivec>) noexcept

include/xsimd/config/xsimd_config.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,23 @@
413413
*
414414
* Set to 1 if Altivec is available at compile-time, to 0 otherwise.
415415
*/
416-
#ifdef __VEC__
416+
#if defined(__VEC__)
417417
#define XSIMD_WITH_ALTIVEC 1
418418
#else
419419
#define XSIMD_WITH_ALTIVEC 0
420420
#endif
421421

422+
/**
423+
* @ingroup xsimd_config_macro
424+
*
425+
* Set to 1 if Vector Scalar eXtension is available at compile-time, to 0 otherwise.
426+
*/
427+
#if defined(__VSX__)
428+
#define XSIMD_WITH_VSX 1
429+
#else
430+
#define XSIMD_WITH_VSX 0
431+
#endif
432+
422433
// Workaround for MSVC compiler
423434
#ifdef _MSC_VER
424435

0 commit comments

Comments
 (0)