Skip to content

Commit ac36842

Browse files
WIP
1 parent 49fc69f commit ac36842

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 19 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,11 @@ namespace xsimd
107107
{
108108
return vec_avg(self.data, other.data);
109109
}
110+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
111+
XSIMD_INLINE batch<T, A> avgr(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
112+
{
113+
return avgr(self, other, common {});
114+
}
110115

111116
// avg
112117
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
@@ -116,6 +121,11 @@ namespace xsimd
116121
auto adj = ((self ^ other) << nbit) >> nbit;
117122
return avgr(self, other, A {}) - adj;
118123
}
124+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
125+
XSIMD_INLINE batch<T, A> avg(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
126+
{
127+
return avg(self, other, common {});
128+
}
119129

120130
// batch_bool_cast
121131
template <class A, class T_out, class T_in>
@@ -439,6 +449,14 @@ namespace xsimd
439449
return vec_add(tmp6, tmp7);
440450
}
441451

452+
template <class A>
453+
XSIMD_INLINE batch<double, A> haddp(batch<double, A> const* row, requires_arch<altivec>) noexcept
454+
{
455+
auto tmp0 = vec_mergee(row[0].data, row[1].data); // v00 v10 v02 v12
456+
auto tmp1 = vec_mergeo(row[0].data, row[1].data); // v01 v11 v03 v13
457+
return vec_add(tmp0, tmp1);
458+
}
459+
442460
// incr_if
443461
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
444462
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)